mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-03 17:07:17 +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:
+141
-96
@@ -1,99 +1,144 @@
|
||||
<?php
|
||||
|
||||
// ARMOURY UPGRADES
|
||||
|
||||
$abdata = $database->getABTech($village->wid);
|
||||
$ABups = $technology->getABUpgrades('a');
|
||||
$totalUps = count($ABups);
|
||||
$armouryLevel = $building->getTypeLevel(13);
|
||||
$arAttri = $bid13[$armouryLevel]['attri'] / 100;
|
||||
|
||||
$start = $session->tribe * 10 - 9;
|
||||
$end = $session->tribe * 10 - 2;
|
||||
?>
|
||||
<table cellpadding="1" cellspacing="1" class="build_details">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?php echo ARMOURY; ?></td>
|
||||
<td><?php echo ACTION; ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<?php
|
||||
$abdata = $database->getABTech($village->wid);
|
||||
$ABups = $technology->getABUpgrades('a');
|
||||
$totalUps = count($ABups);
|
||||
for($i=($session->tribe*10-9);$i<=($session->tribe*10-2);$i++) {
|
||||
$j = $i % 10 ;
|
||||
if ( $technology->getTech($i) || $j == 1 ) {
|
||||
|
||||
echo "<tr><td class=\"desc\"><div class=\"tit\">
|
||||
<img class=\"unit u".$i."\" src=\"img/x.gif\" alt=\"".$technology->getUnitName($i)."\" title=\"".$technology->getUnitName($i)."\" />
|
||||
<a href=\"#\" onClick=\"return Popup(".$i.",1);\">".$technology->getUnitName($i)."</a> (Level ".$abdata['a'.$j];
|
||||
$ups = 0;
|
||||
if($totalUps > 0){
|
||||
foreach($ABups as $upgrade){
|
||||
if(in_array(("a".$j), $upgrade)) $ups++;
|
||||
}
|
||||
if($ups > 0) echo "+".$ups;
|
||||
}
|
||||
echo ")</div>";
|
||||
|
||||
if($abdata['a'.$j]+$ups != 20) {
|
||||
echo "<div class=\"details\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood']."|<img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay']."|<img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron']."|<img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']."|<img class=\"clock\" src=\"img/x.gif\" alt=\"duration\" title=\"duration\" />";
|
||||
echo $generator->getTimeFormat(round(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['time']*($bid13[$building->getTypeLevel(13)]['attri'] / 100)/SPEED));
|
||||
|
||||
//-- If available resources combined are not enough, remove NPC button
|
||||
$total_required = (int)(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] + ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']);
|
||||
if($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) {
|
||||
echo "|<a href=\"build.php?gid=17&t=3&r1=".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood']."&r2=".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay']."&r3=".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron']."&r4=".${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']."\" title=\"NPC trade\"><img class=\"npc\" src=\"img/x.gif\" alt=\"NPC trade\" title=\"NPC trade\" /></a>";
|
||||
}
|
||||
}
|
||||
if($abdata['a'.$j] == 20) {
|
||||
echo "<td class=\"act\"><div class=\"none\">".MAXIMUM_LEVEL."</div></td></tr>";
|
||||
}
|
||||
else if ($building->getTypeLevel(13) <= $abdata['a'.$j]+$ups) {
|
||||
echo "<td class=\"act\"><div class=\"none\">".UPGRADE_ARMOURY."</div></td></tr>";
|
||||
}
|
||||
else if(${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] > $village->maxstore || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] > $village->maxstore || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] > $village->maxstore) {
|
||||
echo "<td class=\"act\"><div class=\"none\">".EXPAND_WAREHOUSE."</div></td></tr>";
|
||||
}
|
||||
else if (${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop'] > $village->maxcrop) {
|
||||
echo "<td class=\"act\"><div class=\"none\">".EXPAND_GRANARY."</div></td></tr>";
|
||||
}
|
||||
else if (${'ab'.$i}[$abdata['a'.$j]+1+$ups]['wood'] > $village->awood || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['clay'] > $village->aclay || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['iron'] > $village->airon || ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop'] > $village->acrop) {
|
||||
if($village->getProd("crop")>0 || $village->acrop > ${'ab'.$i}[$abdata['a'.$j]+1+$ups]['crop']){
|
||||
$time = $technology->calculateAvaliable(13,${'ab'.$i}[$abdata['a'.$j]+1+$ups]);
|
||||
echo "<br><span class=\"none\">".ENOUGH_RESOURCES." ".$time[0]." at ".$time[1]."</span></div></td>";
|
||||
} else {
|
||||
echo "<br><span class=\"none\">".CROP_NEGATIVE."</span></div></td>";
|
||||
}
|
||||
echo "<td class=\"act\"><div class=\"none\">".TOO_FEW_RESOURCES."</div></td></tr>";
|
||||
}
|
||||
else if ($totalUps == 1 && !$session->plus || $totalUps > 1) {
|
||||
echo "<td class=\"act\"><div class=\"none\">".UPGRADE_IN_PROGRESS."</div></td></tr>";
|
||||
}
|
||||
else if($session->access != BANNED){
|
||||
echo "<td class=\"act\"><a class=\"research\" href=\"build.php?id=$id&a=$j&c=".$session->mchecker."\">".UPGRADE."</a>";
|
||||
if($totalUps != 0) echo "<span class=\"none\"> ".WAITING."</span>";
|
||||
echo"</td></tr>";
|
||||
}else{
|
||||
echo "<td class=\"act\"><a class=\"research\" href=\"banned.php\">".UPGRADE."</a>";
|
||||
if($totalUps != 0) echo "<span class=\"none\"> ".WAITING."</span>";
|
||||
echo"</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= ARMOURY?></td>
|
||||
<td><?= ACTION?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php for ($i = $start; $i <= $end; $i++):
|
||||
$j = $i % 10;
|
||||
if (!($technology->getTech($i) || $j == 1)) continue;
|
||||
|
||||
$unitName = $technology->getUnitName($i);
|
||||
$current = (int)$abdata['a'.$j];
|
||||
|
||||
// câte upgrade-uri sunt deja în coadă pentru unitatea asta
|
||||
$ups = 0;
|
||||
foreach ($ABups as $up) {
|
||||
if (in_array('a'.$j, $up)) $ups++;
|
||||
}
|
||||
$shownLevel = $current + $ups;
|
||||
$nextLevel = $shownLevel + 1;
|
||||
$ab = ${'ab'.$i};
|
||||
$next = $ab[$nextLevel]?? null;
|
||||
?>
|
||||
<tr>
|
||||
<td class="desc">
|
||||
<div class="tit">
|
||||
<img class="unit u<?= $i?>" src="img/x.gif" alt="<?= $unitName?>" title="<?= $unitName?>">
|
||||
<a href="#" onclick="return Popup(<?= $i?>,1);"><?= $unitName?></a>
|
||||
(<?= LEVEL?> <?= $current?><?= $ups > 0? '+'.$ups : ''?>)
|
||||
</div>
|
||||
|
||||
<?php if ($current < 20 && $next):?>
|
||||
<div class="details">
|
||||
<img class="r1" src="img/x.gif" alt="Lumber" title="Lumber"> <?= $next['wood']?>|
|
||||
<img class="r2" src="img/x.gif" alt="Clay" title="Clay"> <?= $next['clay']?>|
|
||||
<img class="r3" src="img/x.gif" alt="Iron" title="Iron"> <?= $next['iron']?>|
|
||||
<img class="r4" src="img/x.gif" alt="Crop" title="Crop"> <?= $next['crop']?>|
|
||||
<img class="clock" src="img/x.gif" alt="duration" title="duration">
|
||||
<?= $generator->getTimeFormat(round($next['time'] * $arAttri / SPEED))?>
|
||||
|
||||
<?php
|
||||
$totalRequired = $next['wood'] + $next['clay'] + $next['iron'] + $next['crop'];
|
||||
$canNpc = $session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $totalRequired;
|
||||
?>
|
||||
<?php if ($canNpc):?>
|
||||
|<a href="build.php?gid=17&t=3&r1=<?= $next['wood']?>&r2=<?= $next['clay']?>&r3=<?= $next['iron']?>&r4=<?= $next['crop']?>" title="NPC trade">
|
||||
<img class="npc" src="img/x.gif" alt="NPC trade" title="NPC trade">
|
||||
</a>
|
||||
<?php endif;?>
|
||||
|
||||
<?php
|
||||
if ($next['wood'] > $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop) {
|
||||
if ($village->getProd('crop') > 0 || $village->acrop > $next['crop']) {
|
||||
$time = $technology->calculateAvaliable(13, $next);
|
||||
echo '<br><span class="none">'.ENOUGH_RESOURCES.' '.$time[0].' at '.$time[1].'</span>';
|
||||
} else {
|
||||
echo '<br><span class="none">'.CROP_NEGATIVE.'</span>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
|
||||
<td class="act">
|
||||
<?php if ($current >= 20):?>
|
||||
<div class="none"><?= MAXIMUM_LEVEL?></div>
|
||||
|
||||
<?php elseif ($armouryLevel <= $shownLevel):?>
|
||||
<div class="none"><?= UPGRADE_ARMOURY?></div>
|
||||
|
||||
<?php elseif ($next && ($next['wood'] > $village->maxstore || $next['clay'] > $village->maxstore || $next['iron'] > $village->maxstore)):?>
|
||||
<div class="none"><?= EXPAND_WAREHOUSE?></div>
|
||||
|
||||
<?php elseif ($next && $next['crop'] > $village->maxcrop):?>
|
||||
<div class="none"><?= EXPAND_GRANARY?></div>
|
||||
|
||||
<?php elseif ($next && ($next['wood'] > $village->awood || $next['clay'] > $village->aclay || $next['iron'] > $village->airon || $next['crop'] > $village->acrop)):?>
|
||||
<div class="none"><?= TOO_FEW_RESOURCES?></div>
|
||||
|
||||
<?php elseif ($totalUps == 1 &&!$session->plus || $totalUps > 1):?>
|
||||
<div class="none"><?= UPGRADE_IN_PROGRESS?></div>
|
||||
|
||||
<?php elseif ($session->access!= BANNED):?>
|
||||
<a class="research" href="build.php?id=<?= $id?>&a=<?= $j?>&c=<?= $session->mchecker?>"><?= UPGRADE?></a>
|
||||
<?php if ($totalUps!= 0):?><span class="none"> <?= WAITING?></span><?php endif;?>
|
||||
|
||||
<?php else:?>
|
||||
<a class="research" href="banned.php"><?= UPGRADE?></a>
|
||||
<?php if ($totalUps!= 0):?><span class="none"> <?= WAITING?></span><?php endif;?>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endfor;?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
if($totalUps > 0) {
|
||||
echo "<table cellpadding=\"1\" cellspacing=\"1\" class=\"under_progress\"><thead><tr><td>".UPGRADING."</td><td>".DURATION."</td><td>".COMPLETE."</td></tr>
|
||||
</thead><tbody>";
|
||||
foreach($ABups as $arms) {
|
||||
$count++;
|
||||
$ABUnit = substr($arms['tech'], 1, 2);
|
||||
$abdata['a' . $ABUnit]++;
|
||||
$unit = ($session->tribe - 1) * 10 + $ABUnit;
|
||||
echo "<tr><td class=\"desc\"><img class=\"unit u$unit\" src=\"img/x.gif\" alt=\"".$technology->getUnitName($unit)."\" title=\"".$technology->getUnitName($unit)."\" />".$technology->getUnitName($unit);
|
||||
echo "<span class=\"none\"> (".LEVEL." ".$abdata['a'.$ABUnit].")</span>";
|
||||
if($count > 1) echo "<span class=\"none\"> ".WAITING."</span>";
|
||||
echo "</td>";
|
||||
echo "<td class=\"dur\"><span id=\"timer".++$session->timer."\">".$generator->getTimeFormat($arms['timestamp']-time())."</span></td>";
|
||||
$date = $generator->procMtime($arms['timestamp']);
|
||||
echo "<td class=\"fin\"><span>".$date[1]."</span><span> hrs</span></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</tbody></table>";
|
||||
}
|
||||
?>
|
||||
<?php if ($totalUps > 0):?>
|
||||
<table cellpadding="1" cellspacing="1" class="under_progress">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= UPGRADING?></td>
|
||||
<td><?= DURATION?></td>
|
||||
<td><?= COMPLETE?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach ($ABups as $arms):
|
||||
$count++;
|
||||
$ABUnit = (int)substr($arms['tech'], 1, 2);
|
||||
$abdata['a'.$ABUnit]++;
|
||||
$unit = ($session->tribe - 1) * 10 + $ABUnit;
|
||||
$unitName = $technology->getUnitName($unit);
|
||||
$date = $generator->procMtime($arms['timestamp']);
|
||||
?>
|
||||
<tr>
|
||||
<td class="desc">
|
||||
<img class="unit u<?= $unit?>" src="img/x.gif" alt="<?= $unitName?>" title="<?= $unitName?>">
|
||||
<?= $unitName?>
|
||||
<span class="none"> (<?= LEVEL?> <?= $abdata['a'.$ABUnit]?>)</span>
|
||||
<?php if ($count > 1):?><span class="none"> <?= WAITING?></span><?php endif;?>
|
||||
</td>
|
||||
<td class="dur"><span id="timer<?= ++$session->timer?>"><?= $generator->getTimeFormat($arms['timestamp'] - time())?></span></td>
|
||||
<td class="fin"><span><?= $date[1]?></span><span> hrs</span></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif;?>
|
||||
Reference in New Issue
Block a user