General fixes

+Fixed an exploit that permitted to starts other players' farm lists
+Fixed an exploit that permitted to save our raids to other players'
farm lists
+Fixed an exploit that permitted to edit other players' farm lists
+Fixed a rounding upkeep bug
+Moved the whole startRaid.tpl to a new method in Units.php
+A lot of clean-up
+Improoved indentation
+In the raid list, the "carry" image will now show to the left of an
attack
+Fixed a bug that displayed the wrong loot to returning troops released
by traps
+General minor bug fixing and improovements
-Deleted a lot of redundant code
This commit is contained in:
iopietro
2018-05-04 22:12:18 +02:00
parent 49bc3c5073
commit cf74514451
17 changed files with 762 additions and 1274 deletions
+6 -98
View File
@@ -648,10 +648,6 @@ class adm_DB {
} else {
$enforce['hero']='0';
}
$artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($enforce['from'],2,1,1));
$artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
$troopsTime = $this->procDistanceTime($fromCor, $toCor, min($speeds), $enforce['from']);
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
@@ -663,27 +659,15 @@ class adm_DB {
}
public function calculateProduction($wid,$uid,$b1,$b2,$b3,$b4,$fdata,$ocounter,$pop) {
global $technology,$database;
$normalA = $database->getOwnArtefactInfoByType($wid,4);
$largeA = $database->getOwnUniqueArtefactInfo($uid,4,2);
$uniqueA = $database->getOwnUniqueArtefactInfo($uid,4,3);
$upkeep = $this->getUpkeep($this->getAllUnits($wid),0,$wid,$uid);
$production=array();
public function calculateProduction($wid, $uid, $b1, $b2, $b3, $b4, $fdata, $ocounter, $pop) {
global $technology, $database;
$upkeep = $technology->getUpkeep($this->getAllUnits($wid), 0, $wid);
$production = [];
$production['wood'] = $this->getWoodProd($fdata, $ocounter,$b1);
$production['clay'] = $this->getClayProd($fdata, $ocounter,$b2);
$production['iron'] = $this->getIronProd($fdata, $ocounter,$b3);
if ($uniqueA['size']==3 && $uniqueA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.50));
}elseif ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.25));
}else if ($largeA['size']==2 && $largeA['owner']==$uid){
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-(($upkeep)-round($upkeep*0.25));
}else{
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4)-$pop-$upkeep;
}
$production['crop'] = $this->getCropProd($fdata, $ocounter,$b4) - $pop - $upkeep;
return $production;
}
@@ -852,82 +836,6 @@ class adm_DB {
}
return $ownunit;
}
public function getUpkeep($array,$type,$vid,$uid,$prisoners=0) {
global $database;
$buildarray = array();
$buildarray = $database->getResourceLevel($vid);
$upkeep = 0;
switch($type) {
case 0:
$start = 1;
$end = 50;
break;
case 1:
$start = 1;
$end = 10;
break;
case 2:
$start = 11;
$end = 20;
break;
case 3:
$start = 21;
$end = 30;
break;
case 4:
$start = 31;
$end = 40;
break;
case 5:
$start = 41;
$end = 50;
break;
}
for($i=$start;$i<=$end;$i++) {
$k = $i-$start+1;
$unit = "u".$i;
$unit2 = "t".$k;
global $$unit;
$dataarray = $$unit;
for($j=19;$j<=38;$j++) {
if($buildarray['f'.$j.'t'] == 41) {
$horsedrinking = $j;
}
}
if($prisoners == 0){
if(isset($horsedrinking)){
if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
|| ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
|| ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
$upkeep += ($dataarray['pop']-1) * $array[$unit];
} else {
$upkeep += $dataarray['pop'] * $array[$unit];
}}else{
$upkeep += $dataarray['pop'] * $array[$unit];
}
}else{
if(isset($horsedrinking)){
if(($i==4 && $buildarray['f'.$horsedrinking] >= 10)
|| ($i==5 && $buildarray['f'.$horsedrinking] >= 15)
|| ($i==6 && $buildarray['f'.$horsedrinking] == 20)) {
$upkeep += ($dataarray['pop']-1) * $array[$unit2];
} else {
$upkeep += $dataarray['pop'] * $array[$unit2];
}}else{
$upkeep += $dataarray['pop'] * $array[$unit2];
}
}
}
$unit = ($prisoners > 0) ? 't11' : 'hero';
if(!isset($array[$unit])) $array[$unit] = 0;
$upkeep += $array[$unit] * 6;
return $database->getArtifactsValueInfluence($uid, $vid, 4, $upkeep);
}
};
$admin = new adm_DB;
+145 -363
View File
@@ -18,17 +18,21 @@
class Automation {
private $bountyresarray = array();
private $bountyinfoarray = array();
private $bountyproduction = array();
private $bountyocounter = array();
private $bountyunitall = array();
private $bountyresarray = [];
private $bountyinfoarray = [];
private $bountyproduction = [];
private $bountyocounter = [];
private $bountyunitall = [];
private $bountypop;
private $bountyOresarray = array();
private $bountyOinfoarray = array();
private $bountyOproduction = array();
private $bountyOresarray = [];
private $bountyOinfoarray = [];
private $bountyOproduction = [];
private $bountyOpop = 1;
const bountyOWoodProd = 40 * SPEED;
const bountyOClayProd = 40 * SPEED;
const bountyOIronProd = 40 * SPEED;
const bountyOCropProd = 40 * SPEED;
public function __construct() {
$this->procNewClimbers();
@@ -38,55 +42,54 @@ class Automation {
$this->pruneResource();
$this->pruneOResource();
$this->checkWWAttacks();
if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>50) {
if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time() - filemtime("GameEngine/Prevention/culturepoints.txt") > 50) {
$this->culturePoints();
}
if(!file_exists("GameEngine/Prevention/updatehero.txt") or time()-filemtime("GameEngine/Prevention/updatehero.txt")>50) {
if(!file_exists("GameEngine/Prevention/updatehero.txt") or time() - filemtime("GameEngine/Prevention/updatehero.txt") > 50) {
$this->updateHero();
}
if(!file_exists("GameEngine/Prevention/cleardeleting.txt") or time()-filemtime("GameEngine/Prevention/cleardeleting.txt")>50) {
if(!file_exists("GameEngine/Prevention/cleardeleting.txt") or time() - filemtime("GameEngine/Prevention/cleardeleting.txt") > 50) {
$this->clearDeleting();
}
if(!file_exists("GameEngine/Prevention/build.txt") or time() - filemtime("GameEngine/Prevention/build.txt")>50)
if(!file_exists("GameEngine/Prevention/build.txt") or time() - filemtime("GameEngine/Prevention/build.txt") > 50)
{
$this->buildComplete();
}
$this->MasterBuilder();
if(!file_exists("GameEngine/Prevention/demolition.txt") or time() - filemtime("GameEngine/Prevention/demolition.txt")>50)
if(!file_exists("GameEngine/Prevention/demolition.txt") or time() - filemtime("GameEngine/Prevention/demolition.txt") > 50)
{
$this->demolitionComplete();
}
$this->delTradeRoute();
$this->TradeRoute();
if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>50) {
if(!file_exists("GameEngine/Prevention/market.txt") or time() - filemtime("GameEngine/Prevention/market.txt") > 50) {
$this->marketComplete();
}
if(!file_exists("GameEngine/Prevention/research.txt") or time()-filemtime("GameEngine/Prevention/research.txt")>50) {
if(!file_exists("GameEngine/Prevention/research.txt") or time() - filemtime("GameEngine/Prevention/research.txt") > 50) {
$this->researchComplete();
}
if(!file_exists("GameEngine/Prevention/training.txt") or time()-filemtime("GameEngine/Prevention/training.txt")>50) {
if(!file_exists("GameEngine/Prevention/training.txt") or time() - filemtime("GameEngine/Prevention/training.txt") > 50) {
$this->trainingComplete();
}
if(!file_exists("GameEngine/Prevention/starvation.txt") or time()-filemtime("GameEngine/Prevention/starvation.txt")>50) {
if(!file_exists("GameEngine/Prevention/starvation.txt") or time() - filemtime("GameEngine/Prevention/starvation.txt") > 50) {
$this->starvation();
}
if(!file_exists("GameEngine/Prevention/celebration.txt") or time()-filemtime("GameEngine/Prevention/celebration.txt")>50) {
if(!file_exists("GameEngine/Prevention/celebration.txt") or time() - filemtime("GameEngine/Prevention/celebration.txt") > 50) {
$this->celebrationComplete();
}
if(!file_exists("GameEngine/Prevention/sendunits.txt") or time()-filemtime("GameEngine/Prevention/sendunits.txt")>50) {
if(!file_exists("GameEngine/Prevention/sendunits.txt") or time() - filemtime("GameEngine/Prevention/sendunits.txt") > 50) {
$this->sendunitsComplete();
}
if(!file_exists("GameEngine/Prevention/loyalty.txt") or time()-filemtime("GameEngine/Prevention/loyalty.txt")>60) {
if(!file_exists("GameEngine/Prevention/loyalty.txt") or time() - filemtime("GameEngine/Prevention/loyalty.txt") > 60) {
$this->loyaltyRegeneration();
}
if(!file_exists("GameEngine/Prevention/sendreinfunits.txt") or time()-filemtime("GameEngine/Prevention/sendreinfunits.txt")>50) {
if(!file_exists("GameEngine/Prevention/sendreinfunits.txt") or time() - filemtime("GameEngine/Prevention/sendreinfunits.txt") > 50) {
$this->sendreinfunitsComplete();
}
if(!file_exists("GameEngine/Prevention/returnunits.txt") or time()-filemtime("GameEngine/Prevention/returnunits.txt")>50) {
if(!file_exists("GameEngine/Prevention/returnunits.txt") or time() - filemtime("GameEngine/Prevention/returnunits.txt") > 50) {
$this->returnunitsComplete();
}
if(!file_exists("GameEngine/Prevention/settlers.txt") or time()-filemtime("GameEngine/Prevention/settlers.txt")>50) {
if(!file_exists("GameEngine/Prevention/settlers.txt") or time() - filemtime("GameEngine/Prevention/settlers.txt") > 50) {
$this->sendSettlersComplete();
}
if(!file_exists("GameEngine/Prevention/artifacts.txt") or time() - filemtime("GameEngine/Prevention/artifacts.txt") > 60) {
@@ -261,7 +264,7 @@ class Automation {
$element = count($keyholder);
if($element >= 2) {
if($tid <= 4) {
$temparray = array();
$temparray = [];
for($i = 0; $i <= $element - 1; $i++) {
array_push($temparray,$resourcearray['f'.$keyholder[$i]]);
}
@@ -349,24 +352,28 @@ class Automation {
private function ClearUser() {
global $database;
if(AUTO_DEL_INACTIVE) {
$time = time()-UN_ACT_TIME;
$time = time() - UN_ACT_TIME;
$q = "INSERT INTO ".TB_PREFIX."deleting SELECT id, UNIX_TIMESTAMP() FROM ".TB_PREFIX."users WHERE timestamp < $time AND tribe IN(1,2,3)";
$q = "INSERT INTO ".TB_PREFIX."deleting SELECT id, UNIX_TIMESTAMP() FROM ".TB_PREFIX."users WHERE timestamp < $time AND tribe IN(1, 2, 3)";
$database->query($q);
}
}
private function ClearInactive() {
global $database;
if(TRACK_USR) {
$timeout = time()-USER_TIMEOUT*60;
$timeout = time()-USER_TIMEOUT * 60;
$q = "DELETE FROM ".TB_PREFIX."active WHERE timestamp < $timeout";
$database->query($q);
}
}
private function pruneOResource() {
global $database;
if(!ALLOW_BURST) {
$database->query("UPDATE
".TB_PREFIX."odata
@@ -388,6 +395,7 @@ class Automation {
}
private function pruneResource() {
global $database;
if(!ALLOW_BURST) {
$database->query("UPDATE
".TB_PREFIX."vdata
@@ -491,13 +499,9 @@ class Automation {
$fieldDbName = (in_array($indi['type'], [10, 38]) ? 'maxstore' : 'maxcrop');
$max = $villageData[$fieldDbName];
if($level == 1 && $max == STORAGE_BASE) {
$max=STORAGE_BASE;
}
if ($level != 1) {
$max -= ${'bid'.$indi['type']}[$level-1]['attri'] * STORAGE_MULTIPLIER;
}
if($level == 1 && $max == STORAGE_BASE) $max = STORAGE_BASE;
if ($level != 1) $max -= ${'bid'.$indi['type']}[$level-1]['attri'] * STORAGE_MULTIPLIER;
$max += ${'bid'.$indi['type']}[$level]['attri'] * STORAGE_MULTIPLIER;
@@ -583,141 +587,42 @@ class Automation {
// bad, but should work :D
// I took the data from my first ww (first .org world)
// todo: get the algo from the real travian with the 100 biggest
// offs and so on
$troops = array(
5 => array(
array(3412, 2814, 4156, 3553, 9, 0),
array(35, 0, 77, 33, 17, 10)
),
// TODO: get the algo from the real travian with the 100 biggest offs
10 => array(
array(4314, 3688, 5265, 4621, 13, 0),
array(65, 0, 175, 77, 28, 17)
),
15 => array(
array(4645, 4267, 5659, 5272, 15, 0),
array(99, 0, 305, 134, 40, 25)
),
20 => array(
array(6207, 5881, 7625, 7225, 22, 0),
array(144, 0, 456, 201, 56, 36)
),
25 => array(
array(6004, 5977, 7400, 7277, 23, 0),
array(152, 0, 499, 220, 58, 37)
),
30 => array(
array(7073, 7181, 8730, 8713, 27, 0),
array(183, 0, 607, 268, 69, 45)
),
35 => array(
array(7090, 7320, 8762, 8856, 28, 0),
array(186, 0, 620, 278, 70, 45)
),
40 => array(
array(7852, 6967, 9606, 8667, 25, 0),
array(146, 0, 431, 190, 60, 37)
),
45 => array(
array(8480, 8883, 10490, 10719, 35, 0),
array(223, 0, 750, 331, 83, 54)
),
50 => array(
array(8522, 9038, 10551, 10883, 35, 0),
array(224, 0, 757, 335, 83, 54)
),
55 => array(
array(8931, 8690, 10992, 10624, 32, 0),
array(219, 0, 707, 312, 84, 54)
),
60 => array(
array(12138, 13013, 15040, 15642, 51, 0),
array(318, 0, 1079, 477, 118, 76)
),
65 => array(
array(13397, 14619, 16622, 17521, 58, 0),
array(345, 0, 1182, 522, 127, 83)
),
70 => array(
array(16323, 17665, 20240, 21201, 70, 0),
array(424, 0, 1447, 640, 157, 102)
),
75 => array(
array(20739, 22796, 25746, 27288, 91, 0),
array(529, 0, 1816, 803, 194, 127)
),
80 => array(
array(21857, 24180, 27147, 28914, 97, 0),
array(551, 0, 1898, 839, 202, 132)
),
85 => array(
array(22476, 25007, 27928, 29876, 100, 0),
array(560, 0, 1933, 855, 205, 134)
),
90 => array(
array(31345, 35053, 38963, 41843, 141, 0),
array(771, 0, 2668, 1180, 281, 184)
),
95 => array(
array(31720, 35635, 39443, 42506, 144, 0),
array(771, 0, 2671, 1181, 281, 184)
),
96 => array(
array(32885, 37007, 40897, 44130, 150, 0),
array(795, 0, 2757, 1219, 289, 190)
),
97 => array(
array(32940, 37099, 40968, 44235, 150, 0),
array(794, 0, 2755, 1219, 289, 190)
),
98 => array(
array(33521, 37691, 41686, 44953, 152, 0),
array(812, 0, 2816, 1246, 296, 194)
),
99 => array(
array(36251, 40861, 45089, 48714, 165, 0),
array(872, 0, 3025, 1338, 317, 208)
)
);
$troops = [5 => [[3412, 2814, 4156, 3553, 9, 0], [35, 0, 77, 33, 17, 10]],
10 => [[4314, 3688, 5265, 4621, 13, 0], [65, 0, 175, 77, 28, 17]],
15 => [[4645, 4267, 5659, 5272, 15, 0], [99, 0, 305, 134, 40, 25]],
20 => [[6207, 5881, 7625, 7225, 22, 0], [144, 0, 456, 201, 56, 36]],
25 => [[6004, 5977, 7400, 7277, 23, 0], [152, 0, 499, 220, 58, 37]],
30 => [[7073, 7181, 8730, 8713, 27, 0], [183, 0, 607, 268, 69, 45]],
35 => [[7090, 7320, 8762, 8856, 28, 0], [186, 0, 620, 278, 70, 45]],
40 => [[7852, 6967, 9606, 8667, 25, 0], [146, 0, 431, 190, 60, 37]],
45 => [[8480, 8883, 10490, 10719, 35, 0], [223, 0, 750, 331, 83, 54]],
50 => [[8522, 9038, 10551, 10883, 35, 0], [224, 0, 757, 335, 83, 54]],
55 => [[8931, 8690, 10992, 10624, 32, 0], [219, 0, 707, 312, 84, 54]],
60 => [[12138, 13013, 15040, 15642, 51, 0], [318, 0, 1079, 477, 118, 76]],
65 => [[13397, 14619, 16622, 17521, 58, 0], [345, 0, 1182, 522, 127, 83]],
70 => [[16323, 17665, 20240, 21201, 70, 0], [424, 0, 1447, 640, 157, 102]],
75 => [[20739, 22796, 25746, 27288, 91, 0], [529, 0, 1816, 803, 194, 127]],
80 => [[21857, 24180, 27147, 28914, 97, 0], [551, 0, 1898, 839, 202, 132]],
85 => [[22476, 25007, 27928, 29876, 100, 0], [560, 0, 1933, 855, 205, 134]],
90 => [[31345, 35053, 38963, 41843, 141, 0], [771, 0, 2668, 1180, 281, 184]],
95 => [[31720, 35635, 39443, 42506, 144, 0], [771, 0, 2671, 1181, 281, 184]],
96 => [[32885, 37007, 40897, 44130, 150, 0], [795, 0, 2757, 1219, 289, 190]],
97 => [[32940, 37099, 40968, 44235, 150, 0], [794, 0, 2755, 1219, 289, 190]],
98 => [[33521, 37691, 41686, 44953, 152, 0], [812, 0, 2816, 1246, 296, 194]],
99 => [[36251, 40861, 45089, 48714, 165, 0], [872, 0, 3025, 1338, 317, 208]]];
// select the troops^^
if (isset($troops[$level]))
{
$units = $troops[$level];
}
else
{
return false;
}
if (isset($troops[$level])) $units = $troops[$level];
else return false;
// get the capital village from the natars
$query = mysqli_query($database->dblink,'SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysqli_error($database->dblink));
$row = mysqli_fetch_assoc($query);
// start the attacks
$endtime = $time + round((60 * 60 * 24) / INCREASE_SPEED);
$endtime = $time + round(86400 / INCREASE_SPEED);
// -.-
$vid = (int) $vid;
@@ -729,7 +634,7 @@ class Automation {
$database->addMovement(3, $row['wref'], $vid, $ref, $time, $endtime);
// wave 2
$ref2 = $database->addAttack($row['wref'], 0, $units[1][0], $units[1][1], 0, $units[1][2], $units[1][3], $units[1][4], $units[1][5], 0, 0, 0, 3, 40, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20, array('vid' => $vid, 'endtime' => ($endtime + 1)));
$ref2 = $database->addAttack($row['wref'], 0, $units[1][0], $units[1][1], 0, $units[1][2], $units[1][3], $units[1][4], $units[1][5], 0, 0, 0, 3, 40, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20, ['vid' => $vid, 'endtime' => ($endtime + 1)]);
$database->addMovement(3, $row['wref'], $vid, $ref2, $time, $endtime + 1);
}
@@ -744,20 +649,20 @@ class Automation {
}
}
private function getPop($tid,$level) {
private function getPop($tid, $level) {
$name = "bid".$tid;
global $$name,$village;
global $$name;
$dataarray = $$name;
$pop = $dataarray[($level+1)]['pop'];
$cp = $dataarray[($level+1)]['cp'];
return array($pop,$cp);
$pop = $dataarray[($level + 1)]['pop'];
$cp = $dataarray[($level + 1)]['cp'];
return [$pop, $cp];
}
private function delTradeRoute() {
global $database;
$time = time();
$q = "DELETE from ".TB_PREFIX."route where timeleft < $time";
$database->query($q);
$database->delTradeRoute();
}
private function TradeRoute() {
@@ -868,17 +773,17 @@ class Automation {
$maxcarry2 *= $bid28[$this->getTypeLevel(28, $from)]['attri'] / 100;
}
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
$reqMerc = ceil((array_sum($resource)-0.1)/$maxcarry2);
$resource = [$wtrans, $ctrans, $itrans, $crtrans];
$reqMerc = ceil((array_sum($resource) - 0.1) / $maxcarry2);
if($merchantAvail2 != 0 && $reqMerc <= $merchantAvail2) {
if($merchantAvail2 > 0 && $reqMerc <= $merchantAvail2) {
if($database->getVillageState($to)) {
$timetaken = $units->getWalkingTroopsTime($from, $to, 0, 0, [$tribe], 0);
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
if($res!=0){
$reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
$database->modifyResource($from,$resource[0],$resource[1],$resource[2],$resource[3],0);
$database->addMovement(0,$from,$to,$reference,microtime(true),microtime(true)+$timetaken,$send);
$res = $resource[0] + $resource[1] + $resource[2] + $resource[3];
if($res > 0){
$reference = $database->sendResource($resource[0], $resource[1], $resource[2], $resource[3], $reqMerc, 0);
$database->modifyResource($from, $resource[0], $resource[1], $resource[2], $resource[3], 0);
$database->addMovement(0, $from, $to, $reference, microtime(true), microtime(true) + $timetaken, $send);
}
}
}
@@ -931,11 +836,9 @@ class Automation {
}
// oasis cannot be destroyed
$pop=$this->recountPop($data['to'], false);
$pop = $this->recountPop($data['to'], false);
if ($isoasis == 0) {
if($pop==0 && $can_destroy==1){
$village_destroyed = 1;
}
if($pop == 0 && $can_destroy == 1) $village_destroyed = 1;
}
if ($isSecondRow) {
@@ -1000,9 +903,7 @@ class Automation {
// recalculate population and check if the village shouldn't be destroyed at this point
$pop = $this->recountPop($data['to'], false);
if ($isoasis == 0) {
if($pop==0 && $can_destroy==1) {
$village_destroyed = 1;
}
if($pop == 0 && $can_destroy == 1) $village_destroyed = 1;
}
if ($isSecondRow) {
@@ -1063,8 +964,7 @@ class Automation {
endtime < $time
ORDER BY endtime ASC";
$dataarray = $database->query_return($q);
$totalattackdead = 0;
$data_num = 0;
$totalattackdead = $data_num = 0;
if ($dataarray && count($dataarray)) {
// preload village data
@@ -1108,7 +1008,7 @@ class Automation {
$NatarCapital= ($toF['owner'] == 3 && $toF['capital']==1);
if(!isset($to['name']) || $to['name']=='') $to['name']="??";
$DefenderUnit = array();
$DefenderUnit = [];
$DefenderUnit = $database->getUnit($data['to']);
$evasion = $toF["evasion"];
$maxevasion = $DefenderUserData["maxevasion"];
@@ -1159,7 +1059,7 @@ class Automation {
$database->modifyUnit($data['to'], $evasionUnitModifications_units, $evasionUnitModifications_amounts, $evasionUnitModifications_modes);
}
//get defence units
$enforDefender = array();
$enforDefender = [];
$rom = $ger = $gal = $nat = $natar = 0;
$Defender = $database->getUnit($data['to'], false);
$enforcementarray = $database->getEnforceVillage($data['to'], 0);
@@ -1192,22 +1092,22 @@ class Automation {
}
//get attack units
$Attacker = array();
$start = ($owntribe-1)*10+1;
$end = ($owntribe*10);
$u = (($owntribe-1)*10);
$catapult = array(8,18,28,48);
$ram = array(7,17,27,47);
$chief = array(9,19,29,49);
$spys = array(4,14,23,44);
$Attacker = [];
$start = ($owntribe - 1) * 10 + 1;
$end = $owntribe * 10;
$u = ($owntribe - 1) * 10;
$catapult = [8, 18, 28, 48];
$ram = [7, 17, 27, 47];
$chief = [9, 19, 29, 49];
$spys = [4, 14, 23, 44];
for($i = $start; $i <= $end; $i++) {
$y = $i - $u;
$Attacker['u'.$i] = $dataarray[$data_num]['t'.$y];
//there are catas
if(in_array($i,$catapult)) $catp_pic = $i;
if(in_array($i,$ram)) $ram_pic = $i;
if(in_array($i,$chief)) $chief_pic = $i;
if(in_array($i,$spys)) $spy_pic = $i;
if(in_array($i, $catapult)) $catp_pic = $i;
if(in_array($i, $ram)) $ram_pic = $i;
if(in_array($i, $chief)) $chief_pic = $i;
if(in_array($i, $spys)) $spy_pic = $i;
}
$Attacker['uhero'] = $dataarray[$data_num]['t11'];
$hero_pic = "hero";
@@ -1298,30 +1198,22 @@ class Automation {
}
//get attack units
$Attacker = array();
$start = ($owntribe-1)*10+1;
$end = ($owntribe*10);
$u = (($owntribe-1)*10);
$catapult = array(8,18,28,38,48);
$ram = array(7,17,27,37,47);
$chief = array(9,19,29,39,49);
$spys = array(4,14,23,44);
for($i=$start;$i<=$end;$i++) {
$y = $i-$u;
$Attacker = [];
$start = ($owntribe - 1) * 10 + 1;
$end = $owntribe * 10;
$u = ($owntribe - 1) * 10;
$catapult = [8, 18, 28, 38, 48];
$ram = [7, 17, 27, 37, 47];
$chief = [9, 19, 29, 39, 49];
$spys = [4, 14, 23, 44];
for($i = $start; $i <= $end; $i++) {
$y = $i - $u;
$Attacker['u'.$i] = $dataarray[$data_num]['t'.$y];
//there are catas
if(in_array($i,$catapult)) {
$catp_pic = $i;
}
if(in_array($i,$ram)) {
$ram_pic = $i;
}
if(in_array($i,$chief)) {
$chief_pic = $i;
}
if(in_array($i,$spys)) {
$spy_pic = $i;
}
if(in_array($i, $catapult)) $catp_pic = $i;
if(in_array($i, $ram)) $ram_pic = $i;
if(in_array($i, $chief)) $chief_pic = $i;
if(in_array($i, $spys)) $spy_pic = $i;
}
$Attacker['uhero'] = $dataarray[$data_num]['t11'];
$hero_pic = "hero";
@@ -1993,8 +1885,8 @@ class Automation {
// we're manually targetting 1st and/or 2nd row of catapults
if (!$catapults1TargetRandom)
{
$_catapultsTarget1Levels=array();
$__catapultsTarget1AltTargets=array();
$_catapultsTarget1Levels = [];
$__catapultsTarget1AltTargets = [];
// calculate targets for 1st rows of catapults
$j = 0;
@@ -2030,7 +1922,7 @@ class Automation {
// 1st row of catapults set to target randomly
if ($catapults1TargetRandom)
{
$list=array();
$list = [];
for ($i = 1; $i <= 41; $i++)
{
if ($i == 41) $i = 99;
@@ -2052,8 +1944,8 @@ class Automation {
// we're manually targetting 2nd row of catapults
if (!$catapults2TargetRandom)
{
$_catapultsTarget2Levels=array();
$__catapultsTarget2AltTargets=array();
$_catapultsTarget2Levels = [];
$__catapultsTarget2AltTargets = [];
// calculate targets for 2nd rows of catapults
$j = 0;
@@ -3065,12 +2957,12 @@ class Automation {
if (!isset($wavesData[$data['from'].$data['to'].$data['starttime'].$data['endtime']])) {
$tribe = $database->getUserField($database->getVillageField($data['to'],"owner"),"tribe",0);
if($tribe == 1){ $u = ""; } elseif($tribe == 2){ $u = "1"; } elseif($tribe == 3){ $u = "2"; } elseif($tribe == 4){ $u = "3"; } else{ $u = "4"; }
$u = $tribe == 1 ? "" : $tribe - 1;
$database->modifyUnit(
$data['to'],
array($u."1",$u."2",$u."3",$u."4",$u."5",$u."6",$u."7",$u."8",$u."9",$tribe."0","hero"),
array($data['t1'],$data['t2'],$data['t3'],$data['t4'],$data['t5'],$data['t6'],$data['t7'],$data['t8'],$data['t9'],$data['t10'],$data['t11']),
array(1,1,1,1,1,1,1,1,1,1,1)
[$u."1", $u."2", $u."3", $u."4", $u."5", $u."6", $u."7", $u."8", $u."9", $tribe."0", "hero"],
[$data['t1'], $data['t2'], $data['t3'], $data['t4'], $data['t5'], $data['t6'], $data['t7'], $data['t8'], $data['t9'], $data['t10'], $data['t11']],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);
$movementProcIDs[] = $data['moveid'];
@@ -3080,12 +2972,9 @@ class Automation {
// 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;
} else {
// duplicate record, just mark it as processed
$movementProcIDs[] = $data['moveid'];
}
} // duplicate record, just mark it as processed
else $movementProcIDs[] = $data['moveid'];
}
$database->setMovementProc(implode(', ', $movementProcIDs));
}
@@ -3098,10 +2987,10 @@ class Automation {
foreach($dataarray as $data) {
if($data['wood'] >= $data['clay'] && $data['wood'] >= $data['iron'] && $data['wood'] >= $data['crop']){ $sort_type = "10"; }
elseif($data['clay'] >= $data['wood'] && $data['clay'] >= $data['iron'] && $data['clay'] >= $data['crop']){ $sort_type = "11"; }
elseif($data['iron'] >= $data['wood'] && $data['iron'] >= $data['clay'] && $data['iron'] >= $data['crop']){ $sort_type = "12"; }
elseif($data['crop'] >= $data['wood'] && $data['crop'] >= $data['clay'] && $data['crop'] >= $data['iron']){ $sort_type = "13"; }
if($data['wood'] >= $data['clay'] && $data['wood'] >= $data['iron'] && $data['wood'] >= $data['crop']) $sort_type = 10;
elseif($data['clay'] >= $data['wood'] && $data['clay'] >= $data['iron'] && $data['clay'] >= $data['crop']) $sort_type = 11;
elseif($data['iron'] >= $data['wood'] && $data['iron'] >= $data['clay'] && $data['iron'] >= $data['crop']) $sort_type = 12;
elseif($data['crop'] >= $data['wood'] && $data['crop'] >= $data['clay'] && $data['crop'] >= $data['iron']) $sort_type = 13;
$to = $database->getMInfo($data['to']);
$from = $database->getMInfo($data['from']);
@@ -3117,7 +3006,6 @@ class Automation {
$this->pruneResource();
// Settlers
$q = "SELECT `to`, moveid FROM ".TB_PREFIX."movement where ref = 0 and proc = '0' and sort_type = '4' and endtime < $time";
$dataarray = $database->query_return($q);
@@ -3129,7 +3017,6 @@ class Automation {
$database->modifyUnit($data['to'],array($tribe."0"),array(3),array(1));
$movementProcIDs[] = $data['moveid'];
}
$database->setMovementProc(implode(', ', $movementProcIDs));
}
@@ -3487,108 +3374,17 @@ class Automation {
return $ownunit;
}
public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
global $database, $session, $village;
if ( $vid == 0 ) {
$vid = $village->wid;
}
$buildarray = array();
if ( $vid != 0 ) {
$buildarray = $database->getResourceLevel( $vid );
}
$upkeep = 0;
switch ( $type ) {
case 0:
$start = 1;
$end = 50;
break;
case 1:
$start = 1;
$end = 10;
break;
case 2:
$start = 11;
$end = 20;
break;
case 3:
$start = 21;
$end = 30;
break;
case 4:
$start = 31;
$end = 40;
break;
case 5:
$start = 41;
$end = 50;
break;
}
for ( $i = $start; $i <= $end; $i ++ ) {
$k = $i - $start + 1;
$unit = "u" . $i;
$unit2 = "t" . $k;
global $$unit;
$dataarray = $$unit;
for ( $j = 19; $j <= 38; $j ++ ) {
if ( $buildarray[ 'f' . $j . 't' ] == 41 ) {
$horsedrinking = $j;
}
}
if ( $prisoners == 0 ) {
if ( isset( $horsedrinking ) ) {
if ( ( $i == 4 && $buildarray[ 'f' . $horsedrinking ] >= 10 )
|| ( $i == 5 && $buildarray[ 'f' . $horsedrinking ] >= 15 )
|| ( $i == 6 && $buildarray[ 'f' . $horsedrinking ] == 20 ) ) {
$upkeep += ( $dataarray['pop'] - 1 ) * $array[ $unit ];
} else {
$upkeep += $dataarray['pop'] * $array[ $unit ];
}
} else {
$upkeep += $dataarray['pop'] * $array[ $unit ];
}
} else {
if ( isset( $horsedrinking ) ) {
if ( ( $i == 4 && $buildarray[ 'f' . $horsedrinking ] >= 10 )
|| ( $i == 5 && $buildarray[ 'f' . $horsedrinking ] >= 15 )
|| ( $i == 6 && $buildarray[ 'f' . $horsedrinking ] == 20 ) ) {
$upkeep += ( $dataarray['pop'] - 1 ) * $array[ $unit2 ];
} else {
$upkeep += $dataarray['pop'] * $array[ $unit2 ];
}
} else {
$upkeep += $dataarray['pop'] * $array[ $unit2 ];
}
}
}
$unit = ($prisoners > 0) ? 't11' : 'hero';
if(!isset($array[$unit])) $array[$unit] = 0;
$upkeep += $array[$unit] * 6;
$who = $database->getVillageField($vid, "owner");
return $database->getArtifactsValueInfluence($who, $vid, 4, $upkeep);
}
private function bountycalculateOProduction($bountywid) {
$this->bountyOproduction['wood'] = $this->bountyGetOWoodProd();
$this->bountyOproduction['clay'] = $this->bountyGetOClayProd();
$this->bountyOproduction['iron'] = $this->bountyGetOIronProd();
$this->bountyOproduction['crop'] = $this->bountyGetOCropProd();
$this->bountyOproduction['wood'] = self::bountyOWoodProd;
$this->bountyOproduction['clay'] = self::bountyOClayProd;
$this->bountyOproduction['iron'] = self::bountyOIronProd;
$this->bountyOproduction['crop'] = self::bountyOCropProd;
}
private function bountycalculateProduction($bountywid, $uid) {
$upkeep = $this->getUpkeep($this->getAllUnits($bountywid), 0);
global $technology;
$upkeep = $technology->getUpkeep($this->getAllUnits($bountywid), 0, $bountywid);
$this->bountyproduction['wood'] = $this->bountyGetWoodProd();
$this->bountyproduction['clay'] = $this->bountyGetClayProd();
$this->bountyproduction['iron'] = $this->bountyGetIronProd();
@@ -3597,6 +3393,7 @@ class Automation {
private function bountyprocessProduction($bountywid) {
global $database;
$timepast = time() - $this->bountyinfoarray['lastupdate'];
$nwood = ($this->bountyproduction['wood'] / 3600) * $timepast;
$nclay = ($this->bountyproduction['clay'] / 3600) * $timepast;
@@ -3607,6 +3404,7 @@ class Automation {
}
private function bountyprocessOProduction($bountywid) {
global $database;
$timepast = time() - $this->bountyinfoarray['lastupdated'];
$nwood = ($this->bountyOproduction['wood'] / 3600) * $timepast;
$nclay = ($this->bountyOproduction['clay'] / 3600) * $timepast;
@@ -3616,22 +3414,6 @@ class Automation {
$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() {
global $bid1, $bid5;
@@ -3672,7 +3454,7 @@ class Automation {
global $bid3, $bid7;
$iron = $foundry = 0;
$ironholder = array();
$ironholder = [];
for($i = 1; $i <= 38; $i++) {
if($this->bountyresarray['f'.$i.'t'] == 3) array_push($ironholder,'f'.$i);
if($this->bountyresarray['f'.$i.'t'] == 7) $foundry = $this->bountyresarray['f'.$i];
@@ -4205,7 +3987,7 @@ class Automation {
*/
private function addStarvationData($wref){
global $database;
global $database, $technology;
$getVillage = $database->getVillage($wref);
@@ -4213,7 +3995,7 @@ class Automation {
if ($getVillage['owner'] > 5){
$crop = $database->getCropProdstarv($wref, false);
$unitArrays = $this->getAllUnits($wref, false);
$villageUpkeep = $getVillage['pop'] + $this->getUpkeep($unitArrays, 0);
$villageUpkeep = $getVillage['pop'] + $technology->getUpkeep($unitArrays, 0, $wref);
$starv = $getVillage['starv'];
if ($crop < $villageUpkeep){
@@ -4233,7 +4015,7 @@ class Automation {
//TODO: This function needs to be splitted in many subfunctions (for TravianZ refactor)
private function starvation() {
global $database, $autoprefix;
global $database, $technology, $autoprefix;
if(file_exists($autoprefix."GameEngine/Prevention/starvation.txt")) {
unlink($autoprefix."GameEngine/Prevention/starvation.txt");
@@ -4269,7 +4051,7 @@ class Automation {
{
$unitarrays = $this->getAllUnits($starv['wref']);
$upkeep = $starv['pop'] + $this->getUpkeep($unitarrays, 0, $starv['wref']);
$upkeep = $starv['pop'] + $technology->getUpkeep($unitarrays, 0, $starv['wref']);
$enforceArrays = $prisonerArrays = $unitArrays = $attackArrays = $allTroopsArray = $starvingTroops = $killedUnits = [];
+3 -3
View File
@@ -253,9 +253,9 @@ class Battle {
$cap = $ap = $dp = $cdp = $rap = $rdp = 0;
//Get involved artifacts
$attacker_artefact = $database->getArtifactsValueInfluence($AttackerID, $AttackerWref, 3, 1);
$defender_artefact = $database->getArtifactsValueInfluence($DefenderID, $DefenderWref, 3, 1);
$strongerbuildings = $database->getArtifactsValueInfluence($DefenderID, $DefenderWref, 1, 1);
$attacker_artefact = $database->getArtifactsValueInfluence($AttackerID, $AttackerWref, 3, 1, false);
$defender_artefact = $database->getArtifactsValueInfluence($DefenderID, $DefenderWref, 3, 1, false);
$strongerbuildings = $database->getArtifactsValueInfluence($DefenderID, $DefenderWref, 1, 1, false);
if(isset($Attacker['uhero']) && $Attacker['uhero'] != 0){
$atkhero = $this->getBattleHero($AttackerID);
+20 -64
View File
@@ -224,11 +224,6 @@ class MYSQLi_DB implements IDbConnection {
*/
$artefactDataCache = [],
/**
* @var array Cache of fool artefacts.
*/
$foolArtefactCache = [],
/**
* @var array Cache of own artefact infos, from the simple SQL select.
*/
@@ -4307,6 +4302,17 @@ References: User ID/Message ID, Mode
return $this->mysqli_fetch_all($result);
}
/**
* Delete expired trade routes
*
*/
function delTradeRoute() {
$time = time();
$q = "DELETE from " . TB_PREFIX . "route where timeleft < $time";
return mysqli_query($this->dblink, $q);
}
function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) {
list($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) = $this->escape_input((int) $uid,(int) $wid,(int) $from,(int) $r1,(int) $r2,(int) $r3,(int) $r4,(int) $start,(int) $deliveries,(int) $merchant,(int) $time);
@@ -6917,8 +6923,8 @@ References: User ID/Message ID, Mode
* @return int Returns the new value, multiplied or divided by artifacts bonus or malus
*/
function getArtifactsValueInfluence($uid, $vid, $kind, $multiplicand){
list($uid, $vid, $kind, $multiplicand) = $this->escape_input((int) $uid,(int) $vid, $kind, $multiplicand);
function getArtifactsValueInfluence($uid, $vid, $kind, $multiplicand, $round = true){
list($uid, $vid, $kind, $multiplicand, $round) = $this->escape_input((int) $uid,(int) $vid, $kind, $multiplicand, $round);
$artefacts = $foolArefacts = [];
$multipliers = [1 => [4, 5, 3], 2 => [1/2, 1/3, 2/3], 3 => [5, 10, 3], 4 => [1/2, 1/2, 3/4], 5 => [1/2, 1/2, 3/4], 7 => [3, 6, 2]];
@@ -6951,7 +6957,7 @@ References: User ID/Message ID, Mode
if(in_array($kind, [2, 4, 5])) $foolEffect = 1 / $foolEffect;
return ($multiplicand == 1 ) ? $multiplicand * $multiplier * $foolEffect : round($multiplicand * $multiplier * $foolEffect);
return !$round ? $multiplicand * $multiplier * $foolEffect : round($multiplicand * $multiplier * $foolEffect);
}
/**
@@ -7100,56 +7106,6 @@ References: User ID/Message ID, Mode
return (isset(self::$artefactDataCache[$id.$mode][$size.$type]) ? self::$artefactDataCache[$id.$mode][$size.$type] : []);
}
function getFoolArtefactInfo($type, $vid, $uid, $use_cache = true) {
list($type, $vid, $uid) = $this->escape_input((int) $type, (int) $vid, (int) $uid);
// first of all, check if we should be using cache and whether the field
// required is already cached
if ($use_cache && isset(self::$foolArtefactCache[$vid]) && is_array(self::$foolArtefactCache[$vid]) && !count(self::$foolArtefactCache[$vid])) {
return [];
} else if ($use_cache && ($cachedValue = self::returnCachedContent(self::$foolArtefactCache, $vid)) && !is_null($cachedValue)) {
$data = [];
// prepare the data as requested
if (isset($cachedValue[$type.$uid])) {
foreach ($cachedValue[$type.$uid] as $row) {
if ($row['type'] == 8 && $row['kind'] == $type && $row['owner'] == $uid && $row['size'] > 1 && $row['active'] > 1) {
$data[] = $row;
}
}
}
return $data;
}
$q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid"; //" AND ((type = 8 AND kind = $type) OR (owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type))";
$result = $this->mysqli_fetch_all(mysqli_query($this->dblink,$q));
// cache all types and return the requested one
if (count($result)) {
foreach ($result as $arteInfo) {
if (!isset(self::$foolArtefactCache[$vid][$arteInfo['type'].$arteInfo['owner']])) {
self::$foolArtefactCache[$vid][$arteInfo['type'].$arteInfo['owner']] = [];
}
self::$foolArtefactCache[$vid][$arteInfo['type'].$arteInfo['owner']][] = $arteInfo;
}
} else {
self::$foolArtefactCache[$vid] = [];
}
if (
isset(self::$foolArtefactCache[$vid][$type.$uid]) &&
self::$foolArtefactCache[$vid][$type.$uid]['type'] == 8 &&
self::$foolArtefactCache[$vid][$type.$uid]['kind'] == $type &&
self::$foolArtefactCache[$vid][$type.$uid]['owner'] == $uid &&
self::$foolArtefactCache[$vid][$type.$uid]['size'] > 1 &&
self::$foolArtefactCache[$vid][$type.$uid]['active'] > 1
) {
return self::$foolArtefactCache[$vid][$type.$uid];
} else {
return [];
}
}
function villageHasArtefact($vref) {
// this is a somewhat non-ideal, externally non-changeable way of caching
// but since we're only ever going to be calling this from a single point of Automation,
@@ -7425,17 +7381,17 @@ References: User ID/Message ID, Mode
return mysqli_query($this->dblink,$q);
}
function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
list($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10);
function addSlotFarm($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
list($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10);
$q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10')";
$q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) SELECT '$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10' WHERE EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner)";
return mysqli_query($this->dblink,$q);
}
function editSlotFarm($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
list($eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input((int) $eid, $lid, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10);
function editSlotFarm($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) {
list($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input((int) $eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10);
$q = "UPDATE " . TB_PREFIX . "raidlist set lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid";
$q = "UPDATE " . TB_PREFIX . "raidlist SET lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid AND lid = $oldLid AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner) AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $oldLid AND owner = $owner)";
return mysqli_query($this->dblink,$q);
}
+146 -195
View File
@@ -49,7 +49,7 @@ class Technology {
public function getABUpgrades($type='a') {
global $village;
$holder = array();
$holder = [];
foreach($village->researching as $research) {
if(substr($research['tech'],0,1) == $type){
array_push($holder,$research);
@@ -111,16 +111,17 @@ class Technology {
public function getTrainingList($type) {
global $database,$village;
$trainingarray = $database->getTraining($village->wid);
$listarray = array();
$barracks = array(1,2,3,11,12,13,14,21,22,31,32,33,34,35,36,37,38,39,40,41,42,43,44);
$listarray = [];
$barracks = [1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44];
// fix by brainiac - THANK YOU
$greatbarracks = array(61,62,63,71,72,73,74,81,82,91,92,93,94,95,96,97,98,99,100,101,102,103,104);
$stables = array(4,5,6,15,16,23,24,25,26,45,46);
$greatstables = array(64,65,66,75,76,83,84,85,86,105,106);
$workshop = array(7,8,17,18,27,28,47,48);
$greatworkshop = array(67,68,77,78,87,88,107,108);
$residence = array(9,10,19,20,29,30,49,50);
$trapper = array(99);
$greatbarracks = [61, 62, 63, 71, 72, 73, 74, 81, 82, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104];
$stables = [4, 5, 6, 15, 16, 23, 24, 25, 26, 45, 46];
$greatstables = [64, 65, 66, 75, 76, 83, 84, 85, 86, 105, 106];
$workshop = [7, 8, 17, 18, 27, 28, 47, 48];
$greatworkshop = [67, 68, 77, 78, 87, 88, 107, 108];
$residence = [9, 10, 19, 20, 29, 30, 49, 50];
$trapper = [99];
if(count($trainingarray) > 0) {
foreach($trainingarray as $train) {
if($type == 1 && in_array($train['unit'],$barracks)) {
@@ -165,11 +166,11 @@ class Technology {
public function getUnitList() {
global $database,$village;
$unitarray = func_num_args() == 1? $database->getUnit(func_get_arg(0)) : $village->unitall;
$listArray = array();
for($i=1;$i<count($this->unarray);$i++) {
$holder = array();
if(!empty($unitarray['u'.$i]) && $unitarray['u'.$i] != 0 && $unitarray['u'.$i] != "") {
$unitarray = func_num_args() == 1 ? $database->getUnit(func_get_arg(0)) : $village->unitall;
$listArray = [];
for($i = 1; $i < count($this->unarray); $i++) {
$holder = [];
if(!empty($unitarray['u'.$i]) && $unitarray['u'.$i] > 0 && !empty($unitarray['u'.$i])) {
$holder['id'] = $i;
$holder['name'] = $this->unarray[$i];
$holder['amt'] = $unitarray['u'.$i];
@@ -177,65 +178,62 @@ class Technology {
}
}
if($unitarray['hero'] != 0 && $unitarray['hero'] != "") {
if($unitarray['hero'] > 0 && !empty($unitarray['hero'])) {
$holder['id'] = "hero";
$holder['name'] = $this->unarray[$i];
$holder['amt'] = $unitarray['hero'];
array_push($listArray,$holder);
}
}
return $listArray;
}
public function maxUnit($unit,$great=false) {
$unit = "u".$unit;
global $village,$$unit,$database;
$unitarray = $$unit;
$unit = "u" . $unit;
global $village, $$unit, $database;
$unitarray = $$unit;
$res = $database->getVillage($village->wid, 0, false);
if ($res['wood'] > $res['maxstore']){$res['wood'] = $res['maxstore'];}
if ($res['clay'] > $res['maxstore']){$res['clay'] = $res['maxstore'];}
if ($res['iron'] > $res['maxstore']){$res['iron'] = $res['maxstore'];}
if ($res['crop'] > $res['maxcrop']){$res['crop'] = $res['maxcrop'];}
$woodcalc = floor($res['wood'] / ($unitarray['wood'] * ($great?3:1)));
$claycalc = floor($res['clay'] / ($unitarray['clay'] * ($great?3:1)));
$ironcalc = floor($res['iron'] / ($unitarray['iron'] * ($great?3:1)));
if($res['crop']>0){
$cropcalc = floor($res['crop'] / ($unitarray['crop'] * ($great?3:1)));
}else{
$cropcalc = 0;
}
if($unit != "u99"){
$popcalc = floor($village->getProd("crop")/$unitarray['pop']);
}else{
$popcalc = $village->getProd("crop");
}
return min($woodcalc,$claycalc,$ironcalc,$cropcalc);
if($res['wood'] > $res['maxstore']) $res['wood'] = $res['maxstore'];
if($res['clay'] > $res['maxstore']) $res['clay'] = $res['maxstore'];
if($res['iron'] > $res['maxstore']) $res['iron'] = $res['maxstore'];
if($res['crop'] > $res['maxcrop']) $res['crop'] = $res['maxcrop'];
$woodcalc = floor($res['wood'] / ($unitarray['wood'] * ($great ? 3 : 1)));
$claycalc = floor($res['clay'] / ($unitarray['clay'] * ($great ? 3 : 1)));
$ironcalc = floor($res['iron'] / ($unitarray['iron'] * ($great ? 3 : 1)));
if($res['crop'] > 0) $cropcalc = floor($res['crop'] / ($unitarray['crop'] * ($great ? 3 : 1)));
else $cropcalc = 0;
if($unit != "u99") $popcalc = floor($village->getProd("crop") / $unitarray['pop']);
else $popcalc = $village->getProd("crop");
return min($woodcalc, $claycalc, $ironcalc, $cropcalc);
}
public function maxUnitPlus($unit,$great=false) {
$unit = "u".$unit;
global $village,$$unit,$database;
$unit = "u" . $unit;
global $village, $$unit, $database;
$unitarray = $$unit;
$res = $database->getVillage($village->wid);
$totalres = $res['wood']+$res['clay']+$res['iron']+$res['crop'];
$totalresunit = ($unitarray['wood'] * ($great?3:1))+($unitarray['clay'] * ($great?3:1))+($unitarray['iron'] * ($great?3:1))+($unitarray['crop'] * ($great?3:1));
$max =round($totalres/$totalresunit);
$totalres = $res['wood'] + $res['clay'] + $res['iron'] + $res['crop'];
$totalresunit = ($unitarray['wood'] * ($great ? 3 : 1)) + ($unitarray['clay'] * ($great ? 3 : 1)) + ($unitarray['iron'] * ($great ? 3 : 1)) + ($unitarray['crop'] * ($great ? 3 : 1));
$max = round($totalres / $totalresunit);
return $max;
}
public function getUnits() {
global $database,$village;
if(func_num_args() == 1) {
$base = func_get_arg(0);
}
$ownunit = func_num_args() == 2? func_get_arg(0) : $database->getUnit($base);
$enforcementarray = func_num_args() == 2? func_get_arg(1) : $database->getEnforceVillage($base,0);
if(count($enforcementarray) > 0) {
foreach($enforcementarray as $enforce) {
for($i=1;$i<=50;$i++) {
$ownunit['u'.$i] += $enforce['u'.$i];
}
global $database, $village;
if(func_num_args() == 1) $base = func_get_arg(0);
$ownunit = func_num_args() == 2 ? func_get_arg(0) : $database->getUnit($base);
$enforcementarray = func_num_args() == 2 ? func_get_arg(1) : $database->getEnforceVillage($base, 0);
if(count($enforcementarray) > 0){
foreach($enforcementarray as $enforce){
for($i = 1; $i <= 50; $i++) $ownunit['u'.$i] += $enforce['u'.$i];
}
}
return $ownunit;
@@ -243,70 +241,71 @@ class Technology {
function getAllUnits($base,$InVillageOnly=False,$mode=0) {
global $database;
$ownunit = $database->getUnit($base);
$ownunit['u99'] -= $ownunit['u99'];
$ownunit['u99o'] -= $ownunit['u99o'];
$enforcementarray = $database->getEnforceVillage($base,0);
if(count($enforcementarray) > 0) {
foreach($enforcementarray as $enforce) {
for($i=1;$i<=50;$i++) {
$ownunit['u'.$i] += $enforce['u'.$i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
if ($mode==0) {
$enforceoasis=$database->getOasisEnforce($base,0);
if(count($enforceoasis) > 0) {
foreach($enforceoasis as $enforce) {
for($i=1;$i<=50;$i++) {
$ownunit['u'.$i] += $enforce['u'.$i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
$enforceoasis1=$database->getOasisEnforce($base,1);
if(count($enforceoasis1) > 0) {
foreach($enforceoasis1 as $enforce) {
for($i=1;$i<=50;$i++) {
$ownunit['u'.$i] += $enforce['u'.$i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
$prisoners = $database->getPrisoners($base,1);
if(!empty($prisoners)) {
foreach($prisoners as $prisoner){
$owner = $database->getVillageField($base,"owner");
$ownertribe = $database->getUserField($owner,"tribe",0);
$start = ($ownertribe-1)*10+1;
$end = ($ownertribe*10);
for($i=$start;$i<=$end;$i++) {
$j = $i-$start+1;
$ownunit['u'.$i] += $prisoner['t'.$j];
}
$ownunit['hero'] += $prisoner['t11'];
}
}
}
if(!$InVillageOnly) {
$movement = $database->getVillageMovement($base);
if(!empty($movement)) {
for($i=1;$i<=50;$i++) {
if (!isset($ownunit['u'.$i])) {
$ownunit['u'.$i] = 0;
}
$ownunit['u'.$i] += (isset($movement['u'.$i]) ? $movement['u'.$i] : 0);
}
if (!isset($ownunit['hero'])) {
$ownunit['hero'] = 0;
}
$ownunit['hero'] += (isset($movement['hero']) ? $movement['hero'] : 0);
}
}
return $ownunit;
$ownunit = $database->getUnit($base);
$ownunit['u99'] -= $ownunit['u99'];
$ownunit['u99o'] -= $ownunit['u99o'];
$enforcementarray = $database->getEnforceVillage($base, 0);
if(count($enforcementarray) > 0){
foreach($enforcementarray as $enforce){
for($i = 1; $i <= 50; $i++){
$ownunit['u' . $i] += $enforce['u' . $i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
if($mode == 0){
$enforceoasis = $database->getOasisEnforce($base, 0);
if(count($enforceoasis) > 0){
foreach($enforceoasis as $enforce){
for($i = 1; $i <= 50; $i++){
$ownunit['u' . $i] += $enforce['u' . $i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
$enforceoasis1 = $database->getOasisEnforce($base, 1);
if(count($enforceoasis1) > 0){
foreach($enforceoasis1 as $enforce){
for($i = 1; $i <= 50; $i++){
$ownunit['u' . $i] += $enforce['u' . $i];
}
$ownunit['hero'] += $enforce['hero'];
}
}
$prisoners = $database->getPrisoners($base, 1);
if(!empty($prisoners)){
foreach($prisoners as $prisoner){
$owner = $database->getVillageField($base, "owner");
$ownertribe = $database->getUserField($owner, "tribe", 0);
$start = ($ownertribe - 1) * 10 + 1;
$end = ($ownertribe * 10);
for($i = $start; $i <= $end; $i++){
$j = $i - $start + 1;
$ownunit['u' . $i] += $prisoner['t' . $j];
}
$ownunit['hero'] += $prisoner['t11'];
}
}
}
if(!$InVillageOnly){
$movement = $database->getVillageMovement($base);
if(!empty($movement)){
for($i = 1; $i <= 50; $i++){
if(!isset($ownunit['u' . $i])){
$ownunit['u' . $i] = 0;
}
$ownunit['u' . $i] += (isset($movement['u' . $i]) ? $movement['u' . $i] : 0);
}
if(!isset($ownunit['hero'])){
$ownunit['hero'] = 0;
}
$ownunit['hero'] += (isset($movement['hero']) ? $movement['hero'] : 0);
}
}
return $ownunit;
}
public function meetTRequirement($unit) {
@@ -419,92 +418,44 @@ class Technology {
}
}
public function getUpkeep($array,$type,$vid=0,$prisoners=0) {
global $database, $session, $village;
public function getUpkeep($array, $type, $vid = 0, $prisoners = 0) {
global $database, $village;
if ( $vid == 0 ) {
$vid = $village->wid;
if ($vid == 0) $vid = $village->wid;
$upkeep = 0;
$horsedrinking = $database->getFieldLevelInVillage($vid, 41);
if(!$type){
$start = 1;
$end = 50;
}else{
$start = ($type - 1) * 10 + 1;
$end = $type * 10;
}
$buildarray = array();
$buildarray = $database->getResourceLevel( $vid );
$upkeep = 0;
switch ( $type ) {
case 0:
$start = 1;
$end = 50;
break;
case 1:
$start = 1;
$end = 10;
break;
case 2:
$start = 11;
$end = 20;
break;
case 3:
$start = 21;
$end = 30;
break;
case 4:
$start = 31;
$end = 40;
break;
case 5:
$start = 41;
$end = 50;
break;
}
for ( $j = 19; $j <= 38; $j ++ ) {
if ( $buildarray[ 'f' . $j . 't' ] == 41 ) {
$horsedrinking = $j;
break;
}
}
for ( $i = $start; $i <= $end; $i ++ ) {
$k = $i - $start + 1;
$unit = "u" . $i;
$unit2 = "t" . $k;
global $$unit;
for ($i = $start; $i <= $end; $i ++) {
$k = $i - $start + 1;
$unit = $prisoners == 0 ? "u" . $i : "t" . $k;
global $$unit;
$dataarray = $$unit;
if ( $prisoners == 0 ) {
if ( isset( $horsedrinking ) ) {
if ( ( $i == 4 && $buildarray[ 'f' . $horsedrinking ] >= 10 )
|| ( $i == 5 && $buildarray[ 'f' . $horsedrinking ] >= 15 )
|| ( $i == 6 && $buildarray[ 'f' . $horsedrinking ] == 20 )
) {
$upkeep += (( $dataarray['pop'] - 1 ) * $array[ $unit ]);
} else {
$upkeep += ($dataarray['pop'] * $array[ $unit ]);
}
} else {
$upkeep += ($dataarray['pop'] * $array[ $unit ]);
}
} else {
if ( isset( $horsedrinking ) ) {
if ( ( $i == 4 && $buildarray[ 'f' . $horsedrinking ] >= 10 )
|| ( $i == 5 && $buildarray[ 'f' . $horsedrinking ] >= 15 )
|| ( $i == 6 && $buildarray[ 'f' . $horsedrinking ] == 20 )
) {
$upkeep += (( $dataarray['pop'] - 1 ) * $array[ $unit2 ]);
} else {
$upkeep += ($dataarray['pop'] * $array[ $unit2 ]);
}
} else {
$upkeep += ($dataarray['pop'] * $array[ $unit2 ]);
if($horsedrinking > 0) {
if (($i == 4 && $horsedrinking >= 10) || ($i == 5 && $horsedrinking >= 15) || ( $i == 6 && $horsedrinking == 20)) {
$upkeep += ($dataarray['pop'] - 1) * $array[$unit];
}
else $upkeep += ($dataarray['pop'] * $array[$unit]);
}
else $upkeep += ($dataarray['pop'] * $array[$unit]);
}
$unit = ($prisoners > 0) ? 't11' : 'hero';
if(!isset($array[$unit])) $array[$unit] = 0;
$upkeep += $array[$unit] * 6;
$who = $database->getVillageField($vid, "owner");
return $database->getArtifactsValueInfluence($session->uid, $vid, 4, $upkeep);
return ceil($database->getArtifactsValueInfluence($who, $vid, 4, $upkeep, false));
}
private function trainUnit($unit, $amt, $great = false) {
@@ -591,7 +542,7 @@ class Technology {
}
public function meetRRequirement($tech) {
global $session,$building;
global $session, $building;
switch($tech) {
case 2: return $building->getTypeLevel(22) >= 1 && $building->getTypeLevel(13) >= 1;
case 3: return $building->getTypeLevel(22) >= 5 && $building->getTypeLevel(12) >= 1;
@@ -735,7 +686,7 @@ class Technology {
return mysqli_affected_rows($database->dblink);
}
public function calculateAvaliable($id,$resarray=array()) {
public function calculateAvaliable($id, $resarray = []) {
global $village,$generator,${'r'.$id};
if(count($resarray)==0) {
$resarray['wood'] = ${'r'.$id}['wood'];
+100 -6
View File
@@ -40,11 +40,7 @@ class Units {
return $post;
}
break;
case "8":
$this->sendTroopsBack($post);
break;
case "3":
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else{
@@ -67,6 +63,10 @@ class Units {
$post = $this->loadUnits($post);
return $post;
}
case "8":
$this->sendTroopsBack($post);
break;
}
}
}
@@ -77,7 +77,7 @@ class Units {
// Coordinates and look confirm name people
if(isset($post['x']) && isset($post['y']) && !empty($post['x']) && !empty($post['y'])) {
$vid = $database->getVilWref($post['x'], $post['y']);
unset($post['dname'], $_POST['dname']);
unset($post['dname'], $post['dname']);
}else if(isset($post['dname']) && !empty($post['dname'])){
$vid = $database->getVillageByName(stripslashes($post['dname']));
}
@@ -774,6 +774,100 @@ class Units {
return $generator->procDistanceTime($fromCor, $toCor, min($speeds), $mode);
}
public function startRaidList($post){
global $database, $generator, $session;
$slots = $post['slot'];
$lid = $post['lid'];
$tribe = $session->tribe;
$getFLData = $database->getFLData($lid);
if($getFLData['owner'] != $session->uid) {
header("Location: build.php?id=39&t=99");
exit();
}
$sql = "SELECT id, towref, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 FROM " . TB_PREFIX . "raidlist WHERE lid = ".$database->escape((int)$lid)." order by id asc";
$array = $database->query_return($sql);
foreach($array as $row){
$sql1 = mysqli_fetch_array(mysqli_query($database->dblink, "SELECT * FROM " . TB_PREFIX . "units WHERE vref = ".(int)$getFLData['wref']));
$sid = $row['id'];
$wref = $row['towref'];
for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i];
$t11 = 0;
$villageOwner = $database->getVillageField($wref, 'owner');
$userAccess = $database->getUserField($villageOwner, 'access', 0);
$userID = $database->getUserField($villageOwner, 'id', 0);
if($userAccess != 0 && !($userAccess == MULTIHUNTER && $userID == 5) && ($userAccess != ADMIN || (ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN))){
if($tribe == 1){
$uname = "u";
$uname1 = "u1";
$uname2 = "";
}elseif($tribe == 2){
$uname = "u1";
$uname1 = "u2";
$uname2 = "1";
}elseif($tribe == 3){
$uname = "u2";
$uname1 = "u3";
$uname2 = "2";
}elseif($tribe == 4){
$uname = "u3";
$uname1 = "u4";
$uname2 = "3";
}else{
$uname = "u4";
$uname1 = "u5";
$uname2 = "4";
}
if($sql1[$uname.'1'] >= $t1 && $sql1[$uname.'2'] >= $t2 && $sql1[$uname.'3'] >= $t3 && $sql1[$uname.'4'] >= $t4 && $sql1[$uname.'5'] >= $t5 && $sql1[$uname.'6'] >= $t6 && $sql1[$uname.'7'] >= $t7 && $sql1[$uname.'8'] >= $t8 && $sql1[$uname.'9'] >= $t9 && $sql1[$uname1.'0'] >= $t10 && $sql1['hero'] >= $t11){
if($post['slot'.$sid] == 'on'){
$ckey = $generator->generateRandStr(6);
$time_now = time();
$id = $database->addA2b($ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4);
$data = $database->getA2b($ckey, $time_now);
$troopsTime = $this->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u');
$time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime);
$ctar1 = $ctar2 = 0;
$abdata = $database->getABTech($getFLData['wref']);
$reference = $database->addAttack(($getFLData['wref']), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8']);
$troops = [];
$amounts = [];
$modes = [];
for($u = 1; $u <= 10; $u++){
if($tribe == 1) $unitKey = $uname2 . $u;
else $unitKey = $uname2.($u < 10 ? $u : 0);
$troops[] = $unitKey;
$amounts[] = $data['u'.$u];
$modes[] = 0;
}
$troops[] = 'hero';
$amounts[] = $data['u11'];
$modes[] = 0;
$database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes);
$database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time()));
// prevent re-use of the same attack via re-POSTing the same data
$database->remA2b($id);
}
}
}
}
header("Location: build.php?id=39&t=99");
exit();
}
};
$units = new Units;
+258 -283
View File
@@ -1,364 +1,339 @@
<?php
include_once("GameEngine/Data/unitdata.php");
include_once ("GameEngine/Data/unitdata.php");
$units = $database->getMovement("34",$village->wid,1);
$units = $database->getMovement(34, $village->wid, 1);
$total_for = count($units);
$send = $database->getMovement("1",$village->wid,1);
$send = $database->getMovement(1, $village->wid, 1);
$total_for2 = count($send);
$artifactsSum = $database->getArtifactsSumByKind($session->uid, $village->wid, 3);
for($y=0;$y < $total_for;$y++){
for($i=0;$i < $total_for2;$i++){
if($units[$y]['ref'] == $send[$i]['ref2']){
$res1 = mysqli_query($database->dblink,"SELECT wood, clay, iron, crop FROM " . TB_PREFIX . "send where id = ".(int) $send[$i]['ref']."");
$res = mysqli_fetch_array($res1);
}
}
$session->timer++;
if ($units[$y]['sort_type']==3){
if ($units[$y]['attack_type']==3){
$actionType = ATTACK_ON;
} else if ($units[$y]['attack_type']==4){
$actionType = RAID_ON;
} else if ($units[$y]['attack_type']==2){
$actionType = REINFORCEMENTFOR;
for($y = 0; $y < $total_for; $y++){
for($i = 0; $i < $total_for2; $i++){
if($units[$y]['ref'] == $send[$i]['ref2']){
$res1 = mysqli_query($database->dblink, "SELECT wood, clay, iron, crop FROM ".TB_PREFIX."send where id = ".(int)$send[$i]['ref']."");
$res = mysqli_fetch_array($res1);
}
}
$reinfowner = $database->getVillageField($units[$y]['from'],"owner");
if($units[$y]['attack_type'] != 1){
if($units[$y]['from'] != 0){
if($units[$y]['t11'] > 0 && $reinfowner == $session->uid) {
$colspan = 11;
}else{
$colspan = 10;
}
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
<a href=\"karte.php?d=".$units[$y]['from']."&c=".$generator->getMapCheck($units[$y]['from'])."\">".$database->getVillageField($units[$y]['from'],"name")."</a></td>
$session->timer++;
if($units[$y]['sort_type'] == 3){
if($units[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR;
elseif($units[$y]['attack_type'] == 3) $actionType = ATTACK_ON;
elseif($units[$y]['attack_type'] == 4) $actionType = RAID_ON;
$reinfowner = $database->getVillageField($units[$y]['from'], "owner");
if($units[$y]['attack_type'] != 1){
if($units[$y]['from'] != 0){
if($units[$y]['t11'] > 0 && $reinfowner == $session->uid) $colspan = 11;
else $colspan = 10;
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
<a href=\"karte.php?d=".$units[$y]['from']."&c=".$generator->getMapCheck($units[$y]['from'])."\">".$database->getVillageField($units[$y]['from'], "name")."</a></td>
<td colspan=\"$colspan\">";
echo "<a href=\"karte.php?d=".$units[$y]['to']."&c=".$generator->getMapCheck($units[$y]['to'])."\">".$actionType." ".$database->getVillageField($units[$y]['to'],"name")."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $database->getUserField($database->getVillageField($units[$y]['from'],"owner"),"tribe",0);
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($units[$y]['t11'] != 0 && $reinfowner == $session->uid) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i=1;$i<=$colspan;$i++) {
$totalunits = $units[$y]['t1']+$units[$y]['t2']+$units[$y]['t3']+$units[$y]['t4']+$units[$y]['t5']+$units[$y]['t6']+$units[$y]['t7']+$units[$y]['t8']+$units[$y]['t9']+$units[$y]['t10']+$units[$y]['t11'];
if($units[$y]['attack_type'] == 2){
if($reinfowner != $session->uid){
echo "<td class=\"none\">?</td>";
}else{
if($units[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}
else {
echo "<td>";
echo $units[$y]['t'.$i]."</td>";
echo "<a href=\"karte.php?d=".$units[$y]['to']."&c=".$generator->getMapCheck($units[$y]['to'])."\">".$actionType." ".$database->getVillageField($units[$y]['to'], "name")."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $database->getUserField($database->getVillageField($units[$y]['from'], "owner"), "tribe", 0);
$start = ($tribe - 1) * 10 + 1;
$end = ($tribe * 10);
echo "<tr><th>&nbsp;</th>";
for($i = $start; $i <= ($end); $i++){
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
}}else{
if($artifactsSum['totals'] == 0){
echo "<td class=\"none\">?</td>";
}else{
if($units[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}else{
echo "<td>?</td>";
}
}
}
}
echo "</tr></tbody>";
echo '
if($units[$y]['t11'] != 0 && $reinfowner == $session->uid){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i = 1; $i <= $colspan; $i++){
$totalunits = $units[$y]['t1'] + $units[$y]['t2'] + $units[$y]['t3'] + $units[$y]['t4'] + $units[$y]['t5'] + $units[$y]['t6'] + $units[$y]['t7'] + $units[$y]['t8'] + $units[$y]['t9'] + $units[$y]['t10'] + $units[$y]['t11'];
if($units[$y]['attack_type'] == 2){
if($reinfowner != $session->uid) echo "<td class=\"none\">?</td>";
else
{
if($units[$y]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else
{
echo "<td>";
echo $units[$y]['t'.$i]."</td>";
}
}
}else{
if($artifactsSum['totals'] == 0) echo "<td class=\"none\">?</td>";
else
{
if($units[$y]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>?</td>";
}
}
}
echo "</tr></tbody>";
echo '
<tbody class="infos">
<tr>
<th>'.ARRIVAL.'</th>
<td colspan='.$colspan.'>
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($units[$y]['endtime']-time()).'</span> h</div>';
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">";
if($datetime[0] != "today") {
echo "".ON." ".$datetime[0]." ";
}
echo "".AT." ".$datetime[1]." ".HRS."</div>
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($units[$y]['endtime'] - time()).'</span> h</div>';
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">";
if($datetime[0] != "today") echo "".ON." ".$datetime[0]." ";
echo "".AT." ".$datetime[1]." ".HRS."</div>
</div>
</td>
</tr>
</tbody>";
echo "</table>";
}else{
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
echo "</table>";
}else{
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
<a>village of the elders</a></td>
<td colspan=\"10\">";
echo "<a>".VILLAGE_OF_THE_ELDERS_TROOPS."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = 4;
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i=1;$i<=10;$i++) {
echo "<td class=\"none\">?</td>";
}
echo "</tr></tbody>";
echo '
echo "<a>".VILLAGE_OF_THE_ELDERS_TROOPS."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = 4;
$start = ($tribe - 1) * 10 + 1;
$end = ($tribe * 10);
echo "<tr><th>&nbsp;</th>";
for($i = $start; $i <= ($end); $i++){
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i = 1; $i <= 10; $i++){
echo "<td class=\"none\">?</td>";
}
echo "</tr></tbody>";
echo '
<tbody class="infos">
<tr>
<th>'.ARRIVAL.'</th>
<td colspan="10">
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($units[$y]['endtime']-time()).'</span> h</div>';
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">";
if($datetime[0] != "today") {
echo "".ON." ".$datetime[0]." ";
}
echo "".AT." ".$datetime[1]."</div>
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($units[$y]['endtime'] - time()).'</span> h</div>';
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">";
if($datetime[0] != "today") echo "".ON." ".$datetime[0]." ";
echo "".AT." ".$datetime[1]."</div>
</div>
</td>
</tr>
</tbody>";
echo "</table>";
echo "</table>";
}
}
}
}else if ($units[$y]['sort_type']==4){
if ($units[$y]['attack_type']==1){
}else if($units[$y]['sort_type'] == 4){
$actionType = RETURNFROM;
} else if ($units[$y]['attack_type']==2){
$actionType = RETURNFROM;
} else if ($units[$y]['attack_type']==3){
$actionType = RETURNFROM;
} else if ($units[$y]['attack_type']==4){
$actionType = RETURNFROM;
}
$isoasis = $database->isVillageOases($units[$y]['from']);
if ($isoasis ==0){
$from = $database->getMInfo($units[$y]['from']);
} else {
$from = $database->getOMInfo($units[$y]['from']);}
$to = $database->getMInfo($units[$y]['vref']);
?>
<table class="troop_details" cellpadding="1" cellspacing="1">
$isoasis = $database->isVillageOases($units[$y]['from']);
if($isoasis == 0) $from = $database->getMInfo($units[$y]['from']);
else $from = $database->getOMInfo($units[$y]['from']);
$to = $database->getMInfo($units[$y]['vref']);
?>
<table class="troop_details" cellpadding="1" cellspacing="1">
<thead>
<tr>
<td class="role"><a href="karte.php?d=<?php echo $village->wid."&c=".$generator->getMapCheck($village->wid); ?>"><?php echo $village->vname; ?></a></td>
<td colspan="<?php echo $units[$y]['t11'] > 0 ? 11 : 10 ?>"><a href="karte.php?d=<?php echo $from['wref']."&c=".$generator->getMapCheck($from['wref']); ?>"><?php echo $actionType." ".$from['name']; ?></a></td>
<td class="role"><a
href="karte.php?d=<?php echo $village->wid."&c=".$generator->getMapCheck($village->wid); ?>"><?php echo $village->vname; ?></a></td>
<td colspan="<?php echo $units[$y]['t11'] > 0 ? 11 : 10 ?>"><a
href="karte.php?d=<?php echo $from['wref']."&c=".$generator->getMapCheck($from['wref']); ?>"><?php echo $actionType." ".$from['name']; ?></a></td>
</tr>
</thead>
<tbody class="units"><tr>
<tbody class="units">
<tr>
<?php
$tribe = $session->tribe;
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($units[$y]['t11'] != 0) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
?>
$tribe = $session->tribe;
$start = ($tribe - 1) * 10 + 1;
$end = ($tribe * 10);
echo "<th>&nbsp;</th>";
for($i = $start; $i <= ($end); $i++){
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($units[$y]['t11'] != 0){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
?>
</tr>
<tr><th><?php echo TROOPS;?></th>
<tr>
<th><?php echo TROOPS;?></th>
<?php
for($i=1;$i<($units[$y]['t11'] != 0?12:11);$i++) {
if($units[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}
else {
echo "<td>";
echo $units[$y]['t'.$i]."</td>";
}
for($i = 1; $i < ($units[$y]['t11'] != 0 ? 12 : 11); $i++){
if($units[$y]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else
{
echo "<td>";
echo $units[$y]['t'.$i]."</td>";
}
?>
</tr></tbody>
}
?>
</tr>
</tbody>
<?php
if (isset($res)) $totalres = $res['wood'] + $res['clay'] + $res['iron'] + $res['crop'];
else $totalres = 0;
if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && !empty($totalres)){?>
<tbody class="goods"><tr><th><?php echo BOUNTY;?></th>
if(isset($res)) $totalres = $res['wood'] + $res['clay'] + $res['iron'] + $res['crop'];
else $totalres = 0;
if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && !empty($totalres)){
?>
<tbody class="goods">
<tr>
<th><?php echo BOUNTY;?></th>
<td colspan="<?php echo $units[$y]['t11'] == 0 ? 10 : 11; ?>">
<?php
$totalcarry = $units[$y]['t1']*${'u'.$start.''}['cap']+$units[$y]['t2']*${'u'.($start+1).''}['cap']+$units[$y]['t3']*${'u'.($start+2).''}['cap']+$units[$y]['t4']*${'u'.($start+3).''}['cap']+$units[$y]['t5']*${'u'.($start+4).''}['cap']+$units[$y]['t6']*${'u'.($start+5).''}['cap']+$units[$y]['t7']*${'u'.($start+6).''}['cap']+$units[$y]['t8']*${'u'.($start+7).''}['cap']+$units[$y]['t9']*${'u'.($start+8).''}['cap']+$units[$y]['t10']*${'u'.($start+9).''}['cap'];
$totalcarry = 0;
for($i = 0; $i <= 9; $i++) $totalcarry += $units[$y]['t'.($i + 1)] * ${'u'.($start + $i)}['cap'];
echo "<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".$res['wood']." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".$res['clay']." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".$res['iron']." | <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".$res['crop']."</div>";
echo "<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\"/>".$totalres."/".$totalcarry."</div>";
?>
</tr></tbody>
</tr>
</tbody>
<?php } ?>
<tbody class="infos">
<tr>
<th><?php echo ARRIVAL;?></th>
<td colspan="<?php echo $units[$y]['t11'] == 0 ? 10 : 11 ?>">
<tr>
<th><?php echo ARRIVAL;?></th>
<td colspan="<?php echo $units[$y]['t11'] == 0 ? 10 : 11 ?>">
<?php
echo "<div class=\"in small\"><span id=timer".$session->timer.">".$generator->getTimeFormat($units[$y]['endtime']-time())."</span> h</div>";
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") {
echo "".ON." ".$datetime[0]." ";
}
echo "".AT." ".$datetime[1]."</div>";
?>
echo "<div class=\"in small\"><span id=timer".$session->timer.">".$generator->getTimeFormat($units[$y]['endtime'] - time())."</span> h</div>";
$datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") echo "".ON." ".$datetime[0]." ";
echo "".AT." ".$datetime[1]."</div>";
?>
</div>
</td>
</tr>
</tbody>
</td>
</tr>
</tbody>
</table>
<?php
}
}
unset($res, $res1);
}
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
$oasis = $database->getMovement("6",$conqured['wref'],0);
$total_for = count($oasis);
for($y=0;$y < $total_for;$y++){
$session->timer++;
$to = $database->getOMInfo($oasis[$y]['to']);
if ($oasis[$y]['attack_type']==2){
$actionType = REINFORCEMENTFOR;
} else if ($oasis[$y]['attack_type']==3){
$actionType = ATTACK_ON;
} else if ($oasis[$y]['attack_type']==4){
$actionType = RAID_ON;
}
$reinfowner = $database->getVillageField($oasis[$y]['from'],"owner");
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) {
$colspan = 11;
}else{
$colspan = 10;
}
$oasis = $database->getMovement("6", $conqured['wref'], 0);
$total_for = count($oasis);
for($y = 0; $y < $total_for; $y++){
$session->timer++;
$to = $database->getOMInfo($oasis[$y]['to']);
if($oasis[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR;
else if($oasis[$y]['attack_type'] == 3) $actionType = ATTACK_ON;
else if($oasis[$y]['attack_type'] == 4) $actionType = RAID_ON;
$reinfowner = $database->getVillageField($oasis[$y]['from'], "owner");
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) $colspan = 11;
else $colspan = 10;
echo "<table class=\"troop_details\" cellpadding=\"1\" cellspacing=\"1\"><thead><tr><td class=\"role\">
<a href=\"karte.php?d=".$oasis[$y]['from']."&c=".$generator->getMapCheck($oasis[$y]['from'])."\">".$database->getVillageField($oasis[$y]['from'],"name")."</a></td>
<a href=\"karte.php?d=".$oasis[$y]['from']."&c=".$generator->getMapCheck($oasis[$y]['from'])."\">".$database->getVillageField($oasis[$y]['from'], "name")."</a></td>
<td colspan=\"$colspan\">";
echo "<a href=\"karte.php?d=".$oasis[$y]['to']."&c=".$generator->getMapCheck($oasis[$y]['to'])."\">".$actionType." ".$to['name']."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $database->getUserField($reinfowner,"tribe",0);
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid) {
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i=1;$i<=$colspan;$i++) {
$totalunits = $oasis[$y]['t1']+$oasis[$y]['t2']+$oasis[$y]['t3']+$oasis[$y]['t4']+$oasis[$y]['t5']+$oasis[$y]['t6']+$oasis[$y]['t7']+$oasis[$y]['t8']+$oasis[$y]['t9']+$oasis[$y]['t10']+$oasis[$y]['t11'];
if($oasis[$y]['attack_type'] == 2){
if($reinfowner != $session->uid){
echo "<td class=\"none\">?</td>";
}else{
if($oasis[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}
else {
echo "<td>";
echo $oasis[$y]['t'.$i]."</td>";
echo "<a href=\"karte.php?d=".$oasis[$y]['to']."&c=".$generator->getMapCheck($oasis[$y]['to'])."\">".$actionType." ".$to['name']."</a>";
echo "</td></tr></thead><tbody class=\"units\">";
$tribe = $database->getUserField($reinfowner, "tribe", 0);
$start = ($tribe - 1) * 10 + 1;
$end = ($tribe * 10);
echo "<tr><th>&nbsp;</th>";
for($i = $start; $i <= ($end); $i++){
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
if($oasis[$y]['t11'] != 0 && $reinfowner == $session->uid){
echo "<td><img src=\"img/x.gif\" class=\"unit uhero\" title=\"Hero\" alt=\"Hero\" /></td>";
}
echo "</tr><tr><th>".TROOPS."</th>";
for($i = 1; $i <= $colspan; $i++){
$totalunits = $oasis[$y]['t1'] + $oasis[$y]['t2'] + $oasis[$y]['t3'] + $oasis[$y]['t4'] + $oasis[$y]['t5'] + $oasis[$y]['t6'] + $oasis[$y]['t7'] + $oasis[$y]['t8'] + $oasis[$y]['t9'] + $oasis[$y]['t10'] + $oasis[$y]['t11'];
if($oasis[$y]['attack_type'] == 2){
if($reinfowner != $session->uid) echo "<td class=\"none\">?</td>";
else
{
if($oasis[$y]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else
{
echo "<td>";
echo $oasis[$y]['t'.$i]."</td>";
}
}
}}else{
if($artifactsSum['totals'] == 0){
echo "<td class=\"none\">?</td>";
}else{
if($oasis[$y]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}else{
echo "<td>?</td>";
}
}
}
}
echo "</tr></tbody>";
echo '
}else{
if($artifactsSum['totals'] == 0) echo "<td class=\"none\">?</td>";
else
{
if($oasis[$y]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else echo "<td>?</td>";
}
}
}
echo "</tr></tbody>";
echo '
<tbody class="infos">
<tr>
<th>'.ARRIVAL.'</th>
<td colspan="'.$colspan.'">
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($oasis[$y]['endtime']-time()).'</span> h</div>';
$datetime = $generator->procMtime($oasis[$y]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") {
echo "".ON." ".$datetime[0]." ";
}
echo "".AT." ".$datetime[1]." ".HRS."</div>
<div class="in small"><span id=timer'.$session->timer.'>'.$generator->getTimeFormat($oasis[$y]['endtime'] - time()).'</span> h</div>';
$datetime = $generator->procMtime($oasis[$y]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") echo "".ON." ".$datetime[0]." ";
echo "".AT." ".$datetime[1]." ".HRS."</div>
</div>
</td>
</tr>
</tbody>";
echo "</table>";
}
}
}
$settlers = $database->getMovement("7",$village->wid,1);
$settlers = $database->getMovement(7, $village->wid, 1);
$total_for3 = count($settlers);
for($x=0;$x < $total_for3;$x++){
$session->timer++;
$to = $database->getMInfo($settlers[$x]['to']);
?>
<table class="troop_details" cellpadding="1" cellspacing="1">
for($x = 0; $x < $total_for3; $x++){
$session->timer++;
$to = $database->getMInfo($settlers[$x]['to']);
?>
<table class="troop_details" cellpadding="1" cellspacing="1">
<thead>
<tr>
<td class="role"><a href="karte.php?d=<?php echo $village->wid."&c=".$generator->getMapCheck($village->wid); ?>"><?php echo $village->vname; ?></a></td>
<td colspan="10"><a href="karte.php?d=<?php echo $from['wref']."&c=".$generator->getMapCheck($from['wref']); ?>"><?php echo $actionType." ".$from['name']; ?></a></td>
<td class="role"><a
href="karte.php?d=<?php echo $village->wid."&c=".$generator->getMapCheck($village->wid); ?>"><?php echo $village->vname; ?></a></td>
<td colspan="10"><a
href="karte.php?d=<?php echo $from['wref']."&c=".$generator->getMapCheck($from['wref']); ?>"><?php echo $actionType." ".$from['name']; ?></a></td>
</tr>
</thead>
<tbody class="units">
<?php
$tribe = $session->tribe;
$start = ($tribe-1)*10+1;
$end = ($tribe*10);
echo "<tr><th>&nbsp;</th>";
for($i=$start;$i<=($end);$i++) {
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
?>
$tribe = $session->tribe;
$start = ($tribe - 1) * 10 + 1;
$end = ($tribe * 10);
echo "<tr><th>&nbsp;</th>";
for($i = $start; $i <= ($end); $i++){
echo "<td><img src=\"img/x.gif\" class=\"unit u$i\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
}
?>
</tr>
<tr><th><?php echo TROOPS;?></th>
<tr>
<th><?php echo TROOPS;?></th>
<?php
for($z=1;$z<=9;$z++) {
$settlers[$x]['t'.$z]=0;
}
$settlers[$x]['t10']=3;
for($i=1;$i<11;$i++) {
if($settlers[$x]['t'.$i] == 0) {
echo "<td class=\"none\">0</td>";
}
else {
echo "<td>";
echo $settlers[$x]['t'.$i]."</td>";
}
}
?>
for($z = 1; $z <= 9; $z++) $settlers[$x]['t'.$z] = 0;
$settlers[$x]['t10'] = 3;
for($i = 1; $i < 11; $i++){
if($settlers[$x]['t'.$i] == 0) echo "<td class=\"none\">0</td>";
else
{
echo "<td>";
echo $settlers[$x]['t'.$i]."</td>";
}
}
?>
</tr>
<tbody class="infos">
<tr>
<th><?php echo ARRIVAL;?></th>
<td colspan="10">
<tbody class="infos">
<tr>
<th><?php echo ARRIVAL;?></th>
<td colspan="10">
<?php
echo "<div class=\"in small\"><span id=timer".$session->timer.">".$generator->getTimeFormat($settlers[$x]['endtime']-time())."</span> h</div>";
$datetime = $generator->procMtime($settlers[$x]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") {
echo "".ON." ".$datetime[0]." ";
}
echo "".AT." ".$datetime[1]."</div>";
?>
echo "<div class=\"in small\"><span id=timer".$session->timer.">".$generator->getTimeFormat($settlers[$x]['endtime'] - time())."</span> h</div>";
$datetime = $generator->procMtime($settlers[$x]['endtime']);
echo "<div class=\"at\">";
if($datetime[0] != "today") echo "".ON." ".$datetime[0]." ";
echo "".AT." ".$datetime[1]."</div>";
?>
</div>
</td>
</tr>
</tbody>
</td>
</tr>
</tbody>
</table>
<?php } ?>
+1 -1
View File
@@ -89,7 +89,7 @@ if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $villa
echo "<span class=\"none\">".UPGRADE_GRANARY.".</span>";
}
else if($bindicate == 7) {
if($village->allcrop - $village->pop - $automation->getUpkeep($village->unitall, 0) > 0){
if($village->allcrop - $village->pop - $technology->getUpkeep($village->unitall, 0) > 0){
$neededtime = $building->calculateAvaliable($id,$village->resarray['f'.$id.'t'],1+$loopsame+$doublebuild+$master);
echo "<span class=\"none\">".ENOUGH_RESOURCES." ".$neededtime[0]." at ".$neededtime[1]."</span>";
}else{
-102
View File
@@ -1,102 +0,0 @@
<?php
$slots = $_POST['slot'];
$lid = $_POST['lid'];
$tribe = $_POST['tribe'];
$getFLData = $database->getFLData($lid);
$sql = "SELECT id, towref, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 FROM ".TB_PREFIX."raidlist WHERE lid = ".$database->escape((int) $lid)." order by id asc";
$array = $database->query_return($sql);
foreach($array as $row){
$sql1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE vref = ".(int) $getFLData['wref']));
$sid = $row['id'];
$wref = $row['towref'];
for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i];
$t11 = 0;
$villageOwner = $database->getVillageField($wref,'owner');
$userAccess = $database->getUserField($villageOwner,'access',0);
$userID = $database->getUserField($villageOwner,'id',0);
if ( $userAccess != '0' && !($userAccess == MULTIHUNTER && $userID == 5) && ( $userAccess != ADMIN || ( ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN ) ) ) {
if ( $tribe == 1 ) {
$uname = "u";
$uname1 = "u1";
$uname2 = "";
} elseif ( $tribe == 2 ) {
$uname = "u1";
$uname1 = "u2";
$uname2 = "1";
} elseif ( $tribe == 3 ) {
$uname = "u2";
$uname1 = "u3";
$uname2 = "2";
} elseif ( $tribe == 4 ) {
$uname = "u3";
$uname1 = "u4";
$uname2 = "3";
} else {
$uname = "u4";
$uname1 = "u5";
$uname2 = "4";
}
if (
$sql1[ $uname . '1' ] >= $t1 &&
$sql1[ $uname . '2' ] >= $t2 &&
$sql1[ $uname . '3' ] >= $t3 &&
$sql1[ $uname . '4' ] >= $t4 &&
$sql1[ $uname . '5' ] >= $t5 &&
$sql1[ $uname . '6' ] >= $t6 &&
$sql1[ $uname . '7' ] >= $t7 &&
$sql1[ $uname . '8' ] >= $t8 &&
$sql1[ $uname . '9' ] >= $t9 &&
$sql1[ $uname1 . '0' ] >= $t10 &&
$sql1['hero'] >= $t11
) {
if ( $_POST[ 'slot' . $sid ] == 'on' ) {
$ckey = $generator->generateRandStr( 6 );
$time_now = time();
$id = $database->addA2b( $ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4 );
$data = $database->getA2b( $ckey, $time_now );
$troopsTime = $units->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u');
$time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime);
$ctar1 = $ctar2 = 0;
$abdata = $database->getABTech( $getFLData['wref'] );
$reference = $database->addAttack( ( $getFLData['wref'] ), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8'] );
$totalunits = $data['u1'] + $data['u2'] + $data['u3'] + $data['u4'] + $data['u5'] + $data['u6'] + $data['u7'] + $data['u8'] + $data['u9'] + $data['u10'] + $data['u11'];
$troops = [];
$amounts = [];
$modes = [];
for ( $u = 1; $u <= 10; $u ++ ) {
if ($tribe == 1) {
$unitKey = $uname2 . $u;
} else {
$unitKey = $uname2 . ($u < 10 ? $u : 0);
}
$troops[] = $unitKey;
$amounts[] = $data[ 'u' . $u];
$modes[] = 0;
}
$troops[] = 'hero';
$amounts[] = $data['u11'];
$modes[] = 0;
$database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes);
$database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time()));
// prevent re-use of the same attack via re-POSTing the same data
$database->remA2b( $id );
}
}
}
}
header("Location: build.php?id=39&t=99");
exit;
?>
+40 -110
View File
@@ -2,7 +2,7 @@
if(isset($_GET['t']) == 99 && isset($_GET['action']) == 0) {
if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList' && !empty($_POST['did']) && !empty($_POST['name'])){
if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList' && !empty($_POST['did']) && !empty($_POST['name']) && $database->getVillageField($_POST['did'], 'owner') == $session->uid){
$database->createFarmList($_POST['did'], $session->uid, $_POST['name']);
}else if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList'){
header("Location: build.php?gid=16&t=99&action=addList");
@@ -23,7 +23,6 @@ while($row = mysqli_fetch_array($sql)){
<input type="hidden" name="action" value="startRaid">
<input type="hidden" name="a" value="c35">
<input type="hidden" name="sort" value="distance">
<input type="hidden" name="tribe" value="<?php echo $session->tribe; ?>">
<input type="hidden" name="direction" value="asc">
<input type="hidden" name="lid" value="<?php echo $lid; ?>">
<div class="listTitleText">
@@ -53,19 +52,21 @@ while($row = mysqli_fetch_array($sql)){
<?php
$sql2 = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid." ORDER BY distance ASC");
$query2 = mysqli_num_rows($sql2);
if($query2 == 0) {
if(!$query2) {
echo '<td class="noData" colspan="7">There are no village.</td>';
}else{
while($row = mysqli_fetch_array($sql2)){
$id= $row['id'];$lid = $row['lid'];$towref = $row['towref'];$x = $row['x'];$y = $row['y'];
if($village->wid == $towref){
$distance = '0';
}else{
$distance = $row['distance'];
}
$id = $row['id'];
$lid = $row['lid'];
$towref = $row['towref'];
$x = $row['x'];
$y = $row['y'];
if($village->wid == $towref) $distance = '0';
else $distance = $row['distance'];
for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i];
$t1 = $row['t1'];$t2 = $row['t2'];$t3 = $row['t3'];$t4 = $row['t4'];$t5 = $row['t5'];$t6 = $row['t6'];$t7 = $row['t7'];
$t8 = $row['t8'];$t9 = $row['t9'];$t10 = $row['t10'];
$vdata = $database->getVillage($towref);
?>
@@ -80,29 +81,21 @@ $vdata = $database->getVillage($towref);
<td class="village">
<?php
$incoming_attacks = $database->getMovement(3,$towref,1);
$att = '';
if (count($incoming_attacks) > 0) {
$inc_atts = count($incoming_attacks);
if($incoming_attacks[$i]['attack_type'] == 2) {
$inc_atts -= 1;
}
if($inc_atts > 0) {
echo '<img class="att2" src="img/x.gif" title="Incoming Attacker" />';
$incoming_attacks = $database->getMovement(3, $towref, 1);
if (($inc_atts = count($incoming_attacks)) > 0) {
foreach($incoming_attacks as $attack){
if($attack['attack_type'] != 4) $inc_atts -= 1;
}
if($inc_atts > 0) echo '<img class="att2" src="img/x.gif" title="'.OWN_ATTACKING_TROOPS.'" />';
}
}
?>
<label for="slot<?php echo $id; ?>">
<?php
$oasistype = $database->getVillageType2($towref);
if($oasistype != 0){
$thisVillageName = 'Oasis';
}
else
{
$thisVillageName = $vdata["name"];
$thisVillageName = $database->getOasisField($towref, 'conqured') ? OCCUOASIS : UNOCCUOASIS;
}
else $thisVillageName = $vdata["name"];
?>
<span class="coordinates coordinatesWithText">
<span class="coordText"><?php echo $thisVillageName; ?></span>
@@ -119,70 +112,13 @@ $vdata = $database->getVillage($towref);
<td class="troops">
<?php
if($session->tribe == 1){
if($t1 != 0){
echo '<div class="troopIcon"><img class="unit u1" title="'.U1.'" src="img/x.gif"><span class="troopIconAmount">'.$t1.'</span></div>'; }
if($t2 != 0){
echo '<div class="troopIcon"><img class="unit u2" title="'.U2.'" src="img/x.gif"><span class="troopIconAmount">'.$t2.'</span></div>'; }
if($t3 != 0){
echo '<div class="troopIcon"><img class="unit u3" title="'.U3.'" src="img/x.gif"><span class="troopIconAmount">'.$t3.'</span></div>'; }
if($t4 != 0){
echo '<div class="troopIcon"><img class="unit u4" title="'.U4.'" src="img/x.gif"><span class="troopIconAmount">'.$t4.'</span></div>'; }
if($t5 != 0){
echo '<div class="troopIcon"><img class="unit u5" title="'.U5.'" src="img/x.gif"><span class="troopIconAmount">'.$t5.'</span></div>'; }
if($t6 != 0){
echo '<div class="troopIcon"><img class="unit u6" title="'.U6.'" src="img/x.gif"><span class="troopIconAmount">'.$t6.'</span></div>'; }
if($t7 != 0){
echo '<div class="troopIcon"><img class="unit u7" title="'.U7.'" src="img/x.gif"><span class="troopIconAmount">'.$t7.'</span></div>'; }
if($t8 != 0){
echo '<div class="troopIcon"><img class="unit u8" title="'.U8.'" src="img/x.gif"><span class="troopIconAmount">'.$t8.'</span></div>'; }
if($t9 != 0){
echo '<div class="troopIcon"><img class="unit u9" title="'.U9.'" src="img/x.gif"><span class="troopIconAmount">'.$t9.'</span></div>'; }
if($t10 != 0){
echo '<div class="troopIcon"><img class="unit u10" title="'.U10.'" src="img/x.gif"><span class="troopIconAmount">'.$t10.'</span></div>'; }
}elseif($session->tribe == 2){
if($t1 != 0){
echo '<div class="troopIcon"><img class="unit u11" title="'.U11.'" src="img/x.gif"><span class="troopIconAmount">'.$t1.'</span></div>'; }
if($t2 != 0){
echo '<div class="troopIcon"><img class="unit u12" title="'.U12.'" src="img/x.gif"><span class="troopIconAmount">'.$t2.'</span></div>'; }
if($t3 != 0){
echo '<div class="troopIcon"><img class="unit u13" title="'.U13.'" src="img/x.gif"><span class="troopIconAmount">'.$t3.'</span></div>'; }
if($t4 != 0){
echo '<div class="troopIcon"><img class="unit u14" title="'.U14.'" src="img/x.gif"><span class="troopIconAmount">'.$t4.'</span></div>'; }
if($t5 != 0){
echo '<div class="troopIcon"><img class="unit u15" title="'.U15.'" src="img/x.gif"><span class="troopIconAmount">'.$t5.'</span></div>'; }
if($t6 != 0){
echo '<div class="troopIcon"><img class="unit u16" title="'.U16.'" src="img/x.gif"><span class="troopIconAmount">'.$t6.'</span></div>'; }
if($t7 != 0){
echo '<div class="troopIcon"><img class="unit u17" title="'.U17.'" src="img/x.gif"><span class="troopIconAmount">'.$t7.'</span></div>'; }
if($t8 != 0){
echo '<div class="troopIcon"><img class="unit u18" title="'.U18.'" src="img/x.gif"><span class="troopIconAmount">'.$t8.'</span></div>'; }
if($t9 != 0){
echo '<div class="troopIcon"><img class="unit u19" title="'.U19.'" src="img/x.gif"><span class="troopIconAmount">'.$t9.'</span></div>'; }
if($t10 != 0){
echo '<div class="troopIcon"><img class="unit u20" title="'.U20.'" src="img/x.gif"><span class="troopIconAmount">'.$t10.'</span></div>'; }
}elseif($session->tribe == 3){
if($t1 != 0){
echo '<div class="troopIcon"><img class="unit u21" title="'.U21.'" src="img/x.gif"><span class="troopIconAmount">'.$t1.'</span></div>'; }
if($t2 != 0){
echo '<div class="troopIcon"><img class="unit u22" title="'.U22.'" src="img/x.gif"><span class="troopIconAmount">'.$t2.'</span></div>'; }
if($t3 != 0){
echo '<div class="troopIcon"><img class="unit u23" title="'.U23.'" src="img/x.gif"><span class="troopIconAmount">'.$t3.'</span></div>'; }
if($t4 != 0){
echo '<div class="troopIcon"><img class="unit u24" title="'.U24.'" src="img/x.gif"><span class="troopIconAmount">'.$t4.'</span></div>'; }
if($t5 != 0){
echo '<div class="troopIcon"><img class="unit u25" title="'.U25.'" src="img/x.gif"><span class="troopIconAmount">'.$t5.'</span></div>'; }
if($t6 != 0){
echo '<div class="troopIcon"><img class="unit u26" title="'.U26.'" src="img/x.gif"><span class="troopIconAmount">'.$t6.'</span></div>'; }
if($t7 != 0){
echo '<div class="troopIcon"><img class="unit u27" title="'.U27.'" src="img/x.gif"><span class="troopIconAmount">'.$t7.'</span></div>'; }
if($t8 != 0){
echo '<div class="troopIcon"><img class="unit u28" title="'.U28.'" src="img/x.gif"><span class="troopIconAmount">'.$t8.'</span></div>'; }
if($t9 != 0){
echo '<div class="troopIcon"><img class="unit u29" title="'.U29.'" src="img/x.gif"><span class="troopIconAmount">'.$t9.'</span></div>'; }
if($t10 != 0){
echo '<div class="troopIcon"><img class="unit u30" title="'.U30.'" src="img/x.gif"><span class="troopIconAmount">'.$t10.'</span></div>'; }
$start = ($session->tribe - 1) * 10 + 1;
$end = $session->tribe * 10;
for($i = $start; $i <= $end; $i++){
if(${'t'.($i - $start + 1)} > 0){
echo '<div class="troopIcon"><img class="unit u'.$i.'" title="'.$technology->getUnitName($i).'" src="img/x.gif"><span class="troopIconAmount">'.${'t'.($i - $start + 1)}.'</span></div>';
}
}
?>
@@ -200,18 +136,10 @@ while($row2 = mysqli_fetch_array($getnotice)){
$type2 = $row2['ntype'];
echo "<img src=\"img/x.gif\" class=\"iReport iReport".$row2['ntype']."\" title=\"".$noticeClass[$type2]."\"> ";
$allres = ($dataarray[25]+$dataarray[26]+$dataarray[27]+$dataarray[28]);
$allres = $dataarray[25] + $dataarray[26] + $dataarray[27] + $dataarray[28];
$carry = $dataarray[29];
if ($dataarray[25]+$dataarray[26]+$dataarray[27]+$dataarray[28] == 0) {
echo "<img title=\"bounty: ".$allres." resouces max carry: ".$carry." resouces.\" src=\"img/x.gif\" class=\"carry empty\">";
} elseif ($dataarray[25]+$dataarray[26]+$dataarray[27]+$dataarray[28] != $dataarray[29]) {
echo "<img title=\"bounty: ".$allres." resouces. max carry: ".$carry." resouces.\" src=\"img/x.gif\" class=\"carry half\">";
} else {
echo "<img title=\"bounty: ".$allres." resouces. max carry: ".$carry." resouces.\" src=\"img/x.gif\" class=\"carry full\">";
}
echo "<img title=\"$allres/$carry\" src=\"img/x.gif\" class=\"carry\"/>";
$date = $generator->procMtime($row2['time']);
echo "<a href=\"berichte.php?id=".$row2['id']."\">".$date[0]." ".date('H:i',$row2['time'])."</a> ";
@@ -361,13 +289,15 @@ $NUM1++;
</script>
<?php } ?>
<?php if($create == 1){
$hideevasion = 1;
include("Templates/goldClub/farmlist_add.tpl");
<?php
if($create == 1){
$hideevasion = 1;
include("Templates/goldClub/farmlist_add.tpl");
}else if($create == 2){
$hideevasion = 1;
include("Templates/goldClub/farmlist_addraid.tpl");
$hideevasion = 1;
include("Templates/goldClub/farmlist_addraid.tpl");
}else if($create == 3){
$hideevasion = 1;
include("Templates/goldClub/farmlist_editraid.tpl");
}
$hideevasion = 1;
include("Templates/goldClub/farmlist_editraid.tpl");
}
?>
+5 -8
View File
@@ -3,7 +3,7 @@
<form action="build.php?gid=16&t=99" method="post">
<div class="boxes boxesColor gray"><div class="boxes-tl"></div><div class="boxes-tr"></div><div class="boxes-tc"></div><div class="boxes-ml"></div><div class="boxes-mr"></div><div class="boxes-mc"></div><div class="boxes-bl"></div><div class="boxes-br"></div><div class="boxes-bc"></div><div class="boxes-contents cf">
<input type="hidden" name="action" value="addList">
<table cellpadding="1" cellspacing="1" class="transparent">
<table cellpadding="1" cellspacing="1" class="transparent" id="raidList">
<tbody><tr>
<th>
Name: </th>
@@ -18,12 +18,9 @@
<select id="did" name="did">
<?php
for($i=1;$i<=count($session->villages);$i++) {
if($session->villages[$i-1] == $village->wid){
$select = 'selected="selected"';
}else{
$select = '';
}
for($i = 1; $i <= count($session->villages); $i++){
if($session->villages[$i-1] == $village->wid) $select = 'selected="selected"';
else $select = '';
echo "<option value=\"".$session->villages[$i-1]."\" ".$select.">".$database->getVillageField($session->villages[$i-1],'name')."</option>";
}
@@ -35,6 +32,6 @@
</div>
</div>
<button type="submit" value="create"><div class="button-container"><div class="button-position"><div class="btl"><div class="btr"><div class="btc"></div></div></div><div class="bml"><div class="bmr"><div class="bmc"></div></div></div><div class="bbl"><div class="bbr"><div class="bbc"></div></div></div></div><div class="button-contents">Create</div></div></button>
<button class="trav_buttons" type="submit" value="create">Create</button>
</form>
</div>
+3 -7
View File
@@ -30,8 +30,7 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
elseif($database->hasBeginnerProtection($Wref) == 1) $errormsg = "Player under protection.";
elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from.";
else
{
{
if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref);
@@ -58,7 +57,7 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
}
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$database->addSlotFarm($_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
$database->addSlotFarm($_POST['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
header("Location: build.php?id=39&t=99");
exit;
@@ -73,11 +72,8 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) {
</b></font>
<form action="build.php?id=39&t=99&action=addraid&lid=<?php echo $_GET['lid']; ?>" method="post">
<div class="boxes boxesColor gray"><div class="boxes-tl"></div><div class="boxes-tr"></div><div class="boxes-tc"></div><div class="boxes-ml"></div><div class="boxes-mr"></div><div class="boxes-mc"></div><div class="boxes-bl"></div><div class="boxes-br"></div><div class="boxes-bc"></div><div class="boxes-contents cf">
<div class="boxes boxesColor gray"><div class="boxes-tl"></div><div class="boxes-tr"></div><div class="boxes-tc"></div><div class="boxes-ml"></div><div class="boxes-mr"></div><div class="boxes-mc"></div><div class="boxes-bl"></div><div class="boxes-br"></div><div class="boxes-bc"></div><div class="boxes-contents cf">
<input type="hidden" name="action" value="addSlot">
<table cellpadding="1" cellspacing="1" class="transparent" id="raidList">
<tbody><tr>
<th>List name:</th>
+26 -30
View File
@@ -7,7 +7,7 @@ if(isset($_GET['action']) == 'editSlot' && $_GET['eid']) {
$FLData = $database->getFLData($eiddata['lid']);
}
if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) {
if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET['eid']) && isset($_POST['lid']) && !empty($_POST['lid'])) {
if(!empty($_POST['target_id'])){
$Wref = $_POST['target_id'];
$WrefCoor = $database->getCoor($Wref);
@@ -61,9 +61,8 @@ if(isset($_POST['action']) == 'editSlot' && $_POST['eid']) {
return round($dist, 1);
}
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$database->editSlotFarm($_GET['eid'], $_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
$distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY);
$database->editSlotFarm($_GET['eid'], $_POST['lid'], $database->getRaidList($_GET['eid'])['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']);
header("Location: build.php?id=39&t=99");
exit;
@@ -73,7 +72,7 @@ if($FLData['owner'] == $session->uid){
?>
<div id="raidListSlot">
<h4>Add Slot</h4>
<h4>Edit Slot</h4>
<font color="#FF0000"><b>
<?php echo $errormsg; ?>
</b></font>
@@ -85,13 +84,10 @@ if($FLData['owner'] == $session->uid){
$getlid = $database->getRaidList($database->escape($_GET["eid"]));
$lid2 = $getlid['lid'];
?>
<input type="hidden" name="action" value="editSlot">
<input type="hidden" name="eid" value="<?php echo $_GET['eid']; ?>">
<input type="hidden" name="lid" value="<?php echo $lid2; ?>">
<input type="hidden" name="action" value="editSlot">
<table cellpadding="1" cellspacing="1" class="transparent" id="raidList">
<tbody><tr>
<th>Farm Name:</th><?php echo $_GET["lid"]; ?>
<th>List name:</th><?php echo $_GET["lid"]; ?>
<td>
<select onchange="getTargetsByLid();" id="lid" name="lid">
<?php
@@ -103,7 +99,8 @@ $lowner = $row["owner"];
$lwref = $row["wref"];
$lvname = $database->getVillageField($row["wref"], 'name');
if($lid==$lid2){ $selected = 'selected=""'; }else{ $selected = ''; }
if($lid == $lid2) $selected = 'selected=""';
else $selected = '';
echo '<option value="'.$lid.'" '.$selected.'>'.$lvname.' - '.$lname.'</option>';
}
?>
@@ -111,7 +108,7 @@ $lvname = $database->getVillageField($row["wref"], 'name');
</td>
</tr>
<tr>
<th>Select target:</th>
<th>Target village:</th>
<td class="target">
<div class="coordinatesInput">
@@ -133,24 +130,23 @@ $lvname = $database->getVillageField($row["wref"], 'name');
$getwref = "SELECT id, towref FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid2;
$arraywref = $database->query_return($getwref);
echo '<option value="">Select village</option>';
if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
foreach($arraywref as $row){
$towref = $row["towref"];
$tocoor = $database->getCoor($towref);
$totype = $database->getVillageType2($towref);
$tooasistype = $type['oasistype'];
if($tooasistype == 0){
$tovname = $database->getVillageField($towref, 'name');
}else{
$tovname = $database->getOasisField($towref, 'name');
}
if($row["id"] == $_GET['eid']){ $selected = 'selected=""'; }else{ $selected = ''; }
if($vill[$towref] == 0){
echo '<option value="'.$towref.'" '.$selected.'>'.$tovname.'('.$tocoor['x'].'|'.$tocoor['y'].')</option>';
}
$vill[$towref] = 1;
}
}
if(mysqli_num_rows(mysqli_query($database->dblink, $getwref)) != 0){
foreach($arraywref as $row){
$towref = $row["towref"];
$tocoor = $database->getCoor($towref);
$totype = $database->getVillageType2($towref);
$tooasistype = $type['oasistype'];
if($tooasistype == 0) $tovname = $database->getVillageField($towref, 'name');
else $tovname = $database->getOasisField($towref, 'name');
if($row["id"] == $_GET['eid']) $selected = 'selected=""';
else $selected = '';
if($vill[$towref] == 0){
echo '<option value="' . $towref . '" ' . $selected . '>' . $tovname . '(' . $tocoor['x'] . '|' . $tocoor['y'] . ')</option>';
}
$vill[$towref] = 1;
}
}
?>
</select>
</div>
+1 -1
View File
@@ -98,7 +98,7 @@ div.c1 {text-align: center}
</div>
</div>
<div id="side_info">
<br /><br /><br /><br /><div id="side_info">
<?php
include("Templates/multivillage.tpl");
include("Templates/quest.tpl");
+2 -2
View File
@@ -212,8 +212,8 @@ if ($session->goldclub == 1) {
exit;
}
if(isset($_POST['action'] ) && $_POST['action'] == 'startRaid') {
if($session->access != BANNED) include("Templates/a2b/startRaid.tpl");
if(isset($_POST['action']) && $_POST['action'] == 'startRaid') {
if($session->access != BANNED) $units->startRaidList($_POST);
else
{
header( "Location: banned.php");
@@ -6862,6 +6862,11 @@ div#map div#map_content div span.m6 {
div#map div#map_content div span.m9 {
background-image: url("../../img/m/mret.gif");
}
img.carry {
background: url("../../img/a/car.gif") no-repeat scroll 0 0 transparent;
height: 12px;
width: 18px;
}
img.iReport {
background-image: url("../../img/a/report_icons.gif");
height: 17px;
+1 -1
View File
@@ -1,5 +1,5 @@
- shouldn't we create accounts from middle towards corners, not middle-corners-everywhere?
- change "incoming attacker" title of the raid list icon when actually attacking a farm (it should be "Own attacking troops")
+ change "incoming attacker" title of the raid list icon when actually attacking a farm (it should be "Own attacking troops")
- change "select all" button to actually select all checkboxes via JS, not via page reload
- make sure that when auto-removing inactive players, anyone who have units going there + anyone with them in their raid lists etc. gets notified and sorted out
- display "send troops" link for own villages, so we don't have to enter coordinates or search by name (which can search good name but wrong owner!)