mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-13 23:01:02 +00:00
Fix warsim security issue & hero building
Fix warsim security issue & hero building
This commit is contained in:
+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>
|
||||
|
||||
Reference in New Issue
Block a user