mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-20 10:11:00 +00:00
Refactor + BugFix
1. Fix a bug in Admin Panel that you can edit by yourself your rank, now you cannot edit your rank anymore. 2. Now Alliance Leader can edit his own Position 3. Fix negative value on Demolition Building, now in database at lvl is appear new level not -1 4. Refactor Ajax map, now all is alligned (Ajax folder and Map folder) 5. Fix bug from Palace (when change capital now Automation recount population automaticaly on old capital and new capital)
This commit is contained in:
@@ -1,89 +1,84 @@
|
||||
<?php
|
||||
$bid = $_GET['bid'];
|
||||
unset($_GET['bid']);
|
||||
$bindicator = $building->canBuild($id,$bid);
|
||||
$loopsame = ($building->isCurrent($id) || $building->isLoop($id))?1:0;
|
||||
$doublebuild = ($building->isCurrent($id) && $building->isLoop($id))?1:0;
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* availupgrade.tpl - fix redeclare + PHP 8.2 safe
|
||||
* NU mai declară funcții, folosește variabilă
|
||||
*/
|
||||
$bid = (int)($_GET['bid']?? 0);
|
||||
$id = (int)$id;
|
||||
|
||||
$bindicator = (int)$building->canBuild($id, $bid);
|
||||
$uprequire = $building->resourceRequired($id, $bid);
|
||||
|
||||
// --- pregătim o singură dată HTML-ul pentru Master Builder ---
|
||||
$masterBuilderHtml = '';
|
||||
if ($session->goldclub == 1) {
|
||||
$canUse = ($session->gold >= 1 && $village->master == 0);
|
||||
$checker = htmlspecialchars((string)$session->checker, ENT_QUOTES, 'UTF-8');
|
||||
$url = "dorf2.php?master={$bid}&id={$id}&c={$checker}";
|
||||
$label = htmlspecialchars(CONSTRUCTING_MASTER_BUILDER, ENT_QUOTES, 'UTF-8');
|
||||
$goldIcon = htmlspecialchars(GP_LOCATE. 'img/a/gold_g.gif', ENT_QUOTES, 'UTF-8');
|
||||
$cost = '<span class="gold-cost">(costs: <img src="'.$goldIcon.'" alt="Gold" title="Gold"/>1)</span>';
|
||||
|
||||
$masterBuilderHtml = $canUse
|
||||
? '<br><a class="build" href="'.htmlspecialchars($url, ENT_QUOTES, 'UTF-8').'">'.$label.'</a> '.$cost
|
||||
: '<br><span class="none">'.$label.'</span> '.$cost;
|
||||
}
|
||||
|
||||
$totalRequired = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']);
|
||||
$canNpc = ($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired);
|
||||
?>
|
||||
<td class="res">
|
||||
<img class="r1" src="img/x.gif" alt="Lumber" title="Lumber" /><?php echo $uprequire['wood']; ?> | <img class="r2" src="img/x.gif" alt="Clay" title="Clay" /><?php echo $uprequire['clay']; ?> | <img class="r3" src="img/x.gif" alt="Iron" title="Iron" /><?php echo $uprequire['iron']; ?> | <img class="r4" src="img/x.gif" alt="Crop" title="Crop" /><?php echo $uprequire['crop']; ?> | <img class="r5" src="img/x.gif" alt="Crop consumption" title="Crop consumption" /><?php echo $uprequire['pop']; ?> | <img class="clock" src="img/x.gif" alt="duration" title="duration" /><?php echo $generator->getTimeFormat($uprequire['time']);
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)($uprequire['wood'] + $uprequire['clay'] + $uprequire['iron'] + $uprequire['crop']);
|
||||
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
echo "|<a href=\"build.php?gid=17&t=3&r1=".$uprequire['wood']."&r2=".$uprequire['clay']."&r3=".$uprequire['iron']."&r4=".$uprequire['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
} ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="link">
|
||||
<?php
|
||||
if($bindicator == 2) {
|
||||
echo "<span class=\"none\">" . WORKERS_ALREADY_WORK_WAITING . "</span>";
|
||||
if($session->goldclub == 1){
|
||||
?> </br>
|
||||
<?php
|
||||
if($session->gold >= 1 && $village->master == 0){
|
||||
echo "<a class=\"build\" href=\"dorf2.php?master=$bid&id=$id&c=$session->checker\">" . CONSTRUCTING_MASTER_BUILDER . "</a>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}else{
|
||||
echo "<span class=\"none\">" . CONSTRUCTING_MASTER_BUILDER . "</span>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($bindicator == 3) {
|
||||
echo "<span class=\"none\">The workers are already at work. (waiting loop)</span>";
|
||||
if($session->goldclub == 1){
|
||||
?> </br>
|
||||
<?php
|
||||
if($session->gold >= 1 && $village->master == 0){
|
||||
echo "<a class=\"build\" href=\"dorf2.php?master=$bid&id=$id&c=$session->checker\">" . CONSTRUCTING_MASTER_BUILDER . "</a>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}else{
|
||||
echo "<span class=\"none\">" . CONSTRUCTING_MASTER_BUILDER . "</span>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($bindicator == 4) {
|
||||
echo "<span class=\"none\">Not enough food. Expand cropland.</span>";
|
||||
}
|
||||
else if($bindicator == 5) {
|
||||
echo "<span class=\"none\">Upgrade Warehouse.</span>";
|
||||
}
|
||||
else if($bindicator == 6) {
|
||||
echo "<span class=\"none\">Upgrade Granary.</span>";
|
||||
}
|
||||
else if($bindicator == 7) {
|
||||
$neededtime = $building->calculateAvaliable($id,$bid);
|
||||
echo "<span class=\"none\">" .ENOUGH_RESOURCES . " " .$neededtime[0]." at ".$neededtime[1]."</span>";
|
||||
if($session->goldclub == 1){
|
||||
?> </br>
|
||||
<?php
|
||||
if($session->gold >= 1 && $village->master == 0){
|
||||
echo "<a class=\"build\" href=\"dorf2.php?master=$bid&id=$id&c=$session->checker\">" . CONSTRUCTING_MASTER_BUILDER . "</a>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}else{
|
||||
echo "<span class=\"none\">" . CONSTRUCTING_MASTER_BUILDER . "</span>";
|
||||
echo '<font color="#B3B3B3">(costs: <img src="'.GP_LOCATE.'img/a/gold_g.gif" alt="Gold" title="Gold"/>1)</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($bindicator == 8) {
|
||||
if($session->access!=BANNED){
|
||||
echo "<a class=\"build\" href=\"dorf2.php?a=$bid&id=$id&c=".$session->checker."\">". CONSTRUCT_BUILD."</a>";
|
||||
}else{
|
||||
echo "<a class=\"build\" href=\"banned.php\">". CONSTRUCT_BUILD."</a>";
|
||||
}
|
||||
}
|
||||
else if($bindicator == 9) {
|
||||
if($session->access!=BANNED){
|
||||
echo "<a class=\"build\" href=\"dorf2.php?a=$bid&id=$id&c=".$session->checker."\">Construct building. (waiting loop)</a>";
|
||||
}else{
|
||||
echo "<a class=\"build\" href=\"banned.php?a=$bid&id=$id&c=".$session->checker."\">Construct building. (waiting loop)</a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<img class="r1" src="img/x.gif" alt="Lumber" title="Lumber" /><?= (int)$uprequire['wood']?> |
|
||||
<img class="r2" src="img/x.gif" alt="Clay" title="Clay" /><?= (int)$uprequire['clay']?> |
|
||||
<img class="r3" src="img/x.gif" alt="Iron" title="Iron" /><?= (int)$uprequire['iron']?> |
|
||||
<img class="r4" src="img/x.gif" alt="Crop" title="Crop" /><?= (int)$uprequire['crop']?> |
|
||||
<img class="r5" src="img/x.gif" alt="Crop consumption" title="Crop consumption" /><?= (int)$uprequire['pop']?> |
|
||||
<img class="clock" src="img/x.gif" alt="duration" title="duration" /><?= htmlspecialchars($generator->getTimeFormat($uprequire['time']), ENT_QUOTES, 'UTF-8')?>
|
||||
<?php if ($canNpc):?>
|
||||
| <a href="build.php?gid=17&t=3&r1=<?= (int)$uprequire['wood']?>&r2=<?= (int)$uprequire['clay']?>&r3=<?= (int)$uprequire['iron']?>&r4=<?= (int)$uprequire['crop']?>" title="NPC trade">
|
||||
<img class="npc" src="img/x.gif" alt="NPC trade" title="NPC trade" />
|
||||
</a>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="link">
|
||||
<?php
|
||||
switch ($bindicator) {
|
||||
case 2:
|
||||
echo '<span class="none">'.htmlspecialchars(WORKERS_ALREADY_WORK_WAITING, ENT_QUOTES, 'UTF-8').'</span>';
|
||||
echo $masterBuilderHtml;
|
||||
break;
|
||||
case 3:
|
||||
echo '<span class="none">The workers are already at work. (waiting loop)</span>';
|
||||
echo $masterBuilderHtml;
|
||||
break;
|
||||
case 4:
|
||||
echo '<span class="none">Not enough food. Expand cropland.</span>';
|
||||
break;
|
||||
case 5:
|
||||
echo '<span class="none">Upgrade Warehouse.</span>';
|
||||
break;
|
||||
case 6:
|
||||
echo '<span class="none">Upgrade Granary.</span>';
|
||||
break;
|
||||
case 7:
|
||||
$needed = $building->calculateAvaliable($id, $bid);
|
||||
echo '<span class="none">'.htmlspecialchars(ENOUGH_RESOURCES, ENT_QUOTES, 'UTF-8').' '.htmlspecialchars((string)$needed[0], ENT_QUOTES, 'UTF-8').' at '.htmlspecialchars((string)$needed[1], ENT_QUOTES, 'UTF-8').'</span>';
|
||||
echo $masterBuilderHtml;
|
||||
break;
|
||||
case 8:
|
||||
$url = ($session->access!= BANNED)
|
||||
? "dorf2.php?a={$bid}&id={$id}&c={$session->checker}"
|
||||
: "banned.php";
|
||||
echo '<a class="build" href="'.htmlspecialchars($url, ENT_QUOTES, 'UTF-8').'">'.htmlspecialchars(CONSTRUCT_BUILD, ENT_QUOTES, 'UTF-8').'</a>';
|
||||
break;
|
||||
case 9:
|
||||
$url = ($session->access!= BANNED)
|
||||
? "dorf2.php?a={$bid}&id={$id}&c={$session->checker}"
|
||||
: "banned.php?a={$bid}&id={$id}&c={$session->checker}";
|
||||
echo '<a class="build" href="'.htmlspecialchars($url, ENT_QUOTES, 'UTF-8').'">Construct building. (waiting loop)</a>';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
Reference in New Issue
Block a user