Fixed some bugs

+Returning troops time will now flow correctly in the rally point
+Resources won't be set to 0 anymore if overflow (this could have
happened in high speed servers)
+Fixed a distorted view of the right part  of the page, while reading a
mass message
This commit is contained in:
iopietro
2018-05-03 14:35:19 +02:00
parent 554a8a8d7f
commit e751a0c01f
6 changed files with 212 additions and 261 deletions
+66 -94
View File
@@ -2280,9 +2280,8 @@ class Automation {
//no units can stay in the village itself //no units can stay in the village itself
$units2reset = []; $units2reset = [];
for ($u = 1; $u <= 50; $u++) { for ($u = 1; $u <= 50; $u++) $units2reset[] = 'u'.$u.' = 0';
$units2reset[] = 'u'.$u.' = 0';
}
$units2reset[] = 'u99 = 0'; $units2reset[] = 'u99 = 0';
$units2reset[] = 'u99o = 0'; $units2reset[] = 'u99o = 0';
$units2reset[] = 'hero = 0'; $units2reset[] = 'hero = 0';
@@ -2298,10 +2297,9 @@ class Automation {
$pop2 = $poparray[1]['Total']; $pop2 = $poparray[1]['Total'];
if($pop1 > $pop2){ if($pop1 > $pop2){
$buildlevel = $database->getResourceLevel($data['to']); $buildlevel = $database->getResourceLevel($data['to']);
for ($i = 1; $i <= 39; $i++){
for ($i=1; $i<=39; $i++){
if($buildlevel['f'.$i]!=0){ if($buildlevel['f'.$i]!=0){
if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){ if($buildlevel['f'.$i."t"] != 35 && $buildlevel['f'.$i."t"] != 36 && $buildlevel['f'.$i."t"] != 41){
$leveldown = $buildlevel['f'.$i]-1; $leveldown = $buildlevel['f'.$i]-1;
$newLevels_fieldNames[] = "f".$i; $newLevels_fieldNames[] = "f".$i;
$newLevels_fieldValues[] = $leveldown; $newLevels_fieldValues[] = $leveldown;
@@ -2321,8 +2319,8 @@ class Automation {
} }
} }
if ($buildlevel['f99']!=0) { if ($buildlevel['f99'] != 0) {
$leveldown = $buildlevel['f99']-1; $leveldown = $buildlevel['f99'] - 1;
$newLevels_fieldNames[] = "f99"; $newLevels_fieldNames[] = "f99";
$newLevels_fieldValues[] = $leveldown; $newLevels_fieldValues[] = $leveldown;
} }
@@ -2381,12 +2379,12 @@ class Automation {
$info_chief = "".$chief_pic.",Could not reduce cultural points during raid"; $info_chief = "".$chief_pic.",Could not reduce cultural points during raid";
} }
if(($data['t11'] - $dead11 - $traped11)> 0){ //hero if(($data['t11'] - $dead11 - $traped11) > 0){ //hero
if ($heroxp == 0) { if ($heroxp == 0) {
$xp=""; $xp = "";
$info_hero = $hero_pic.",Your hero had nothing to kill therefore gains no XP at all."; $info_hero = $hero_pic.",Your hero had nothing to kill therefore gains no XP at all.";
} else { } else {
$xp=" and gained <b>".$heroxp."</b> XP from the battle."; $xp = " and gained <b>".$heroxp."</b> XP from the battle.";
$info_hero = $hero_pic.",Your hero gained <b>".$heroxp."</b> XP."; $info_hero = $hero_pic.",Your hero gained <b>".$heroxp."</b> XP.";
} }
@@ -2449,7 +2447,7 @@ class Automation {
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".round($totclay)." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".round($totclay)." |
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".round($totiron)." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".round($totiron)." |
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".round($totcrop)."</div> <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".round($totcrop)."</div>
<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\" />Total Resources : ".round($totwood+$totclay+$totiron+$totcrop)."</div> <div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\" />Total Resources: ".round($totwood+$totclay+$totiron+$totcrop)."</div>
"; ";
}else if($data['spy'] == 2){ }else if($data['spy'] == 2){
if ($isoasis == 0){ if ($isoasis == 0){
@@ -3685,108 +3683,82 @@ class Automation {
} }
private function bountyGetWoodProd() { private function bountyGetWoodProd() {
global $bid1,$bid5,$session; global $bid1, $bid5;
$wood = $sawmill = 0; $wood = $sawmill = 0;
$woodholder = array(); $woodholder = [];
for($i=1;$i<=38;$i++) { for($i = 1; $i <= 38; $i++) {
if($this->bountyresarray['f'.$i.'t'] == 1) { if($this->bountyresarray['f'.$i.'t'] == 1) array_push($woodholder,'f'.$i);
array_push($woodholder,'f'.$i); if($this->bountyresarray['f'.$i.'t'] == 5) $sawmill = $this->bountyresarray['f'.$i];
}
if($this->bountyresarray['f'.$i.'t'] == 5) {
$sawmill = $this->bountyresarray['f'.$i];
}
} }
for($i=0;$i<=count($woodholder)-1;$i++) { $wood+= $bid1[$this->bountyresarray[$woodholder[$i]]]['prod']; }
if($sawmill >= 1) { for($i = 0; $i <= count($woodholder) - 1; $i++) $wood += $bid1[$this->bountyresarray[$woodholder[$i]]]['prod'];
$wood += $wood /100 * $bid5[$sawmill]['attri'];
} if($sawmill >= 1) $wood += $wood / 100 * $bid5[$sawmill]['attri'];
if($this->bountyocounter[0] != 0) { if($this->bountyocounter[0] != 0) $wood += $wood * 0.25 * $this->bountyocounter[0];
$wood += $wood*0.25*$this->bountyocounter[0];
} return round($wood * SPEED);
$wood *= SPEED;
return round($wood);
} }
private function bountyGetClayProd() { private function bountyGetClayProd() {
global $bid2,$bid6,$session; global $bid2, $bid6;
$clay = $brick = 0; $clay = $brick = 0;
$clayholder = array(); $clayholder = [];
for($i=1;$i<=38;$i++) { for($i = 1; $i <= 38; $i++) {
if($this->bountyresarray['f'.$i.'t'] == 2) { if($this->bountyresarray['f'.$i.'t'] == 2) array_push($clayholder,'f'.$i);
array_push($clayholder,'f'.$i); if($this->bountyresarray['f'.$i.'t'] == 6) $brick = $this->bountyresarray['f'.$i];
}
if($this->bountyresarray['f'.$i.'t'] == 6) {
$brick = $this->bountyresarray['f'.$i];
}
} }
for($i=0;$i<=count($clayholder)-1;$i++) { $clay+= $bid2[$this->bountyresarray[$clayholder[$i]]]['prod']; }
if($brick >= 1) { for($i = 0; $i <= count($clayholder) - 1; $i++) $clay+= $bid2[$this->bountyresarray[$clayholder[$i]]]['prod'];
$clay += $clay /100 * $bid6[$brick]['attri'];
} if($brick >= 1) $clay += $clay / 100 * $bid6[$brick]['attri'];
if($this->bountyocounter[1] != 0) { if($this->bountyocounter[1] != 0) $clay += $clay * 0.25 * $this->bountyocounter[1];
$clay += $clay*0.25*$this->bountyocounter[1];
} return round($clay * SPEED);
$clay *= SPEED;
return round($clay);
} }
private function bountyGetIronProd() { private function bountyGetIronProd() {
global $bid3,$bid7,$session; global $bid3, $bid7;
$iron = $foundry = 0; $iron = $foundry = 0;
$ironholder = array(); $ironholder = array();
for($i=1;$i<=38;$i++) { for($i = 1; $i <= 38; $i++) {
if($this->bountyresarray['f'.$i.'t'] == 3) { if($this->bountyresarray['f'.$i.'t'] == 3) array_push($ironholder,'f'.$i);
array_push($ironholder,'f'.$i); if($this->bountyresarray['f'.$i.'t'] == 7) $foundry = $this->bountyresarray['f'.$i];
}
if($this->bountyresarray['f'.$i.'t'] == 7) {
$foundry = $this->bountyresarray['f'.$i];
}
} }
for($i=0;$i<=count($ironholder)-1;$i++) { $iron+= $bid3[$this->bountyresarray[$ironholder[$i]]]['prod']; }
if($foundry >= 1) { for($i = 0; $i <= count($ironholder) - 1; $i++) $iron+= $bid3[$this->bountyresarray[$ironholder[$i]]]['prod'];
$iron += $iron /100 * $bid7[$foundry]['attri'];
} if($foundry >= 1) $iron += $iron / 100 * $bid7[$foundry]['attri'];
if($this->bountyocounter[2] != 0) { if($this->bountyocounter[2] != 0) $iron += $iron * 0.25 * $this->bountyocounter[2];
$iron += $iron*0.25*$this->bountyocounter[2];
} return round($iron * SPEED);
$iron *= SPEED;
return round($iron);
} }
private function bountyGetCropProd() { private function bountyGetCropProd() {
global $bid4,$bid8,$bid9,$session; global $bid4, $bid8, $bid9;
$crop = $grainmill = $bakery = 0; $crop = $grainmill = $bakery = 0;
$cropholder = array(); $cropholder = [];
for($i=1;$i<=38;$i++) { for($i = 1; $i <= 38;$i++) {
if($this->bountyresarray['f'.$i.'t'] == 4) { if($this->bountyresarray['f'.$i.'t'] == 4) array_push($cropholder,'f'.$i);
array_push($cropholder,'f'.$i); if($this->bountyresarray['f'.$i.'t'] == 8) $grainmill = $this->bountyresarray['f'.$i];
} if($this->bountyresarray['f'.$i.'t'] == 9) $bakery = $this->bountyresarray['f'.$i];
if($this->bountyresarray['f'.$i.'t'] == 8) {
$grainmill = $this->bountyresarray['f'.$i];
}
if($this->bountyresarray['f'.$i.'t'] == 9) {
$bakery = $this->bountyresarray['f'.$i];
}
} }
for($i=0;$i<=count($cropholder)-1;$i++) { $crop+= $bid4[$this->bountyresarray[$cropholder[$i]]]['prod']; } for($i = 0; $i <= count($cropholder) - 1; $i++) $crop+= $bid4[$this->bountyresarray[$cropholder[$i]]]['prod'];
if($grainmill >= 1) {
$crop += $crop /100 * (isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0); if($grainmill >= 1) $crop += $crop / 100 * (isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0);
} if($bakery >= 1) $crop += $crop / 100 * (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0);
if($bakery >= 1) { if($this->bountyocounter[3] != 0) $crop += $crop * 0.25 * $this->bountyocounter[3];
$crop += $crop /100 * (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0);
} if(!empty($bountyresarray['vref']) && is_numeric($bountyresarray['vref'])){
if($this->bountyocounter[3] != 0) {
$crop += $crop*0.25*$this->bountyocounter[3];
}
if(!empty($bountyresarray['vref']) && is_numeric($bountyresarray['vref'])){
$who=$database->getVillageField($bountyresarray['vref'],"owner"); $who=$database->getVillageField($bountyresarray['vref'],"owner");
$croptrue=$database->getUserField($who,"b4",0); $croptrue = $database->getUserField($who, "b4", 0);
if($croptrue > time()) { if($croptrue > time()) $crop *= 1.25;
$crop*=1.25;
}
} }
$crop *= SPEED;
return round($crop); return round($crop * SPEED);
} }
private function trainingComplete() { private function trainingComplete() {
+1
View File
@@ -69,6 +69,7 @@ class Session {
var $bonus2 = 0; var $bonus2 = 0;
var $bonus3 = 0; var $bonus3 = 0;
var $bonus4 = 0; var $bonus4 = 0;
var $timer = 0;
var $checker, $mchecker; var $checker, $mchecker;
public $userinfo = array(); public $userinfo = array();
private $userarray = array(); private $userarray = array();
+129 -150
View File
@@ -18,23 +18,20 @@ include_once("Technology.php");
class Village { class Village {
public $type; public $type;
public $coor = array(); public $coor = [];
public $awood,$aclay,$airon,$acrop,$pop,$maxstore,$maxcrop,$atotal; public $awood, $aclay, $airon, $acrop, $pop, $maxstore, $maxcrop, $atotal;
public $wid,$vname,$capital,$natar,$master; public $wid, $vname, $capital, $natar, $master;
public $resarray = array(); public $resarray = [];
public $unitarray,$techarray,$unitall,$researching,$abarray = array(); public $unitarray, $techarray, $unitall, $researching, $abarray = [];
private $infoarray = array(); private $infoarray = [];
private $production = array(); private $production = [];
private $oasisowned,$ocounter = array(); private $oasisowned, $ocounter = [];
function __construct() { function __construct() {
global $session, $database; global $session, $database;
if(isset($_SESSION['wid'])) {
$this->wid = $_SESSION['wid']; if(isset($_SESSION['wid'])) $this->wid = $_SESSION['wid'];
} else $this->wid = $session->villages[0];
else {
$this->wid = $session->villages[0];
}
$this->preloadVillagesData(); $this->preloadVillagesData();
@@ -67,12 +64,13 @@ class Village {
} }
public function getAllUnits($vid) { public function getAllUnits($vid) {
global $database,$technology; global $database, $technology;
return $technology->getUnits($database->getUnit($vid),$database->getEnforceVillage($vid,0)); return $technology->getUnits($database->getUnit($vid),$database->getEnforceVillage($vid,0));
} }
private function LoadTown($second_run = false) { private function LoadTown($second_run = false) {
global $database,$session,$logging,$technology; global $database, $session, $logging, $technology;
$this->infoarray = $database->getVillage($this->wid); $this->infoarray = $database->getVillage($this->wid);
if($this->infoarray['owner'] != $session->uid && !$session->isAdmin) { if($this->infoarray['owner'] != $session->uid && !$session->isAdmin) {
unset($_SESSION['wid']); unset($_SESSION['wid']);
@@ -110,15 +108,35 @@ class Village {
$this->allcrop = $this->getCropProd(); $this->allcrop = $this->getCropProd();
$this->loyalty = $this->infoarray['loyalty']; $this->loyalty = $this->infoarray['loyalty'];
$this->master = count($database->getMasterJobs($this->wid)); $this->master = count($database->getMasterJobs($this->wid));
//de gs in town, zetten op max pakhuisinhoud
//If resources overflow the warehouse/granary limit, set them at the maximum value
$resourceUpdates = []; $resourceUpdates = [];
if($this->awood>$this->maxstore){ $this->awood=$this->maxstore; $resourceUpdates['wood'] = $this->maxstore; } if($this->awood > $this->maxstore)
if($this->aclay>$this->maxstore){ $this->aclay=$this->maxstore; $resourceUpdates['clay'] = $this->maxstore; } {
if($this->airon>$this->maxstore){ $this->airon=$this->maxstore; $resourceUpdates['iron'] = $this->maxstore; } $this->awood = $this->maxstore;
if($this->acrop>$this->maxcrop){ $this->acrop=$this->maxcrop; $resourceUpdates['crop'] = $this->maxcrop; } $resourceUpdates['wood'] = $this->maxstore;
}
if($this->aclay > $this->maxstore)
{
$this->aclay = $this->maxstore;
$resourceUpdates['clay'] = $this->maxstore;
}
if($this->airon > $this->maxstore)
{
$this->airon = $this->maxstore;
$resourceUpdates['iron'] = $this->maxstore;
}
if($this->acrop > $this->maxcrop)
{
$this->acrop = $this->maxcrop;
$resourceUpdates['crop'] = $this->maxcrop;
}
if (count($resourceUpdates)) { if (count($resourceUpdates)) {
$database->updateResource( $this->wid, array_keys( $resourceUpdates ), array_values($resourceUpdates) ); $database->updateResource($this->wid, array_keys($resourceUpdates), array_values($resourceUpdates));
// reload cache if we've updated resources and the like // reload cache if we've updated resources and the like
if ($second_run) { if ($second_run) {
@@ -126,188 +144,148 @@ class Village {
call_user_func(get_class($database).'::clearVillageCache'); call_user_func(get_class($database).'::clearVillageCache');
$this->preloadVillagesData(); $this->preloadVillagesData();
} }
} else if ($second_run) { }
$this->preloadVillagesData(); else if ($second_run) $this->preloadVillagesData();
}
} }
private function calculateProduction() { private function calculateProduction() {
global $technology,$database,$session; global $technology, $database, $session;
// clear cache, since we're updating village data // clear cache, since we're updating village data
call_user_func(get_class($database).'::clearVillageCache'); call_user_func(get_class($database).'::clearVillageCache');
$normalA = $database->getOwnArtefactInfoByType($_SESSION['wid'],4);
$largeA = $database->getOwnUniqueArtefactInfo($session->uid,4,2);
$uniqueA = $database->getOwnUniqueArtefactInfo($session->uid,4,3);
$upkeep = $technology->getUpkeep($this->unitall, 0, $this->wid); $upkeep = $technology->getUpkeep($this->unitall, 0, $this->wid);
$this->production['wood'] = $this->getWoodProd(); $this->production['wood'] = $this->getWoodProd();
$this->production['clay'] = $this->getClayProd(); $this->production['clay'] = $this->getClayProd();
$this->production['iron'] = $this->getIronProd(); $this->production['iron'] = $this->getIronProd();
$this->production['crop'] = $this->getCropProd() - $this->pop - $upkeep;
if ($uniqueA['size']==3 && $uniqueA['owner']==$session->uid){
$this->production['crop'] = $this->getCropProd()- $this->pop - (($upkeep)-round($upkeep*0.50));
}else if ($normalA['type']==4 && $normalA['size']==1 && $normalA['owner']==$session->uid){
$this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));
}else if ($largeA['size']==2 && $largeA['owner']==$session->uid){
$this->production['crop'] = $this->getCropProd()-$this->pop-(($upkeep)-round($upkeep*0.25));
}else{
$this->production['crop'] = $this->getCropProd()-$this->pop-$upkeep;
} }
}
private function processProduction() { private function processProduction() {
global $database; global $database;
$timepast = time() - $this->infoarray['lastupdate'];
$nwood = ($this->production['wood'] / 3600) * $timepast;
$nclay = ($this->production['clay'] / 3600) * $timepast;
$niron = ($this->production['iron'] / 3600) * $timepast;
$ncrop = ($this->production['crop'] / 3600) * $timepast;
$database->modifyResource($this->wid,$nwood,$nclay,$niron,$ncrop,1); $timepast = time() - $this->infoarray['lastupdate'];
$nwood = min(($this->production['wood'] / 3600) * $timepast, $this->maxstore);
$nclay = min(($this->production['clay'] / 3600) * $timepast, $this->maxstore);
$niron = min(($this->production['iron'] / 3600) * $timepast, $this->maxstore);
$ncrop = min(($this->production['crop'] / 3600) * $timepast, $this->maxcrop);
$database->modifyResource($this->wid, $nwood, $nclay, $niron, $ncrop, 1);
$database->updateVillage($this->wid); $database->updateVillage($this->wid);
$this->LoadTown(true); $this->LoadTown(true);
} }
private function getWoodProd() { private function getWoodProd() {
global $bid1,$bid5,$session; global $bid1, $bid5, $session;
$basewood = $sawmill = 0;
$woodholder = array(); $wood = $sawmill = 0;
for($i=1;$i<=38;$i++) { $woodholder = [];
if($this->resarray['f'.$i.'t'] == 1) { for($i = 1; $i <= 38; $i++) {
array_push($woodholder,'f'.$i); if($this->resarray['f'.$i.'t'] == 1) array_push($woodholder,'f'.$i);
} if($this->resarray['f'.$i.'t'] == 5) $sawmill = $this->resarray['f'.$i];
if($this->resarray['f'.$i.'t'] == 5) {
$sawmill = $this->resarray['f'.$i];
}
} }
for($i=0;$i<=count($woodholder)-1;$i++) { $basewood+= $bid1[$this->resarray[$woodholder[$i]]]['prod']; }
$wood = $basewood + $basewood * 0.25 * $this->ocounter[0]; for($i = 0; $i <= count($woodholder) - 1; $i++) $wood += $bid1[$this->resarray[$woodholder[$i]]]['prod'];
if($sawmill >= 1) { $wood = $wood + $wood * 0.25 * $this->ocounter[0];
$wood += $basewood / 100 * $bid5[$sawmill]['attri'];
} if($sawmill >= 1) $wood += $wood / 100 * $bid5[$sawmill]['attri'];
if($session->bonus1 == 1) { if($session->bonus1 == 1) $wood *= 1.25;
$wood *= 1.25;
} return round($wood * SPEED);
$wood *= SPEED;
return round($wood);
} }
private function getClayProd() { private function getClayProd() {
global $bid2,$bid6,$session; global $bid2, $bid6, $session;
$baseclay = $clay = $brick = 0;
$clayholder = array(); $clay = $brick = 0;
for($i=1;$i<=38;$i++) { $clayholder = [];
if($this->resarray['f'.$i.'t'] == 2) { for($i = 1; $i <= 38; $i++) {
array_push($clayholder,'f'.$i); if($this->resarray['f'.$i.'t'] == 2) array_push($clayholder,'f'.$i);
} if($this->resarray['f'.$i.'t'] == 6) $brick = $this->resarray['f'.$i];
if($this->resarray['f'.$i.'t'] == 6) {
$brick = $this->resarray['f'.$i];
}
} }
for($i=0;$i<=count($clayholder)-1;$i++) { $baseclay+= $bid2[$this->resarray[$clayholder[$i]]]['prod']; }
$clay = $baseclay + $baseclay * 0.25 * $this->ocounter[1]; for($i = 0; $i <= count($clayholder) - 1; $i++) $clay+= $bid2[$this->resarray[$clayholder[$i]]]['prod'];
if($brick >= 1) { $clay = $clay + $clay * 0.25 * $this->ocounter[1];
$clay += $baseclay / 100 * $bid6[$brick]['attri'];
} if($brick >= 1) $clay += $clay / 100 * $bid6[$brick]['attri'];
if($session->bonus2 == 1) { if($session->bonus2 == 1) $clay *= 1.25;
$clay *= 1.25;
} return round($clay * SPEED);
$clay *= SPEED;
return round($clay);
} }
private function getIronProd() { private function getIronProd() {
global $bid3,$bid7,$session; global $bid3, $bid7, $session;
$baseiron = $foundry = 0;
$ironholder = array(); $iron = $foundry = 0;
for($i=1;$i<=38;$i++) { $ironholder = [];
if($this->resarray['f'.$i.'t'] == 3) { for($i = 1; $i <= 38; $i++) {
array_push($ironholder,'f'.$i); if($this->resarray['f'.$i.'t'] == 3) array_push($ironholder,'f'.$i);
} if($this->resarray['f'.$i.'t'] == 7) $foundry = $this->resarray['f'.$i];
if($this->resarray['f'.$i.'t'] == 7) {
$foundry = $this->resarray['f'.$i];
}
} }
for($i=0;$i<=count($ironholder)-1;$i++) { $baseiron+= $bid3[$this->resarray[$ironholder[$i]]]['prod']; }
$iron = $baseiron + $baseiron * 0.25 * $this->ocounter[2]; for($i = 0;$i <= count($ironholder) - 1; $i++) $iron+= $bid3[$this->resarray[$ironholder[$i]]]['prod'];
if($foundry >= 1) { $iron = $iron + $iron * 0.25 * $this->ocounter[2];
$iron += $baseiron / 100 * $bid7[$foundry]['attri'];
} if($foundry >= 1) $iron += $iron / 100 * $bid7[$foundry]['attri'];
if($session->bonus3 == 1) { if($session->bonus3 == 1) $iron *= 1.25;
$iron *= 1.25;
} return round($iron * SPEED);
$iron *= SPEED;
return round($iron);
} }
private function getCropProd() { private function getCropProd() {
global $bid4,$bid8,$bid9,$session; global $bid4, $bid8, $bid9, $session;
$basecrop = $grainmill = $bakery = 0;
$cropholder = array(); $crop = $grainmill = $bakery = 0;
for($i=1;$i<=38;$i++) { $cropholder = [];
if($this->resarray['f'.$i.'t'] == 4) { for($i = 1; $i <= 38; $i++) {
array_push($cropholder,'f'.$i); if($this->resarray['f'.$i.'t'] == 4) array_push($cropholder,'f'.$i);
} if($this->resarray['f'.$i.'t'] == 8) $grainmill = $this->resarray['f'.$i];
if($this->resarray['f'.$i.'t'] == 8) { if($this->resarray['f'.$i.'t'] == 9) $bakery = $this->resarray['f'.$i];
$grainmill = $this->resarray['f'.$i];
}
if($this->resarray['f'.$i.'t'] == 9) {
$bakery = $this->resarray['f'.$i];
}
} }
for ( $i = 0; $i <= count( $cropholder ) - 1; $i ++ ) {
$basecrop += $bid4[ $this->resarray[ $cropholder[ $i ] ] ]['prod']; for ($i = 0; $i <= count($cropholder) - 1; $i++) $crop += $bid4[$this->resarray[$cropholder[$i]]]['prod'];
}
$bonus = 0.25 * $this->ocounter[3]; $bonus = 0.25 * $this->ocounter[3];
$crop = $basecrop + $basecrop * 0.25 * $this->ocounter[3]; $crop = $crop + $crop * 0.25 * $this->ocounter[3];
if($grainmill >= 1 || $bakery >= 1) { if($grainmill >= 1 || $bakery >= 1) {
$crop += $basecrop /100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0)); $crop += $crop / 100 * ((isset($bid8[$grainmill]['attri']) ? $bid8[$grainmill]['attri'] : 0) + (isset($bid9[$bakery]['attri']) ? $bid9[$bakery]['attri'] : 0));
} }
if($session->bonus4 == 1) $crop *= 1.25;
if($session->bonus4 == 1) { return round($crop * SPEED);
$crop *= 1.25;
}
$crop *= SPEED;
return round($crop);
} }
private function sortOasis() { private function sortOasis() {
$crop = $clay = $wood = $iron = 0; $crop = $clay = $wood = $iron = 0;
if (!empty($this->oasisowned)) { if(!empty($this->oasisowned)){
foreach ($this->oasisowned as $oasis) { foreach($this->oasisowned as $oasis){
switch ( $oasis['type'] ) { switch($oasis['type']){
case 1: case 1:
case 2: case 2:
$wood += 1; $wood++;
break; break;
case 3: case 3:
$wood += 1; $wood++;
$crop += 1; $crop++;
break; break;
case 4: case 4:
case 5: case 5:
$clay += 1; $clay++;
break; break;
case 6: case 6:
$clay += 1; $clay++;
$crop += 1; $crop++;
break; break;
case 7: case 7:
case 8: case 8:
$iron += 1; $iron++;
break; break;
case 9: case 9:
$iron += 1; $iron++;
$crop += 1; $crop++;
break; break;
case 10: case 10:
case 11: case 11:
$crop += 1; $crop++;
break; break;
case 12: case 12:
$crop += 2; $crop += 2;
@@ -315,19 +293,20 @@ class Village {
} }
} }
} }
return array($wood,$clay,$iron,$crop); return [$wood, $clay, $iron, $crop];
} }
private function ActionControl() { private function ActionControl() {
global $session; global $session;
if(SERVER_WEB_ROOT) {
$page = $_SERVER['SCRIPT_NAME']; if(SERVER_WEB_ROOT) $page = $_SERVER['SCRIPT_NAME'];
} else
else { {
$explode = explode("/",$_SERVER['SCRIPT_NAME']); $explode = explode("/",$_SERVER['SCRIPT_NAME']);
$i = count($explode)-1; $i = count($explode)-1;
$page = $explode[$i]; $page = $explode[$i];
} }
if($page == "build.php" && $session->uid != $this->infoarray['owner']) { if($page == "build.php" && $session->uid != $this->infoarray['owner']) {
unset($_SESSION['wid']); unset($_SESSION['wid']);
header("Location: dorf1.php"); header("Location: dorf1.php");
+8 -8
View File
@@ -13,7 +13,7 @@ $res1 = mysqli_query($database->dblink,"SELECT wood, clay, iron, crop FROM " . T
$res = mysqli_fetch_array($res1); $res = mysqli_fetch_array($res1);
} }
} }
$timer = $y+1; $session->timer++;
if ($units[$y]['sort_type']==3){ if ($units[$y]['sort_type']==3){
if ($units[$y]['attack_type']==3){ if ($units[$y]['attack_type']==3){
$actionType = ATTACK_ON; $actionType = ATTACK_ON;
@@ -79,7 +79,7 @@ if ($units[$y]['sort_type']==3){
<tr> <tr>
<th>'.ARRIVAL.'</th> <th>'.ARRIVAL.'</th>
<td colspan='.$colspan.'> <td colspan='.$colspan.'>
<div class="in small"><span id=timer'.$timer.'>'.$generator->getTimeFormat($units[$y]['endtime']-time()).'</span> h</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']); $datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">"; echo "<div class=\"at small\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
@@ -114,7 +114,7 @@ if ($units[$y]['sort_type']==3){
<tr> <tr>
<th>'.ARRIVAL.'</th> <th>'.ARRIVAL.'</th>
<td colspan="10"> <td colspan="10">
<div class="in small"><span id=timer'.$timer.'>'.$generator->getTimeFormat($units[$y]['endtime']-time()).'</span> h</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']); $datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at small\">"; echo "<div class=\"at small\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
@@ -201,7 +201,7 @@ $to = $database->getMInfo($units[$y]['vref']);
<th><?php echo ARRIVAL;?></th> <th><?php echo ARRIVAL;?></th>
<td colspan="<?php echo $units[$y]['t11'] == 0 ? 10 : 11 ?>"> <td colspan="<?php echo $units[$y]['t11'] == 0 ? 10 : 11 ?>">
<?php <?php
echo "<div class=\"in small\"><span id=timer".$timer.">".$generator->getTimeFormat($units[$y]['endtime']-time())."</span> h</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']); $datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at\">"; echo "<div class=\"at\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
@@ -222,7 +222,7 @@ foreach($array as $conqured){
$oasis = $database->getMovement("6",$conqured['wref'],0); $oasis = $database->getMovement("6",$conqured['wref'],0);
$total_for = count($oasis); $total_for = count($oasis);
for($y=0;$y < $total_for;$y++){ for($y=0;$y < $total_for;$y++){
$timer = $y+1; $session->timer++;
$to = $database->getOMInfo($oasis[$y]['to']); $to = $database->getOMInfo($oasis[$y]['to']);
if ($oasis[$y]['attack_type']==2){ if ($oasis[$y]['attack_type']==2){
$actionType = REINFORCEMENTFOR; $actionType = REINFORCEMENTFOR;
@@ -286,7 +286,7 @@ $to = $database->getOMInfo($oasis[$y]['to']);
<tr> <tr>
<th>'.ARRIVAL.'</th> <th>'.ARRIVAL.'</th>
<td colspan="'.$colspan.'"> <td colspan="'.$colspan.'">
<div class="in small"><span id=timer'.$timer.'>'.$generator->getTimeFormat($oasis[$y]['endtime']-time()).'</span> h</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']); $datetime = $generator->procMtime($oasis[$y]['endtime']);
echo "<div class=\"at\">"; echo "<div class=\"at\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
@@ -304,7 +304,7 @@ $to = $database->getOMInfo($oasis[$y]['to']);
$settlers = $database->getMovement("7",$village->wid,1); $settlers = $database->getMovement("7",$village->wid,1);
$total_for3 = count($settlers); $total_for3 = count($settlers);
for($x=0;$x < $total_for3;$x++){ for($x=0;$x < $total_for3;$x++){
$timer = $x+1; $session->timer++;
$to = $database->getMInfo($settlers[$x]['to']); $to = $database->getMInfo($settlers[$x]['to']);
?> ?>
<table class="troop_details" cellpadding="1" cellspacing="1"> <table class="troop_details" cellpadding="1" cellspacing="1">
@@ -348,7 +348,7 @@ $to = $database->getMInfo($settlers[$x]['to']);
<th><?php echo ARRIVAL;?></th> <th><?php echo ARRIVAL;?></th>
<td colspan="10"> <td colspan="10">
<?php <?php
echo "<div class=\"in small\"><span id=timer".$timer.">".$generator->getTimeFormat($settlers[$x]['endtime']-time())."</span> h</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']); $datetime = $generator->procMtime($settlers[$x]['endtime']);
echo "<div class=\"at\">"; echo "<div class=\"at\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
+4 -5
View File
@@ -1,10 +1,9 @@
<?php <?php
$units = $database->getMovement(3,$village->wid,0); $units = $database->getMovement(3,$village->wid,0);
$total_for = count($units); $total_for = count($units);
$timer = 0;
for($y=0;$y<$total_for;$y++){ for($y=0;$y<$total_for;$y++){
$timer += 1; $session->timer++;
if($units[$y]['attack_type'] == 2){ if($units[$y]['attack_type'] == 2){
$attack_type = REINFORCEMENTFOR; $attack_type = REINFORCEMENTFOR;
@@ -78,7 +77,7 @@ $to = $database->getOMInfo($units[$y]['to']);}
<th><?php echo ARRIVAL;?></th> <th><?php echo ARRIVAL;?></th>
<td colspan="<?php if($units[$y]['t11'] == 0) {echo"10";}else{echo"11";}?>"> <td colspan="<?php if($units[$y]['t11'] == 0) {echo"10";}else{echo"11";}?>">
<?php <?php
echo "<div class=\"in small\"><span id=timer$timer>".$generator->getTimeFormat($units[$y]['endtime']-time())."</span> h</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']); $datetime = $generator->procMtime($units[$y]['endtime']);
echo "<div class=\"at\">"; echo "<div class=\"at\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
@@ -104,7 +103,7 @@ $to = $database->getOMInfo($units[$y]['to']);}
$total_for = count($settlers); $total_for = count($settlers);
for($y=0;$y<$total_for;$y++){ for($y=0;$y<$total_for;$y++){
$timer += 1; $session->timer++;
?> ?>
<table class="troop_details" cellpadding="1" cellspacing="1"> <table class="troop_details" cellpadding="1" cellspacing="1">
@@ -147,7 +146,7 @@ $timer += 1;
<th><?php echo ARRIVAL;?></th> <th><?php echo ARRIVAL;?></th>
<td colspan="<?php if($units[$y]['t11'] == 0) {echo"10";}else{echo"11";}?>"> <td colspan="<?php if($units[$y]['t11'] == 0) {echo"10";}else{echo"11";}?>">
<?php <?php
echo "<div class=\"in small\"><span id=timer$timer>".$generator->getTimeFormat($settlers[$y]['endtime']-time())."</span> h</div>"; echo "<div class=\"in small\"><span id=timer$session->timer>".$generator->getTimeFormat($settlers[$y]['endtime']-time())."</span> h</div>";
$datetime = $generator->procMtime($settlers[$y]['endtime']); $datetime = $generator->procMtime($settlers[$y]['endtime']);
echo "<div class=\"at small\">"; echo "<div class=\"at small\">";
if($datetime[0] != "today") { if($datetime[0] != "today") {
+2 -2
View File
@@ -84,7 +84,7 @@ div.c1 {text-align: center}
} }
?> ?>
</div><?php </div><?php
if($_SESSION['ok']=='1'){ if($_SESSION['ok'] == 1){
?> ?>
<div id="content" class="village1"> <div id="content" class="village1">
@@ -100,9 +100,9 @@ div.c1 {text-align: center}
<div id="side_info"> <div id="side_info">
<?php <?php
include("Templates/multivillage.tpl");
include("Templates/quest.tpl"); include("Templates/quest.tpl");
include("Templates/news.tpl"); include("Templates/news.tpl");
include("Templates/multivillage.tpl");
?> ?>
</div> </div>