mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Fix warsim security issue & hero building
Fix warsim security issue & hero building
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
@@ -17,6 +18,7 @@
|
||||
## Copyright : TravianZ (c) 2010-2025. All rights reserved. ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
#################################################################################
|
||||
|
||||
if($_SESSION['access'] < ADMIN) die("Access Denied!");
|
||||
$id = $_SESSION['id'];
|
||||
|
||||
|
||||
+28
-32
@@ -22,6 +22,32 @@
|
||||
$hero_info = $units->Hero($session->uid);
|
||||
$heroes = $units->Hero($session->uid, 1);
|
||||
$define['reset_level'] = 3; // Until which level you are able to reset your points
|
||||
// NOTE: $define['reset_level'] doesn't seem to be used in any of the
|
||||
// 37*.tpl files - the "3" threshold is hardcoded directly into 37_hero.tpl. Possible dead code
|
||||
// in these files; I left it unchanged (it can be read
|
||||
// in another part of the project that I don't see here).
|
||||
|
||||
// Explicit lookup instead of if/elseif chain - covers all 15
|
||||
// possible hero types (5 per tribe x 3 tribes). Same behavior:
|
||||
// if $hero_info['unit'] doesn't match any (which shouldn't
|
||||
// happen), $name returns null instead of "undefined variable".
|
||||
$heroUnitNames = [
|
||||
1 => U1,
|
||||
2 => U2,
|
||||
3 => U3,
|
||||
5 => U5,
|
||||
6 => U6,
|
||||
11 => U11,
|
||||
12 => U12,
|
||||
13 => U13,
|
||||
15 => U15,
|
||||
16 => U16,
|
||||
21 => U21,
|
||||
22 => U22,
|
||||
24 => U24,
|
||||
25 => U25,
|
||||
26 => U26,
|
||||
];
|
||||
|
||||
?>
|
||||
|
||||
@@ -36,37 +62,7 @@
|
||||
|
||||
<?php
|
||||
if ($hero_info) {
|
||||
if ( $hero_info['unit'] == 1 ) {
|
||||
$name = U1;
|
||||
} else if ( $hero_info['unit'] == 2 ) {
|
||||
$name = U2;
|
||||
} else if ( $hero_info['unit'] == 3 ) {
|
||||
$name = U3;
|
||||
} else if ( $hero_info['unit'] == 5 ) {
|
||||
$name = U5;
|
||||
} else if ( $hero_info['unit'] == 6 ) {
|
||||
$name = U6;
|
||||
} else if ( $hero_info['unit'] == 11 ) {
|
||||
$name = U11;
|
||||
} else if ( $hero_info['unit'] == 12 ) {
|
||||
$name = U12;
|
||||
} else if ( $hero_info['unit'] == 13 ) {
|
||||
$name = U13;
|
||||
} else if ( $hero_info['unit'] == 15 ) {
|
||||
$name = U15;
|
||||
} else if ( $hero_info['unit'] == 16 ) {
|
||||
$name = U16;
|
||||
} else if ( $hero_info['unit'] == 21 ) {
|
||||
$name = U21;
|
||||
} else if ( $hero_info['unit'] == 22 ) {
|
||||
$name = U22;
|
||||
} else if ( $hero_info['unit'] == 24 ) {
|
||||
$name = U24;
|
||||
} else if ( $hero_info['unit'] == 25 ) {
|
||||
$name = U25;
|
||||
} else if ( $hero_info['unit'] == 26 ) {
|
||||
$name = U26;
|
||||
}
|
||||
$name = $heroUnitNames[$hero_info['unit']] ?? null;
|
||||
$name1 = $hero_info['name'];
|
||||
} else {
|
||||
$name = 'Mr. Nobody';
|
||||
@@ -129,4 +125,4 @@
|
||||
}
|
||||
include ("upgrade.tpl"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+54
-62
@@ -20,14 +20,36 @@
|
||||
#################################################################################
|
||||
|
||||
include_once("GameEngine/Data/hero_full.php");
|
||||
global $database;
|
||||
global $database;
|
||||
|
||||
if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
$_POST['name'] = $database->escape(stripslashes($_POST['name']));
|
||||
mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `name`='".$_POST['name']."' where `uid`='".$database->escape($session->uid)."' AND dead = 0") or die("ERROR:".mysqli_error($database->dblink));
|
||||
if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
$_POST['name'] = $database->escape(stripslashes($_POST['name']));
|
||||
mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `name`='" . $_POST['name'] . "' where `uid`='" . $database->escape($session->uid) . "' AND dead = 0") or die("ERROR:" . mysqli_error($database->dblink));
|
||||
$hero_info['name'] = $_POST['name'];
|
||||
echo "".NAME_CHANGED."";
|
||||
echo "" . NAME_CHANGED . "";
|
||||
}
|
||||
|
||||
// Explicit lookup: action from URL (?add=...) => column from `hero` table.
|
||||
// Used for both "(+)" links in the table and for the update
|
||||
// in the DB below. Single source of truth instead of 5 identical blocks.
|
||||
$heroStatColumns = [
|
||||
'off' => 'attack',
|
||||
'deff' => 'defence',
|
||||
'obonus' => 'attackbonus',
|
||||
'dbonus' => 'defencebonus',
|
||||
'reg' => 'regeneration',
|
||||
];
|
||||
|
||||
// Render the "(+)" link for a stat, or "(+)" uneditable
|
||||
// if the hero has no more points or the stat is already at the top (100).
|
||||
// Identical behavior to the original 5 if/else blocks.
|
||||
$renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) {
|
||||
$field = $heroStatColumns[$action];
|
||||
if ($hero_info['points'] > 0 && $hero_info[$field] < 100) {
|
||||
return "<a href=\"build.php?id=" . $id . "&add=" . $action . "\">(<b>+</b>)</a>";
|
||||
}
|
||||
return "<span class=\"none\">(+)</span>";
|
||||
};
|
||||
?>
|
||||
|
||||
<table id="distribution" cellpadding="1" cellspacing="1">
|
||||
@@ -47,10 +69,7 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<td class="val"><?php echo $hero_info['atk']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['attack'])+1; ?>px;" alt="<?php echo $hero_info['atk']; ?>" title="<?php echo $hero_info['atk']; ?>" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['attack'] < 100) echo "<a href=\"build.php?id=".$id."&add=off\">(<b>+</b>)</a>";
|
||||
else echo "<span class=\"none\">(+)</span>";
|
||||
?>
|
||||
<?php echo $renderAddLink('off'); ?>
|
||||
</td>
|
||||
<td class="po"><?php echo $hero_info['attack']; ?></td>
|
||||
</tr>
|
||||
@@ -59,10 +78,7 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<td class="val"><?php echo $hero_info['dc'] . "/" . $hero_info['di']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['defence'])+1; ?>px;" alt="<?php echo ($hero_info['di']) . "/" . ($hero_info['dc']); ?>" title="<?php echo ($hero_info['di']) . "/" . ($hero_info['dc']); ?>" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['defence'] < 100) echo "<a href=\"build.php?id=".$id."&add=deff\">(<b>+</b>)</a>";
|
||||
else echo "<span class=\"none\">(+)</span>";
|
||||
?>
|
||||
<?php echo $renderAddLink('deff'); ?>
|
||||
</td>
|
||||
<td class="po"><?php echo $hero_info['defence']; ?></td>
|
||||
</tr>
|
||||
@@ -71,10 +87,7 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<td class="val"><?php echo ($hero_info['ob']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['ob']-1)*1000+1; ?>px;" alt="<?php echo ($hero_info['ob']-1)*100; ?>%" title="<?php echo ($hero_info['ob']-1)*100; ?>%" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['attackbonus'] < 100) echo "<a href=\"build.php?id=".$id."&add=obonus\">(<b>+</b>)</a>";
|
||||
else echo "<span class=\"none\">(+)</span>";
|
||||
?>
|
||||
<?php echo $renderAddLink('obonus'); ?>
|
||||
</td>
|
||||
<td class="po"><?php echo $hero_info['attackbonus']; ?></td>
|
||||
</tr>
|
||||
@@ -83,10 +96,7 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<td class="val"><?php echo ($hero_info['db']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['db']-1)*1000+1; ?>px;" alt="<?php echo ($hero_info['db']-1)*100; ?>%" title="<?php echo ($hero_info['db']-1)*100; ?>%" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['defencebonus'] < 100) echo "<a href=\"build.php?id=".$id."&add=dbonus\">(<b>+</b>)</a>";
|
||||
else echo "<span class=\"none\">(+)</span>";
|
||||
?>
|
||||
<?php echo $renderAddLink('dbonus'); ?>
|
||||
</td>
|
||||
<td class="po"><?php echo $hero_info['defencebonus']; ?></td>
|
||||
</tr>
|
||||
@@ -95,10 +105,7 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<td class="val"><?php echo ($hero_info['regeneration']*5*SPEED); ?>/<?php echo DAY; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['regeneration']*2)+1; ?>px;" alt="<?php echo ($hero_info['regeneration']*5*SPEED); ?>%/Day" title="<?php echo ($hero_info['regeneration']*5*SPEED); ?>%/Day" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['regeneration'] < 100) echo "<a href=\"build.php?id=".$id."&add=reg\">(<b>+</b>)</a>";
|
||||
else echo "<span class=\"none\">(+)</span>";
|
||||
?>
|
||||
<?php echo $renderAddLink('reg'); ?>
|
||||
</td>
|
||||
<td class="po"><?php echo $hero_info['regeneration']; ?></td>
|
||||
</tr>
|
||||
@@ -145,40 +152,25 @@ if (isset($_POST['name']) && !empty($_POST['name'])) {
|
||||
<p><?php echo YOUR_HERO_HAS; ?> <b><?php echo floor($hero_info['health']); ?></b>% <?php echo OF_HIT_POINTS; ?>.<br/>
|
||||
<?php echo YOUR_HERO_HAS; ?> <?php echo CONQUERED; ?> <b><?php echo $database->VillageOasisCount($village->wid); ?></b> <a href="build.php?id=<?php echo $id; ?>&land"><?php echo OASES; ?></a>.</p>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['add'])) {
|
||||
if($_GET['add'] == "reset") {
|
||||
if($hero_info['level'] <= 3){
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = (`level` * 5) + 5, `attack` = 0, `defence` = 0, `attackbonus` = 0, `defencebonus` = 0, `regeneration` = 0 WHERE `heroid` = " . $hero_info['heroid'] . " AND `level` <= 3 AND (`attack` != 0 OR `defence` != 0 OR `attackbonus` != 0 OR `defencebonus` != 0 OR `regeneration` != 0)");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if($_GET['add'] == "off") {
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `attack` < 100");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
if($_GET['add'] == "deff") {
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `defence` < 100");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
if($_GET['add'] == "obonus") {
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `attackbonus` < 100");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
if($_GET['add'] == "dbonus") {
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `defencebonus` < 100");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
if($_GET['add'] == "reg") {
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `regeneration` < 100");
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
// NOTE: the actions below are triggered by GET (?add=...) and modify
|
||||
// data in the DB. This was the original (without CSRF), I did not change this aspect -
|
||||
// it is an existing behavior in all build.php, not specific to this file.
|
||||
if (isset($_GET['add'])) {
|
||||
$action = $_GET['add'];
|
||||
|
||||
if ($action == "reset") {
|
||||
if ($hero_info['level'] <= 3) {
|
||||
mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `points` = (`level` * 5) + 5, `attack` = 0, `defence` = 0, `attackbonus` = 0, `defencebonus` = 0, `regeneration` = 0 WHERE `heroid` = " . $hero_info['heroid'] . " AND `level` <= 3 AND (`attack` != 0 OR `defence` != 0 OR `attackbonus` != 0 OR `defencebonus` != 0 OR `regeneration` != 0)");
|
||||
header("Location: build.php?id=" . $id . "");
|
||||
exit;
|
||||
}
|
||||
// if level > 3, exactly like in the original: nothing happens (no redirect).
|
||||
} elseif (isset($heroStatColumns[$action])) {
|
||||
$column = $heroStatColumns[$action];
|
||||
mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `$column` = `$column` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `$column` < 100");
|
||||
header("Location: build.php?id=" . $id . "");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
+65
-54
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
@@ -20,12 +20,57 @@
|
||||
#################################################################################
|
||||
|
||||
$oasisarray = $database->getOasis($village->wid);
|
||||
if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid){
|
||||
$units->returnTroops($village->wid, 1);
|
||||
$database->removeOases($_GET['del']);
|
||||
header("Location: build.php?id=".$id."&land");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid) {
|
||||
$units->returnTroops($village->wid, 1);
|
||||
$database->removeOases($_GET['del']);
|
||||
header("Location: build.php?id=" . $id . "&land");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Explicit lookup, instead of the original repetitive switch:
|
||||
// each oasis type => which resources get bonus and how much.
|
||||
// Identical behavior to the original (same alt/title on each icon,
|
||||
// including the existing asymmetry: for wood, alt uses TZ_WOOD but
|
||||
// title uses LUMBER - kept exactly as in the original source).
|
||||
$oasisResourceIcons = [
|
||||
'wood' => ['class' => 'r1', 'alt' => TZ_WOOD, 'title' => LUMBER],
|
||||
'clay' => ['class' => 'r2', 'alt' => CLAY, 'title' => CLAY],
|
||||
'iron' => ['class' => 'r3', 'alt' => IRON, 'title' => IRON],
|
||||
'crop' => ['class' => 'r4', 'alt' => CROP, 'title' => CROP],
|
||||
];
|
||||
|
||||
$oasisTypeBonuses = [
|
||||
1 => [['wood', 25]],
|
||||
2 => [['wood', 25]],
|
||||
3 => [['wood', 25], ['crop', 25]],
|
||||
4 => [['clay', 25]],
|
||||
5 => [['clay', 25]],
|
||||
6 => [['clay', 25], ['crop', 25]],
|
||||
7 => [['iron', 25]],
|
||||
8 => [['iron', 25]],
|
||||
9 => [['iron', 25], ['crop', 25]],
|
||||
10 => [['crop', 25]],
|
||||
11 => [['crop', 25]],
|
||||
12 => [['crop', 50]],
|
||||
];
|
||||
|
||||
// Replace the original switch with 12 identical cases as the structure.
|
||||
// Unknown types => empty string, just like the lack of a 'default' in the original switch.
|
||||
$renderOasisBonus = function ($type) use ($oasisResourceIcons, $oasisTypeBonuses) {
|
||||
if (!isset($oasisTypeBonuses[$type])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($oasisTypeBonuses[$type] as $bonus) {
|
||||
[$resource, $percent] = $bonus;
|
||||
$icon = $oasisResourceIcons[$resource];
|
||||
$html .= '<img class="' . $icon['class'] . '" src="img/x.gif" alt="' . $icon['alt'] . '" title="' . $icon['title'] . '" />+' . $percent . '%';
|
||||
}
|
||||
|
||||
return $html;
|
||||
};
|
||||
?>
|
||||
<table id="oases" cellpadding="1" cellspacing="1">
|
||||
<thead><tr>
|
||||
@@ -40,64 +85,30 @@ if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
if(!empty($oasisarray)){
|
||||
for($i = 0; $i < count($oasisarray); $i++){
|
||||
$oasiscoor = $database->getCoor($oasisarray[$i]['wref']);
|
||||
if (!empty($oasisarray)) {
|
||||
foreach ($oasisarray as $oasis) {
|
||||
$oasiscoor = $database->getCoor($oasis['wref']);
|
||||
?>
|
||||
<tr>
|
||||
<td class="nam">
|
||||
<a href="build.php?gid=37&c=<?php echo $generator->getMapCheck($oasisarray[$i]['wref']); ?>&del=<?php echo $oasisarray[$i]['wref']; ?>&land"><img class="del" src="img/x.gif" alt="<?php echo DELETE; ?>" title="<?php echo DELETE; ?>"></a>
|
||||
<a href="karte.php?d=<?php echo $oasisarray[$i]['wref']; ?>&c=<?php echo $generator->getMapCheck($oasisarray[$i]['wref']) ?>"><?php echo $oasisarray[$i]['name']; ?></a>
|
||||
<a href="build.php?gid=37&c=<?php echo $generator->getMapCheck($oasis['wref']); ?>&del=<?php echo $oasis['wref']; ?>&land"><img class="del" src="img/x.gif" alt="<?php echo DELETE; ?>" title="<?php echo DELETE; ?>"></a>
|
||||
<a href="karte.php?d=<?php echo $oasis['wref']; ?>&c=<?php echo $generator->getMapCheck($oasis['wref']) ?>"><?php echo $oasis['name']; ?></a>
|
||||
</td>
|
||||
<td class="aligned_coords">
|
||||
<div class="cox">(<?php echo $oasiscoor['x']; ?></div>
|
||||
<div class="pi">|</div>
|
||||
<div class="coy"><?php echo $oasiscoor['y']; ?>)</div>
|
||||
</td>
|
||||
<td class="zp"><?php echo floor($oasisarray[$i]['loyalty']); ?>%</td>
|
||||
<td class="res"><?php
|
||||
switch($oasisarray[$i]['type']) {
|
||||
case 1:
|
||||
case 2:
|
||||
?><img class="r1" src="img/x.gif" alt="<?php echo TZ_WOOD; ?>" title="<?php echo LUMBER; ?>" />+25%<?php
|
||||
break;
|
||||
case 3:
|
||||
?><img class="r1" src="img/x.gif" alt="<?php echo TZ_WOOD; ?>" title="<?php echo LUMBER; ?>" />+25%
|
||||
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />+25%<?php
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
?><img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" />+25%<?php
|
||||
break;
|
||||
case 6:
|
||||
?><img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" />+25%
|
||||
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />+25%<?php
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
?><img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" />+25%<?php
|
||||
break;
|
||||
case 9:
|
||||
?><img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" />+25%
|
||||
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />+25%<?php
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
?><img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />+25%<?php
|
||||
break;
|
||||
case 12:
|
||||
?><img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" />+50%<?php
|
||||
break;
|
||||
}
|
||||
?></td>
|
||||
<td class="zp"><?php echo floor($oasis['loyalty']); ?>%</td>
|
||||
<td class="res"><?php echo $renderOasisBonus($oasis['type']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}else{
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td class="none" colspan="4"><?php echo NO_OASIS; ?></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
+130
-116
@@ -31,36 +31,102 @@
|
||||
|
||||
<?php
|
||||
|
||||
// check if there is a hero in revive already
|
||||
$reviving = $training = false;
|
||||
|
||||
foreach ($heroes as $hero_datarow) {
|
||||
if ($hero_datarow['inrevive']) $reviving = true;
|
||||
if ($hero_datarow['intraining']) $training = true;
|
||||
|
||||
$name = $technology->getUnitName($hero_datarow['unit']);
|
||||
|
||||
if($hero_datarow['level'] <= 60){
|
||||
$wood = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['wood']);
|
||||
$clay = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['clay']);
|
||||
$iron = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['iron']);
|
||||
$crop = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['crop']);
|
||||
$timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['time']) / SPEED);
|
||||
$training_time = $generator->getTimeFormat($timeToTrain);
|
||||
$training_time2 = time() + $timeToTrain;
|
||||
}else{
|
||||
$wood = (${'h'.$hero_datarow['unit'].'_full'}[60]['wood']);
|
||||
$clay = (${'h'.$hero_datarow['unit'].'_full'}[60]['clay']);
|
||||
$iron = (${'h'.$hero_datarow['unit'].'_full'}[60]['iron']);
|
||||
$crop = (${'h'.$hero_datarow['unit'].'_full'}[60]['crop']);
|
||||
$timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, (${'h'.$hero_datarow['unit'].'_full'}[60]['time']) / SPEED);
|
||||
$training_time = $generator->getTimeFormat($timeToTrain);
|
||||
$training_time2 = time() + $timeToTrain;
|
||||
}
|
||||
|
||||
if($hero_datarow['inrevive'] == 1) {
|
||||
$timeleft = $generator->getTimeFormat($hero_datarow['trainingtime'] - time());
|
||||
?>
|
||||
// Explicit lookup instead of dynamic variables ${'h'.$unit.'_full'}.
|
||||
// The variables h1_full, h2_full, ... h26_full are defined elsewhere
|
||||
// (hero_full.php / build.php's global context), exactly as they were
|
||||
// accessed dynamically in the original - here we just put them in a single array,
|
||||
// without changing where the values come from.
|
||||
$heroFullData = [
|
||||
1 => $h1_full ?? [],
|
||||
2 => $h2_full ?? [],
|
||||
3 => $h3_full ?? [],
|
||||
5 => $h5_full ?? [],
|
||||
6 => $h6_full ?? [],
|
||||
11 => $h11_full ?? [],
|
||||
12 => $h12_full ?? [],
|
||||
13 => $h13_full ?? [],
|
||||
15 => $h15_full ?? [],
|
||||
16 => $h16_full ?? [],
|
||||
21 => $h21_full ?? [],
|
||||
22 => $h22_full ?? [],
|
||||
24 => $h24_full ?? [],
|
||||
25 => $h25_full ?? [],
|
||||
26 => $h26_full ?? [],
|
||||
];
|
||||
|
||||
// The "can be resurrected" line was duplicated identically in the original: one version
|
||||
// for the base unit of the tribe (without research check) and one for
|
||||
// the rest of the units (with research check) - but the generated HTML was byte-for-byte
|
||||
// the same. Extracted here once, called from both branches below.
|
||||
$renderReviveRow = function ($hero_datarow, $name, $wood, $clay, $iron, $crop, $training_time, $id) use ($session, $building, $village) {
|
||||
$total_required = (int) ($wood + $clay + $iron + $crop);
|
||||
|
||||
$html = "<tr>";
|
||||
$html .= "<td class=\"desc\">";
|
||||
$html .= "<div class=\"tit\">";
|
||||
$html .= "<img class=\"unit u" . $hero_datarow['unit'] . "\" src=\"img/x.gif\" alt=\"" . $name . "\" title=\"" . $name . "\" />";
|
||||
$html .= $name . " (Level " . $hero_datarow['level'] . ")";
|
||||
$html .= "</div>";
|
||||
$html .= "<div class=\"details\">";
|
||||
$html .= "<img class=\"r1\" src=\"img/x.gif\" alt=\"" . TZ_WOOD . "\" title=\"" . LUMBER . "\" />" . $wood . "|";
|
||||
$html .= "<img class=\"r2\" src=\"img/x.gif\" alt=\"" . CLAY . "\" title=\"" . CLAY . "\" />" . $clay . "|";
|
||||
$html .= "<img class=\"r3\" src=\"img/x.gif\" alt=\"" . IRON . "\" title=\"" . IRON . "\" />" . $iron . "|";
|
||||
$html .= "<img class=\"r4\" src=\"img/x.gif\" alt=\"" . CROP . "\" title=\"" . CROP . "\" />" . $crop . "|";
|
||||
$html .= "<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"" . CROP_COM . "\" />6|";
|
||||
$html .= "<img class=\"clock\" src=\"img/x.gif\" alt=\"" . DURATION . "\" title=\"" . DURATION . "\" />";
|
||||
$html .= $training_time;
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
if ($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$html .= "|<a href=\"build.php?gid=17&t=3&r1=" . $wood . "&r2=" . $clay . "&r3=" . $iron . "&r4=" . $crop . "\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$html .= "</div>";
|
||||
$html .= "</td>";
|
||||
|
||||
$html .= "<td class=\"val\" width=\"20%\" style=\"text-align: center\">";
|
||||
if ($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) {
|
||||
$html .= "<span class=\"none\">" . NOT . "" . ENOUGH_RESOURCES . "</span>";
|
||||
} else {
|
||||
$html .= "<a href=\"build.php?id=" . $id . "&revive=1&hid=" . $hero_datarow['heroid'] . "\">" . REVIVE . "</a>";
|
||||
}
|
||||
$html .= "</td>";
|
||||
$html .= "</tr>";
|
||||
|
||||
return $html;
|
||||
};
|
||||
|
||||
// check if there is a hero in revive already
|
||||
$reviving = $training = false;
|
||||
|
||||
foreach ($heroes as $hero_datarow) {
|
||||
if ($hero_datarow['inrevive']) {
|
||||
$reviving = true;
|
||||
}
|
||||
if ($hero_datarow['intraining']) {
|
||||
$training = true;
|
||||
}
|
||||
|
||||
$name = $technology->getUnitName($hero_datarow['unit']);
|
||||
|
||||
// Collapsed the two branches (level <= 60 / level > 60) that differed
|
||||
// only by the key used in the lookup (current level vs. ceiling 60) -
|
||||
// same result, without duplicating the 5 calculation lines.
|
||||
$levelKey = ($hero_datarow['level'] <= 60) ? $hero_datarow['level'] : 60;
|
||||
$heroLevelData = $heroFullData[$hero_datarow['unit']][$levelKey];
|
||||
|
||||
$wood = $heroLevelData['wood'];
|
||||
$clay = $heroLevelData['clay'];
|
||||
$iron = $heroLevelData['iron'];
|
||||
$crop = $heroLevelData['crop'];
|
||||
|
||||
$timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $heroLevelData['time'] / SPEED);
|
||||
$training_time = $generator->getTimeFormat($timeToTrain);
|
||||
$training_time2 = time() + $timeToTrain;
|
||||
|
||||
if ($hero_datarow['inrevive'] == 1) {
|
||||
$timeleft = $generator->getTimeFormat($hero_datarow['trainingtime'] - time());
|
||||
?>
|
||||
<table id="distribution" cellpadding="1" cellspacing="1">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -70,6 +136,10 @@
|
||||
|
||||
<tr>
|
||||
<?php
|
||||
// NOTE (pre-existing bug, kept unchanged): $name1 comes from
|
||||
// the parent scope (37.tpl), where at this point in the flow it is
|
||||
// 'unknown' - NOT the real name of this $hero_datarow. Same
|
||||
// behavior as in the original file.
|
||||
echo "<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
@@ -80,95 +150,39 @@
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<?php }else if (!$reviving) if(in_array($hero_datarow['unit'], [1, 11, 21])){ ?>
|
||||
<tr>
|
||||
<td class="desc">
|
||||
<div class="tit">
|
||||
<img class="unit u<?php echo $hero_datarow['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
|
||||
<?php echo $name." (Level ".$hero_datarow['level'].")"; ?>
|
||||
</div>
|
||||
<div class="details">
|
||||
<img class="r1" src="img/x.gif" alt="<?php echo TZ_WOOD; ?>" title="<?php echo LUMBER; ?>" /><?php echo $wood; ?>|
|
||||
<img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" /><?php echo $clay; ?>|
|
||||
<img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" /><?php echo $iron; ?>|
|
||||
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" /><?php echo $crop; ?>|
|
||||
<img class="r5" src="img/x.gif" alt="Crop consumption" title="<?php echo CROP_COM; ?>" />6|
|
||||
<img class="clock" src="img/x.gif" alt="<?php echo DURATION; ?>" title="<?php echo DURATION; ?>" />
|
||||
<?php echo $training_time; ?>
|
||||
<?php
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($wood + $clay + $iron + $crop);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
echo "|<a href=\"build.php?gid=17&t=3&r1=".$wood."&r2=".$clay."&r3=".$iron."&r4=".$crop."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<?php
|
||||
} elseif (!$reviving) {
|
||||
if (in_array($hero_datarow['unit'], [1, 11, 21])) {
|
||||
// basic unit of the tribe - available without research
|
||||
echo $renderReviveRow($hero_datarow, $name, $wood, $clay, $iron, $crop, $training_time, $id);
|
||||
} else {
|
||||
if ($database->checkIfResearched($village->wid, 't' . $hero_datarow['unit']) != 0) {
|
||||
echo $renderReviveRow($hero_datarow, $name, $wood, $clay, $iron, $crop, $training_time, $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<td class="val" width="20%" style="text-align: center">
|
||||
<?php
|
||||
if($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) {
|
||||
echo "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else {
|
||||
echo "<a href=\"build.php?id=".$id."&revive=1&hid=".$hero_datarow['heroid']."\">".REVIVE."</a>";
|
||||
}
|
||||
|
||||
?></td>
|
||||
</tr>
|
||||
<?php }else { ?>
|
||||
|
||||
|
||||
<?php if($database->checkIfResearched($village->wid, 't'.$hero_datarow['unit']) != 0){ ?>
|
||||
<tr>
|
||||
<td class="desc">
|
||||
<div class="tit">
|
||||
<img class="unit u<?php echo $hero_datarow['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
|
||||
<?php echo $name." (Level ".$hero_datarow['level'].")"; ?>
|
||||
</div>
|
||||
<div class="details">
|
||||
<img class="r1" src="img/x.gif" alt="<?php echo TZ_WOOD; ?>" title="<?php echo LUMBER; ?>" /><?php echo $wood; ?>|
|
||||
<img class="r2" src="img/x.gif" alt="<?php echo CLAY; ?>" title="<?php echo CLAY; ?>" /><?php echo $clay; ?>|
|
||||
<img class="r3" src="img/x.gif" alt="<?php echo IRON; ?>" title="<?php echo IRON; ?>" /><?php echo $iron; ?>|
|
||||
<img class="r4" src="img/x.gif" alt="<?php echo CROP; ?>" title="<?php echo CROP; ?>" /><?php echo $crop; ?>|
|
||||
<img class="r5" src="img/x.gif" alt="Crop consumption" title="<?php echo CROP_COM; ?>" />6|
|
||||
<img class="clock" src="img/x.gif" alt="<?php echo DURATION; ?>" title="<?php echo DURATION; ?>" />
|
||||
<?php echo $training_time; ?>
|
||||
<?php
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($wood + $clay + $iron + $crop);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
echo "|<a href=\"build.php?gid=17&t=3&r1=".$wood."&r2=".$clay."&r3=".$iron."&r4=".$crop."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="val" width="20%" style="text-align: center">
|
||||
<?php
|
||||
if($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) {
|
||||
echo "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else {
|
||||
echo "<a href=\"build.php?id=".$id."&revive=1&hid=".$hero_datarow['heroid']."\">".REVIVE."</a>";
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
}
|
||||
|
||||
if(isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1){
|
||||
mysqli_query($database->dblink,"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'");
|
||||
$database->modifyResource($village->wid, $wood, $clay, $iron, $crop, 0);
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if (isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1) {
|
||||
mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `inrevive` = '1', `trainingtime` = '" . (int) $training_time2 . "', `wref` = '" . (int) $village->wid . "' WHERE `heroid` = " . (int) $_GET['hid'] . " AND `uid` = '" . (int) $session->uid . "'");
|
||||
$database->modifyResource($village->wid, $wood, $clay, $iron, $crop, 0);
|
||||
header("Location: build.php?id=" . $id . "");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</table><br />
|
||||
|
||||
|
||||
<?php
|
||||
if(!$reviving && !$training) include ("37_train.tpl");
|
||||
?>
|
||||
<?php
|
||||
// NOTE: plain include() (not include_once), just like in the original. It
|
||||
// is important to keep it that way - if 37_train.tpl has already been included from
|
||||
// 37.tpl via an include_once earlier in the same request, PHP
|
||||
// tracks the file as "already included" globally (regardless of what kind of
|
||||
// include it was first brought in), so a subsequent include_once in
|
||||
// 37.tpl will not re-run it. Changing to include_once here wouldn't be
|
||||
// wrong per se, but I preferred not to change this detail at all.
|
||||
if (!$reviving && !$training) {
|
||||
include("37_train.tpl");
|
||||
}
|
||||
?>
|
||||
|
||||
+158
-635
@@ -19,658 +19,181 @@
|
||||
## --------------------------------------------------------------------------- ##
|
||||
#################################################################################
|
||||
|
||||
// ============================================================================
|
||||
// REFACTOR - NOTE IMPORTANTE
|
||||
// ============================================================================
|
||||
// Two pre-existing bugs were found during the audit and are EXACTLY REPRODUCED
|
||||
// (not corrected), according to the rule of not changing logic:
|
||||
// 1) U3 (Imperian): in the original unfactored, the row did not close
|
||||
// </center></td></tr> - it was written as a string without "$output.=" in front,
|
||||
// so it was evaluated and thrown, with no effect. Replicated via the flag
|
||||
// 'skip_closing_tags' below.
|
||||
// 2) U13: the call $generator->getTimeFormat(...) for the training duration
|
||||
// was executed, but the result was never concatenated to $output -
|
||||
// the duration did not appear on that row at all. Replicated via the flag
|
||||
// 'skip_duration' below (the call is made identically, only the result
|
||||
// is no longer displayed).
|
||||
// If at some point you want to FIX these 2 bugs (not just keep them
|
||||
//), just delete the two entries in $bugOverrides below.
|
||||
// ============================================================================
|
||||
|
||||
//check if there is unit needed in the village
|
||||
|
||||
$result = mysqli_query($database->dblink,"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid."");
|
||||
$result = mysqli_query($database->dblink, "SELECT * FROM " . TB_PREFIX . "units WHERE `vref` = " . (int) $village->wid . "");
|
||||
$units_array = mysqli_fetch_array($result);
|
||||
|
||||
$count_hero = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC);
|
||||
$count_hero = mysqli_fetch_array(mysqli_query($database->dblink, "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC);
|
||||
$count_hero = $count_hero['Total'];
|
||||
|
||||
// Explicit lookup instead of dynamic variables ${'u'.$unitID}. Variables
|
||||
// u1, u2, u3, u5, u6, u11... are defined elsewhere (just like in
|
||||
// the original that accessed them dynamically) - here we just put them in a single
|
||||
// array, without changing where the values come from. The "?? []" fallback is just
|
||||
// defensive (avoid notices), the original didn't have one and assumed that
|
||||
// the variables always exist.
|
||||
$unitData = [
|
||||
1 => $u1 ?? [],
|
||||
2 => $u2 ?? [],
|
||||
3 => $u3 ?? [],
|
||||
5 => $u5 ?? [],
|
||||
6 => $u6 ?? [],
|
||||
11 => $u11 ?? [],
|
||||
12 => $u12 ?? [],
|
||||
13 => $u13 ?? [],
|
||||
15 => $u15 ?? [],
|
||||
16 => $u16 ?? [],
|
||||
21 => $u21 ?? [],
|
||||
22 => $u22 ?? [],
|
||||
24 => $u24 ?? [],
|
||||
25 => $u25 ?? [],
|
||||
26 => $u26 ?? [],
|
||||
];
|
||||
|
||||
// The single source of truth for "which units belong to each tribe", used
|
||||
// both when displaying the rows and when validating ?train=ID below (in
|
||||
// the original it was duplicated: once implicitly through the 3 if(tribe==X) blocks,
|
||||
// once explicitly in the switch in the validationArray).
|
||||
// The first ID in each list (1, 11, 21) is the base unit of the tribe -
|
||||
// it is always displayed, without research check, exactly as in the original.
|
||||
$tribeUnits = [
|
||||
1 => [1, 2, 3, 5, 6],
|
||||
2 => [11, 12, 13, 15, 16],
|
||||
3 => [21, 22, 24, 25, 26],
|
||||
];
|
||||
|
||||
// The 2 pre-existing bugs, explicitly identified on the unit (see note above).
|
||||
$bugOverrides = [
|
||||
3 => ['skip_closing_tags' => true],
|
||||
13 => ['skip_duration' => true],
|
||||
];
|
||||
|
||||
// Render a row from the hero training table for a unit.
|
||||
// Replace the 15 nearly identical blocks in the unfactored original.
|
||||
$renderTrainRow = function ($unitID, $unitData, $unitName, $units_array, $bugOptions = []) use ($database, $session, $village, $building, $generator, $id) {
|
||||
$skipDuration = $bugOptions['skip_duration'] ?? false;
|
||||
$skipClosingTags = $bugOptions['skip_closing_tags'] ?? false;
|
||||
|
||||
$data = $unitData[$unitID];
|
||||
|
||||
$row = "<tr>";
|
||||
$row .= "<td class=\"desc\">";
|
||||
$row .= "<div class=\"tit\">";
|
||||
$row .= "<img class=\"unit u" . $unitID . "\" src=\"img/x.gif\" alt=\"" . $unitName . "\" title=\"" . $unitName . "\" />";
|
||||
$row .= $unitName;
|
||||
$row .= "</div>";
|
||||
$row .= "<div class=\"details\">";
|
||||
$row .= "<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"" . LUMBER . "\" />" . $data['wood'] . "|";
|
||||
$row .= "<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"" . CLAY . "\" />" . $data['clay'] . "|";
|
||||
$row .= "<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"" . IRON . "\" />" . $data['iron'] . "|";
|
||||
$row .= "<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"" . CROP . "\" />" . $data['crop'] . "|";
|
||||
$row .= "<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"" . CROP_COM . "\" />6|";
|
||||
$row .= "<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"" . DURATION . "\" />";
|
||||
|
||||
// The call is always made (just like in the original, including for U13);
|
||||
// only the display of the result is omitted for the pre-existing bug of U13.
|
||||
$durationText = $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $data['time'] / SPEED) * 3);
|
||||
if (!$skipDuration) {
|
||||
$row .= $durationText;
|
||||
}
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int) ($data['wood'] + $data['clay'] + $data['iron'] + $data['crop']);
|
||||
if ($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$row .= "|<a href=\"build.php?gid=17&t=3&r1=" . $data['wood'] . "&r2=" . $data['clay'] . "&r3=" . $data['iron'] . "&r4=" . $data['crop'] . "\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$row .= "</div>";
|
||||
$row .= "</td>";
|
||||
$row .= "<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if ($village->awood < $data['wood'] || $village->aclay < $data['clay'] || $village->airon < $data['iron'] || $village->acrop < $data['crop']) {
|
||||
$row .= "<span class=\"none\">" . NOT . "" . ENOUGH_RESOURCES . "</span>";
|
||||
} elseif ($units_array['u' . $unitID] == 0) {
|
||||
$row .= "<span class=\"none\">" . NOT_UNITS . "</span>";
|
||||
} else {
|
||||
$row .= "<a href=\"build.php?id=" . $id . "&train=" . $unitID . "\">" . TRAIN . "</a>";
|
||||
}
|
||||
|
||||
// Pre-existing U3 bug: closing tags are no longer added.
|
||||
if (!$skipClosingTags) {
|
||||
$row .= "</center></td></tr>";
|
||||
}
|
||||
|
||||
return $row;
|
||||
};
|
||||
|
||||
if ($count_hero < 3) {
|
||||
|
||||
$output="<table cellpadding=1 cellspacing=1 class=\"build_details\">
|
||||
$output = "<table cellpadding=1 cellspacing=1 class=\"build_details\">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan=2>".TRAIN_HERO."</th>
|
||||
<th colspan=2>" . TRAIN_HERO . "</th>
|
||||
</tr>
|
||||
</thead>";
|
||||
|
||||
if($session->tribe == 1) {
|
||||
$output.=" <tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u1\" src=\"img/x.gif\" alt=\"".U1."\" title=\"".U1."\" />
|
||||
".U1."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u1['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u1['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u1['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u1['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />";
|
||||
$output .= $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5,$u1['time'] / SPEED)*3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u1['wood'] + $u1['clay'] + $u1['iron'] + $u1['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u1['wood']."&r2=".$u1['clay']."&r3=".$u1['iron']."&r4=".$u1['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
$output.="</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
|
||||
if($village->awood < $u1['wood'] || $village->aclay < $u1['clay'] || $village->airon < $u1['iron'] || $village->acrop < $u1['crop'])
|
||||
$output.="<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
elseif( $units_array['u1'] == 0)
|
||||
$output.="<span class=\"none\">".NOT_UNITS."</span>";
|
||||
else $output.="<a href=\"build.php?id=".$id."&train=1\">".TRAIN."</a>";
|
||||
|
||||
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't2') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u2\" src=\"img/x.gif\" alt=\"".U2."\" title=\"".U2."\" />
|
||||
".U2."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u2['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u2['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u2['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u2['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />";
|
||||
$output.=$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u2['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u2['wood'] + $u2['clay'] + $u2['iron'] + $u2['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u2['wood']."&r2=".$u2['clay']."&r3=".$u2['iron']."&r4=".$u2['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output.="</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u2['wood'] OR $village->aclay < $u2['clay'] OR $village->airon < $u2['iron'] OR $village->acrop < $u2['crop'])
|
||||
$output.="<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
elseif( $units_array['u2'] == 0)
|
||||
$output.="<span class=\"none\">".NOT_UNITS."</span>";
|
||||
else
|
||||
$output.="<a href=\"build.php?id=".$id."&train=2\">".TRAIN."</a>";
|
||||
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't3') != 0){
|
||||
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u3\" src=\"img/x.gif\" alt=\"".U3."\" title=\"".U3."\" />
|
||||
".U3."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u3['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u3['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u3['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u3['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />";
|
||||
|
||||
$output.= $generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u3['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u3['wood'] + $u3['clay'] + $u3['iron'] + $u3['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u3['wood']."&r2=".$u3['clay']."&r3=".$u3['iron']."&r4=".$u3['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output.= "</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u3['wood'] OR $village->aclay < $u3['clay'] OR $village->airon < $u3['iron'] OR $village->acrop < $u3['crop']) {
|
||||
$output.="<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u3'] == 0){
|
||||
$output.="<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.="<a href=\"build.php?id=".$id."&train=3\">".TRAIN."</a>";
|
||||
}
|
||||
"</center></td>
|
||||
</tr> " ;
|
||||
}
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't5') != 0){
|
||||
$output.= "<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u5\" src=\"img/x.gif\" alt=\"".U5."\" title=\"".U5."\" />
|
||||
".U5."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u5['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u5['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u5['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u5['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u5['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u5['wood'] + $u5['clay'] + $u5['iron'] + $u5['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u5['wood']."&r2=".$u5['clay']."&r3=".$u5['iron']."&r4=".$u5['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u5['wood'] OR $village->aclay < $u5['clay'] OR $village->airon < $u5['iron'] OR $village->acrop < $u5['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u5'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=5\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't6') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u6\" src=\"img/x.gif\" alt=\"".U6."\" title=\"".U6."\" />
|
||||
".U6."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u6['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u6['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u6['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u6['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u6['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u6['wood'] + $u6['clay'] + $u6['iron'] + $u6['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u6['wood']."&r2=".$u6['clay']."&r3=".$u6['iron']."&r4=".$u6['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center> ";
|
||||
|
||||
if($village->awood < $u6['wood'] OR $village->aclay < $u6['clay'] OR $village->airon < $u6['iron'] OR $village->acrop < $u6['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u6'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=6\">".TRAIN."</a>";
|
||||
}
|
||||
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
if($session->tribe == 2) {
|
||||
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u11\" src=\"img/x.gif\" alt=\"".U11."\" title=\"".U11."\" />
|
||||
".U11."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u11['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u11['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u11['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u11['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u11['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u11['wood'] + $u11['clay'] + $u11['iron'] + $u11['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u11['wood']."&r2=".$u11['clay']."&r3=".$u11['iron']."&r4=".$u11['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u11['wood'] OR $village->aclay < $u11['clay'] OR $village->airon < $u11['iron'] OR $village->acrop < $u11['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u11'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=11\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't12') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u12\" src=\"img/x.gif\" alt=\"".U12."\" title=\"".U12."\" />
|
||||
".U12."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u12['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u12['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u12['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u12['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u12['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u12['wood'] + $u12['clay'] + $u12['iron'] + $u12['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u12['wood']."&r2=".$u12['clay']."&r3=".$u12['iron']."&r4=".$u12['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u12['wood'] OR $village->aclay < $u12['clay'] OR $village->airon < $u12['iron'] OR $village->acrop < $u12['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u12'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=12\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't13') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u13\" src=\"img/x.gif\" alt=\"".U13."\" title=\"".U13."\" />
|
||||
".U13."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u13['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u13['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u13['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u13['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />";
|
||||
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u13['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u13['wood'] + $u13['clay'] + $u13['iron'] + $u13['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u13['wood']."&r2=".$u13['clay']."&r3=".$u13['iron']."&r4=".$u13['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u13['wood'] OR $village->aclay < $u13['clay'] OR $village->airon < $u13['iron'] OR $village->acrop < $u13['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u13'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=13\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't15') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u15\" src=\"img/x.gif\" alt=\"".U15."\" title=\"".U15."\" />
|
||||
".U15."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u15['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u15['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u15['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u15['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u15['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u15['wood'] + $u15['clay'] + $u15['iron'] + $u15['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u15['wood']."&r2=".$u15['clay']."&r3=".$u15['iron']."&r4=".$u15['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u15['wood'] OR $village->aclay < $u15['clay'] OR $village->airon < $u15['iron'] OR $village->acrop < $u15['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u15'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=15\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't16') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u16\" src=\"img/x.gif\" alt=\"".U16."\" title=\"".U16."\" />
|
||||
".U16."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u16['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u16['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u16['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u16['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u16['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u16['wood'] + $u16['clay'] + $u16['iron'] + $u16['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u16['wood']."&r2=".$u16['clay']."&r3=".$u16['iron']."&r4=".$u16['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u16['wood'] OR $village->aclay < $u16['clay'] OR $village->airon < $u16['iron'] OR $village->acrop < $u16['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u16'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=16\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($session->tribe == 3) {
|
||||
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u21\" src=\"img/x.gif\" alt=\"".U21."\" title=\"".U21."\" />
|
||||
".U21."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u21['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u21['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u21['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u21['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u21['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u21['wood'] + $u21['clay'] + $u21['iron'] + $u21['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u21['wood']."&r2=".$u21['clay']."&r3=".$u21['iron']."&r4=".$u21['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u21['wood'] OR $village->aclay < $u21['clay'] OR $village->airon < $u21['iron'] OR $village->acrop < $u21['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u21'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=21\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't22') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u22\" src=\"img/x.gif\" alt=\"".U22."\" title=\"".U22."\" />
|
||||
".U22."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u22['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u22['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u22['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u22['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u22['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u22['wood'] + $u22['clay'] + $u22['iron'] + $u22['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u22['wood']."&r2=".$u22['clay']."&r3=".$u22['iron']."&r4=".$u22['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u22['wood'] OR $village->aclay < $u22['clay'] OR $village->airon < $u22['iron'] OR $village->acrop < $u22['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u22'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=22\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't24') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u24\" src=\"img/x.gif\" alt=\"".U24."\" title=\"".U24."\" />
|
||||
".U24."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u24['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u24['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u24['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u24['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u24['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u24['wood'] + $u24['clay'] + $u24['iron'] + $u24['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u24['wood']."&r2=".$u24['clay']."&r3=".$u24['iron']."&r4=".$u24['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u24['wood'] OR $village->aclay < $u24['clay'] OR $village->airon < $u24['iron'] OR $village->acrop < $u24['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u24'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=24\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't25') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u25\" src=\"img/x.gif\" alt=\"".U25."\" title=\"".U25."\" />
|
||||
".U25."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u25['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u25['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u25['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u25['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u25['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u25['wood'] + $u25['clay'] + $u25['iron'] + $u25['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u25['wood']."&r2=".$u25['clay']."&r3=".$u25['iron']."&r4=".$u25['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u25['wood'] OR $village->aclay < $u25['clay'] OR $village->airon < $u25['iron'] OR $village->acrop < $u25['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u25'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=25\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
|
||||
if($database->checkIfResearched($village->wid, 't26') != 0){
|
||||
$output.="<tr>
|
||||
<td class=\"desc\">
|
||||
<div class=\"tit\">
|
||||
<img class=\"unit u26\" src=\"img/x.gif\" alt=\"".U26."\" title=\"".U26."\" />
|
||||
".U26."
|
||||
</div>
|
||||
<div class=\"details\">
|
||||
<img class=\"r1\" src=\"img/x.gif\" alt=\"Wood\" title=\"".LUMBER."\" />".$u26['wood']."|
|
||||
<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"".CLAY."\" />".$u26['clay']."|
|
||||
<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"".IRON."\" />".$u26['iron']."|
|
||||
<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"".CROP."\" />".$u26['crop']."|
|
||||
<img class=\"r5\" src=\"img/x.gif\" alt=\"Crop consumption\" title=\"".CROP_COM."\" />6|
|
||||
<img class=\"clock\" src=\"img/x.gif\" alt=\"Duration\" title=\"".DURATION."\" />".
|
||||
$generator->getTimeFormat($database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $u26['time'] / SPEED) * 3);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($u26['wood'] + $u26['clay'] + $u26['iron'] + $u26['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
$output .= "|<a href=\"build.php?gid=17&t=3&r1=".$u26['wood']."&r2=".$u26['clay']."&r3=".$u26['iron']."&r4=".$u26['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class=\"val\" width=\"20%\"><center>";
|
||||
|
||||
if($village->awood < $u26['wood'] OR $village->aclay < $u26['clay'] OR $village->airon < $u26['iron'] OR $village->acrop < $u26['crop']) {
|
||||
$output.= "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
|
||||
}else if( $units_array['u26'] == 0){
|
||||
$output.= "<span class=\"none\">".NOT_UNITS."</span>";
|
||||
}else {
|
||||
$output.= "<a href=\"build.php?id=".$id."&train=26\">".TRAIN."</a>";
|
||||
}
|
||||
$output.="</center></td>
|
||||
</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//HERO TRAINING
|
||||
if (isset($_GET['train'])) {
|
||||
$validationArray = [];
|
||||
switch ($session->tribe) {
|
||||
case 1: $validationArray = [1, 2, 3, 5, 6];
|
||||
break;
|
||||
|
||||
case 2: $validationArray = [11, 12, 13, 15, 16];
|
||||
break;
|
||||
|
||||
case 3: $validationArray = [21, 22, 24, 25, 26];
|
||||
break;
|
||||
}
|
||||
|
||||
// check for a valid unit value
|
||||
if (in_array($_GET['train'], $validationArray)) {
|
||||
if($count_hero < 3){
|
||||
$unitID = $_GET['train'];
|
||||
mysqli_query($database->dblink,"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES (".$database->escape($session->uid).", " . (int) $village->wid . ", 0, ".$unitID.", '".$database->escape($session->username)."', 0, 5, 0, 0, 100, 0, 0, 0, 0, ".round((time() + (${'u'.$unitID}['time'] / SPEED)*3)).", 50, 1)");
|
||||
mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "units SET `u$unitID` = `u$unitID` - 1 WHERE `vref` = " . (int) $village->wid);
|
||||
mysqli_query($database->dblink,"
|
||||
if (isset($tribeUnits[$session->tribe])) {
|
||||
foreach ($tribeUnits[$session->tribe] as $index => $unitID) {
|
||||
$isBaseUnit = ($index === 0); // u1 / u11 / u21: mereu afisat, fara research check
|
||||
$unitName = constant('U' . $unitID);
|
||||
$bugOptions = $bugOverrides[$unitID] ?? [];
|
||||
|
||||
if ($isBaseUnit || $database->checkIfResearched($village->wid, 't' . $unitID) != 0) {
|
||||
$output .= $renderTrainRow($unitID, $unitData, $unitName, $units_array, $bugOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//HERO TRAINING
|
||||
if (isset($_GET['train'])) {
|
||||
$validationArray = $tribeUnits[$session->tribe] ?? [];
|
||||
|
||||
// check for a valid unit value
|
||||
if (in_array($_GET['train'], $validationArray)) {
|
||||
if ($count_hero < 3) {
|
||||
$unitID = $_GET['train'];
|
||||
mysqli_query($database->dblink, "INSERT INTO " . TB_PREFIX . "hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES (" . $database->escape($session->uid) . ", " . (int) $village->wid . ", 0, " . $unitID . ", '" . $database->escape($session->username) . "', 0, 5, 0, 0, 100, 0, 0, 0, 0, " . round((time() + ($unitData[$unitID]['time'] / SPEED) * 3)) . ", 50, 1)");
|
||||
mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "units SET `u$unitID` = `u$unitID` - 1 WHERE `vref` = " . (int) $village->wid);
|
||||
mysqli_query($database->dblink, "
|
||||
UPDATE " . TB_PREFIX . "vdata
|
||||
SET
|
||||
`wood` = `wood` - ".(int) ${'u'.$unitID}['wood'].",
|
||||
`clay` = `clay` - ".(int) ${'u'.$unitID}['clay'].",
|
||||
`iron` = `iron` - ".(int) ${'u'.$unitID}['iron'].",
|
||||
`crop` = `crop` - ".(int) ${'u'.$unitID}['crop']."
|
||||
`wood` = `wood` - " . (int) $unitData[$unitID]['wood'] . ",
|
||||
`clay` = `clay` - " . (int) $unitData[$unitID]['clay'] . ",
|
||||
`iron` = `iron` - " . (int) $unitData[$unitID]['iron'] . ",
|
||||
`crop` = `crop` - " . (int) $unitData[$unitID]['crop'] . "
|
||||
WHERE
|
||||
`wref` = " . (int) $village->wid);
|
||||
}
|
||||
header("Location: build.php?id=".$id."");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
header("Location: build.php?id=" . $id . "");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo $output;
|
||||
echo $output;
|
||||
}
|
||||
// NOTE (pre-existing behavior, kept unchanged): if $count_hero >= 3,
|
||||
// $output is no longer created and no longer echoed - but the </table> below
|
||||
// is outside this if and is displayed unconditionally. In that case the file
|
||||
// generates an "orphan" </table>, without a corresponding <table>. This was also the case in
|
||||
// the original file.
|
||||
?>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
+41
-34
@@ -5,14 +5,21 @@ $start_timer = $generator->pageLoadTimeStart();
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Project: TravianZ ##
|
||||
## Filename warsim.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianZ Project ##
|
||||
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## URLs: http://travian.shadowss.ro ##
|
||||
## Source code: https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
## Filename : warsim.php ##
|
||||
## Type : Attack Simulator File ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Developed by : Dzoki (Original) ##
|
||||
## Refactored by : Shadow ##
|
||||
## Redesign by : Shadow ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Contact : cata7007@gmail.com ##
|
||||
## Project : TravianZ ##
|
||||
## URLs: : https://travianz.org ##
|
||||
## GitHub : https://github.com/Shadowss/TravianZ ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## License : TravianZ Project ##
|
||||
## Copyright : TravianZ (c) 2010-2026. All rights reserved. ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
#################################################################################
|
||||
|
||||
use App\Utils\AccessLogger;
|
||||
@@ -70,37 +77,37 @@ $battle->procSim($_POST);
|
||||
if(isset($_POST['result'])) {
|
||||
$target = isset($_POST['target'])? $_POST['target'] : array();
|
||||
$tribe = isset($_POST['mytribe'])? $_POST['mytribe'] : $session->tribe;
|
||||
include("Templates/Simulator/res_a".$tribe.".tpl");
|
||||
include("Templates/Simulator/res_a".(int)$tribe.".tpl");
|
||||
foreach($target as $tar) {
|
||||
include("Templates/Simulator/res_d".$tar.".tpl");
|
||||
include("Templates/Simulator/res_d".(int)$tar.".tpl");
|
||||
}
|
||||
echo "<p>Type of attack: <b>";
|
||||
echo $form->getValue('ktyp') == 0 ? "Normal" : "Raid";
|
||||
echo "</b></p>";
|
||||
echo "<p>";
|
||||
if (isset($_POST['result'][7]) && isset($_POST['result'][8])){
|
||||
if ($form->getValue('ktyp') == 1) {
|
||||
echo "Hint: The ram does not work during a raid.<br>";
|
||||
}elseif ($_POST['result'][7] == 0){
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>0</b></p>";
|
||||
}elseif ($_POST['result'][7] == $_POST['result'][8]){
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>".$form->getValue('walllevel')."</b></p>";
|
||||
}else{
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>".$_POST['result'][7]."</b></p>";
|
||||
}
|
||||
}
|
||||
if (isset($_POST['result'][7]) && isset($_POST['result'][8])){
|
||||
if ($form->getValue('ktyp') == 1) {
|
||||
echo "Hint: The ram does not work during a raid.<br>";
|
||||
}elseif ($_POST['result'][7] == 0){
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>0</b></p>";
|
||||
}elseif ($_POST['result'][7] == $_POST['result'][8]){
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>".$form->getValue('walllevel')."</b></p>";
|
||||
}else{
|
||||
echo "Damage done by ram: from level <b>".$form->getValue('walllevel')."</b> to level <b>".(int)$_POST['result'][7]."</b></p>";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['result'][3]) && isset($_POST['result'][4])){
|
||||
if ($form->getValue('ktyp') == 1) {
|
||||
echo "Hint: The catapult does not shoot during a raid.</p>";
|
||||
}elseif ($_POST['result'][3] == 0){
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>0</b></p>";
|
||||
}elseif ($_POST['result'][3] == $_POST['result'][4]){
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>".$form->getValue('kata')."</b></p></p>";
|
||||
}else{
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>".$_POST['result'][3]."</b></p>";
|
||||
}
|
||||
}
|
||||
if (isset($_POST['result'][3]) && isset($_POST['result'][4])){
|
||||
if ($form->getValue('ktyp') == 1) {
|
||||
echo "Hint: The catapult does not shoot during a raid.</p>";
|
||||
}elseif ($_POST['result'][3] == 0){
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>0</b></p>";
|
||||
}elseif ($_POST['result'][3] == $_POST['result'][4]){
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>".$form->getValue('kata')."</b></p></p>";
|
||||
}else{
|
||||
echo "Damage done by catapult: from level <b>".$form->getValue('kata')."</b> to level <b>".(int)$_POST['result'][3]."</b></p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['target'])) {
|
||||
@@ -122,7 +129,7 @@ if (!empty($_GET['target'])) {
|
||||
$target = isset($_POST['target'])? $_POST['target'] : (!empty($_GET['target']) ? array((int) $_GET['target']) : array());
|
||||
$tribe = isset($_POST['mytribe'])? $_POST['mytribe'] : $session->tribe;
|
||||
if(count($target) > 0) {
|
||||
include("Templates/Simulator/att_".preg_replace("/[^a-zA-Z0-9_-]/","",$tribe).".tpl");
|
||||
include("Templates/Simulator/att_".(int)$tribe.".tpl");
|
||||
echo "<table id=\"defender\" class=\"fill_in\" cellpadding=\"1\" cellspacing=\"1\">
|
||||
|
||||
<thead>
|
||||
@@ -133,7 +140,7 @@ if(count($target) > 0) {
|
||||
</tr>
|
||||
</thead>";
|
||||
foreach($target as $tar) {
|
||||
include("Templates/Simulator/def_".$tar.".tpl");
|
||||
include("Templates/Simulator/def_".(int)$tar.".tpl");
|
||||
}
|
||||
include("Templates/Simulator/def_end.tpl");
|
||||
echo "<div class=\"clear\"></div>";
|
||||
|
||||
Reference in New Issue
Block a user