mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-18 16:17:20 +00:00
Fixed some bugs and errors
+Part 1 of the starvation refactor, attacking troops will now be killed +Fixed some errors in Units.php, Technology.php, Battle.php and some 16_incomming.tpl -Removed an unused function in Database.php +Fixed a bug that could have destroyed a village after taking an artefact even if it had more than 0 pop
This commit is contained in:
+139
-119
@@ -2614,8 +2614,9 @@ class Automation {
|
|||||||
$newLevels_fieldNames = [];
|
$newLevels_fieldNames = [];
|
||||||
$newLevels_fieldValues = [];
|
$newLevels_fieldValues = [];
|
||||||
|
|
||||||
$pop1 = $database->getTotalPopulation($AttackerID);
|
$poparray = $database->getVSumField([$AttackerID, $DefenderID] ,"pop");
|
||||||
$pop2 = $database->getTotalPopulation($DefenderID);
|
$pop1 = $poparray[0]['Total'];
|
||||||
|
$pop2 = $poparray[1]['Total'];
|
||||||
if($pop1 > $pop2){
|
if($pop1 > $pop2){
|
||||||
$buildlevel = $database->getResourceLevel($data['to']);
|
$buildlevel = $database->getResourceLevel($data['to']);
|
||||||
|
|
||||||
@@ -2746,9 +2747,11 @@ class Automation {
|
|||||||
if ($database->canClaimArtifact($data['from'],$artifact['vref'],$artifact['size'],$artifact['type'])) {
|
if ($database->canClaimArtifact($data['from'],$artifact['vref'],$artifact['size'],$artifact['type'])) {
|
||||||
$database->claimArtefact($data['from'],$data['to'],$database->getVillageField($data['from'],"owner"));
|
$database->claimArtefact($data['from'],$data['to'],$database->getVillageField($data['from'],"owner"));
|
||||||
$info_hero = $hero_pic.",Your hero is carrying home an artefact".$xp;
|
$info_hero = $hero_pic.",Your hero is carrying home an artefact".$xp;
|
||||||
if($pop == 0){
|
|
||||||
|
// if the defender pop is 0 with no artefact, then destroy the village
|
||||||
|
if($database->getVillageField($data['to'], "pop") == 0){
|
||||||
$can_destroy = $village_destroyed = 1;
|
$can_destroy = $village_destroyed = 1;
|
||||||
$info_hero .= ". The village has been destroyed.";
|
$info_hero .= " The village has been destroyed.";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$info_hero = $hero_pic.",".$form->getError("error").$xp;
|
$info_hero = $hero_pic.",".$form->getError("error").$xp;
|
||||||
@@ -4893,15 +4896,14 @@ class Automation {
|
|||||||
if ($crop < $village_upkeep){
|
if ($crop < $village_upkeep){
|
||||||
// add starv data
|
// add starv data
|
||||||
$database->setVillageField($village->wid, 'starv', $village_upkeep);
|
$database->setVillageField($village->wid, 'starv', $village_upkeep);
|
||||||
if($starv==0)
|
if($starv==0) $database->setVillageField($village->wid, 'starvupdate', time());
|
||||||
$database->setVillageField($village->wid, 'starvupdate', time());
|
|
||||||
}
|
}
|
||||||
unset($crop,$unitarrays,$getvillage,$village_upkeep);
|
unset($crop,$unitarrays,$getvillage,$village_upkeep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load villages with minus prod
|
// load villages with minus prod
|
||||||
|
|
||||||
$starvarray = array();
|
$starvarray = [];
|
||||||
$starvarray = $database->getStarvation();
|
$starvarray = $database->getStarvation();
|
||||||
|
|
||||||
$vilIDs = [];
|
$vilIDs = [];
|
||||||
@@ -4912,17 +4914,17 @@ class Automation {
|
|||||||
$database->getEnforceVillage($vilIDs, 0);
|
$database->getEnforceVillage($vilIDs, 0);
|
||||||
$database->getOasisEnforce($vilIDs, 2);
|
$database->getOasisEnforce($vilIDs, 2);
|
||||||
$database->getOasisEnforce($vilIDs, 3);
|
$database->getOasisEnforce($vilIDs, 3);
|
||||||
|
$database->getMovement(3, $vilIDs, 0);
|
||||||
|
|
||||||
foreach ($starvarray as $starv){
|
foreach ($starvarray as $starv){
|
||||||
$unitarrays = $this->getAllUnits($starv['wref']);
|
$unitarrays = $this->getAllUnits($starv['wref']);
|
||||||
$howweeating=$this->getUpkeep($unitarrays, 0,$starv['wref']);
|
$upkeep = $starv['pop'] + $this->getUpkeep($unitarrays, 0, $starv['wref']);
|
||||||
$upkeep = $starv['pop'] + $howweeating;
|
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: getting enforcements could be done by using a recursive function
|
||||||
|
|
||||||
// get enforce other player from oasis
|
// get enforce other player from oasis
|
||||||
$enforceoasis = $database->getOasisEnforce($starv['wref'], 2);
|
$enforceoasis = $database->getOasisEnforce($starv['wref'], 2);
|
||||||
$maxcount=0;
|
$maxcount = $totalunits = 0;
|
||||||
$totalunits=0;
|
|
||||||
if(count($enforceoasis)>0){
|
if(count($enforceoasis)>0){
|
||||||
foreach ($enforceoasis as $enforce){
|
foreach ($enforceoasis as $enforce){
|
||||||
for($i=1;$i<=50;$i++){
|
for($i=1;$i<=50;$i++){
|
||||||
@@ -4930,33 +4932,36 @@ class Automation {
|
|||||||
if($enforce['u'.$i] > $maxcount){
|
if($enforce['u'.$i] > $maxcount){
|
||||||
$maxcount = $enforce['u'.$i];
|
$maxcount = $enforce['u'.$i];
|
||||||
$maxtype = $i;
|
$maxtype = $i;
|
||||||
$enf = $enforce['id'];
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
$totalunits += $enforce['u'.$i];
|
$totalunits += $enforce['u'.$i];
|
||||||
}
|
}
|
||||||
if($totalunits == 0){
|
if($totalunits == 0 && $enforce['hero'] > 0){
|
||||||
$maxcount = $enforce['hero'];
|
$maxcount = $enforce['hero'];
|
||||||
$maxtype = "hero";
|
$maxtype = "hero";
|
||||||
|
$heroinfo = $database->getHero($database->getVillageField($enf['from'], "owner"))[0];
|
||||||
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
$other_reinf=true;
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//own troops from oasis
|
//own troops from oasis
|
||||||
$enforceoasis = $database->getOasisEnforce($starv['wref'], 3);
|
$enforceoasis = $database->getOasisEnforce($starv['wref'], 3);
|
||||||
if(count($enforceoasis)>0){
|
if(count($enforceoasis)>0){
|
||||||
foreach ($enforceoasis as $enforce){
|
foreach ($enforceoasis as $enforce){
|
||||||
for($i=1;$i<=50;$i++){
|
for($i = 1; $i <= 50; $i++){
|
||||||
$units = $enforce['u'.$i];
|
$units = $enforce['u'.$i];
|
||||||
if($enforce['u'.$i] > $maxcount){
|
if($enforce['u'.$i] > $maxcount){
|
||||||
$maxcount = $enforce['u'.$i];
|
$maxcount = $enforce['u'.$i];
|
||||||
$maxtype = $i;
|
$maxtype = $i;
|
||||||
$enf = $enforce['id'];
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
$totalunits += $enforce['u'.$i];
|
$totalunits += $enforce['u'.$i];
|
||||||
}
|
}
|
||||||
if($totalunits == 0){
|
if($totalunits == 0 && $enforce['hero'] > 0){
|
||||||
$maxcount = $enforce['hero'];
|
$maxcount = $enforce['hero'];
|
||||||
$maxtype = "hero";
|
$maxtype = "hero";
|
||||||
|
$heroinfo = $database->getHero($database->getVillageField($enf['from'], "owner"))[0];
|
||||||
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -4964,18 +4969,20 @@ class Automation {
|
|||||||
$enforcearray = $database->getEnforceVillage($starv['wref'], 2);
|
$enforcearray = $database->getEnforceVillage($starv['wref'], 2);
|
||||||
if(count($enforcearray)>0){
|
if(count($enforcearray)>0){
|
||||||
foreach ($enforcearray as $enforce){
|
foreach ($enforcearray as $enforce){
|
||||||
for($i = 0 ; $i <= 50 ; $i++){
|
for($i = 1 ; $i <= 50 ; $i++){
|
||||||
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
|
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
|
||||||
if($units > $maxcount){
|
if($units > $maxcount){
|
||||||
$maxcount = $units;
|
$maxcount = $units;
|
||||||
$maxtype = $i;
|
$maxtype = $i;
|
||||||
$enf = $enforce['id'];
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
$totalunits += $units;
|
$totalunits += $units;
|
||||||
}
|
}
|
||||||
if($totalunits == 0){
|
if($totalunits == 0 && $enforce['hero'] > 0){
|
||||||
$maxcount = $enforce['hero'];
|
$maxcount = $enforce['hero'];
|
||||||
$maxtype = "hero";
|
$maxtype = "hero";
|
||||||
|
$heroinfo = $database->getHero($database->getVillageField($enf['from'], "owner"))[0];
|
||||||
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -4983,24 +4990,26 @@ class Automation {
|
|||||||
$enforcearray = $database->getEnforceVillage($starv['wref'], 3);
|
$enforcearray = $database->getEnforceVillage($starv['wref'], 3);
|
||||||
if(count($enforcearray)>0){
|
if(count($enforcearray)>0){
|
||||||
foreach ($enforcearray as $enforce){
|
foreach ($enforcearray as $enforce){
|
||||||
for($i = 0 ; $i <= 50 ; $i++){
|
for($i = 1 ; $i <= 50 ; $i++){
|
||||||
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
|
$units = (isset($enforce['u'.$i]) ? $enforce['u'.$i] : 0);
|
||||||
if($units > $maxcount){
|
if($units > $maxcount){
|
||||||
$maxcount = $units;
|
$maxcount = $units;
|
||||||
$maxtype = $i;
|
$maxtype = $i;
|
||||||
$enf = $enforce['id'];
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
$totalunits += $units;
|
$totalunits += $units;
|
||||||
}
|
}
|
||||||
if($totalunits == 0){
|
if($totalunits == 0 && $enforce['hero'] > 0){
|
||||||
$maxcount = $enforce['hero'];
|
$maxcount = $enforce['hero'];
|
||||||
$maxtype = "hero";
|
$maxtype = "hero";
|
||||||
|
$heroinfo = $database->getHero($database->getVillageField($enf['from'], "owner"))[0];
|
||||||
|
$enf = $enforce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//get own unit
|
//get own unit
|
||||||
$unitarray = $database->getUnit($starv['wref']);
|
$unitarray = $database->getUnit($starv['wref']);
|
||||||
for($i = 0 ; $i <= 50 ; $i++){
|
for($i = 1 ; $i <= 50 ; $i++){
|
||||||
$units = (isset($unitarray['u'.$i]) ? $unitarray['u'.$i] : 0);
|
$units = (isset($unitarray['u'.$i]) ? $unitarray['u'.$i] : 0);
|
||||||
if($units > $maxcount){
|
if($units > $maxcount){
|
||||||
$maxcount = $units;
|
$maxcount = $units;
|
||||||
@@ -5009,9 +5018,35 @@ class Automation {
|
|||||||
$totalunits += $units;
|
$totalunits += $units;
|
||||||
}
|
}
|
||||||
if($totalunits == 0){
|
if($totalunits == 0){
|
||||||
$maxcount = $unitarray['hero'];
|
if($unitarray['hero'] > 0){
|
||||||
$maxtype = "hero";
|
$maxcount = $unitarray['hero'];
|
||||||
}
|
$maxtype = "hero";
|
||||||
|
$heroinfo = $database->getHero($starv['owner'])[0];
|
||||||
|
}else{
|
||||||
|
//get own travelling troops
|
||||||
|
$attackarray = $database->getMovement(3, $starv['wref'], 0);
|
||||||
|
$tribe = $database->getUserField($starv['owner'], "tribe", 0);
|
||||||
|
foreach ($attackarray as $attack){
|
||||||
|
for($i = 1 ; $i <= 10; $i++){
|
||||||
|
$units = (isset($attack['t'.$i]) ? $attack['t'.$i] : 0);
|
||||||
|
if($units > $maxcount){
|
||||||
|
$maxcount = $units;
|
||||||
|
$maxtypeatt = $i;
|
||||||
|
$maxtype = $maxtypeatt + (($tribe - 1) * 10);
|
||||||
|
$att = $attack['moveid'];
|
||||||
|
}
|
||||||
|
$totalunits += $units;
|
||||||
|
}
|
||||||
|
if($totalunits == 0 && $attack['t11'] > 0){
|
||||||
|
$maxcount = $attack['t11'];
|
||||||
|
$maxtype = "hero";
|
||||||
|
$maxtypeatt = 11;
|
||||||
|
$heroinfo = $database->getHero($starv['owner'])[0];
|
||||||
|
$att = $attack['moveid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5020,102 +5055,81 @@ class Automation {
|
|||||||
// counting
|
// counting
|
||||||
|
|
||||||
$timedif = $time-$starv['starvupdate'];
|
$timedif = $time-$starv['starvupdate'];
|
||||||
$skolko=$database->getCropProdstarv($starv['wref'])-$starv['starv'];
|
$skolko = $database->getCropProdstarv($starv['wref'])-$starv['starv'];
|
||||||
if($skolko<0){$golod=true;}
|
if($skolko < 0)
|
||||||
else{$golod=false;}
|
{
|
||||||
if($golod){
|
|
||||||
$starvsec = (abs($skolko)/3600);
|
$starvsec = (abs($skolko)/3600);
|
||||||
$difcrop = ($timedif*$starvsec); //crop eat up over time
|
$difcrop = ($timedif*$starvsec); //crop eat up over time
|
||||||
$newcrop = 0;
|
$newcrop = 0;
|
||||||
$oldcrop = $database->getVillageField($starv['wref'], 'crop');
|
$oldcrop = $database->getVillageField($starv['wref'], 'crop');
|
||||||
if ($oldcrop > 100){ //if the grain is then tries to send all
|
if ($oldcrop > 100) //if the grain is then tries to send all
|
||||||
|
{
|
||||||
$difcrop = $difcrop-$oldcrop;
|
$difcrop = $difcrop-$oldcrop;
|
||||||
if($difcrop < 0){
|
if($difcrop < 0)
|
||||||
|
{
|
||||||
$difcrop = 0;
|
$difcrop = 0;
|
||||||
$newcrop = $oldcrop-$difcrop;
|
$newcrop = $oldcrop-$difcrop;
|
||||||
$database->setVillageField($starv['wref'], 'crop', $newcrop);
|
$database->setVillageField($starv['wref'], 'crop', $newcrop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($difcrop > 0)
|
||||||
|
{
|
||||||
|
global ${'u'.$maxtype}, ${'h'.$heroinfo['unit'].'_full'};
|
||||||
|
|
||||||
if($difcrop > 0){
|
$hungry = [];
|
||||||
global ${'u'.$maxtype};
|
$hungry = ($maxtype != "hero") ? ${'u'.$maxtype} : ${'h'.$heroinfo['unit'].'_full'}[min($heroinfo['level'], 60)];
|
||||||
|
|
||||||
$hungry=array();
|
if ($hungry['crop'] > 0 && $oldcrop <= 0) $killunits = ceil($difcrop/$hungry['crop']);
|
||||||
$hungry=${'u'.$maxtype};
|
else $killunits = 0;
|
||||||
|
|
||||||
if ($hungry['crop']>0 && $oldcrop <=0) {
|
if($killunits > 0)
|
||||||
$killunits = intval($difcrop/$hungry['crop']);
|
{
|
||||||
}else $killunits=0;
|
$pskolko = abs($skolko);
|
||||||
|
if($killunits > $pskolko && $skolko < 0) $killunits = $pskolko;
|
||||||
|
|
||||||
if($killunits > 0){
|
if($maxtype == "hero" && $maxcount > 0)
|
||||||
$pskolko = abs($skolko);
|
{
|
||||||
if($killunits > $pskolko && $skolko <0){
|
$totalunits = $maxcount;
|
||||||
$killunits = $pskolko;
|
$database->modifyHero("dead", 1, $heroinfo['heroid']);
|
||||||
|
$database->modifyHero("health", 0, $heroinfo['heroid']);
|
||||||
}
|
}
|
||||||
if (isset($enf)){
|
|
||||||
if($killunits < $maxcount){
|
if (isset($enf))
|
||||||
$database->modifyEnforce($enf, $maxtype, $killunits, 0);
|
{
|
||||||
$database->setVillageField(
|
if($killunits < $totalunits)
|
||||||
$starv['wref'],
|
{
|
||||||
['starv', 'starvupdate'],
|
$database->modifyEnforce($enf['id'], $maxtype, min($killunits, $maxcount), 0);
|
||||||
[$upkeep, $time]
|
|
||||||
);
|
|
||||||
$database->modifyResource($starv['wref'],0,0,0,$hungry['crop'],1);
|
|
||||||
|
|
||||||
if($maxtype == "hero"){
|
|
||||||
$heroid = $database->getHeroField($database->getVillageField($enf,"owner"),"heroid");
|
|
||||||
$database->modifyHero("dead", 1, $heroid);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$database->deleteReinf($enf);
|
|
||||||
$database->setVillageField(
|
|
||||||
$starv['wref'],
|
|
||||||
['starv', 'starvupdate'],
|
|
||||||
[$upkeep, $time]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if($killunits < $maxcount){
|
|
||||||
$database->modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0));
|
|
||||||
$database->setVillageField(
|
|
||||||
$starv['wref'],
|
|
||||||
['starv', 'starvupdate'],
|
|
||||||
[$upkeep, $time]
|
|
||||||
);
|
|
||||||
$database->modifyResource($starv['wref'],0,0,0,$hungry['crop'],1);
|
|
||||||
if($maxtype == "hero"){
|
|
||||||
$heroid = $database->getHeroField($starv['owner'],"heroid");
|
|
||||||
$database->modifyHero("dead", 1, $heroid);
|
|
||||||
}
|
|
||||||
}elseif($killunits > $maxcount){
|
|
||||||
$killunits = $maxcount;
|
|
||||||
$database->modifyUnit($starv['wref'], array($maxtype), array($killunits), array(0));
|
|
||||||
$database->setVillageField(
|
|
||||||
$starv['wref'],
|
|
||||||
['starv', 'starvupdate'],
|
|
||||||
[$upkeep, $time]
|
|
||||||
);
|
|
||||||
|
|
||||||
if($maxtype == "hero"){
|
|
||||||
$heroid = $database->getHeroField($starv['owner'],"heroid");
|
|
||||||
$database->modifyHero("dead", 1, $heroid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else $database->deleteReinf($enf['id']);
|
||||||
}
|
}
|
||||||
|
elseif(isset($att))
|
||||||
|
{
|
||||||
|
if($killunits < $totalunits)
|
||||||
|
{
|
||||||
|
$database->modifyAttack($att, $maxtypeatt, min($killunits, $maxcount));
|
||||||
|
}
|
||||||
|
else $database->setMovementProc($att);
|
||||||
|
}
|
||||||
|
elseif(isset($maxtype))
|
||||||
|
{
|
||||||
|
$database->modifyUnit($starv['wref'], [$maxtype], [min($killunits, $maxcount)], [0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($totalunits > 0)
|
||||||
|
{
|
||||||
|
$database->modifyResource($starv['wref'], 0, 0, 0, $hungry['crop'], 1);
|
||||||
|
$database->setVillageField($starv['wref'], ['starv', 'starvupdate'], [$upkeep, $time]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$crop = $database->getCropProdstarv($starv['wref'], false);
|
$crop = $database->getCropProdstarv($starv['wref'], false);
|
||||||
if ($crop > $upkeep){
|
|
||||||
$database->setVillageField(
|
if ($crop > $upkeep) $database->setVillageField($starv['wref'], ['starv', 'starvupdate'], [0, 0]);
|
||||||
$starv['wref'],
|
|
||||||
['starv', 'starvupdate'],
|
|
||||||
[0, 0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
unset ($starv,$unitarrays,$enforcearray,$enforce,$starvarray);
|
unset ($starv,$unitarrays,$enforcearray,$enforce,$starvarray,$enf,$att,$attackarray,$maxtype,$maxtypeatt,$heroinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists("GameEngine/Prevention/starvation.txt")) {
|
if(file_exists("GameEngine/Prevention/starvation.txt")) {
|
||||||
@@ -5133,10 +5147,10 @@ class Automation {
|
|||||||
if(file_exists("GameEngine/Prevention/climbers.txt")) {
|
if(file_exists("GameEngine/Prevention/climbers.txt")) {
|
||||||
unlink("GameEngine/Prevention/climbers.txt");
|
unlink("GameEngine/Prevention/climbers.txt");
|
||||||
}
|
}
|
||||||
global $database,$ranking;
|
global $database, $ranking;
|
||||||
$ranking->procRankArray();
|
$ranking->procRankArray();
|
||||||
$climbers = $ranking->getRank();
|
$climbers = $ranking->getRank();
|
||||||
if(count($ranking->getRank()) > 0){
|
if(count($climbers) > 0){
|
||||||
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
|
$q = "SELECT week FROM ".TB_PREFIX."medal order by week DESC LIMIT 0, 1";
|
||||||
$result = mysqli_query($database->dblink,$q);
|
$result = mysqli_query($database->dblink,$q);
|
||||||
if(mysqli_num_rows($result)) {
|
if(mysqli_num_rows($result)) {
|
||||||
@@ -5150,28 +5164,34 @@ class Automation {
|
|||||||
foreach($array as $user){
|
foreach($array as $user){
|
||||||
$newrank = $ranking->getUserRank($user['id']);
|
$newrank = $ranking->getUserRank($user['id']);
|
||||||
if($week > 1){
|
if($week > 1){
|
||||||
for($i=$newrank+1;$i<count($ranking->getRank());$i++) {
|
for($i=$newrank+1;$i<count($climbers);$i++) {
|
||||||
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
if(isset($climbers[$i]['userid'])){
|
||||||
$totalpoints = $oldrank - $climbers[$i]['oldrank'];
|
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
||||||
$database->removeclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
$totalpoints = $oldrank - $climbers[$i]['oldrank'];
|
||||||
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
$database->removeclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
||||||
|
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$database->updateoldrank($user['id'], $newrank);
|
$database->updateoldrank($user['id'], $newrank);
|
||||||
}else{
|
}else{
|
||||||
$totalpoints = count($ranking->getRank()) - $newrank;
|
$totalpoints = count($climbers) - $newrank;
|
||||||
$database->setclimberrankpop($user['id'], $totalpoints);
|
$database->setclimberrankpop($user['id'], $totalpoints);
|
||||||
$database->updateoldrank($user['id'], $newrank);
|
$database->updateoldrank($user['id'], $newrank);
|
||||||
for($i=1;$i<$newrank;$i++){
|
for($i=1;$i<$newrank;$i++){
|
||||||
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
if(isset($climbers[$i]['userid'])){
|
||||||
$totalpoints = count($ranking->getRank()) - $oldrank;
|
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
||||||
$database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
$totalpoints = count($climbers) - $oldrank;
|
||||||
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
$database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
||||||
|
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for($i=$newrank+1;$i<count($ranking->getRank());$i++){
|
for($i=$newrank+1;$i<count($climbers);$i++){
|
||||||
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
if(isset($climbers[$i]['userid'])){
|
||||||
$totalpoints = count($ranking->getRank()) - $oldrank;
|
$oldrank = $ranking->getUserRank($climbers[$i]['userid']);
|
||||||
$database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
$totalpoints = count($climbers) - $oldrank;
|
||||||
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
$database->setclimberrankpop($climbers[$i]['userid'], $totalpoints);
|
||||||
|
$database->updateoldrank($climbers[$i]['userid'], $oldrank);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ class Battle {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[6] = pow($rap/$rdp*$moralbonus,$Mfactor);
|
$result[6] = pow($rap/($rdp*$moralbonus > 0 ? $rdp*$moralbonus : 1),$Mfactor);
|
||||||
|
|
||||||
$total_att_units = count($units['Att_unit']);
|
$total_att_units = count($units['Att_unit']);
|
||||||
$start = intval(($att_tribe-1)*10+1);
|
$start = intval(($att_tribe-1)*10+1);
|
||||||
|
|||||||
+1
-17
@@ -1869,22 +1869,6 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to get the population of the whole account
|
|
||||||
*
|
|
||||||
* @param int $uid the user id
|
|
||||||
* @return int Returns the total population of the account
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getTotalPopulation($uid){
|
|
||||||
list($uid) = $this->escape_input((int) $uid);
|
|
||||||
|
|
||||||
$q = "SELECT Sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = ".$uid."";
|
|
||||||
$result = mysqli_query($this->dblink, $q);
|
|
||||||
$row = mysqli_fetch_row($result);
|
|
||||||
return $row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getVillageByWorldID($vid, $use_cache = true) {
|
function getVillageByWorldID($vid, $use_cache = true) {
|
||||||
$array_passed = is_array($vid);
|
$array_passed = is_array($vid);
|
||||||
@@ -7788,7 +7772,7 @@ References:
|
|||||||
function KillMyHero($id) {
|
function KillMyHero($id) {
|
||||||
list( $id ) = $this->escape_input( (int) $id );
|
list( $id ) = $this->escape_input( (int) $id );
|
||||||
|
|
||||||
$q = "UPDATE " . TB_PREFIX . "hero set dead = 1, intraining = 0, inrevive = 0 where uid = " . $id . " AND dead = 0";
|
$q = "UPDATE " . TB_PREFIX . "hero set dead = 1, intraining = 0, inrevive = 0, health = 0 where uid = " . $id . " AND dead = 0";
|
||||||
|
|
||||||
return mysqli_query( $this->dblink, $q );
|
return mysqli_query( $this->dblink, $q );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ class Technology {
|
|||||||
$ABUpgradesCount = count($ABUpgrades);
|
$ABUpgradesCount = count($ABUpgrades);
|
||||||
|
|
||||||
$ups = 0;
|
$ups = 0;
|
||||||
if(count($ABUpgradesCount) > 0){
|
if($ABUpgradesCount > 0){
|
||||||
foreach($ABUpgrades as $upgrade){
|
foreach($ABUpgrades as $upgrade){
|
||||||
if(in_array(("b".$get['a']), $upgrade)) $ups++;
|
if(in_array(("b".$get['a']), $upgrade)) $ups++;
|
||||||
}
|
}
|
||||||
@@ -759,7 +759,7 @@ class Technology {
|
|||||||
$ABUpgradesCount = count($ABUpgrades);
|
$ABUpgradesCount = count($ABUpgrades);
|
||||||
|
|
||||||
$ups = 0;
|
$ups = 0;
|
||||||
if(count($ABUpgradesCount) > 0){
|
if($ABUpgradesCount > 0){
|
||||||
foreach($ABUpgrades as $upgrade){
|
foreach($ABUpgrades as $upgrade){
|
||||||
if(in_array(("a".$get['a']), $upgrade)) $ups++;
|
if(in_array(("a".$get['a']), $upgrade)) $ups++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ class Units {
|
|||||||
|
|
||||||
public function returnTroops($wref,$mode=0) {
|
public function returnTroops($wref,$mode=0) {
|
||||||
global $database;
|
global $database;
|
||||||
if (!mode) {
|
if (!$mode) {
|
||||||
$getenforce=$database->getEnforceVillage($wref,0);
|
$getenforce=$database->getEnforceVillage($wref,0);
|
||||||
foreach($getenforce as $enforce) {
|
foreach($getenforce as $enforce) {
|
||||||
$this->processReturnTroops($enforce);
|
$this->processReturnTroops($enforce);
|
||||||
@@ -414,14 +414,10 @@ class Units {
|
|||||||
array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
||||||
);
|
);
|
||||||
|
|
||||||
$data21 = $database->getUserField( $database->getVrefField( $village->wid, 'owner' )['owner'], 'tribe', 0 );
|
$fromcoor = $database->getCoor( $village->wid );
|
||||||
$eigen = $database->getCoor( $village->wid );
|
$from = array('x' => $fromcoor['x'], 'y' => $fromcoor['y']);
|
||||||
$from = array( 'x' => $eigen['x'], 'y' => $eigen['y'] );
|
$tocoor = $database->getCoor( $data['to_vid'] );
|
||||||
$ander = $database->getCoor( $data['to_vid'] );
|
$to = array('x' => $tocoor['x'], 'y' => $tocoor['y']);
|
||||||
$to = array( 'x' => $ander['x'], 'y' => $ander['y'] );
|
|
||||||
$start = ( $data21['tribe'] - 1 ) * 10 + 1;
|
|
||||||
$end = ( $data21['tribe'] * 10 );
|
|
||||||
|
|
||||||
$speeds = array();
|
$speeds = array();
|
||||||
$scout = 1;
|
$scout = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ $total_for2 = count($send);
|
|||||||
for($y=0;$y < $total_for;$y++){
|
for($y=0;$y < $total_for;$y++){
|
||||||
for($i=0;$i < $total_for2;$i++){
|
for($i=0;$i < $total_for2;$i++){
|
||||||
if($units[$y]['ref'] == $send[$i]['ref2']){
|
if($units[$y]['ref'] == $send[$i]['ref2']){
|
||||||
$res1 = mysqli_query($GLOBALS['link'],"SELECT wood, clay, iron, crop FROM " . TB_PREFIX . "send where id = ".(int) $send[$i]['ref']."");
|
$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);
|
$res = mysqli_fetch_array($res1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user