Merge pull request #449 from Shadowss/patch-112

fix conquer artefact
This commit is contained in:
yi12345
2013-11-07 14:16:37 -08:00
+64 -67
View File
@@ -3282,73 +3282,70 @@ class MYSQL_DB {
return mysql_query($q, $this->connection); return mysql_query($q, $this->connection);
} }
public function canClaimArtifact($from,$vref,$type,$kind) { public function canClaimArtifact($from,$vref,$type,$kind) {
$numArtefatti = mysql_query("SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $from"); //fix by Ronix
$numArtefatti2 = mysql_num_rows($numArtefatti); global $session, $form;
if($numArtefatti2 > 0){ $type1 = $type2 = $type3 = 0;
return FALSE;
} $artifact = $this->getOwnArtefactInfo($from);
$type2 = $type3 = 0; if (!empty($artifact)) {
if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,2,0)) > 0 && $type == 2){ $form->addError("error","Treasury is full. Your hero could not claim the artefact and");
$type2 = 1; return false;
} }
if(count($this->getOwnUniqueArtefactInfo2($this->getVillagefield($from,"owner"),2,3,0)) > 0 && $type == 3){ $uid=$session->uid;
$type3 = 1; $q="SELECT Count(type) AS totals,
} SUM(IF(type = '1',1,0)) small,
if((count($this->getOwnArtefactInfo2($from)) < 3 && $type2 == 0 && $type3 == 0) or $kind == 11){ SUM(IF(type = '2',1,0)) great,
$DefenderFields = $this->getResourceLevel($vref); SUM(IF(type = '3',1,0)) unique,
$defcanclaim = TRUE; FROM ".TB_PREFIX."artefacts WHERE owner = ".$uid;
for($i=19;$i<=38;$i++) { $result = mysql_query($q, $this->connection);
if($DefenderFields['f'.$i.'t'] == 27) { $artifact= $this->mysql_fetch_all($result);
$defTresuaryLevel = $DefenderFields['f'.$i]; if($artifact['totals'] < 3) {
if($defTresuaryLevel > 0) { $DefenderFields = $this->getResourceLevel($vref);
$defcanclaim = FALSE; $defcanclaim = TRUE;
} else { for($i=19;$i<=38;$i++) {
$defcanclaim = TRUE; if($DefenderFields['f'.$i.'t'] == 27) {
} $defTresuaryLevel = $DefenderFields['f'.$i];
} if($defTresuaryLevel > 0) {
} $defcanclaim = FALSE;
$AttackerFields = $this->getResourceLevel($from); $form->addError("error","Treasury has not been destroyed. Your hero could not claim the artefact and");
for($i=19;$i<=38;$i++) { return false;
if($AttackerFields['f'.$i.'t'] == 27) { } else {
$attTresuaryLevel = $AttackerFields['f'.$i]; $defcanclaim = TRUE;
if ($attTresuaryLevel >= 10) { }
$villageartifact = TRUE; }
} else { }
$villageartifact = FALSE; $AttackerFields = $this->getResourceLevel($from,2);
} for($i=19;$i<=38;$i++) {
if ($attTresuaryLevel >= 20){ if($AttackerFields['f'.$i.'t'] == 27) {
$accountartifact = TRUE; $attTresuaryLevel = $AttackerFields['f'.$i];
} else { if ($attTresuaryLevel >= 10) {
$accountartifact = FALSE; $villageartifact = TRUE;
} } else {
} $villageartifact = FALSE;
} }
if ($type == 1) { if ($attTresuaryLevel >= 20){
if ($defcanclaim == TRUE && $villageartifact == TRUE) { $accountartifact = TRUE;
return TRUE; } else {
} else { $accountartifact = FALSE;
return FALSE; }
} }
} else if ($type == 2) { }
if ($defcanclaim == TRUE && $accountartifact == TRUE) { if (($artifact['great']>0 || $artifact['unique']>0) && $type>1) {
return TRUE; $form->addError("error","Max num. of great/unique artefacts. Your hero could not claim the artefact and");
} else { return FALSE;
return FALSE; }
} if (($type == 1 && ($villageartifact || $accountartifact)) || (($type == 2 || $type == 3)&& $accountartifact)) {
} else if ($type == 3) { return TRUE;
if ($defcanclaim == TRUE && $accountartifact == TRUE) { } else {
return TRUE; $form->addError("error","Level treasury is low. Your hero could not claim the artefact and");
} else { return FALSE;
return FALSE; }
} } else {
} else { $form->addError("error","Max num. of artefacts. Your hero could not claim the artefact and");
return FALSE; return FALSE;
} }
}else{ }
return FALSE;
}
}
function getArtefactDetails($id) { function getArtefactDetails($id) {
$q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . ""; $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id = " . $id . "";