mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-22 02:57:14 +00:00
Fixed trap bugs
+Traps are now repaired (built) in the trapper building, instead of instantly given after a successful normal attack or a dismiss/releasing from the rally point +1/4 of trapped troops are now lost after a successful normal attack +Traps are now released when troops die from starvation +If you'll dismiss your trapped troops from the rally point, the gaul player will be able to only repair 1/3 of the total used traps +Created a new method to delete some redundant and duplicated code starvation related +The effect of WW building plans will be displayed correctly, when they're active +Troops related artifacts are now counted when building traps +Some minor improovements and bug fixing +Some clean-up
This commit is contained in:
+230
-330
@@ -295,51 +295,44 @@ class Automation {
|
|||||||
return round($dist, 1);
|
return round($dist, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTypeLevel($tid,$vid) {
|
public function getTypeLevel($tid, $vid) {
|
||||||
global $village,$database;
|
global $village, $database;
|
||||||
$keyholder = array();
|
|
||||||
|
$keyholder = [];
|
||||||
|
|
||||||
$resourcearray = $database->getResourceLevel($vid);
|
$resourcearray = $database->getResourceLevel($vid);
|
||||||
|
foreach(array_keys($resourcearray, $tid) as $key) {
|
||||||
foreach(array_keys($resourcearray,$tid) as $key) {
|
|
||||||
if(strpos($key,'t')) {
|
if(strpos($key,'t')) {
|
||||||
$key = preg_replace("/[^0-9]/", '', $key);
|
$key = preg_replace("/[^0-9]/", '', $key);
|
||||||
array_push($keyholder, $key);
|
array_push($keyholder, $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = count($keyholder);
|
$element = count($keyholder);
|
||||||
if($element >= 2) {
|
if($element >= 2) {
|
||||||
if($tid <= 4) {
|
if($tid <= 4) {
|
||||||
$temparray = array();
|
$temparray = array();
|
||||||
for($i=0;$i<=$element-1;$i++) {
|
for($i = 0; $i <= $element - 1; $i++) {
|
||||||
array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
|
array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
|
||||||
}
|
}
|
||||||
foreach ($temparray as $key => $val) {
|
foreach ($temparray as $key => $val) {
|
||||||
if ($val == max($temparray))
|
if ($val == max($temparray)) $target = $key;
|
||||||
$target = $key;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$target = 0;
|
$target = 0;
|
||||||
for($i=1;$i<=$element-1;$i++) {
|
for($i = 1; $i <= $element - 1; $i++) {
|
||||||
if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) {
|
if($resourcearray['f'.$keyholder[$i]] > $resourcearray['f'.$keyholder[$target]]) {
|
||||||
$target = $i;
|
$target = $i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($element == 1) {
|
else if($element == 1) $target = 0;
|
||||||
$target = 0;
|
else return 0;
|
||||||
}
|
|
||||||
else {
|
if(!empty($keyholder[$target])) return $resourcearray['f'.$keyholder[$target]];
|
||||||
return 0;
|
else return 0;
|
||||||
}
|
|
||||||
if($keyholder[$target] != "") {
|
|
||||||
return $resourcearray['f'.$keyholder[$target]];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function clearDeleting() {
|
private function clearDeleting() {
|
||||||
@@ -598,17 +591,8 @@ class Automation {
|
|||||||
$dbIdsToDelete[] = (int) $indi['id'];
|
$dbIdsToDelete[] = (int) $indi['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$crop = $database->getCropProdstarv($indi['wid']);
|
//Update starvation data
|
||||||
$unitarrays = $this->getAllUnits($indi['wid']);
|
$this->addStarvationData($indi['wid']);
|
||||||
$upkeep = $villageData['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $villageData["starv"];
|
|
||||||
if ($crop < $upkeep) {
|
|
||||||
// add starv data
|
|
||||||
$fieldsToSet['starv'] = $upkeep;
|
|
||||||
if($starv==0){
|
|
||||||
$fieldsToSet['starvupdate'] = $time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the requested fields, all at once
|
// update the requested fields, all at once
|
||||||
$database->setVillageFields($indi['wid'], array_keys($fieldsToSet), array_values($fieldsToSet));
|
$database->setVillageFields($indi['wid'], array_keys($fieldsToSet), array_values($fieldsToSet));
|
||||||
@@ -924,14 +908,14 @@ class Automation {
|
|||||||
if($availableIron < $itrans) $itrans = $availableIron;
|
if($availableIron < $itrans) $itrans = $availableIron;
|
||||||
if($availableCrop < $crtrans) $crtrans = $availableCrop;
|
if($availableCrop < $crtrans) $crtrans = $availableCrop;
|
||||||
|
|
||||||
$merchant2 = ($this->getTypeLevel(17,$from) > 0)? $this->getTypeLevel(17,$from) : 0;
|
$merchant2 = ($this->getTypeLevel(17, $from) > 0)? $this->getTypeLevel(17, $from) : 0;
|
||||||
$used2 = $database->totalMerchantUsed($from, false);
|
$used2 = $database->totalMerchantUsed($from, false);
|
||||||
$merchantAvail2 = $merchant2 - $used2;
|
$merchantAvail2 = $merchant2 - $used2;
|
||||||
$maxcarry2 = ($tribe == 1)? 500 : (($tribe == 2)? 1000 : 750);
|
$maxcarry2 = ($tribe == 1)? 500 : (($tribe == 2)? 1000 : 750);
|
||||||
$maxcarry2 *= TRADER_CAPACITY;
|
$maxcarry2 *= TRADER_CAPACITY;
|
||||||
|
|
||||||
if($this->getTypeLevel(28,$from) != 0) {
|
if($this->getTypeLevel(28, $from) != 0) {
|
||||||
$maxcarry2 *= $bid28[$this->getTypeLevel(28,$from)]['attri'] / 100;
|
$maxcarry2 *= $bid28[$this->getTypeLevel(28, $from)]['attri'] / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
|
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
|
||||||
@@ -1101,7 +1085,7 @@ class Automation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function sendunitsComplete() {
|
private function sendunitsComplete() {
|
||||||
global $bid23,$bid34,$database,$battle,$village,$technology,$logging,$generator,$session,$units,$autoprefix;
|
global $bid19, $bid23, $bid34, $u99, $database, $battle, $village, $technology, $logging, $generator, $session, $units, $autoprefix;
|
||||||
|
|
||||||
if(file_exists($autoprefix."GameEngine/Prevention/sendunits.txt")) {
|
if(file_exists($autoprefix."GameEngine/Prevention/sendunits.txt")) {
|
||||||
unlink($autoprefix."GameEngine/Prevention/sendunits.txt");
|
unlink($autoprefix."GameEngine/Prevention/sendunits.txt");
|
||||||
@@ -2523,7 +2507,7 @@ class Automation {
|
|||||||
if($type == 3 && $totalsend_att - ($totaldead_att + $totaltraped_att) > 0){
|
if($type == 3 && $totalsend_att - ($totaldead_att + $totaltraped_att) > 0){
|
||||||
$prisoners = $database->getPrisoners([$to['wref']], 0, false)[$to['wref'].'0'];
|
$prisoners = $database->getPrisoners([$to['wref']], 0, false)[$to['wref'].'0'];
|
||||||
if(count($prisoners) > 0){
|
if(count($prisoners) > 0){
|
||||||
$anothertroops = $mytorops = 0;
|
$anothertroops = $mytroops = $ownDeads = $anotherDeads = 0;
|
||||||
$prisoners2delete = [];
|
$prisoners2delete = [];
|
||||||
$movementType = [];
|
$movementType = [];
|
||||||
$movementFrom = [];
|
$movementFrom = [];
|
||||||
@@ -2538,12 +2522,18 @@ class Automation {
|
|||||||
|
|
||||||
//If troops are coming from the same village, add it to the returing troops
|
//If troops are coming from the same village, add it to the returing troops
|
||||||
if ($prisoner['from'] == $from['wref']) {
|
if ($prisoner['from'] == $from['wref']) {
|
||||||
|
for($i = 1; $i <= 11; $i++){
|
||||||
|
$deadPrisoners = round($prisoner['t'.$i] / 4);
|
||||||
|
$mytroops += $prisoner['t'.$i];
|
||||||
|
$ownDeads += $deadPrisoners;
|
||||||
|
$prisoner['t'.$i] -= $deadPrisoners;
|
||||||
|
}
|
||||||
|
|
||||||
$database->modifyAttack2(
|
$database->modifyAttack2(
|
||||||
$data['ref'],
|
$data['ref'],
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
|
||||||
[$prisoner['t1'], $prisoner['t2'], $prisoner['t3'], $prisoner['t4'], $prisoner['t5'], $prisoner['t6'], $prisoner['t7'], $prisoner['t8'], $prisoner['t9'], $prisoner['t10'], $prisoner['t11']]
|
[$prisoner['t1'], $prisoner['t2'], $prisoner['t3'], $prisoner['t4'], $prisoner['t5'], $prisoner['t6'], $prisoner['t7'], $prisoner['t8'], $prisoner['t9'], $prisoner['t10'], $prisoner['t11']]
|
||||||
);
|
);
|
||||||
for($i = 1; $i <= 11; $i++) $mytroops += $prisoner['t'.$i];
|
|
||||||
$prisoners2delete[] = $prisoner['id'];
|
$prisoners2delete[] = $prisoner['id'];
|
||||||
} else {
|
} else {
|
||||||
$p_alliance = $database->getUserField($p_owner, "alliance",0);
|
$p_alliance = $database->getUserField($p_owner, "alliance",0);
|
||||||
@@ -2555,20 +2545,28 @@ class Automation {
|
|||||||
if($p_alliance == $ownally || $friend || $neutral){
|
if($p_alliance == $ownally || $friend || $neutral){
|
||||||
$p_tribe = $database->getUserField($p_owner, "tribe", 0);
|
$p_tribe = $database->getUserField($p_owner, "tribe", 0);
|
||||||
|
|
||||||
|
for($i = 1; $i <= 11; $i++){
|
||||||
|
$deadPrisoners = round($prisoner['t'.$i] / 4);
|
||||||
|
if($p_owner == $from['owner']){
|
||||||
|
$mytroops += $prisoner['t'.$i];
|
||||||
|
$ownDeads += $deadPrisoners;
|
||||||
|
}else{
|
||||||
|
$anothertroops += $prisoner['t'.$i];
|
||||||
|
$anotherDeads += $deadPrisoners;
|
||||||
|
}
|
||||||
|
$prisoner['t'.$i] -= $deadPrisoners;
|
||||||
|
}
|
||||||
|
|
||||||
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
||||||
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
||||||
|
|
||||||
$p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
|
$p_reference = $database->addAttack($prisoner['from'], $prisoner['t1'], $prisoner['t2'], $prisoner['t3'], $prisoner['t4'], $prisoner['t5'], $prisoner['t6'], $prisoner['t7'], $prisoner['t8'], $prisoner['t9'], $prisoner['t10'], $prisoner['t11'], 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
$movementType[] = 4;
|
$movementType[] = 4;
|
||||||
$movementFrom[] = $prisoner['wref'];
|
$movementFrom[] = $prisoner['wref'];
|
||||||
$movementTo[] = $prisoner['from'];
|
$movementTo[] = $prisoner['from'];
|
||||||
$movementRef[] = $p_reference;
|
$movementRef[] = $p_reference;
|
||||||
$movementTime[] = $utime;
|
$movementTime[] = $utime;
|
||||||
$movementEndtime[] = $p_time + $utime;
|
$movementEndtime[] = $p_time + $utime;
|
||||||
for($i = 1; $i <= 11; $i++){
|
|
||||||
if($p_owner == $from['owner']) $mytroops += $prisoner['t'.$i];
|
|
||||||
else $anothertroops += $prisoner['t'.$i];
|
|
||||||
}
|
|
||||||
$prisoners2delete[] = $prisoner['id'];
|
$prisoners2delete[] = $prisoner['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2580,23 +2578,33 @@ class Automation {
|
|||||||
|
|
||||||
$database->deletePrisoners($prisoners2delete);
|
$database->deletePrisoners($prisoners2delete);
|
||||||
|
|
||||||
$newtraps = round(($mytroops + $anothertroops) / 3);
|
$ownDeadsText = ($ownAlive = $mytroops - $ownDeads) > 0 ? " of which <b>".$ownAlive."</b> have been saved" : "";
|
||||||
$database->modifyUnit(
|
$anotherDeadsText = ($anotherAlive = $anothertroops - $anotherDeads) > 0 ? " of which <b>".$anotherAlive."</b> have been saved" : "";
|
||||||
$data['to'],
|
|
||||||
['99', '99o'],
|
//Add dead troops to the "General attacks" tab
|
||||||
[$newtraps, $mytroops + $anothertroops],
|
$database->addGeneralAttack($ownDeads + $anotherDeads);
|
||||||
[0, 0]
|
|
||||||
|
//Calculate new traps which have to be repaired
|
||||||
|
$newtraps = round(($mytroops + $anothertroops) / 3);
|
||||||
|
|
||||||
|
//Reset traps
|
||||||
|
$database->modifyUnit($data['to'], ['99', '99o'], [$mytroops + $anothertroops, $mytroops + $anothertroops], [0, 0]);
|
||||||
|
|
||||||
|
//Repair needed traps
|
||||||
|
if($newtraps > 0){
|
||||||
|
$repairDuration = $database->getArtifactsValueInfluence($to['owner'], $to['wref'], 5, round(($bid19[max($this->getTypeLevel(36, $to['wref']), 1)]['attri'] / 100) * $u99['time'] / SPEED));
|
||||||
|
$database->trainUnit($to['wref'], 99, $newtraps, $u99['pop'], $repairDuration, 0);
|
||||||
|
}
|
||||||
|
|
||||||
);
|
|
||||||
$trapper_pic = "<img src=\"".GP_LOCATE."img/u/98.gif\" alt=\"Trap\" title=\"Trap\" />";
|
$trapper_pic = "<img src=\"".GP_LOCATE."img/u/98.gif\" alt=\"Trap\" title=\"Trap\" />";
|
||||||
$p_username = $database->getUserField($from['owner'], "username", 0);
|
$p_username = $database->getUserField($from['owner'], "username", 0);
|
||||||
|
|
||||||
if($mytroops > 0 && $anothertroops > 0){
|
if($mytroops > 0 && $anothertroops > 0){
|
||||||
$info_trap = "".$trapper_pic." <b>".$p_username."</b> released <b>".$mytroops."</b> from his troops and <b>".$anothertroops."</b> friendly troops.";
|
$info_trap = "".$trapper_pic." <b>".$p_username."</b> freed <b>".$mytroops."</b> from his troops".$ownDeadsText." and <b>".$anothertroops."</b> friendly troops".$anotherDeadsText.".";
|
||||||
}elseif($mytroops > 0){
|
}elseif($mytroops > 0){
|
||||||
$info_trap = "".$trapper_pic." <b>".$p_username."</b> released <b>".$mytroops."</b> from his troops.";
|
$info_trap = "".$trapper_pic." <b>".$p_username."</b> freed <b>".$mytroops."</b> from his troops".$ownDeadsText.".";
|
||||||
}elseif($anothertroops > 0){
|
}elseif($anothertroops > 0){
|
||||||
$info_trap = "".$trapper_pic." <b>".$p_username."</b> released <b>".$anothertroops."</b> friendly troops.";
|
$info_trap = "".$trapper_pic." <b>".$p_username."</b> freed <b>".$anothertroops."</b> friendly troops".$anotherDeadsText.".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2681,15 +2689,11 @@ class Automation {
|
|||||||
$database->addNotice($from['owner'],$to['wref'],$ownally,3,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
|
$database->addNotice($from['owner'],$to['wref'],$ownally,3,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data_fail,$AttackArrivalTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($type == 3 or $type == 4){
|
if($type == 3 || $type == 4) $database->addGeneralAttack($totalattackdead);
|
||||||
$database->addGeneralAttack($totalattackdead);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($village_destroyed)) $village_destroyed = 0;
|
if (!isset($village_destroyed)) $village_destroyed = 0;
|
||||||
|
|
||||||
if ($village_destroyed == 1 && $can_destroy==1) {
|
if ($village_destroyed == 1 && $can_destroy == 1) $this->DelVillage($data['to']);
|
||||||
$this->DelVillage($data['to']);
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
//units attack string for battleraport
|
//units attack string for battleraport
|
||||||
$unitssend_att1 = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
|
$unitssend_att1 = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
|
||||||
@@ -2709,22 +2713,8 @@ class Automation {
|
|||||||
$database->addNotice($to['owner'], $to['wref'], $targetally, 23,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'', $data2, $time);
|
$database->addNotice($to['owner'], $to['wref'], $targetally, 23,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'', $data2, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if not natar tribe
|
//Update starvation data
|
||||||
$getvillage = $database->getVillage($to['wref']);
|
$this->addStarvationData($to['wref']);
|
||||||
if ($getvillage['owner']!=3) {
|
|
||||||
$crop = $database->getCropProdstarv($to['wref'], false);
|
|
||||||
$unitarrays = $this->getAllUnits($to['wref'], false);
|
|
||||||
$village_upkeep = $getvillage['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $getvillage['starv'];
|
|
||||||
|
|
||||||
if ($crop < $village_upkeep){
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageField($to['wref'], 'starv', $village_upkeep);
|
|
||||||
if($starv==0)
|
|
||||||
$database->setVillageField($to['wref'], 'starvupdate', time());
|
|
||||||
}
|
|
||||||
unset($crop,$unitarrays,$getvillage,$village_upkeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Returning units back to village is not necessary because it will be taken care when processing movement
|
//Returning units back to village is not necessary because it will be taken care when processing movement
|
||||||
// Fix by AL-Kateb
|
// Fix by AL-Kateb
|
||||||
@@ -2986,13 +2976,12 @@ class Automation {
|
|||||||
$owntribe = $database->getUserField($AttackerID,"tribe",0);
|
$owntribe = $database->getUserField($AttackerID,"tribe",0);
|
||||||
|
|
||||||
//check to see if we're sending a hero between own villages and there's a Mansion at target village
|
//check to see if we're sending a hero between own villages and there's a Mansion at target village
|
||||||
$HeroTransfer=0;
|
$HeroTransfer = $troopsPresent = 0;
|
||||||
$troopsPresent=0;
|
|
||||||
if($data['t11'] != 0) {
|
if($data['t11'] != 0) {
|
||||||
if($AttackerID == $DefenderID) {
|
if($AttackerID == $DefenderID) {
|
||||||
// only add hero if we're sending him alone
|
// only add hero if we're sending him alone
|
||||||
if (
|
if (
|
||||||
($this->getTypeLevel(37,$data['to']) > 0) &&
|
($this->getTypeLevel(37, $data['to']) > 0) &&
|
||||||
($data['t1'] == 0) &&
|
($data['t1'] == 0) &&
|
||||||
($data['t2'] == 0) &&
|
($data['t2'] == 0) &&
|
||||||
($data['t3'] == 0) &&
|
($data['t3'] == 0) &&
|
||||||
@@ -3005,21 +2994,23 @@ class Automation {
|
|||||||
($data['t10'] == 0)
|
($data['t10'] == 0)
|
||||||
) {
|
) {
|
||||||
//don't reinforce, addunit instead
|
//don't reinforce, addunit instead
|
||||||
$database->modifyUnit($data['to'],array("hero"),array(1),array(1));
|
$database->modifyUnit($data['to'], ["hero"], [1], [1]);
|
||||||
$heroid = $database->getHeroField($DefenderID, 'heroid');
|
$heroid = $database->getHeroField($DefenderID, 'heroid');
|
||||||
$database->modifyHero("wref",$data['to'],$heroid,0);
|
$database->modifyHero("wref", $data['to'], $heroid, 0);
|
||||||
$HeroTransfer = 1;
|
$HeroTransfer = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for($i=1;$i<=10;$i++) {
|
|
||||||
if($data['t'.$i]>0) {
|
for($i = 1;$i <= 10; $i++) {
|
||||||
$troopsPresent = 1; break;
|
if($data['t'.$i] > 0) {
|
||||||
|
$troopsPresent = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['t11'] != 0 || $troopsPresent) {
|
if($data['t11'] != 0 || $troopsPresent) {
|
||||||
$temphero=$data['t11'];
|
$temphero = $data['t11'];
|
||||||
if ($HeroTransfer) $data['t11'] = 0;
|
if ($HeroTransfer) $data['t11'] = 0;
|
||||||
//check if there is defence from town in to town
|
//check if there is defence from town in to town
|
||||||
$check = $database->getEnforce($data['to'], $data['from']);
|
$check = $database->getEnforce($data['to'], $data['from']);
|
||||||
@@ -3059,26 +3050,15 @@ class Automation {
|
|||||||
$movementProcIDs[] = $data['moveid'];
|
$movementProcIDs[] = $data['moveid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$crop = $database->getCropProdstarv($data['to']);
|
//Update starvation data
|
||||||
$unitarrays = $this->getAllUnits($data['to']);
|
$this->addStarvationData($data['to']);
|
||||||
$village = $database->getVillage($data['to']);
|
|
||||||
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $database->getVillageField($data['to'],"starv");
|
|
||||||
if ($crop < $upkeep){
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageField($data['to'], 'starv', $upkeep);
|
|
||||||
if($starv==0){
|
|
||||||
$database->setVillageField($data['to'], 'starvupdate', $time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//check empty reinforcement in rally point
|
//check empty reinforcement in rally point
|
||||||
$e_units='';
|
$e_units = '';
|
||||||
for ($i=1; $i <= 50; $i++) {
|
for ($i = 1; $i <= 50; $i++) $e_units.= 'u'.$i.'= 0 AND ';
|
||||||
$e_units.='u'.$i.'=0 AND ';
|
|
||||||
}
|
$e_units.= 'hero = 0';
|
||||||
$e_units.='hero=0';
|
$q = "DELETE FROM ".TB_PREFIX."enforcement WHERE ".$e_units." AND (vref=".(int) $data['to']." OR `from`=".(int) $data['to'].")";
|
||||||
$q="DELETE FROM ".TB_PREFIX."enforcement WHERE ".$e_units." AND (vref=".(int) $data['to']." OR `from`=".(int) $data['to'].")";
|
|
||||||
$database->query($q);
|
$database->query($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3146,18 +3126,9 @@ class Automation {
|
|||||||
|
|
||||||
);
|
);
|
||||||
$movementProcIDs[] = $data['moveid'];
|
$movementProcIDs[] = $data['moveid'];
|
||||||
$crop = $database->getCropProdstarv($data['to']);
|
|
||||||
$unitarrays = $this->getAllUnits($data['to']);
|
//Update starvation data
|
||||||
$village = $database->getVillage($data['to']);
|
$this->addStarvationData($data['to']);
|
||||||
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $database->getVillageField($data['to'],"starv");
|
|
||||||
if ($crop < $upkeep){
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageField($data['to'], 'starv', $upkeep);
|
|
||||||
if($starv==0){
|
|
||||||
$database->setVillageField($data['to'], 'starvupdate', $time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure we don't process duplicate movements until the big bad bug which inserts them into DB is fixed
|
// make sure we don't process duplicate movements until the big bad bug which inserts them into DB is fixed
|
||||||
$wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']] = true;
|
$wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']] = true;
|
||||||
@@ -3189,18 +3160,9 @@ class Automation {
|
|||||||
$database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
|
$database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
|
||||||
//$database->updateVillage($data['to']);
|
//$database->updateVillage($data['to']);
|
||||||
$movementProcIDs[] = $data['moveid'];
|
$movementProcIDs[] = $data['moveid'];
|
||||||
$crop = $database->getCropProdstarv($data['to']);
|
|
||||||
$unitarrays = $this->getAllUnits($data['to']);
|
//Update starvation data
|
||||||
$village = $database->getVillage($data['to']);
|
$this->addStarvationData($data['to']);
|
||||||
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $database->getVillageField($data['to'],"starv");
|
|
||||||
if ($crop < $upkeep){
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageField($data['to'], 'starv', $upkeep);
|
|
||||||
if($starv==0){
|
|
||||||
$database->setVillageField($data['to'], 'starvupdate', $time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$database->setMovementProc(implode(', ', $movementProcIDs));
|
$database->setMovementProc(implode(', ', $movementProcIDs));
|
||||||
@@ -3352,7 +3314,7 @@ class Automation {
|
|||||||
|
|
||||||
//Activate activable artifacts
|
//Activate activable artifacts
|
||||||
foreach($inactiveArtifacts as $artifact){
|
foreach($inactiveArtifacts as $artifact){
|
||||||
if($ownArtifacts['totals'] < 3) {
|
if($ownArtifacts['totals'] < 3){
|
||||||
if($artifact['size'] == 1){ //Village effect
|
if($artifact['size'] == 1){ //Village effect
|
||||||
$database->activateArtifact($artifact['id']);
|
$database->activateArtifact($artifact['id']);
|
||||||
$ownArtifacts['totals']++;
|
$ownArtifacts['totals']++;
|
||||||
@@ -3379,7 +3341,7 @@ class Automation {
|
|||||||
|
|
||||||
$ownArtifacts['small']--;
|
$ownArtifacts['small']--;
|
||||||
$ownArtifacts['totals']++;
|
$ownArtifacts['totals']++;
|
||||||
if($size == 2) $ownArtifacts['great']++;
|
if($artifact['size'] == 2) $ownArtifacts['great']++;
|
||||||
else $ownArtifacts['unique']++;
|
else $ownArtifacts['unique']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3413,18 +3375,12 @@ class Automation {
|
|||||||
$sort_type = substr($data['tech'],0,1);
|
$sort_type = substr($data['tech'],0,1);
|
||||||
switch($sort_type) {
|
switch($sort_type) {
|
||||||
case "t":
|
case "t":
|
||||||
if (!isset($tdata[$data['vref']])) {
|
if (!isset($tdata[$data['vref']])) $tdata[$data['vref']] = [];
|
||||||
$tdata[$data['vref']] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$tdata[$data['vref']][] = $data['tech'].' = 1';
|
$tdata[$data['vref']][] = $data['tech'].' = 1';
|
||||||
break;
|
break;
|
||||||
case "a":
|
case "a":
|
||||||
case "b":
|
case "b":
|
||||||
if (!isset($abdata[$data['vref']])) {
|
if (!isset($abdata[$data['vref']])) $abdata[$data['vref']] = [];
|
||||||
$abdata[$data['vref']] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$abdata[$data['vref']][] = $data['tech']." = ".$data['tech']." + 1";
|
$abdata[$data['vref']][] = $data['tech']." = ".$data['tech']." + 1";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3489,38 +3445,38 @@ class Automation {
|
|||||||
switch($oasis['type']) {
|
switch($oasis['type']) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
$wood += 1;
|
$wood++;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$wood += 1;
|
$wood++;
|
||||||
$crop += 1;
|
$crop++;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
$clay += 1;
|
$clay++;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
$clay += 1;
|
$clay++;
|
||||||
$crop += 1;
|
$crop++;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
$iron += 1;
|
$iron++;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
$iron += 1;
|
$iron++;
|
||||||
$crop += 1;
|
$crop++;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
case 11:
|
case 11:
|
||||||
$crop += 1;
|
$crop++;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
$crop += 2;
|
$crop += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array($wood,$clay,$iron,$crop);
|
return [$wood, $clay, $iron, $crop];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllUnits($base, $use_cache = true) {
|
function getAllUnits($base, $use_cache = true) {
|
||||||
@@ -3712,6 +3668,22 @@ class Automation {
|
|||||||
$database->updateOasis($bountywid);
|
$database->updateOasis($bountywid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function bountyGetOWoodProd() {
|
||||||
|
return round(SPEED * 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function bountyGetOClayProd() {
|
||||||
|
return round(SPEED * 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function bountyGetOIronProd() {
|
||||||
|
return round(SPEED * 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function bountyGetOCropProd() {
|
||||||
|
return round(SPEED * 40);
|
||||||
|
}
|
||||||
|
|
||||||
private function bountyGetWoodProd() {
|
private function bountyGetWoodProd() {
|
||||||
global $bid1,$bid5,$session;
|
global $bid1,$bid5,$session;
|
||||||
$wood = $sawmill = 0;
|
$wood = $sawmill = 0;
|
||||||
@@ -3735,22 +3707,6 @@ class Automation {
|
|||||||
return round($wood);
|
return round($wood);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function bountyGetOWoodProd() {
|
|
||||||
return round(SPEED * 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function bountyGetOClayProd() {
|
|
||||||
return round(SPEED * 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function bountyGetOIronProd() {
|
|
||||||
return round(SPEED * 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function bountyGetOCropProd() {
|
|
||||||
return round(SPEED * 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function bountyGetClayProd() {
|
private function bountyGetClayProd() {
|
||||||
global $bid2,$bid6,$session;
|
global $bid2,$bid6,$session;
|
||||||
$clay = $brick = 0;
|
$clay = $brick = 0;
|
||||||
@@ -3891,22 +3847,10 @@ class Automation {
|
|||||||
if($train['amt'] - $trained <= 0) $database->trainUnit($train['id'], 0, 0, 0, 0, 1);
|
if($train['amt'] - $trained <= 0) $database->trainUnit($train['id'], 0, 0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($valuesUpdated) {
|
if ($valuesUpdated) call_user_func(get_class($database).'::clearUnitsCache');
|
||||||
call_user_func(get_class($database).'::clearUnitsCache');
|
|
||||||
}
|
|
||||||
|
|
||||||
$crop = $database->getCropProdstarv($train['vref']);
|
//Update starvation data
|
||||||
$unitarrays = $this->getAllUnits($train['vref']);
|
$this->addStarvationData($train['vref']);
|
||||||
$village = $database->getVillage($train['vref'], 0);
|
|
||||||
$upkeep = $village['pop'] + $this->getUpkeep($unitarrays, 0);
|
|
||||||
$starv = $database->getVillageField($train['vref'],"starv");
|
|
||||||
if ($crop < $upkeep){
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageField($train['vref'], 'starv', $upkeep);
|
|
||||||
if($starv==0){
|
|
||||||
$database->setVillageField($train['vref'], 'starvupdate', $time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(file_exists("GameEngine/Prevention/training.txt")) {
|
if(file_exists("GameEngine/Prevention/training.txt")) {
|
||||||
@@ -3914,56 +3858,35 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getsort_typeLevel($tid,$resarray) {
|
private function getsort_typeLevel($tid, $resarray) {
|
||||||
global $village;
|
$keyholder = [];
|
||||||
|
|
||||||
$keyholder = array();
|
foreach(array_keys($resarray, $tid) as $key) {
|
||||||
|
if(strpos($key, 't')) {
|
||||||
foreach(array_keys($resarray,$tid) as $key) {
|
|
||||||
if(strpos($key,'t')) {
|
|
||||||
$key = preg_replace("/[^0-9]/", '', $key);
|
$key = preg_replace("/[^0-9]/", '', $key);
|
||||||
array_push($keyholder, $key);
|
array_push($keyholder, $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = count($keyholder);
|
$element = count($keyholder);
|
||||||
|
|
||||||
if($element >= 2) {
|
if($element >= 2) {
|
||||||
|
|
||||||
if($tid <= 4) {
|
if($tid <= 4) {
|
||||||
$temparray = array();
|
$temparray = [];
|
||||||
|
|
||||||
for($i=0;$i<=$element-1;$i++) {
|
for($i = 0; $i <= $element - 1; $i++) {
|
||||||
array_push($temparray,$resarray['f'.$keyholder[$i]]);
|
array_push($temparray, $resarray['f'.$keyholder[$i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($temparray as $key => $val) {
|
foreach ($temparray as $key => $val) {
|
||||||
if ($val == max($temparray))
|
if ($val == max($temparray)) $target = $key;
|
||||||
$target = $key;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/*for($i=0;$i<=$element-1;$i++) {
|
|
||||||
//if($resarray['f'.$keyholder[$i]] != $this->getsort_typeMaxLevel($tid)) {
|
|
||||||
// $target = $i;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if($element == 1) {
|
|
||||||
$target = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else if($element == 1) $target = 0;
|
||||||
|
else return 0;
|
||||||
|
|
||||||
if($keyholder[$target] != "") {
|
if(!empty($keyholder[$target])) return $resarray['f'.$keyholder[$target]];
|
||||||
return $resarray['f'.$keyholder[$target]];
|
else return 0;
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function celebrationComplete() {
|
private function celebrationComplete() {
|
||||||
@@ -3983,7 +3906,7 @@ class Automation {
|
|||||||
$user = $vil['owner'];
|
$user = $vil['owner'];
|
||||||
$cp = ($type == 1) ? 500 : 2000;
|
$cp = ($type == 1) ? 500 : 2000;
|
||||||
$database->clearCel($id);
|
$database->clearCel($id);
|
||||||
$database->setCelCp($user,$cp);
|
$database->setCelCp($user, $cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists("GameEngine/Prevention/celebration.txt")) {
|
if(file_exists("GameEngine/Prevention/celebration.txt")) {
|
||||||
@@ -4032,7 +3955,7 @@ class Automation {
|
|||||||
if ($level == 1) $clear = ",f".$vil['buildnumber']."t=0";
|
if ($level == 1) $clear = ",f".$vil['buildnumber']."t=0";
|
||||||
else $clear = "";
|
else $clear = "";
|
||||||
|
|
||||||
if ($village->natar == 1 && $type == 40) $clear=""; //fix by ronix
|
if ($village->natar == 1 && $type == 40) $clear = ""; //fix by ronix
|
||||||
|
|
||||||
$q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".(($level - 1 >= 0) ? $level - 1 : 0).$clear." WHERE vref=".(int) $vil['vref'];
|
$q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".(($level - 1 >= 0) ? $level - 1 : 0).$clear." WHERE vref=".(int) $vil['vref'];
|
||||||
$database->query($q);
|
$database->query($q);
|
||||||
@@ -4077,35 +4000,26 @@ class Automation {
|
|||||||
$lastUpdateTime = $timeNow;
|
$lastUpdateTime = $timeNow;
|
||||||
$newHealth = -1;
|
$newHealth = -1;
|
||||||
|
|
||||||
if((time()-$hdata['lastupdate'])>=1){
|
if((time()-$hdata['lastupdate']) >= 1){
|
||||||
if($hdata['health']<100 and $hdata['health']>0){
|
if($hdata['health'] < 100 and $hdata['health'] > 0){
|
||||||
if(SPEED <= 10){
|
if(SPEED <= 10) $speed = SPEED;
|
||||||
$speed = SPEED;
|
else if(SPEED <= 100) $speed = ceil(SPEED / 10);
|
||||||
}else if(SPEED <= 100){
|
else $speed = ceil(SPEED / 100);
|
||||||
$speed = ceil(SPEED/10);
|
|
||||||
}else{
|
|
||||||
$speed = ceil(SPEED/100);
|
|
||||||
}
|
|
||||||
|
|
||||||
$reg = $hdata['health']+$hdata['regeneration']*5*$speed/86400*(time()-$hdata['lastupdate']);
|
$reg = $hdata['health'] + $hdata['regeneration'] * 5 * $speed / 86400 * (time() - $hdata['lastupdate']);
|
||||||
|
|
||||||
if($reg <= 100){
|
if($reg <= 100) $newHealth = $reg;
|
||||||
$newHealth = $reg;
|
else $newHealth = 100;
|
||||||
}else{
|
|
||||||
$newHealth = 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$herolevel = $hdata['level'];
|
$herolevel = $hdata['level'];
|
||||||
$newLevel = -1;
|
$newLevel = - 1;
|
||||||
$scorePoints = false;
|
$scorePoints = false;
|
||||||
for ($i = $herolevel+1; $i < 100; $i++){
|
for ($i = $herolevel + 1; $i < 100; $i++){
|
||||||
if($hdata['experience'] >= $hero_levels[$i]){
|
if($hdata['experience'] >= $hero_levels[$i]){
|
||||||
$newLevel = $i;
|
$newLevel = $i;
|
||||||
if ($i < 99) {
|
if ($i < 99) $scorePoints = true;
|
||||||
$scorePoints = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4174,9 +4088,7 @@ class Automation {
|
|||||||
$lastUpdateIDs[] = $hdata['heroid'];
|
$lastUpdateIDs[] = $hdata['heroid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($columns)) {
|
if (count($columns)) $database->modifyHero($columns, $columnValues, $hdata['heroid'], $modes);
|
||||||
$database->modifyHero( $columns, $columnValues, $hdata['heroid'], $modes );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($lastUpdateIDs)) {
|
if (count($lastUpdateIDs)) {
|
||||||
@@ -4194,7 +4106,7 @@ class Automation {
|
|||||||
private function updateStore() {
|
private function updateStore() {
|
||||||
global $database, $bid10, $bid38, $bid11, $bid39;
|
global $database, $bid10, $bid38, $bid11, $bid39;
|
||||||
|
|
||||||
$result = mysqli_query($database->dblink,'SELECT * FROM `' . TB_PREFIX . 'fdata`');
|
$result = mysqli_query($database->dblink, 'SELECT * FROM `' . TB_PREFIX . 'fdata`');
|
||||||
|
|
||||||
mysqli_begin_transaction($database->dblink);
|
mysqli_begin_transaction($database->dblink);
|
||||||
while ($row = mysqli_fetch_assoc($result))
|
while ($row = mysqli_fetch_assoc($result))
|
||||||
@@ -4202,23 +4114,25 @@ class Automation {
|
|||||||
$ress = $crop = 0;
|
$ress = $crop = 0;
|
||||||
for ($i = 19; $i < 40; ++$i)
|
for ($i = 19; $i < 40; ++$i)
|
||||||
{
|
{
|
||||||
|
//Warehouse
|
||||||
if ($row['f' . $i . 't'] == 10)
|
if ($row['f' . $i . 't'] == 10)
|
||||||
{
|
{
|
||||||
$ress += ((isset($bid10[$row['f' . $i]]) && isset($bid10[$row['f' . $i]]['attri'])) ? $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
$ress += ((isset($bid10[$row['f' . $i]]) && isset($bid10[$row['f' . $i]]['attri'])) ? $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Great warehouse
|
||||||
if ($row['f' . $i . 't'] == 38)
|
if ($row['f' . $i . 't'] == 38)
|
||||||
{
|
{
|
||||||
$ress += ((isset($bid38[$row['f' . $i]]) && isset($bid38[$row['f' . $i]]['attri'])) ? $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
$ress += ((isset($bid38[$row['f' . $i]]) && isset($bid38[$row['f' . $i]]['attri'])) ? $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Granary
|
||||||
|
|
||||||
if ($row['f' . $i . 't'] == 11)
|
if ($row['f' . $i . 't'] == 11)
|
||||||
{
|
{
|
||||||
$crop += ((isset($bid11[$row['f' . $i]]) && isset($bid11[$row['f' . $i]]['attri'])) ? $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
$crop += ((isset($bid11[$row['f' . $i]]) && isset($bid11[$row['f' . $i]]['attri'])) ? $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Great granary
|
||||||
if ($row['f' . $i . 't'] == 39)
|
if ($row['f' . $i . 't'] == 39)
|
||||||
{
|
{
|
||||||
$crop += ((isset($bid39[$row['f' . $i]]) && isset($bid39[$row['f' . $i]]['attri'])) ? $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
$crop += ((isset($bid39[$row['f' . $i]]) && isset($bid39[$row['f' . $i]]['attri'])) ? $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
|
||||||
@@ -4227,18 +4141,11 @@ class Automation {
|
|||||||
|
|
||||||
// no need for update, since we didn't find any warehouses or granaries
|
// no need for update, since we didn't find any warehouses or granaries
|
||||||
// and maximums would have been set to correct values inside prune* functions already
|
// and maximums would have been set to correct values inside prune* functions already
|
||||||
if ($ress == 0 && $crop == 0) {
|
if ($ress == 0 && $crop == 0) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// maxstore nor maxcrop can go below the minimum threshold
|
// maxstore nor maxcrop can go below the minimum threshold
|
||||||
if ($ress < STORAGE_BASE) {
|
if ($ress < STORAGE_BASE) $ress = STORAGE_BASE;
|
||||||
$ress = STORAGE_BASE;
|
if ($crop < STORAGE_BASE) $crop = STORAGE_BASE;
|
||||||
}
|
|
||||||
|
|
||||||
if ($crop < STORAGE_BASE) {
|
|
||||||
$crop = STORAGE_BASE;
|
|
||||||
}
|
|
||||||
|
|
||||||
mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']);
|
mysqli_query($database->dblink,'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']);
|
||||||
}
|
}
|
||||||
@@ -4309,12 +4216,12 @@ class Automation {
|
|||||||
$array = $database->query_return($q);
|
$array = $database->query_return($q);
|
||||||
|
|
||||||
foreach($array as $master) {
|
foreach($array as $master) {
|
||||||
$owner = $database->getVillageField($master['wid'],'owner');
|
$owner = $database->getVillageField($master['wid'], 'owner');
|
||||||
$tribe = $database->getUserField($owner,'tribe',0);
|
$tribe = $database->getUserField($owner, 'tribe', 0);
|
||||||
$villwood = $database->getVillageField($master['wid'],'wood');
|
$villwood = $database->getVillageField($master['wid'], 'wood');
|
||||||
$villclay = $database->getVillageField($master['wid'],'clay');
|
$villclay = $database->getVillageField($master['wid'], 'clay');
|
||||||
$villiron = $database->getVillageField($master['wid'],'iron');
|
$villiron = $database->getVillageField($master['wid'], 'iron');
|
||||||
$villcrop = $database->getVillageField($master['wid'],'crop');
|
$villcrop = $database->getVillageField($master['wid'], 'crop');
|
||||||
$type = $master['type'];
|
$type = $master['type'];
|
||||||
$level = $master['level'];
|
$level = $master['level'];
|
||||||
$buildarray = $GLOBALS["bid".$type];
|
$buildarray = $GLOBALS["bid".$type];
|
||||||
@@ -4322,10 +4229,9 @@ class Automation {
|
|||||||
$buildclay = $buildarray[$level]['clay'];
|
$buildclay = $buildarray[$level]['clay'];
|
||||||
$buildiron = $buildarray[$level]['iron'];
|
$buildiron = $buildarray[$level]['iron'];
|
||||||
$buildcrop = $buildarray[$level]['crop'];
|
$buildcrop = $buildarray[$level]['crop'];
|
||||||
$ww = count($database->getBuildingByType($master['wid'],40));
|
$ww = count($database->getBuildingByType($master['wid'], 40));
|
||||||
|
|
||||||
if($tribe == 1){
|
if($tribe == 1){
|
||||||
|
|
||||||
if($master['field'] < 19){
|
if($master['field'] < 19){
|
||||||
$dorf1Buildings = $database->getDorf1Building($master['wid']);
|
$dorf1Buildings = $database->getDorf1Building($master['wid']);
|
||||||
$bdata = count($dorf1Buildings);
|
$bdata = count($dorf1Buildings);
|
||||||
@@ -4344,17 +4250,11 @@ class Automation {
|
|||||||
$bdata1 = $dorf1Buildings;
|
$bdata1 = $dorf1Buildings;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($database->getUserField($owner,'plus',0) > time() or $ww > 0){
|
if($database->getUserField($owner, 'plus', 0) > time() || $ww > 0){
|
||||||
|
if($bbdata < 2) $inbuild = 2;
|
||||||
if($bbdata < 2){
|
else $inbuild = 1;
|
||||||
$inbuild = 2;
|
|
||||||
}else{
|
|
||||||
$inbuild = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$inbuild = 1;
|
|
||||||
}
|
}
|
||||||
|
else $inbuild = 1;
|
||||||
|
|
||||||
$usergold = $database->getUserField($owner,'gold',0);
|
$usergold = $database->getUserField($owner,'gold',0);
|
||||||
|
|
||||||
@@ -4363,29 +4263,51 @@ class Automation {
|
|||||||
|
|
||||||
if(!empty($bdata1)){
|
if(!empty($bdata1)){
|
||||||
foreach($bdata1 as $master1) {
|
foreach($bdata1 as $master1) {
|
||||||
$time += ($master1['timestamp']-time());
|
$time += ($master1['timestamp'] - time());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bdata == 0){
|
if($bdata == 0) $database->updateBuildingWithMaster($master['id'], $time, 0);
|
||||||
$database->updateBuildingWithMaster($master['id'],$time,0);
|
else $database->updateBuildingWithMaster($master['id'], $time, 1);
|
||||||
}else{
|
|
||||||
$database->updateBuildingWithMaster($master['id'],$time,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$gold = $usergold-1;
|
$database->updateUserField($owner, 'gold', --$usergold, 1);
|
||||||
$database->updateUserField($owner,'gold',$gold,1);
|
$database->modifyResource($master['wid'], $buildwood, $buildclay, $buildiron, $buildcrop, 0);
|
||||||
$database->modifyResource($master['wid'],$buildwood,$buildclay,$buildiron,$buildcrop,0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************
|
/**
|
||||||
Function for starvation - by brainiacX and Shadow
|
* Adds the starvation data in villages with a negative value of crop
|
||||||
Rework by ronix
|
*
|
||||||
Refactored by iopietro
|
* @param int $wref The village ID where the crop is negative
|
||||||
References:
|
*/
|
||||||
************************************************/
|
|
||||||
|
private function addStarvationData($wref){
|
||||||
|
global $database;
|
||||||
|
|
||||||
|
$getVillage = $database->getVillage($wref);
|
||||||
|
|
||||||
|
//Exlude Support, Nature, Natars, TaskMaster and Multihunter
|
||||||
|
if ($getVillage['owner'] > 5){
|
||||||
|
$crop = $database->getCropProdstarv($wref, false);
|
||||||
|
$unitArrays = $this->getAllUnits($wref, false);
|
||||||
|
$villageUpkeep = $getVillage['pop'] + $this->getUpkeep($unitArrays, 0);
|
||||||
|
$starv = $getVillage['starv'];
|
||||||
|
|
||||||
|
if ($crop < $villageUpkeep){
|
||||||
|
|
||||||
|
//Add starvation data
|
||||||
|
$database->setVillageField($wref, 'starv', $villageUpkeep);
|
||||||
|
$database->setVillageFields($wref, ['starv', 'starvupdate'], [$villageUpkeep, time()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for starvation - by brainiacX and Shadow
|
||||||
|
* Rework by ronix
|
||||||
|
* Refactored by iopietro
|
||||||
|
*/
|
||||||
|
|
||||||
//TODO: This function needs to be splitted in many subfunctions (for TravianZ refactor)
|
//TODO: This function needs to be splitted in many subfunctions (for TravianZ refactor)
|
||||||
private function starvation() {
|
private function starvation() {
|
||||||
@@ -4404,23 +4326,9 @@ class Automation {
|
|||||||
|
|
||||||
//update starvation in every village
|
//update starvation in every village
|
||||||
$starvarray = $database->getProfileVillages(0, 7);
|
$starvarray = $database->getProfileVillages(0, 7);
|
||||||
foreach($starvarray as $starv)
|
foreach($starvarray as $starv) $this->addStarvationData($starv['wref']);
|
||||||
{
|
|
||||||
$crop = $database->getCropProdstarv($starv['wref']);
|
|
||||||
$unitArrays = $this->getAllUnits($starv['wref']);
|
|
||||||
$villageUpkeep = $starv['pop'] + $this->getUpkeep($unitArrays, 0);
|
|
||||||
|
|
||||||
if ($crop < $villageUpkeep)
|
|
||||||
{
|
|
||||||
// add starv data
|
|
||||||
$database->setVillageFields($starv['wref'], ['starv', 'starvupdate'], [$villageUpkeep, time()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($crop, $unitArrays, $villageUpkeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
// load villages with minus prod
|
// load villages with minus prod
|
||||||
|
|
||||||
$starvarray = [];
|
$starvarray = [];
|
||||||
$starvarray = $database->getStarvation();
|
$starvarray = $database->getStarvation();
|
||||||
|
|
||||||
@@ -4560,8 +4468,13 @@ class Automation {
|
|||||||
if($totalKilledUnits < $totalUnits)
|
if($totalKilledUnits < $totalUnits)
|
||||||
{
|
{
|
||||||
$database->modifyPrisoners($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
|
$database->modifyPrisoners($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
|
||||||
|
$database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalKilledUnits], [0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$database->deletePrisoners($starvingTroops['id']);
|
||||||
|
$database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalUnits], [0]);
|
||||||
}
|
}
|
||||||
else $database->deletePrisoners($starvingTroops['id']);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -4595,29 +4508,23 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************
|
|
||||||
Function for starvation - by brainiacX and Shadow
|
|
||||||
Rework by ronix
|
|
||||||
Refactored by iopietro
|
|
||||||
References:
|
|
||||||
************************************************/
|
|
||||||
|
|
||||||
private function procNewClimbers() {
|
private function procNewClimbers() {
|
||||||
if(file_exists("GameEngine/Prevention/climbers.txt")) {
|
if(file_exists("GameEngine/Prevention/climbers.txt")) {
|
||||||
unlink("GameEngine/Prevention/climbers.txt");
|
unlink("GameEngine/Prevention/climbers.txt");
|
||||||
}
|
}
|
||||||
global $database, $ranking;
|
global $database, $ranking;
|
||||||
|
|
||||||
$ranking->procRankArray();
|
$ranking->procRankArray();
|
||||||
$climbers = $ranking->getRank();
|
$climbers = $ranking->getRank();
|
||||||
if(count($climbers) > 0){
|
if(count($climbers) > 0){
|
||||||
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
|
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
|
||||||
$result = mysqli_query($database->dblink,$q);
|
$result = mysqli_query($database->dblink,$q);
|
||||||
if(mysqli_num_rows($result)) {
|
if(mysqli_num_rows($result)) {
|
||||||
$row=mysqli_fetch_assoc($result);
|
$row = mysqli_fetch_assoc($result);
|
||||||
$week=($row['week']+1);
|
$week = $row['week'] + 1;
|
||||||
} else {
|
|
||||||
$week='1';
|
|
||||||
}
|
}
|
||||||
|
else $week = 1;
|
||||||
|
|
||||||
$q = "SELECT id FROM ".TB_PREFIX."users where oldrank = 0 and id > 5";
|
$q = "SELECT id FROM ".TB_PREFIX."users where oldrank = 0 and id > 5";
|
||||||
$array = $database->query_return($q);
|
$array = $database->query_return($q);
|
||||||
foreach($array as $user){
|
foreach($array as $user){
|
||||||
@@ -4662,6 +4569,7 @@ class Automation {
|
|||||||
|
|
||||||
private function procClimbers($uid) {
|
private function procClimbers($uid) {
|
||||||
global $database, $ranking;
|
global $database, $ranking;
|
||||||
|
|
||||||
$ranking->procRankArray();
|
$ranking->procRankArray();
|
||||||
$climbers = $ranking->getRank();
|
$climbers = $ranking->getRank();
|
||||||
if(count($ranking->getRank()) > 0){
|
if(count($ranking->getRank()) > 0){
|
||||||
@@ -4669,10 +4577,10 @@ class Automation {
|
|||||||
$result = mysqli_query($database->dblink,$q);
|
$result = mysqli_query($database->dblink,$q);
|
||||||
if(mysqli_num_rows($result)) {
|
if(mysqli_num_rows($result)) {
|
||||||
$row = mysqli_fetch_assoc($result);
|
$row = mysqli_fetch_assoc($result);
|
||||||
$week = ($row['week'] + 1);
|
$week = $row['week'] + 1;
|
||||||
} else {
|
|
||||||
$week = 1;
|
|
||||||
}
|
}
|
||||||
|
else $week = 1;
|
||||||
|
|
||||||
$myrank = $ranking->getUserRank($uid);
|
$myrank = $ranking->getUserRank($uid);
|
||||||
if(isset($climbers[$myrank]['oldrank']) && $climbers[$myrank]['oldrank'] > $myrank){
|
if(isset($climbers[$myrank]['oldrank']) && $climbers[$myrank]['oldrank'] > $myrank){
|
||||||
for($i = $myrank + 1; $i <= $climbers[$myrank]['oldrank']; $i++) {
|
for($i = $myrank + 1; $i <= $climbers[$myrank]['oldrank']; $i++) {
|
||||||
@@ -4779,23 +4687,20 @@ class Automation {
|
|||||||
|
|
||||||
private function regenerateOasisTroops() {
|
private function regenerateOasisTroops() {
|
||||||
global $database;
|
global $database;
|
||||||
$time = time();
|
|
||||||
$time2 = NATURE_REGTIME;
|
$timeFinal = time() - NATURE_REGTIME;
|
||||||
$timeFinal = $time - $time2;
|
|
||||||
$q = "SELECT wref FROM " . TB_PREFIX . "odata where conqured = 0 and lastupdated2 < $timeFinal";
|
$q = "SELECT wref FROM " . TB_PREFIX . "odata where conqured = 0 and lastupdated2 < $timeFinal";
|
||||||
$array = $database->query_return($q);
|
$array = $database->query_return($q);
|
||||||
if (count($array)) {
|
if (count($array)) {
|
||||||
$ids = [];
|
$ids = [];
|
||||||
foreach($array as $oasis) {
|
foreach($array as $oasis) $ids[] = $oasis['wref'];
|
||||||
$ids[] = $oasis['wref'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$database->regenerateOasisUnits($ids, true);
|
$database->regenerateOasisUnits($ids, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updateMax($leader) {
|
public static function updateMax($leader) {
|
||||||
global $bid18, $database;
|
global $bid18, $database;
|
||||||
|
|
||||||
$q = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "alidata where leader = ". (int) $leader), MYSQLI_ASSOC);
|
$q = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "alidata where leader = ". (int) $leader), MYSQLI_ASSOC);
|
||||||
if ($q['Total'] > 0) {
|
if ($q['Total'] > 0) {
|
||||||
$villages = $database->getVillagesID2($leader);
|
$villages = $database->getVillagesID2($leader);
|
||||||
@@ -4826,7 +4731,7 @@ class Automation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function checkReviveHero(){
|
private function checkReviveHero(){
|
||||||
global $database,$session;
|
global $database, $session;
|
||||||
$herodata = $database->getHero($session->uid, 1);
|
$herodata = $database->getHero($session->uid, 1);
|
||||||
if ($herodata[0]['dead'] == 1){
|
if ($herodata[0]['dead'] == 1){
|
||||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".(int) $session->villages[0]."");
|
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET hero = 0 WHERE vref = ".(int) $session->villages[0]."");
|
||||||
@@ -4841,13 +4746,13 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************
|
/**
|
||||||
Function for automate medals - by yi12345 and Shadow
|
* Function for automate medals - by yi12345 and Shadow
|
||||||
References:
|
*
|
||||||
************************************************/
|
*/
|
||||||
|
|
||||||
function medals(){
|
function medals(){
|
||||||
global $ranking,$database;
|
global $ranking, $database;
|
||||||
|
|
||||||
//we may give away ribbons
|
//we may give away ribbons
|
||||||
$giveMedal = false;
|
$giveMedal = false;
|
||||||
@@ -5370,11 +5275,6 @@ class Automation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************
|
|
||||||
Function for automate medals - by yi12345 and Shadow
|
|
||||||
References:
|
|
||||||
************************************************/
|
|
||||||
|
|
||||||
private function artefactOfTheFool() {
|
private function artefactOfTheFool() {
|
||||||
global $database;
|
global $database;
|
||||||
$time = time();
|
$time = time();
|
||||||
|
|||||||
@@ -855,7 +855,7 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no n eed to cache this method
|
// no need to cache this method
|
||||||
function getSitee($uid) {
|
function getSitee($uid) {
|
||||||
list($uid) = $this->escape_input((int) $uid);
|
list($uid) = $this->escape_input((int) $uid);
|
||||||
|
|
||||||
@@ -6111,13 +6111,13 @@ References: User ID/Message ID, Mode
|
|||||||
else{$unit = 'u' . $unit;}
|
else{$unit = 'u' . $unit;}
|
||||||
|
|
||||||
++$i;
|
++$i;
|
||||||
//Fixed part of negativ troops (double troops) - by InCube
|
//Fixed part of negative troops (double troops) - by InCube
|
||||||
$array_amt[$i] = (int) $array_amt[$i] < 0 ? 0 : $array_amt[$i];
|
$array_amt[$i] = (int) $array_amt[$i] < 0 ? 0 : $array_amt[$i];
|
||||||
//Fixed part of negativ troops (double troops) - by InCube
|
//Fixed part of negative troops (double troops) - by InCube
|
||||||
$units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.($array_amt[$i] ? $array_amt[$i] : 0).(($number > $i+1) ? ', ' : '');
|
$units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.($array_amt[$i] ? $array_amt[$i] : 0).(($number > $i+1) ? ', ' : '');
|
||||||
}
|
}
|
||||||
$q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
|
$q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
|
||||||
return mysqli_query($this->dblink,$q);
|
return mysqli_query($this->dblink, $q);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnforce($vid, $from, $use_cache = true) {
|
function getEnforce($vid, $from, $use_cache = true) {
|
||||||
|
|||||||
+14
-13
@@ -1003,19 +1003,20 @@ define("REQUIRED_LEVEL","Required level");
|
|||||||
define("TIME_CONQUER","Time of conquer");
|
define("TIME_CONQUER","Time of conquer");
|
||||||
define("TIME_ACTIVATION","Time of activation");
|
define("TIME_ACTIVATION","Time of activation");
|
||||||
define("FORMER_OWNER","Former owner(s)");
|
define("FORMER_OWNER","Former owner(s)");
|
||||||
define("BUILDING_STRONGER","building stronger with");
|
define("BUILDING_STRONGER","Building stronger with");
|
||||||
define("BUILDING_WEAKER","building weaker with");
|
define("BUILDING_WEAKER","Building weaker with");
|
||||||
define("TROOPS_FASTER","makes troops faster with");
|
define("TROOPS_FASTER","Makes troops faster with");
|
||||||
define("TROOPS_SLOWEST","makes troops slowest with");
|
define("TROOPS_SLOWEST","Makes troops slowest with");
|
||||||
define("SPIES_INCREASE","spies increase ability with");
|
define("SPIES_INCREASE","Spies increase ability with");
|
||||||
define("SPIES_DECRESE","spies decrese ability with");
|
define("SPIES_DECRESE","Spies decrese ability with");
|
||||||
define("CONSUME_LESS","all troops consume less with");
|
define("CONSUME_LESS","All troops consume less with");
|
||||||
define("CONSUME_HIGH","all troops consume high with");
|
define("CONSUME_HIGH","All troops consume high with");
|
||||||
define("TROOPS_MAKE_FASTER","troops make faster with");
|
define("TROOPS_MAKE_FASTER","Troops make faster with");
|
||||||
define("TROOPS_MAKE_SLOWEST","troops make slowest with");
|
define("TROOPS_MAKE_SLOWEST","Troops make slowest with");
|
||||||
define("YOU_CONSTRUCT","you can construct ");
|
define("YOU_CONSTRUCT","You can construct ");
|
||||||
define("CRANNY_INCREASED","cranny capacity is increased by");
|
define("CRANNY_INCREASED","Cranny capacity is increased by");
|
||||||
define("CRANNY_DECRESE","cranny capacity is decrese by");
|
define("CRANNY_DECRESE","Cranny capacity is decrese by");
|
||||||
|
define("WW_BUILDING_PLAN","You can build the Wonder of the World");
|
||||||
define("NO_PREVIOUS_OWNERS","There are no previous owners.");
|
define("NO_PREVIOUS_OWNERS","There are no previous owners.");
|
||||||
define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective.");
|
define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective.");
|
||||||
|
|
||||||
|
|||||||
+25
-29
@@ -507,7 +507,7 @@ class Technology {
|
|||||||
return $database->getArtifactsValueInfluence($session->uid, $vid, 4, $upkeep);
|
return $database->getArtifactsValueInfluence($session->uid, $vid, 4, $upkeep);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function trainUnit($unit,$amt,$great=false) {
|
private function trainUnit($unit, $amt, $great = false) {
|
||||||
global $session, $database, ${'u'.$unit}, $building, $village, $bid19, $bid20, $bid21, $bid25, $bid26, $bid29, $bid30, $bid36, $bid41, $bid42;
|
global $session, $database, ${'u'.$unit}, $building, $village, $bid19, $bid20, $bid21, $bid25, $bid26, $bid29, $bid30, $bid36, $bid41, $bid42;
|
||||||
|
|
||||||
if($this->getTech($unit) || $unit % 10 <= 1 || $unit == 99) {
|
if($this->getTech($unit) || $unit % 10 <= 1 || $unit == 99) {
|
||||||
@@ -557,36 +557,32 @@ class Technology {
|
|||||||
|
|
||||||
$each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
|
$each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
|
||||||
}
|
}
|
||||||
if($unit%10 == 0 || $unit%10 == 9 && $unit != 99) {
|
if($unit % 10 == 0 || $unit % 10 == 9 && $unit != 99) {
|
||||||
$slots = $database->getAvailableExpansionTraining();
|
$slots = $database->getAvailableExpansionTraining();
|
||||||
if($unit%10 == 0 && $slots['settlers'] <= $amt) { $amt = $slots['settlers']; }
|
if($unit % 10 == 0 && $slots['settlers'] <= $amt) $amt = $slots['settlers'];
|
||||||
if($unit%10 == 9 && $slots['chiefs'] <= $amt) { $amt = $slots['chiefs']; }
|
if($unit % 10 == 9 && $slots['chiefs'] <= $amt) $amt = $slots['chiefs'];
|
||||||
} else {
|
} else {
|
||||||
if($unit != 99){
|
if($unit != 99){
|
||||||
if($this->maxUnit($unit,$great) < $amt) {
|
if($this->maxUnit($unit, $great) < $amt) $amt = 0;
|
||||||
$amt = 0;
|
}else{
|
||||||
}
|
$trainlist = $this->getTrainingList(8);
|
||||||
}else{
|
|
||||||
$trainlist = $this->getTrainingList(8);
|
foreach($trainlist as $train) $train_amt += $train['amt'];
|
||||||
foreach($trainlist as $train) {
|
|
||||||
$train_amt += $train['amt'];
|
$max = 0;
|
||||||
|
for($i = 19; $i < 41; $i++){
|
||||||
|
if($village->resarray['f'.$i.'t'] == 36){
|
||||||
|
$max += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$max1 = $max - ($village->unitarray['u99'] + $train_amt);
|
||||||
|
if($max1 < $amt) $amt = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$max = 0;
|
$wood = ${'u'.$unit}['wood'] * $amt * ($great ? 3 : 1);
|
||||||
for($i=19;$i<41;$i++){
|
$clay = ${'u'.$unit}['clay'] * $amt * ($great ? 3 : 1);
|
||||||
if($village->resarray['f'.$i.'t'] == 36){
|
$iron = ${'u'.$unit}['iron'] * $amt * ($great ? 3 : 1);
|
||||||
$max += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
|
$crop = ${'u'.$unit}['crop'] * $amt * ($great ? 3 : 1);
|
||||||
}
|
|
||||||
}
|
|
||||||
$max1 = $max - ($village->unitarray['u99'] + $train_amt);
|
|
||||||
if($max1 < $amt) {
|
|
||||||
$amt = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$wood = ${'u'.$unit}['wood'] * $amt * ($great?3:1);
|
|
||||||
$clay = ${'u'.$unit}['clay'] * $amt * ($great?3:1);
|
|
||||||
$iron = ${'u'.$unit}['iron'] * $amt * ($great?3:1);
|
|
||||||
$crop = ${'u'.$unit}['crop'] * $amt * ($great?3:1);
|
|
||||||
|
|
||||||
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
|
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
|
||||||
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
|
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
|
||||||
|
|||||||
+163
-130
@@ -1,7 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Database\IDbConnection;
|
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||||
## --------------------------------------------------------------------------- ##
|
## --------------------------------------------------------------------------- ##
|
||||||
@@ -19,110 +16,96 @@ use App\Database\IDbConnection;
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
class Units {
|
class Units {
|
||||||
public $sending,$recieving,$return = array();
|
public $sending, $recieving, $return = [];
|
||||||
|
|
||||||
public function procUnits($post) {
|
public function procUnits($post) {
|
||||||
if(isset($post['c'])) {
|
if(isset($post['c'])) {
|
||||||
if (!isset($post['disabled'])) {
|
if (!isset($post['disabled'])) $post['disabled'] = '';
|
||||||
$post['disabled'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($post['c']) {
|
switch($post['c']) {
|
||||||
|
|
||||||
case "1":
|
case "1":
|
||||||
if (isset($post['a'])&& $post['a']==533374){
|
if (isset($post['a'])&& $post['a']==533374){
|
||||||
$this->sendTroops($post);
|
$this->sendTroops($post);
|
||||||
}else{
|
}else{
|
||||||
$post = $this->loadUnits($post);
|
$post = $this->loadUnits($post);
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "2":
|
case "2":
|
||||||
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
|
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
|
||||||
$this->sendTroops($post);
|
$this->sendTroops($post);
|
||||||
}else{
|
}else{
|
||||||
$post = $this->loadUnits($post);
|
$post = $this->loadUnits($post);
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "8":
|
case "8":
|
||||||
$this->sendTroopsBack($post);
|
$this->sendTroopsBack($post);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "3":
|
case "3":
|
||||||
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
|
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
|
||||||
$this->sendTroops($post);
|
else{
|
||||||
}else{
|
$post = $this->loadUnits($post);
|
||||||
$post = $this->loadUnits($post);
|
return $post;
|
||||||
return $post;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case "4":
|
case "4":
|
||||||
if (isset($post['a'])&& $post['a']==533374){
|
if (isset($post['a']) && $post['a'] == 533374) $this->sendTroops($post);
|
||||||
$this->sendTroops($post);
|
else{
|
||||||
}else{
|
$post = $this->loadUnits($post);
|
||||||
$post = $this->loadUnits($post);
|
return $post;
|
||||||
return $post;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case "5":
|
case "5":
|
||||||
if (isset($post['a']) && $post['a']== "new"){
|
if (isset($post['a']) && $post['a'] == "new") $this->Settlers($post);
|
||||||
$this->Settlers($post);
|
else
|
||||||
}else{
|
{
|
||||||
$post = $this->loadUnits($post);
|
$post = $this->loadUnits($post);
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadUnits($post) {
|
private function loadUnits($post) {
|
||||||
global $database,$village,$session,$generator,$logging,$form;
|
global $database,$village,$session,$generator,$logging,$form;
|
||||||
// Search by town name
|
// Search by town name
|
||||||
// Coordinates and look confirm name people
|
// Coordinates and look confirm name people
|
||||||
if(isset($post['x']) && isset($post['y']) && $post['x'] != "" && $post['y'] != "") {
|
if(isset($post['x']) && isset($post['y']) && !empty($post['x']) && !empty($post['y'])) {
|
||||||
$vid = $database->getVilWref($post['x'],$post['y']);
|
$vid = $database->getVilWref($post['x'], $post['y']);
|
||||||
unset($post['dname']);
|
unset($post['dname'], $_POST['dname']);
|
||||||
unset($_POST['dname']);
|
}else if(isset($post['dname']) && !empty($post['dname'])){
|
||||||
}else if(isset($post['dname']) && $post['dname']!=""){
|
|
||||||
$vid = $database->getVillageByName(stripslashes($post['dname']));
|
$vid = $database->getVillageByName(stripslashes($post['dname']));
|
||||||
}
|
}
|
||||||
if (!empty($vid)) {
|
if (!empty($vid)) {
|
||||||
if($database->isVillageOases($vid)){
|
if($database->isVillageOases($vid)){
|
||||||
$too = $database->getOasisField($vid,"conqured");
|
$too = $database->getOasisField($vid,"conqured");
|
||||||
if($too == 0){
|
if($too == 0) $disabled = $disabledr ="disabled=disabled";
|
||||||
$disabledr ="disabled=disabled"; $disabled ="disabled=disabled";
|
else
|
||||||
}else{
|
{
|
||||||
$disabledr ="";
|
$disabledr = "";
|
||||||
if($session->sit == 0){
|
if($session->sit == 0) $disabled = "";
|
||||||
$disabled ="";
|
else $disabled ="disabled=disabled";
|
||||||
}else{
|
|
||||||
$disabled ="disabled=disabled";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$too = $database->getVillage($vid);
|
$too = $database->getVillage($vid);
|
||||||
if($too['owner'] == 3){
|
if($too['owner'] == 3){
|
||||||
$disabledr ="disabled=disabled"; $disabled ="";
|
$disabledr = "disabled=disabled";
|
||||||
|
$disabled = "";
|
||||||
}else{
|
}else{
|
||||||
$disabledr ="";
|
$disabledr = "";
|
||||||
if($session->sit == 0){
|
if($session->sit == 0) $disabled = "";
|
||||||
$disabled ="";
|
else $disabled ="disabled=disabled";
|
||||||
}else{
|
|
||||||
$disabled ="disabled=disabled";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$disabledr ="";
|
$disabledr = "";
|
||||||
if($session->sit == 0){
|
if($session->sit == 0) $disabled = "";
|
||||||
$disabled ="";
|
else $disabled ="disabled=disabled";
|
||||||
}else{
|
|
||||||
$disabled ="disabled=disabled";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!empty($disabledr) && $post['c'] == 2){
|
if(!empty($disabledr) && $post['c'] == 2){
|
||||||
$form->addError("error","You can't reinforce this village/oasis");
|
$form->addError("error","You can't reinforce this village/oasis");
|
||||||
@@ -134,8 +117,8 @@ class Units {
|
|||||||
|
|
||||||
if($post['c'] < 2 || $post['c'] > 4) $form->addError("error", "Invalid attack type.");
|
if($post['c'] < 2 || $post['c'] > 4) $form->addError("error", "Invalid attack type.");
|
||||||
|
|
||||||
if(empty($post['t1']) && empty($post['t2']) && empty($post['t3']) && empty($post['t4']) && empty($post['t5']) &&
|
if(empty($post['t1']) && empty($post['t2']) && empty($post['t3']) && empty($post['t4']) && empty($post['t5']) &&
|
||||||
empty($post['t6']) && empty($post['t7']) && empty($post['t8']) && empty($post['t9']) && empty($post['t10']) && empty($post['t11'])){
|
empty($post['t6']) && empty($post['t7']) && empty($post['t8']) && empty($post['t9']) && empty($post['t10']) && empty($post['t11'])){
|
||||||
$form->addError("error","You need to mark min. one troop");
|
$form->addError("error","You need to mark min. one troop");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,31 +126,29 @@ class Units {
|
|||||||
$form->addError("error","Insert name or coordinates");
|
$form->addError("error","Insert name or coordinates");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($post['dname']) && $post['dname'] != "") {
|
if(isset($post['dname']) && !empty($post['dname'])) {
|
||||||
$id = $database->getVillageByName(stripslashes($post['dname']));
|
$id = $database->getVillageByName(stripslashes($post['dname']));
|
||||||
if (!isset($id)){
|
|
||||||
$form->addError("error","Village do not exist");
|
if (!isset($id)) $form->addError("error","Village do not exist");
|
||||||
}else{
|
else $coor = $database->getCoor($id);
|
||||||
$coor = $database->getCoor($id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// People search by coordinates
|
// People search by coordinates
|
||||||
// We confirm and seek coordinate coordinates Village
|
// We confirm and seek coordinate coordinates Village
|
||||||
if(isset($post['x']) && isset($post['y']) && $post['x'] != "" && $post['y'] != "") {
|
if(isset($post['x']) && isset($post['y']) && !empty($post['x']) && !empty($post['y'])) {
|
||||||
$coor = array('x'=>$post['x'], 'y'=>$post['y']);
|
$coor = ['x' => $post['x'], 'y' => $post['y']];
|
||||||
$id = $generator->getBaseID($coor['x'],$coor['y']);
|
$id = $generator->getBaseID($coor['x'], $coor['y']);
|
||||||
if (!$database->getVillageState($id)){
|
|
||||||
$form->addError("error","Coordinates do not exist");
|
if (!$database->getVillageState($id)) $form->addError("error","Coordinates do not exist");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($coor)) {
|
if (!empty($coor)) {
|
||||||
if ($session->tribe == 1){$Gtribe = "";}elseif ($session->tribe == 2){$Gtribe = "1";}elseif ($session->tribe == 3){$Gtribe = "2";}elseif ($session->tribe == 4){$Gtribe = "3";}elseif ($session->tribe == 5){$Gtribe = "4";}
|
$Gtribe = $session->tribe == 1 ? "" : $session->tribe - 1;
|
||||||
for($i=1; $i<12; $i++){
|
for($i = 1; $i < 12; $i++){
|
||||||
if(isset($post['t'.$i])){
|
if(isset($post['t'.$i])){
|
||||||
if ($i<10) $troophave=$village->unitarray['u'.$Gtribe.$i];
|
if ($i < 10) $troophave = $village->unitarray['u'.$Gtribe.$i];
|
||||||
if ($i==10)$troophave=$village->unitarray['u'.floor(intval($Gtribe)+1)*$i];
|
if ($i == 10) $troophave = $village->unitarray['u'.floor(intval($Gtribe) + 1) * $i];
|
||||||
if ($i==11)$troophave=$village->unitarray['hero'];
|
if ($i == 11) $troophave = $village->unitarray['hero'];
|
||||||
|
|
||||||
if (intval($post['t'.$i]) > $troophave){
|
if (intval($post['t'.$i]) > $troophave){
|
||||||
$form->addError("error","You can't send more units than you have");
|
$form->addError("error","You can't send more units than you have");
|
||||||
@@ -184,37 +165,38 @@ class Units {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($id) && $database->isVillageOases($id) == 0) {
|
|
||||||
if($database->hasBeginnerProtection($id)==1) {
|
|
||||||
$form->addError("error","Player is under beginners protection. You can't attack him");
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if banned/admin:
|
if(isset($id) && $database->isVillageOases($id) == 0) {
|
||||||
$villageOwner = $database->getVillageField($id,'owner');
|
if($database->hasBeginnerProtection($id) == 1) {
|
||||||
$userAccess = $database->getUserField($villageOwner,'access',0);
|
$form->addError("error","Player is under beginners protection. You can't attack him");
|
||||||
$userID = $database->getUserField($villageOwner,'id',0);
|
}
|
||||||
if($userAccess == '0' or ($userAccess == MULTIHUNTER && $userID == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)){
|
|
||||||
$form->addError("error","Player is Banned. You can't attack him");
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
//check if vacation mode:
|
|
||||||
if($database->getvacmodexy($id)){
|
|
||||||
$form->addError("error","User is on vacation mode");
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if attacking same village that units are in
|
//check if banned/admin:
|
||||||
if($id == $village->wid){
|
$villageOwner = $database->getVillageField($id,'owner');
|
||||||
$form->addError("error","You cant attack same village you are sending from.");
|
$userAccess = $database->getUserField($villageOwner,'access',0);
|
||||||
//break;
|
$userID = $database->getUserField($villageOwner,'id',0);
|
||||||
}
|
if($userAccess == 0 or ($userAccess == MULTIHUNTER && $userID == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)){
|
||||||
// We process the array with the errors given in the form
|
$form->addError("error","Player is Banned. You can't attack him");
|
||||||
if($form->returnErrors() > 0) {
|
//break;
|
||||||
$_SESSION['errorarray'] = $form->getErrors();
|
}
|
||||||
$_SESSION['valuearray'] = $_POST;
|
//check if vacation mode:
|
||||||
header("Location: a2b.php");
|
if($database->getvacmodexy($id)){
|
||||||
exit;
|
$form->addError("error","User is on vacation mode");
|
||||||
}else{
|
//break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if attacking same village that units are in
|
||||||
|
if($id == $village->wid){
|
||||||
|
$form->addError("error","You cant attack same village you are sending from.");
|
||||||
|
//break;
|
||||||
|
}
|
||||||
|
// We process the array with the errors given in the form
|
||||||
|
if($form->returnErrors() > 0) {
|
||||||
|
$_SESSION['errorarray'] = $form->getErrors();
|
||||||
|
$_SESSION['valuearray'] = $_POST;
|
||||||
|
header("Location: a2b.php");
|
||||||
|
exit;
|
||||||
|
}else{
|
||||||
// We must return an array with $ post, which contains all the data more
|
// We must return an array with $ post, which contains all the data more
|
||||||
// another variable that will define the flag is raised and is being sent and the type of shipping
|
// another variable that will define the flag is raised and is being sent and the type of shipping
|
||||||
$villageName = $database->getVillageField($id,'name');
|
$villageName = $database->getVillageField($id,'name');
|
||||||
@@ -222,16 +204,14 @@ class Units {
|
|||||||
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
||||||
array_push($post, "$id", "$villageName", "$villageOwner","$timetaken");
|
array_push($post, "$id", "$villageName", "$villageOwner","$timetaken");
|
||||||
return $post;
|
return $post;
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
if($form->returnErrors() > 0) {
|
||||||
if($form->returnErrors() > 0) {
|
$_SESSION['errorarray'] = $form->getErrors();
|
||||||
$_SESSION['errorarray'] = $form->getErrors();
|
$_SESSION['valuearray'] = $_POST;
|
||||||
$_SESSION['valuearray'] = $_POST;
|
header("Location: a2b.php");
|
||||||
header("Location: a2b.php");
|
exit;
|
||||||
exit;
|
} else if (isset($id)) {
|
||||||
} else if (isset($id)) {
|
|
||||||
$villageName = $database->getOasisField($id,"name");
|
$villageName = $database->getOasisField($id,"name");
|
||||||
$speed= 300;
|
$speed= 300;
|
||||||
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
||||||
@@ -239,8 +219,7 @@ class Units {
|
|||||||
return $post;
|
return $post;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function returnTroops($wref, $mode = 0) {
|
public function returnTroops($wref, $mode = 0) {
|
||||||
@@ -683,6 +662,60 @@ class Units {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to kill/release prisoners
|
||||||
|
*
|
||||||
|
* @param int the ID of the prisoners you want to release
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function deletePrisoners($id){
|
||||||
|
global $village, $database, $session, $building, $bid19, $u99;
|
||||||
|
|
||||||
|
$prisoner = $database->getPrisonersByID($id);
|
||||||
|
$troops = 0;
|
||||||
|
if($prisoner['wref'] == $village->wid){
|
||||||
|
$p_owner = $database->getVillageField($prisoner['from'], "owner");
|
||||||
|
$p_tribe = $database->getUserField($p_owner, "tribe", 0);
|
||||||
|
|
||||||
|
$troopsTime = $this->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
||||||
|
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
||||||
|
|
||||||
|
$p_reference = $database->addAttack($prisoner['from'], $prisoner['t1'],$prisoner['t2'], $prisoner['t3'], $prisoner['t4'], $prisoner['t5'], $prisoner['t6'], $prisoner['t7'], $prisoner['t8'], $prisoner['t9'], $prisoner['t10'], $prisoner['t11'], 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
$database->addMovement(4, $prisoner['wref'], $prisoner['from'], $p_reference, time(), ($p_time + time()));
|
||||||
|
|
||||||
|
for($i = 1; $i <= 11; $i++) $troops += $prisoner['t'.$i];
|
||||||
|
|
||||||
|
//Reset traps
|
||||||
|
$database->modifyUnit($village->wid, ["99", "99o"], [$troops, $troops], [0, 0]);
|
||||||
|
$repairDuration = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[max($building->getTypeLevel(36, $village->wid), 1)]['attri'] / 100) * $u99['time'] / SPEED));
|
||||||
|
$database->trainUnit($village->wid, 99, $troops, $u99['pop'], $repairDuration, 0);
|
||||||
|
|
||||||
|
$database->deletePrisoners($prisoner['id']);
|
||||||
|
}else if($prisoner['from'] == $village->wid){
|
||||||
|
$prisonersToOwner = $database->getVillageField($prisoner['wref'], "owner");
|
||||||
|
|
||||||
|
for($i = 1; $i <= 11; $i++) $troops += $prisoner['t'.$i];
|
||||||
|
|
||||||
|
if($prisoner['t11'] > 0){
|
||||||
|
$p_owner = $database->getVillageField($prisoner['from'], "owner");
|
||||||
|
mysqli_query($database->dblink, "UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."' AND dead = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reset traps
|
||||||
|
$database->modifyUnit($prisoner['wref'], ["99", "99o"], [$troops, $troops], [0, 0]);
|
||||||
|
|
||||||
|
if(($troops = round($troops / 3)) > 0){
|
||||||
|
$repairDuration = $database->getArtifactsValueInfluence($prisonersToOwner, $prisoner['wref'], 5, round(($bid19[max($building->getTypeLevel(36, $prisoner['wref']), 1)]['attri'] / 100) * $u99['time'] / SPEED));
|
||||||
|
$database->trainUnit($prisoner['wref'], 99, $troops, $u99['pop'], $repairDuration, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$database->deletePrisoners($prisoner['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: build.php?id=39");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get how much time troops spend to walk from a village to another
|
* Get how much time troops spend to walk from a village to another
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ switch($kind){
|
|||||||
$betterorbadder = $artefactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
|
$betterorbadder = $artefactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effecty)."</b>)" : "<b>Not yet active</b>";
|
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effecty)."</b>)" : (($kind == 11 && $artefact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
+23
-29
@@ -13,8 +13,7 @@ include("next.tpl");
|
|||||||
<table cellpadding="1" cellspacing="1" id="build_value">
|
<table cellpadding="1" cellspacing="1" id="build_value">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo CURRENT_TRAPS; ?></th>
|
<th><?php echo CURRENT_TRAPS; ?></th>
|
||||||
|
<td><b><?php echo $bid36[$village->resarray['f'.$id]]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
||||||
<td><b><?php echo $bid36[$village->resarray['f'.$id]]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -23,12 +22,12 @@ include("next.tpl");
|
|||||||
if($next<=20){
|
if($next<=20){
|
||||||
?>
|
?>
|
||||||
<th><?php echo TRAPS_LEVEL; ?> <?php echo $next; ?>:</th>
|
<th><?php echo TRAPS_LEVEL; ?> <?php echo $next; ?>:</th>
|
||||||
<td><b><?php echo $bid36[$next]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
<td><b><?php echo $bid36[$next]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
||||||
<?php
|
<?php
|
||||||
}else{
|
}else{
|
||||||
?>
|
?>
|
||||||
<th><?php echo TRAPS_LEVEL; ?> 20:</th>
|
<th><?php echo TRAPS_LEVEL; ?> 20:</th>
|
||||||
<td><b><?php echo $bid36[20]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
<td><b><?php echo $bid36[20]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,34 +65,31 @@ include("next.tpl");
|
|||||||
alt="Iron" title="<?php echo IRON; ?>" />10|</span><span><img class="r4" src="img/x.gif"
|
alt="Iron" title="<?php echo IRON; ?>" />10|</span><span><img class="r4" src="img/x.gif"
|
||||||
alt="Crop" title="<?php echo CROP; ?>" />20|</span><span><img class="r5" src="img/x.gif" alt="Crop consumption"
|
alt="Crop" title="<?php echo CROP; ?>" />20|</span><span><img class="r5" src="img/x.gif" alt="Crop consumption"
|
||||||
title="<?php echo CROP_COM; ?>" />0|<img class="clock" src="img/x.gif"
|
title="<?php echo CROP_COM; ?>" />0|<img class="clock" src="img/x.gif"
|
||||||
alt="Duration" title="<?php echo DURATION; ?>" /><?php echo $generator->getTimeFormat(round(($bid19[$village->resarray['f'.$id]]['attri'] / 100) * ${'u99'}['time'] / SPEED)); ?></span>
|
alt="Duration" title="<?php echo DURATION; ?>" />
|
||||||
|
<?php echo $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[$village->resarray['f'.$id]]['attri'] / 100) * ${'u99'}['time'] / SPEED))); ?>
|
||||||
|
</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
$trainlist = $technology->getTrainingList(8);
|
$trainlist = $technology->getTrainingList(8);
|
||||||
foreach($trainlist as $train) {
|
foreach($trainlist as $train) $train_amt += $train['amt'];
|
||||||
$train_amt += $train['amt'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$max = $technology->maxUnit(99,false);
|
$max = $technology->maxUnit(99, false);
|
||||||
$max1 = 0;
|
$max1 = 0;
|
||||||
for($i=19;$i<41;$i++){
|
for($i = 19; $i < 41; $i++){
|
||||||
if($village->resarray['f'.$i.'t'] == 36){
|
if($village->resarray['f'.$i.'t'] == 36){
|
||||||
$max1 += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
|
$max1 += $bid36[$village->resarray['f'.$i]]['attri'] * TRAPPER_CAPACITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($train_amt)) {
|
if (!isset($train_amt)) $train_amt = 0;
|
||||||
$train_amt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($max > $max1 - ($village->unitarray['u99'] + $train_amt)){
|
if($max > $max1 - ($village->unitarray['u99'] + $train_amt)){
|
||||||
$max = $max1 - ($village->unitarray['u99'] + $train_amt);
|
$max = $max1 - ($village->unitarray['u99'] + $train_amt);
|
||||||
}
|
|
||||||
if($max < 0){
|
|
||||||
$max = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($max < 0) $max = 0;
|
||||||
?>
|
?>
|
||||||
<td class="val"><input type="text" class="text" name="t99" value="0" maxlength="4"></td>
|
<td class="val"><input type="text" class="text" name="t99" value="0" maxlength="4"></td>
|
||||||
<td class="max"><a href="#" onClick="document.snd.t99.value=<?php echo $max; ?>">(<?php echo $max; ?>)</a></td>
|
<td class="max"><a href="#" onClick="document.snd.t99.value=<?php echo $max; ?>">(<?php echo $max; ?>)</a></td>
|
||||||
@@ -105,7 +101,7 @@ include("next.tpl");
|
|||||||
} else {
|
} else {
|
||||||
echo "<b>".TRAINING_COMMENCE_TRAPPER."</b><br>\n";
|
echo "<b>".TRAINING_COMMENCE_TRAPPER."</b><br>\n";
|
||||||
}
|
}
|
||||||
if(count($trainlist) > 0) {
|
if(!empty($trainlist)) {
|
||||||
echo "
|
echo "
|
||||||
<table cellpadding=\"1\" cellspacing=\"1\" class=\"under_progress\">
|
<table cellpadding=\"1\" cellspacing=\"1\" class=\"under_progress\">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
@@ -120,17 +116,15 @@ include("next.tpl");
|
|||||||
echo "<tr><td class=\"desc\">";
|
echo "<tr><td class=\"desc\">";
|
||||||
echo "<img class=\"unit u".$train['unit']."\" src=\"img/x.gif\" alt=\"".U99."\" title=\"".U99."\" />";
|
echo "<img class=\"unit u".$train['unit']."\" src=\"img/x.gif\" alt=\"".U99."\" title=\"".U99."\" />";
|
||||||
echo $train['amt']." ".U99."</td><td class=\"dur\">";
|
echo $train['amt']." ".U99."</td><td class=\"dur\">";
|
||||||
if ($TrainCount == 1 ) {
|
if ($TrainCount == 1) {
|
||||||
$NextFinished = $generator->getTimeFormat(($train['timestamp']-time())-($train['amt']-1)*$train['eachtime']);
|
$NextFinished = $generator->getTimeFormat(($train['timestamp'] - time()) - ($train['amt'] - 1) * $train['eachtime']);
|
||||||
echo "<span id=timer1>".$generator->getTimeFormat($train['timestamp']-time())."</span>";
|
echo "<span id=timer1>".$generator->getTimeFormat($train['timestamp'] - time())."</span>";
|
||||||
} else {
|
|
||||||
echo $generator->getTimeFormat($train['eachtime']*$train['amt']);
|
|
||||||
}
|
}
|
||||||
|
else echo $generator->getTimeFormat($train['eachtime'] * $train['amt']);
|
||||||
|
|
||||||
echo "</td><td class=\"fin\">";
|
echo "</td><td class=\"fin\">";
|
||||||
$time = $generator->procMTime($train['timestamp']);
|
$time = $generator->procMTime($train['timestamp']);
|
||||||
if($time[0] != "today") {
|
if($time[0] != "today") echo "on ".$time[0]." at ";
|
||||||
echo "on ".$time[0]." at ";
|
|
||||||
}
|
|
||||||
echo $time[1];
|
echo $time[1];
|
||||||
} ?>
|
} ?>
|
||||||
</tr><tr class="next"><td colspan="3"><?php echo UNIT_FINISHED; ?> <span id="timer2"><?php echo $NextFinished; ?></span></td></tr>
|
</tr><tr class="next"><td colspan="3"><?php echo UNIT_FINISHED; ?> <span id="timer2"><?php echo $NextFinished; ?></span></td></tr>
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ if(isset($_GET['o'])) {
|
|||||||
if(isset($r)) {
|
if(isset($r)) {
|
||||||
$enforce = $database->getEnforceArray($r, 0);
|
$enforce = $database->getEnforceArray($r, 0);
|
||||||
$enforceoasis=$database->getOasisEnforceArray($r, 0);
|
$enforceoasis=$database->getOasisEnforceArray($r, 0);
|
||||||
if($enforce['from'] == $village->wid || $enforceoasis['conqured']==$village->wid) {
|
if($enforce['from'] == $village->wid || $enforceoasis['conqured'] == $village->wid) {
|
||||||
$to = $database->getVillage($enforce['from']);
|
$to = $database->getVillage($enforce['from']);
|
||||||
$ckey = $r;
|
$ckey = $r;
|
||||||
include ("Templates/a2b/sendback.tpl");
|
include ("Templates/a2b/sendback.tpl");
|
||||||
@@ -171,32 +171,10 @@ if(isset($_GET['o'])) {
|
|||||||
include ("Templates/a2b/units_" . $session->tribe . ".tpl");
|
include ("Templates/a2b/units_" . $session->tribe . ".tpl");
|
||||||
include ("Templates/a2b/search.tpl");
|
include ("Templates/a2b/search.tpl");
|
||||||
}
|
}
|
||||||
} else if(isset($delprisoners)){
|
|
||||||
$prisoner = $database->getPrisonersByID($delprisoners);
|
|
||||||
if($prisoner['wref'] == $village->wid){
|
|
||||||
$p_owner = $database->getVillageField($prisoner['from'],"owner");
|
|
||||||
$p_tribe = $database->getUserField($p_owner,"tribe",0);
|
|
||||||
|
|
||||||
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
|
||||||
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
|
||||||
|
|
||||||
$p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
|
|
||||||
$database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,time(),($p_time+time()));
|
|
||||||
$troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
|
|
||||||
$database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0));
|
|
||||||
$database->deletePrisoners($prisoner['id']);
|
|
||||||
}else if($prisoner['from'] == $village->wid){
|
|
||||||
$troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
|
|
||||||
if($prisoner['t11'] > 0){
|
|
||||||
$p_owner = $database->getVillageField($prisoner['from'],"owner");
|
|
||||||
mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."' AND dead = 0");
|
|
||||||
}
|
|
||||||
$database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0));
|
|
||||||
$database->deletePrisoners($prisoner['id']);
|
|
||||||
}
|
}
|
||||||
header("Location: build.php?id=39");
|
else if(isset($delprisoners) && !empty($delprisoners)) $units->deletePrisoners($delprisoners);
|
||||||
exit;
|
else
|
||||||
} else {
|
{
|
||||||
if(isset($process['0'])) {
|
if(isset($process['0'])) {
|
||||||
$coor = $database->getCoor($process['0']);
|
$coor = $database->getCoor($process['0']);
|
||||||
include ("Templates/a2b/attack.tpl");
|
include ("Templates/a2b/attack.tpl");
|
||||||
@@ -205,7 +183,6 @@ if(isset($_GET['o'])) {
|
|||||||
include ("Templates/a2b/search.tpl");
|
include ("Templates/a2b/search.tpl");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<br /><br /><br /><br /><div id="side_info">
|
<br /><br /><br /><br /><div id="side_info">
|
||||||
|
|||||||
Reference in New Issue
Block a user