From 709ce395555ab521d1d3bdab920ec57dc4749286 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 Apr 2012 17:30:16 +0300 Subject: [PATCH] fix claim artefacts --- GameEngine/Automation.php | 28 ++++---- GameEngine/Database/db_MYSQL.php | 110 +++++++++++++++---------------- 2 files changed, 67 insertions(+), 71 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index b82217b8..5ed31e90 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1739,11 +1739,11 @@ private function loyaltyRegeneration() { } } - if($data['t11'] > 0){ +if($data['t11'] > 0){ if ($isoasis != 0) { if ($database->canConquerOasis($data['from'],$data['to'])) { $database->conquerOasis($data['from'],$data['to']); - $info_chief = $hero_pic." Your hero has conquered this oasis and gained ".$heroxp." XP"; + $info_chief = $hero_pic.",Your hero has conquered this oasis and gained ".$heroxp." XP"; } else { $OasisInfo = $database->getOasisInfo($data['to']); if ($OasisInfo['conqured'] != 0) { @@ -1751,26 +1751,26 @@ private function loyaltyRegeneration() { $database->modifyOasisLoyalty($data['to']); $OasisInfo = $database->getOasisInfo($data['to']); $Oloyaltynow = $OasisInfo['loyalty']; - $info_chief = $hero_pic." Your hero has reduced oasis loyalty to ".$Oloyaltynow." from ".$Oloyaltybefore." and gained ".$heroxp." XP"; + $info_chief = $hero_pic.",Your hero has reduced oasis loyalty to ".$Oloyaltynow." from ".$Oloyaltybefore." and gained ".$heroxp." XP"; } else { if ($heroxp == 0) { - $info_chief = $hero_pic." Your hero had nothing to kill therfore gains no XP at all"; + $info_chief = $hero_pic.",Your hero had nothing to kill therfore gains no XP at all"; } else { - $info_chief = $hero_pic." Your hero gained ".$heroxp." XP"; + $info_chief = $hero_pic.",Your hero gained ".$heroxp." XP"; } } } } else { - $artifact = $database->getOwnArtefactInfo($data['to']); - if ($artifact['vref'] == $data['to']){ - if($database->canClaimArtifact($artifact['vref'],$artifact['size'])) { - $database->claimArtefact($data['to'],$data['to'],$database->getVillageField($data['from'],"owner")); - $info_chief = $hero_pic." Your hero is carrying home a artifact, and gained ".$heroxp." XP from the battle"; - }else{ - $info_chief = $hero_pic." Your hero could not claim the artifact, and gained ".$heroxp." XP from the battle"; + $artifact = $database->getOwnArtefactInfo($data['to']); + if ($artifact['vref'] == $data['to']) { + if ($database->canClaimArtifact($data['from'],$artifact['vref'],$artifact['size'])) { + $database->claimArtefact($data['from'],$data['to'],$database->getVillageField($data['from'],"owner")); + $info_chief = $hero_pic.",Your hero is carrying home a artefact and gained ".$heroxp." XP from the battle"; + } else { + $info_chief = $hero_pic.",Your hero could not claim the artefact and gained ".$heroxp." XP from the battle"; - } - } + } + } } } diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 932d4b93..b5b77469 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -2403,67 +2403,63 @@ $result = mysql_query($q, $this->connection); return mysql_fetch_array($result); } - function claimArtefact($vref, $ovref, $id) { - $time = time(); - $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id WHERE vref = $ovref"; - $result = mysql_query($q, $this->connection); - return mysql_fetch_array($result); - } -## Hero Claim artifact by advocaite - public function canClaimArtifact ($vref,$type) { - $DefenderFields = $this->getResourceLevel($vref); - for($i=19;$i<=38;$i++) { + function claimArtefact($vref, $ovref, $id) { + $time = time(); + $q = "UPDATE " . TB_PREFIX . "artefacts SET vref = $vref, owner = $id, conquered = $time WHERE vref = $ovref"; + return mysql_query($q, $this->connection); + } + + public function canClaimArtifact($from,$vref,$type) { + $DefenderFields = $this->getResourceLevel($vref); + $defcanclaim = TRUE; + for($i=19;$i<=38;$i++) { + if($DefenderFields['f'.$i.'t'] == 27) { + $defTresuaryLevel = $DefenderFields['f'.$i]; + if($defTresuaryLevel > 0) { + $defcanclaim = FALSE; + } else { + $defcanclaim = TRUE; + } + } + } + $AttackerFields = $this->getResourceLevel($from); + for($i=19;$i<=38;$i++) { if($AttackerFields['f'.$i.'t'] == 27) { - $defcanclaim = FALSE; - $defTresuaryLevel = $AttackerFields['f'.$i]; - } else - { - $defcanclaim = TRUE; - } + $attTresuaryLevel = $AttackerFields['f'.$i]; + if ($attTresuaryLevel >= 10) { + $villageartifact = TRUE; + } else { + $villageartifact = FALSE; + } + if ($attTresuaryLevel >= 20){ + $accountartifact = TRUE; + } else { + $accountartifact = FALSE; + } + } } - $AttackerFields = $this->getResourceLevel($vref); - for($i=19;$i<=38;$i++) { - if($AttackerFields['f'.$i.'t'] == 27) { - $attTresuaryLevel = $AttackerFields['f'.$i]; - if ($attTresuaryLevel >= 10){ - $villageartifact = TRUE; - }else{ - $villageartifact = FALSE; - } - if ($attTresuaryLevel == 20){ - $accountartifact = TRUE; - }else{ - $accountartifact = FALSE; - } - } - } - - if ($type == 1) - { - if ($defcanclaim == TRUE && $villageartifact == TRUE) - { - return TRUE; - } - - }else if($type == 2) - { - if ($defcanclaim == TRUE && $accountartifact == TRUE) - { - return TRUE; - } - }else if($type == 3) - { - if ($defcanclaim == TRUE && $accountartifact == TRUE) - { - return TRUE; - } - }else - { - return FALSE; + if ($type == 1) { + if ($defcanclaim == TRUE && $villageartifact == TRUE) { + return TRUE; + } else { + return FALSE; + } + } else if ($type == 2) { + if ($defcanclaim == TRUE && $accountartifact == TRUE) { + return TRUE; + } else { + return FALSE; + } + } else if ($type == 3) { + if ($defcanclaim == TRUE && $accountartifact == TRUE) { + return TRUE; + } else { + return FALSE; + } + } else { + return FALSE; } - - } function getArtefactDetails($id) {