Update db_MYSQL.php

This commit is contained in:
Shadow
2013-12-08 09:28:59 +02:00
parent 0775bd9c2f
commit 7a64c2053f
+30 -33
View File
@@ -529,39 +529,36 @@ class MYSQL_DB {
return $troops_o;
}
public function canConquerOasis($vref,$wref) {
$AttackerFields = $this->getResourceLevel($vref);
for($i=19;$i<=38;$i++) {
if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; }
}
if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) {
$OasisInfo = $this->getOasisInfo($wref);
$troopcount = $this->countOasisTroops($wref);
if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && intval($OasisInfo['loyalty']) < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured']))) && $troopcount == 0) {
$CoordsVillage = $this->getCoor($vref);
$CoordsOasis = $this->getCoor($wref);
//if(abs($CoordsOasis['x']-$CoordsVillage['x'])<=3 && abs($CoordsOasis['y']-$CoordsVillage['y'])<=3) {
$max = 2 * WORLD_MAX + 1;
$x1 = intval($CoordsOasis['x']);
$y1 = intval($CoordsOasis['y']);
$x2 = intval($CoordsVillage['x']);
$y2 = intval($CoordsVillage['y']);
$distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
$distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
if ($distanceX<=3 && $distanceY<=3) {
return True;
} else {
return False;
}
} else {
return False;
}
} else {
return False;
}
}
public function canConquerOasis($vref,$wref) {
$AttackerFields = $this->getResourceLevel($vref);
for($i=19;$i<=38;$i++) {
if($AttackerFields['f'.$i.'t'] == 37) { $HeroMansionLevel = $AttackerFields['f'.$i]; }
}
if($this->VillageOasisCount($vref) < floor(($HeroMansionLevel-5)/5)) {
$OasisInfo = $this->getOasisInfo($wref);
//fix by ronix
if($OasisInfo['conqured'] == 0 || $OasisInfo['conqured'] != 0 && intval($OasisInfo['loyalty']) < 99 / min(3,(4-$this->VillageOasisCount($OasisInfo['conqured'])))){
$CoordsVillage = $this->getCoor($vref);
$CoordsOasis = $this->getCoor($wref);
$max = 2 * WORLD_MAX + 1;
$x1 = intval($CoordsOasis['x']);
$y1 = intval($CoordsOasis['y']);
$x2 = intval($CoordsVillage['x']);
$y2 = intval($CoordsVillage['y']);
$distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1)));
$distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1)));
if ($distanceX<=3 && $distanceY<=3) {
return 1; //can
} else {
return 2; //can but not in 7x7 field
}
} else {
return 3; //loyalty >0
}
} else {
return 0; //req level hero mansion
}
}
public function conquerOasis($vref,$wref) {
$vinfo = $this->getVillage($vref);