Fixed trap bugs

+Traps are now repaired (built) in the trapper building, instead of
instantly given after a successful normal attack or a dismiss/releasing
from the rally point
+1/4 of trapped troops are now lost after a successful normal attack
+Traps are now released when troops die from starvation
+If you'll dismiss your trapped troops from the rally point, the gaul
player will be able to only repair 1/3 of the total used traps
+Created a new method to delete some redundant and duplicated code
starvation related
+The effect of WW building plans will be displayed correctly, when
they're active
+Troops related artifacts are now counted when building traps
+Some minor improovements and bug fixing
+Some clean-up
This commit is contained in:
iopietro
2018-05-02 21:17:20 +02:00
parent 8a760b0aec
commit 9e2d2b6842
8 changed files with 485 additions and 584 deletions
+236 -336
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -855,7 +855,7 @@ class MYSQLi_DB implements IDbConnection {
return $ret;
}
// no n eed to cache this method
// no need to cache this method
function getSitee($uid) {
list($uid) = $this->escape_input((int) $uid);
@@ -6111,13 +6111,13 @@ References: User ID/Message ID, Mode
else{$unit = 'u' . $unit;}
++$i;
//Fixed part of negativ troops (double troops) - by InCube
//Fixed part of negative troops (double troops) - by InCube
$array_amt[$i] = (int) $array_amt[$i] < 0 ? 0 : $array_amt[$i];
//Fixed part of negativ troops (double troops) - by InCube
//Fixed part of negative troops (double troops) - by InCube
$units .= $unit.' = '.$unit.' '.(($array_mode[$i] == 1)? '+':'-').' '.($array_amt[$i] ? $array_amt[$i] : 0).(($number > $i+1) ? ', ' : '');
}
$q = "UPDATE ".TB_PREFIX."units set $units WHERE vref = $vref";
return mysqli_query($this->dblink,$q);
return mysqli_query($this->dblink, $q);
}
function getEnforce($vid, $from, $use_cache = true) {
+14 -13
View File
@@ -1003,19 +1003,20 @@ define("REQUIRED_LEVEL","Required level");
define("TIME_CONQUER","Time of conquer");
define("TIME_ACTIVATION","Time of activation");
define("FORMER_OWNER","Former owner(s)");
define("BUILDING_STRONGER","building stronger with");
define("BUILDING_WEAKER","building weaker with");
define("TROOPS_FASTER","makes troops faster with");
define("TROOPS_SLOWEST","makes troops slowest with");
define("SPIES_INCREASE","spies increase ability with");
define("SPIES_DECRESE","spies decrese ability with");
define("CONSUME_LESS","all troops consume less with");
define("CONSUME_HIGH","all troops consume high with");
define("TROOPS_MAKE_FASTER","troops make faster with");
define("TROOPS_MAKE_SLOWEST","troops make slowest with");
define("YOU_CONSTRUCT","you can construct ");
define("CRANNY_INCREASED","cranny capacity is increased by");
define("CRANNY_DECRESE","cranny capacity is decrese by");
define("BUILDING_STRONGER","Building stronger with");
define("BUILDING_WEAKER","Building weaker with");
define("TROOPS_FASTER","Makes troops faster with");
define("TROOPS_SLOWEST","Makes troops slowest with");
define("SPIES_INCREASE","Spies increase ability with");
define("SPIES_DECRESE","Spies decrese ability with");
define("CONSUME_LESS","All troops consume less with");
define("CONSUME_HIGH","All troops consume high with");
define("TROOPS_MAKE_FASTER","Troops make faster with");
define("TROOPS_MAKE_SLOWEST","Troops make slowest with");
define("YOU_CONSTRUCT","You can construct ");
define("CRANNY_INCREASED","Cranny capacity is increased by");
define("CRANNY_DECRESE","Cranny capacity is decrese by");
define("WW_BUILDING_PLAN","You can build the Wonder of the World");
define("NO_PREVIOUS_OWNERS","There are no previous owners.");
define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective.");
+25 -29
View File
@@ -507,7 +507,7 @@ class Technology {
return $database->getArtifactsValueInfluence($session->uid, $vid, 4, $upkeep);
}
private function trainUnit($unit,$amt,$great=false) {
private function trainUnit($unit, $amt, $great = false) {
global $session, $database, ${'u'.$unit}, $building, $village, $bid19, $bid20, $bid21, $bid25, $bid26, $bid29, $bid30, $bid36, $bid41, $bid42;
if($this->getTech($unit) || $unit % 10 <= 1 || $unit == 99) {
@@ -557,36 +557,32 @@ class Technology {
$each = round(($bid19[$building->getTypeLevel(36)]['attri'] / 100) * ${'u'.$unit}['time'] / SPEED);
}
if($unit%10 == 0 || $unit%10 == 9 && $unit != 99) {
$slots = $database->getAvailableExpansionTraining();
if($unit%10 == 0 && $slots['settlers'] <= $amt) { $amt = $slots['settlers']; }
if($unit%10 == 9 && $slots['chiefs'] <= $amt) { $amt = $slots['chiefs']; }
if($unit % 10 == 0 || $unit % 10 == 9 && $unit != 99) {
$slots = $database->getAvailableExpansionTraining();
if($unit % 10 == 0 && $slots['settlers'] <= $amt) $amt = $slots['settlers'];
if($unit % 10 == 9 && $slots['chiefs'] <= $amt) $amt = $slots['chiefs'];
} else {
if($unit != 99){
if($this->maxUnit($unit,$great) < $amt) {
$amt = 0;
}
}else{
$trainlist = $this->getTrainingList(8);
foreach($trainlist as $train) {
$train_amt += $train['amt'];
if($unit != 99){
if($this->maxUnit($unit, $great) < $amt) $amt = 0;
}else{
$trainlist = $this->getTrainingList(8);
foreach($trainlist as $train) $train_amt += $train['amt'];
$max = 0;
for($i = 19; $i < 41; $i++){
if($village->resarray['f'.$i.'t'] == 36){
$max += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
}
}
$max1 = $max - ($village->unitarray['u99'] + $train_amt);
if($max1 < $amt) $amt = 0;
}
}
$max = 0;
for($i=19;$i<41;$i++){
if($village->resarray['f'.$i.'t'] == 36){
$max += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
}
}
$max1 = $max - ($village->unitarray['u99'] + $train_amt);
if($max1 < $amt) {
$amt = 0;
}
}
}
$wood = ${'u'.$unit}['wood'] * $amt * ($great?3:1);
$clay = ${'u'.$unit}['clay'] * $amt * ($great?3:1);
$iron = ${'u'.$unit}['iron'] * $amt * ($great?3:1);
$crop = ${'u'.$unit}['crop'] * $amt * ($great?3:1);
$wood = ${'u'.$unit}['wood'] * $amt * ($great ? 3 : 1);
$clay = ${'u'.$unit}['clay'] * $amt * ($great ? 3 : 1);
$iron = ${'u'.$unit}['iron'] * $amt * ($great ? 3 : 1);
$crop = ${'u'.$unit}['crop'] * $amt * ($great ? 3 : 1);
if($database->modifyResource($village->wid, $wood , $clay, $iron, $crop, 0) && $amt > 0) {
$database->trainUnit($village->wid, $unit + ($great ? 60 : 0), $amt, ${'u'.$unit}['pop'], $each, 0);
+172 -139
View File
@@ -1,7 +1,4 @@
<?php
use App\Database\IDbConnection;
#################################################################################
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ##
@@ -19,110 +16,96 @@ use App\Database\IDbConnection;
#################################################################################
class Units {
public $sending,$recieving,$return = array();
public $sending, $recieving, $return = [];
public function procUnits($post) {
if(isset($post['c'])) {
if (!isset($post['disabled'])) {
$post['disabled'] = '';
}
if (!isset($post['disabled'])) $post['disabled'] = '';
switch($post['c']) {
case "1":
if (isset($post['a'])&& $post['a']==533374){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
if (isset($post['a'])&& $post['a']==533374){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
case "2":
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
case "8":
$this->sendTroopsBack($post);
break;
$this->sendTroopsBack($post);
break;
case "3":
if (isset($post['a'])&& $post['a']==533374 && $post['disabled'] == ""){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else{
$post = $this->loadUnits($post);
return $post;
}
break;
case "4":
if (isset($post['a'])&& $post['a']==533374){
$this->sendTroops($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
if (isset($post['a']) && $post['a'] == 533374) $this->sendTroops($post);
else{
$post = $this->loadUnits($post);
return $post;
}
case "5":
if (isset($post['a']) && $post['a']== "new"){
$this->Settlers($post);
}else{
$post = $this->loadUnits($post);
return $post;
}
break;
if (isset($post['a']) && $post['a'] == "new") $this->Settlers($post);
else
{
$post = $this->loadUnits($post);
return $post;
}
}
}
}
private function loadUnits($post) {
global $database,$village,$session,$generator,$logging,$form;
// Search by town name
// Coordinates and look confirm name people
if(isset($post['x']) && isset($post['y']) && $post['x'] != "" && $post['y'] != "") {
$vid = $database->getVilWref($post['x'],$post['y']);
unset($post['dname']);
unset($_POST['dname']);
}else if(isset($post['dname']) && $post['dname']!=""){
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']);
}else if(isset($post['dname']) && !empty($post['dname'])){
$vid = $database->getVillageByName(stripslashes($post['dname']));
}
if (!empty($vid)) {
if($database->isVillageOases($vid)){
$too = $database->getOasisField($vid,"conqured");
if($too == 0){
$disabledr ="disabled=disabled"; $disabled ="disabled=disabled";
}else{
$disabledr ="";
if($session->sit == 0){
$disabled ="";
}else{
$disabled ="disabled=disabled";
}
if($too == 0) $disabled = $disabledr ="disabled=disabled";
else
{
$disabledr = "";
if($session->sit == 0) $disabled = "";
else $disabled ="disabled=disabled";
}
}else{
$too = $database->getVillage($vid);
if($too['owner'] == 3){
$disabledr ="disabled=disabled"; $disabled ="";
$disabledr = "disabled=disabled";
$disabled = "";
}else{
$disabledr ="";
if($session->sit == 0){
$disabled ="";
}else{
$disabled ="disabled=disabled";
}
$disabledr = "";
if($session->sit == 0) $disabled = "";
else $disabled ="disabled=disabled";
}
}
}else{
$disabledr ="";
if($session->sit == 0){
$disabled ="";
}else{
$disabled ="disabled=disabled";
}
$disabledr = "";
if($session->sit == 0) $disabled = "";
else $disabled ="disabled=disabled";
}
if(!empty($disabledr) && $post['c'] == 2){
$form->addError("error","You can't reinforce this village/oasis");
@@ -134,8 +117,8 @@ class Units {
if($post['c'] < 2 || $post['c'] > 4) $form->addError("error", "Invalid attack type.");
if(empty($post['t1']) && empty($post['t2']) && empty($post['t3']) && empty($post['t4']) && empty($post['t5']) &&
empty($post['t6']) && empty($post['t7']) && empty($post['t8']) && empty($post['t9']) && empty($post['t10']) && empty($post['t11'])){
if(empty($post['t1']) && empty($post['t2']) && empty($post['t3']) && empty($post['t4']) && empty($post['t5']) &&
empty($post['t6']) && empty($post['t7']) && empty($post['t8']) && empty($post['t9']) && empty($post['t10']) && empty($post['t11'])){
$form->addError("error","You need to mark min. one troop");
}
@@ -143,31 +126,29 @@ class Units {
$form->addError("error","Insert name or coordinates");
}
if(isset($post['dname']) && $post['dname'] != "") {
if(isset($post['dname']) && !empty($post['dname'])) {
$id = $database->getVillageByName(stripslashes($post['dname']));
if (!isset($id)){
$form->addError("error","Village do not exist");
}else{
$coor = $database->getCoor($id);
}
if (!isset($id)) $form->addError("error","Village do not exist");
else $coor = $database->getCoor($id);
}
// People search by coordinates
// We confirm and seek coordinate coordinates Village
if(isset($post['x']) && isset($post['y']) && $post['x'] != "" && $post['y'] != "") {
$coor = array('x'=>$post['x'], 'y'=>$post['y']);
$id = $generator->getBaseID($coor['x'],$coor['y']);
if (!$database->getVillageState($id)){
$form->addError("error","Coordinates do not exist");
}
if(isset($post['x']) && isset($post['y']) && !empty($post['x']) && !empty($post['y'])) {
$coor = ['x' => $post['x'], 'y' => $post['y']];
$id = $generator->getBaseID($coor['x'], $coor['y']);
if (!$database->getVillageState($id)) $form->addError("error","Coordinates do not exist");
}
if (!empty($coor)) {
if ($session->tribe == 1){$Gtribe = "";}elseif ($session->tribe == 2){$Gtribe = "1";}elseif ($session->tribe == 3){$Gtribe = "2";}elseif ($session->tribe == 4){$Gtribe = "3";}elseif ($session->tribe == 5){$Gtribe = "4";}
for($i=1; $i<12; $i++){
$Gtribe = $session->tribe == 1 ? "" : $session->tribe - 1;
for($i = 1; $i < 12; $i++){
if(isset($post['t'.$i])){
if ($i<10) $troophave=$village->unitarray['u'.$Gtribe.$i];
if ($i==10)$troophave=$village->unitarray['u'.floor(intval($Gtribe)+1)*$i];
if ($i==11)$troophave=$village->unitarray['hero'];
if ($i < 10) $troophave = $village->unitarray['u'.$Gtribe.$i];
if ($i == 10) $troophave = $village->unitarray['u'.floor(intval($Gtribe) + 1) * $i];
if ($i == 11) $troophave = $village->unitarray['hero'];
if (intval($post['t'.$i]) > $troophave){
$form->addError("error","You can't send more units than you have");
@@ -184,63 +165,61 @@ class Units {
}
}
}
if (isset($id) && $database->isVillageOases($id) == 0) {
if($database->hasBeginnerProtection($id)==1) {
$form->addError("error","Player is under beginners protection. You can't attack him");
}
//check if banned/admin:
$villageOwner = $database->getVillageField($id,'owner');
$userAccess = $database->getUserField($villageOwner,'access',0);
$userID = $database->getUserField($villageOwner,'id',0);
if($userAccess == '0' or ($userAccess == MULTIHUNTER && $userID == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)){
$form->addError("error","Player is Banned. You can't attack him");
//break;
}
//check if vacation mode:
if($database->getvacmodexy($id)){
$form->addError("error","User is on vacation mode");
//break;
}
//check if attacking same village that units are in
if($id == $village->wid){
$form->addError("error","You cant attack same village you are sending from.");
//break;
}
// We process the array with the errors given in the form
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
exit;
}else{
if(isset($id) && $database->isVillageOases($id) == 0) {
if($database->hasBeginnerProtection($id) == 1) {
$form->addError("error","Player is under beginners protection. You can't attack him");
}
//check if banned/admin:
$villageOwner = $database->getVillageField($id,'owner');
$userAccess = $database->getUserField($villageOwner,'access',0);
$userID = $database->getUserField($villageOwner,'id',0);
if($userAccess == 0 or ($userAccess == MULTIHUNTER && $userID == 5) or (!ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN)){
$form->addError("error","Player is Banned. You can't attack him");
//break;
}
//check if vacation mode:
if($database->getvacmodexy($id)){
$form->addError("error","User is on vacation mode");
//break;
}
//check if attacking same village that units are in
if($id == $village->wid){
$form->addError("error","You cant attack same village you are sending from.");
//break;
}
// We process the array with the errors given in the form
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
exit;
}else{
// We must return an array with $ post, which contains all the data more
// another variable that will define the flag is raised and is being sent and the type of shipping
$villageName = $database->getVillageField($id,'name');
$speed= 300;
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
array_push($post, "$id", "$villageName", "$villageOwner","$timetaken");
return $post;
return $post;
}
}else{
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
exit;
} else if (isset($id)) {
}else{
if($form->returnErrors() > 0) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
header("Location: a2b.php");
exit;
} else if (isset($id)) {
$villageName = $database->getOasisField($id,"name");
$speed= 300;
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
array_push($post, "$id", "$villageName", "2","$timetaken");
return $post;
}
}
}
}
public function returnTroops($wref, $mode = 0) {
@@ -683,6 +662,60 @@ class Units {
}
}
/**
* Function to kill/release prisoners
*
* @param int the ID of the prisoners you want to release
*/
public function deletePrisoners($id){
global $village, $database, $session, $building, $bid19, $u99;
$prisoner = $database->getPrisonersByID($id);
$troops = 0;
if($prisoner['wref'] == $village->wid){
$p_owner = $database->getVillageField($prisoner['from'], "owner");
$p_tribe = $database->getUserField($p_owner, "tribe", 0);
$troopsTime = $this->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
$p_reference = $database->addAttack($prisoner['from'], $prisoner['t1'],$prisoner['t2'], $prisoner['t3'], $prisoner['t4'], $prisoner['t5'], $prisoner['t6'], $prisoner['t7'], $prisoner['t8'], $prisoner['t9'], $prisoner['t10'], $prisoner['t11'], 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
$database->addMovement(4, $prisoner['wref'], $prisoner['from'], $p_reference, time(), ($p_time + time()));
for($i = 1; $i <= 11; $i++) $troops += $prisoner['t'.$i];
//Reset traps
$database->modifyUnit($village->wid, ["99", "99o"], [$troops, $troops], [0, 0]);
$repairDuration = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[max($building->getTypeLevel(36, $village->wid), 1)]['attri'] / 100) * $u99['time'] / SPEED));
$database->trainUnit($village->wid, 99, $troops, $u99['pop'], $repairDuration, 0);
$database->deletePrisoners($prisoner['id']);
}else if($prisoner['from'] == $village->wid){
$prisonersToOwner = $database->getVillageField($prisoner['wref'], "owner");
for($i = 1; $i <= 11; $i++) $troops += $prisoner['t'.$i];
if($prisoner['t11'] > 0){
$p_owner = $database->getVillageField($prisoner['from'], "owner");
mysqli_query($database->dblink, "UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."' AND dead = 0");
}
//Reset traps
$database->modifyUnit($prisoner['wref'], ["99", "99o"], [$troops, $troops], [0, 0]);
if(($troops = round($troops / 3)) > 0){
$repairDuration = $database->getArtifactsValueInfluence($prisonersToOwner, $prisoner['wref'], 5, round(($bid19[max($building->getTypeLevel(36, $prisoner['wref']), 1)]['attri'] / 100) * $u99['time'] / SPEED));
$database->trainUnit($prisoner['wref'], 99, $troops, $u99['pop'], $repairDuration, 0);
}
$database->deletePrisoners($prisoner['id']);
}
header("Location: build.php?id=39");
exit;
}
/**
* Get how much time troops spend to walk from a village to another
*
+1 -1
View File
@@ -52,7 +52,7 @@ switch($kind){
$betterorbadder = $artefactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
break;
}
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effecty)."</b>)" : "<b>Not yet active</b>";
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effecty)."</b>)" : (($kind == 11 && $artefact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");
?>
+29 -35
View File
@@ -13,8 +13,7 @@ include("next.tpl");
<table cellpadding="1" cellspacing="1" id="build_value">
<tr>
<th><?php echo CURRENT_TRAPS; ?></th>
<td><b><?php echo $bid36[$village->resarray['f'.$id]]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
<td><b><?php echo $bid36[$village->resarray['f'.$id]]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
</tr>
<tr>
<?php
@@ -23,12 +22,12 @@ include("next.tpl");
if($next<=20){
?>
<th><?php echo TRAPS_LEVEL; ?> <?php echo $next; ?>:</th>
<td><b><?php echo $bid36[$next]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
<td><b><?php echo $bid36[$next]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
<?php
}else{
?>
<th><?php echo TRAPS_LEVEL; ?> 20:</th>
<td><b><?php echo $bid36[20]['attri']*TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
<td><b><?php echo $bid36[20]['attri'] * TRAPPER_CAPACITY; ?></b> <?php echo TRAPS; ?></td>
<?php
}
}
@@ -66,34 +65,31 @@ include("next.tpl");
alt="Iron" title="<?php echo IRON; ?>" />10|</span><span><img class="r4" src="img/x.gif"
alt="Crop" title="<?php echo CROP; ?>" />20|</span><span><img class="r5" src="img/x.gif" alt="Crop consumption"
title="<?php echo CROP_COM; ?>" />0|<img class="clock" src="img/x.gif"
alt="Duration" title="<?php echo DURATION; ?>" /><?php echo $generator->getTimeFormat(round(($bid19[$village->resarray['f'.$id]]['attri'] / 100) * ${'u99'}['time'] / SPEED)); ?></span>
alt="Duration" title="<?php echo DURATION; ?>" />
<?php echo $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, round(($bid19[$village->resarray['f'.$id]]['attri'] / 100) * ${'u99'}['time'] / SPEED))); ?>
</span>
</div>
</td>
<?php
$trainlist = $technology->getTrainingList(8);
foreach($trainlist as $train) {
$train_amt += $train['amt'];
foreach($trainlist as $train) $train_amt += $train['amt'];
$max = $technology->maxUnit(99, false);
$max1 = 0;
for($i = 19; $i < 41; $i++){
if($village->resarray['f'.$i.'t'] == 36){
$max1 += $bid36[$village->resarray['f'.$i]]['attri'] * TRAPPER_CAPACITY;
}
}
if (!isset($train_amt)) $train_amt = 0;
if($max > $max1 - ($village->unitarray['u99'] + $train_amt)){
$max = $max1 - ($village->unitarray['u99'] + $train_amt);
}
$max = $technology->maxUnit(99,false);
$max1 = 0;
for($i=19;$i<41;$i++){
if($village->resarray['f'.$i.'t'] == 36){
$max1 += $bid36[$village->resarray['f'.$i]]['attri']*TRAPPER_CAPACITY;
}
}
if (!isset($train_amt)) {
$train_amt = 0;
}
if($max > $max1 - ($village->unitarray['u99'] + $train_amt)){
$max = $max1 - ($village->unitarray['u99'] + $train_amt);
}
if($max < 0){
$max = 0;
}
if($max < 0) $max = 0;
?>
<td class="val"><input type="text" class="text" name="t99" value="0" maxlength="4"></td>
<td class="max"><a href="#" onClick="document.snd.t99.value=<?php echo $max; ?>">(<?php echo $max; ?>)</a></td>
@@ -105,7 +101,7 @@ include("next.tpl");
} else {
echo "<b>".TRAINING_COMMENCE_TRAPPER."</b><br>\n";
}
if(count($trainlist) > 0) {
if(!empty($trainlist)) {
echo "
<table cellpadding=\"1\" cellspacing=\"1\" class=\"under_progress\">
<thead><tr>
@@ -120,17 +116,15 @@ include("next.tpl");
echo "<tr><td class=\"desc\">";
echo "<img class=\"unit u".$train['unit']."\" src=\"img/x.gif\" alt=\"".U99."\" title=\"".U99."\" />";
echo $train['amt']." ".U99."</td><td class=\"dur\">";
if ($TrainCount == 1 ) {
$NextFinished = $generator->getTimeFormat(($train['timestamp']-time())-($train['amt']-1)*$train['eachtime']);
echo "<span id=timer1>".$generator->getTimeFormat($train['timestamp']-time())."</span>";
} else {
echo $generator->getTimeFormat($train['eachtime']*$train['amt']);
}
if ($TrainCount == 1) {
$NextFinished = $generator->getTimeFormat(($train['timestamp'] - time()) - ($train['amt'] - 1) * $train['eachtime']);
echo "<span id=timer1>".$generator->getTimeFormat($train['timestamp'] - time())."</span>";
}
else echo $generator->getTimeFormat($train['eachtime'] * $train['amt']);
echo "</td><td class=\"fin\">";
$time = $generator->procMTime($train['timestamp']);
if($time[0] != "today") {
echo "on ".$time[0]." at ";
}
if($time[0] != "today") echo "on ".$time[0]." at ";
echo $time[1];
} ?>
</tr><tr class="next"><td colspan="3"><?php echo UNIT_FINISHED; ?> <span id="timer2"><?php echo $NextFinished; ?></span></td></tr>
+4 -27
View File
@@ -163,7 +163,7 @@ if(isset($_GET['o'])) {
if(isset($r)) {
$enforce = $database->getEnforceArray($r, 0);
$enforceoasis=$database->getOasisEnforceArray($r, 0);
if($enforce['from'] == $village->wid || $enforceoasis['conqured']==$village->wid) {
if($enforce['from'] == $village->wid || $enforceoasis['conqured'] == $village->wid) {
$to = $database->getVillage($enforce['from']);
$ckey = $r;
include ("Templates/a2b/sendback.tpl");
@@ -171,32 +171,10 @@ if(isset($_GET['o'])) {
include ("Templates/a2b/units_" . $session->tribe . ".tpl");
include ("Templates/a2b/search.tpl");
}
} else if(isset($delprisoners)){
$prisoner = $database->getPrisonersByID($delprisoners);
if($prisoner['wref'] == $village->wid){
$p_owner = $database->getVillageField($prisoner['from'],"owner");
$p_tribe = $database->getUserField($p_owner,"tribe",0);
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
$p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
$database->addMovement(4,$prisoner['wref'],$prisoner['from'],$p_reference,time(),($p_time+time()));
$troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
$database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($prisoner['id']);
}else if($prisoner['from'] == $village->wid){
$troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
if($prisoner['t11'] > 0){
$p_owner = $database->getVillageField($prisoner['from'],"owner");
mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."' AND dead = 0");
}
$database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0));
$database->deletePrisoners($prisoner['id']);
}
header("Location: build.php?id=39");
exit;
} else {
else if(isset($delprisoners) && !empty($delprisoners)) $units->deletePrisoners($delprisoners);
else
{
if(isset($process['0'])) {
$coor = $database->getCoor($process['0']);
include ("Templates/a2b/attack.tpl");
@@ -205,7 +183,6 @@ if(isset($_GET['o'])) {
include ("Templates/a2b/search.tpl");
}
}
?>
<br /><br /><br /><br /><div id="side_info">