From 5aca587f1453e4ae761bd5e95b78a06f2fbe47d8 Mon Sep 17 00:00:00 2001 From: yi12345 Date: Sat, 21 Sep 2013 21:12:22 +0300 Subject: [PATCH] fix showing attack on your oasis --- GameEngine/Automation.php | 24 ++++++--- GameEngine/Database/db_MYSQL.php | 2 +- Templates/Build/16.tpl | 9 +++- Templates/Build/16_incomming.tpl | 88 +++++++++++++++++++++++++++++++- Templates/Build/16_walking.tpl | 4 +- Templates/movement.tpl | 53 ++++++++----------- 6 files changed, 137 insertions(+), 43 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 8c1b53ec..30756a02 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -697,7 +697,7 @@ class Automation { $upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0); $starv = $database->getVillageField($indi['wid'],"starv"); if ($crop < $upkeep && $starv == 0){ - // add starv data + // add starv data $database->setVillageField($indi['wid'], 'starv', $upkeep); $database->setVillageField($indi['wid'], 'starvupdate', $time); } @@ -2269,7 +2269,7 @@ class Automation { if(!isset($nochiefing)){ //$info_chief = "".$chief_pic.",You don't have enought CP to chief a village."; if($this->getTypeLevel(35,$data['from']) == 0){ - for ($i=0; $i<($data['t9']-$dead9-$traped9); $i++){ + for ($i=0; $i<($data['t9']-$dead9); $i++){ if($owntribe == 1){ $rand+=rand(20,30); }else{ @@ -2277,7 +2277,7 @@ class Automation { } } }else{ - for ($i=0; $i<($data['t9']-$dead9-$traped9); $i++){ + for ($i=0; $i<($data['t9']-$dead9); $i++){ $rand+=rand(5,15); } } @@ -3009,7 +3009,12 @@ $wallimg = "query_return($q); foreach($dataarray as $data) { if($data['from']==0){ + $isoasis = $database->isVillageOases($data['to']); + if($isoasis == 0){ $to = $database->getMInfo($data['to']); + }else{ + $to = $database->getOMInfo($data['to']); + } $database->addEnforce($data); $reinf = $database->getEnforce($data['to'],$data['from']); $database->modifyEnforce($reinf['id'],31,1,1); @@ -3815,7 +3820,14 @@ $wallimg = "=1){ if($hdata['health']<100 and $hdata['health']>0){ - $reg = $hdata['health']+$hdata['regeneration']*5*SPEED/86400*(time()-$hdata['lastupdate']); + if(SPEED <= 10){ + $speed = SPEED; + }else if(SPEED <= 100){ + $speed = ceil(SPEED/10); + }else{ + $speed = ceil(SPEED/100); + } + $reg = $hdata['health']+$hdata['regeneration']*5*$speed/86400*(time()-$hdata['lastupdate']); if($reg <= 100){ $database->modifyHero("health",$reg,$hdata['heroid']); }else{ @@ -4418,8 +4430,8 @@ $wallimg = "query($q); } } - - function medals(){ + + function medals(){ global $ranking,$database; //we mogen de lintjes weggeven diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 6d47ca51..42cd35d3 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -2221,7 +2221,7 @@ class MYSQL_DB { $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 5 and proc = 0 ORDER BY endtime ASC"; break; case 6: - $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.conqured = $village and " . TB_PREFIX . "movement.to = " . TB_PREFIX . "odata.wref and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; + $q = "SELECT * FROM " . TB_PREFIX . "movement," . TB_PREFIX . "odata, " . TB_PREFIX . "attacks where " . TB_PREFIX . "odata.wref = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "attacks.attack_type != 1 and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 ORDER BY endtime ASC"; break; case 7: $q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC"; diff --git a/Templates/Build/16.tpl b/Templates/Build/16.tpl index fed0716d..ec834594 100644 --- a/Templates/Build/16.tpl +++ b/Templates/Build/16.tpl @@ -14,15 +14,20 @@ getMovement("34",$village->wid,1); $settlers = $database->getMovement("7",$village->wid,1); +$oasis_incoming = 0; +$array = $database->getOasis($village->wid); +foreach($array as $conqured){ +$oasis_incoming += count($database->getMovement(6,$conqured['wref'],0)); +} $units_incoming = count($units_type); $settlers_incoming = count($settlers); for($i=0;$i<$units_incoming;$i++){ if($units_type[$i]['attack_type'] == 1 && $units_type[$i]['sort_type'] == 3) $units_incoming -= 1; } -if($units_incoming > 0 or $settlers_incoming > 0){ +if($units_incoming > 0 or $settlers_incoming > 0 or $oasis_incoming > 0){ ?> -

Incoming troops ()

+

Incoming troops ()

diff --git a/Templates/Build/16_incomming.tpl b/Templates/Build/16_incomming.tpl index 320a8986..ccaef6ed 100644 --- a/Templates/Build/16_incomming.tpl +++ b/Templates/Build/16_incomming.tpl @@ -133,7 +133,7 @@ if ($units[$y]['sort_type']==3){ if ($units[$y]['attack_type']==1){ $actionType = "Return from "; } else if ($units[$y]['attack_type']==2){ - $actionType = "Reinforment for "; + $actionType = "Reinforcement for "; } else if ($units[$y]['attack_type']==3){ $actionType = "Return from "; } else if ($units[$y]['attack_type']==4){ @@ -212,6 +212,92 @@ $to = $database->getMInfo($units[$y]['vref']); getOasis($village->wid); +foreach($array as $conqured){ +$oasis = $database->getMovement("6",$conqured['wref'],0); +$total_for = count($oasis); +for($y=0;$y < $total_for;$y++){ +$timer = $y+1; + if ($oasis[$y]['attack_type']==2){ + $actionType = "Reinforcement for "; + } else if ($oasis[$y]['attack_type']==3){ + $actionType = "Attack on "; + } else if ($oasis[$y]['attack_type']==4){ + $actionType = "Raid on "; + } + $reinfowner = $database->getVillageField($oasis[$y]['from'],"owner"); + if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) { + $colspan = 11; + }else{ + $colspan = 10; + } + echo " + "; + $tribe = $database->getUserField($database->getVillageField($oasis[$y]['from'],"owner"),"tribe",0); + $start = ($tribe-1)*10+1; + $end = ($tribe*10); + echo ""; + for($i=$start;$i<=($end);$i++) { + echo ""; + } + if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) { + echo ""; + } + echo ""; + for($i=1;$i<=$colspan;$i++) { + $totalunits = $oasis[$y]['t1']+$oasis[$y]['t2']+$oasis[$y]['t3']+$oasis[$y]['t4']+$oasis[$y]['t5']+$oasis[$y]['t6']+$oasis[$y]['t7']+$oasis[$y]['t8']+$oasis[$y]['t9']+$oasis[$y]['t10']+$oasis[$y]['t11']; + if($oasis[$y]['attack_type'] == 2){ + if($reinfowner != $session->uid){ + echo ""; + }else{ + + + if($oasis[$y]['t'.$i] == 0) { + echo ""; + } + else { + echo ""; + } + }}else{ + $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,3,3,0)); + $artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,3,1,1)); + $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,3,2,0)); + $total_artefact = $artefact + $artefact1 + $artefact2; + if($totalunits > $building->getTypeLevel(16) && $total_artefact == 0){ + echo ""; + }else{ + if($oasis[$y]['t'.$i] == 0) { + echo ""; + }else{ + echo ""; + } + } + } + } + echo ""; + echo ' + + + + + + "; + echo "
+ getMapCheck($oasis[$y]['from'])."\">".$database->getVillageField($oasis[$y]['from'],"name").""; + echo "getVillageField($oasis[$y]['from'],"owner")."\">".$database->getUserField($database->getVillageField($oasis[$y]['from'],"owner"),"username",0)."'s troops"; + echo "
 getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" />\"Hero\"
Troops?0"; + echo $oasis[$y]['t'.$i]."?0?
Arrival +
'.$generator->getTimeFormat($oasis[$y]['endtime']-time()).' h
'; + $datetime = $generator->procMtime($oasis[$y]['endtime']); + echo "
"; + if($datetime[0] != "today") { + echo "on ".$datetime[0]." "; + } + echo "at ".$datetime[1]." hours
+ +
"; +} +} $settlers = $database->getMovement("7",$village->wid,1); $total_for3 = count($settlers); diff --git a/Templates/Build/16_walking.tpl b/Templates/Build/16_walking.tpl index bfb0cb4b..5899e7e7 100644 --- a/Templates/Build/16_walking.tpl +++ b/Templates/Build/16_walking.tpl @@ -140,9 +140,9 @@ $timer += 1; echo "on ".$datetime[0]." "; } echo "at ".$datetime[1].""; - if (($units[$y]['starttime']+90)>time()){ + if (($settlers[$y]['starttime']+90)>time()){ ?> -
">
+
">
diff --git a/Templates/movement.tpl b/Templates/movement.tpl index 863e771b..95a88af3 100644 --- a/Templates/movement.tpl +++ b/Templates/movement.tpl @@ -9,8 +9,12 @@ ## Copyright: TravianX (c) 2010-2011. All rights reserved. ## ## ## ################################################################################# - -$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(34,$village->wid,1))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))+count($database->getMovement(5,$village->wid,0))+count($database->getMovement(6,$village->wid,0))-count($database->getMovement(8,$village->wid,1))-count($database->getMovement(9,$village->wid,0))); +$oases = 0; +$array = $database->getOasis($village->wid); +foreach($array as $conqured){ +$oases += count($database->getMovement(6,$village->wid,0)); +} +$aantal = (count($database->getMovement(4,$village->wid,1))+count($database->getMovement(3,$village->wid,1))+count($database->getMovement(3,$village->wid,0))+count($database->getMovement(7,$village->wid,1))+count($database->getMovement(5,$village->wid,0))+$oases-count($database->getMovement(8,$village->wid,1))-count($database->getMovement(9,$village->wid,0))); if($aantal > 0){ echo ''; @@ -51,7 +55,7 @@ if($aantal > 0){ if ($receive['attack_type'] == 2) { $action = 'def1'; $aclass = 'd1'; - $title = ''.OWN_REINFORCING_TROOPS.''; + $title = ''.ARRIVING_REINF_TROOPS.''; $short = ''.ARRIVING_REINF_TROOPS_SHORT.''; $NextArrival[] = $receive['endtime']; } @@ -132,31 +136,6 @@ if($lala > 0){ $timer += 1; } -/* Units send to reinf. (to my town) */ -$units_type = $database->getMovement("34",$village->wid,1); -$lala = count($units_type); -for($i=0;$i<$lala;$i++){ - if(($units_type[$i]['attack_type']==1)){ - $lala -= 1; - } -} - - if($lala > 0){ - if(!empty($NextArrival4)) { reset($NextArrival4); } - foreach($units_type as $receive) { - $action = 'def1'; - $aclass = 'd1'; - $title = ''.OWN_REINFORCING_TROOPS.''; - $short = ''.ARRIVING_REINF_TROOPS_SHORT.''; - $NextArrival4[] = $receive['endtime']; - } - - echo ' - '; - $timer += 1; - -} - /* Found NEW VILLAGE by Shadow */ $aantal = count($database->getMovement(5,$village->wid,0)); @@ -179,15 +158,27 @@ if($aantal > 0){ /* Attacks on Oasis (to my oasis) by Shadow */ -$aantal = count($database->getMovement(6,$village->wid,0)); -$aantal2 = $database->getMovement(6,$village->wid,0); +$aantal = 0; +$aantal2 = array(); +$array = $database->getOasis($village->wid); +foreach($array as $conqured){ +$aantal += count($database->getMovement(6,$conqured['wref'],0)); +$aantal2 = array_merge($database->getMovement(6,$conqured['wref'],0), $aantal2); +} if($aantal > 0){ if(!empty($NextArrival6)) { reset($NextArrival6); } foreach($aantal2 as $receive) { + if($receive['attack_type'] == 2){ + $action = 'def3'; + $aclass = 'd3'; + $title = ''.ARRIVING_REINF_TROOPS.''; + $short = ''.ARRIVING_REINF_TROOPS_SHORT.''; + }else{ $action = 'att3'; - $aclass = 'a1'; + $aclass = 'a3'; $title = ''.OASISATTACK.''; $short = ''.OASISATTACKS.''; + } $NextArrival6[] = $receive['endtime']; }
'.TROOP_MOVEMENTS.'
'.$title.'»
'.$lala.' '.$short.'
 '.$generator->getTimeFormat($receive['endtime']-time()).' '.HOURS.'