Add in ACP T4 Resource Level

Add in ACP T4 Resource Level
This commit is contained in:
novgorodschi catalin
2026-07-24 11:13:41 +03:00
parent ef6d7c658f
commit ed1e06b23c
8 changed files with 163 additions and 23 deletions
+89 -9
View File
@@ -56,6 +56,13 @@ if(isset($_GET['uid'])){
.hero-head a:hover{text-decoration:underline;}
.card{background:#fff;border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.04);margin-bottom:12px;}
/* FIX: pe tema inchisa a panoului (admin_dark.css, incarcat ultimul) cardurile
albe mosteneau text deschis si deveneau ilizibile. Fortam culori inchise pe
tot ce e in interiorul lor. */
.card, .card .body, .card .body div, .card .body b, .card .body span,
.card .form-row, .card .form-row .field, .card table, .card td, .card th{color:#1f2937;}
.card .body{color:#1f2937;}
.card .body b{color:#0f172a;}
.card h3{margin:0;padding:9px 14px;background:#f8fafc;border-bottom:1px solid #e5e7eb;font-size:12px;text-transform:uppercase;color:#475569;letter-spacing:.4px;font-weight:600;display:flex;align-items:center;gap:6px;}
.card.body{padding:14px;}
@@ -146,12 +153,36 @@ function go_url(url){ location=url; return false; }
<div class="unit-preview"><span id="unt"><img class="unit u<?php echo $hero['unit'];?>" src="img/x.gif"></span>
<select name="hunit" onchange="check_unit(this)" style="flex:1;padding:6px 8px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;color:#0f172a;font-size:13px;">
<?php
// sloturile care au erou definit in hero_full.php (generic pentru toate triburile)
for($i=1;$i<7;$i++){
$v=$utribe+$i;
if(!isset(${'h'.$v})) continue;
echo "<option value='$v'".($hero['unit']==$v?' selected':'').">".$unarray[$v]."</option>";
}?>
/**
* Unitatile care pot fi erou pentru tribul jucatorului.
*
* Inainte se citeau prin variabile dinamice (${'h'.$v}), ceea ce
* facea greu de vazut ce se intampla si ascundea erorile daca
* lipsea o definitie. Acum construim o lista explicita: un slot
* intra doar daca are si datele de erou (hN), si un nume.
*/
$eHeroUnits = [];
for ($i = 1; $i < 7; $i++) {
$eUnitId = $utribe + $i;
if (!isset($GLOBALS['h' . $eUnitId]) || !isset($unarray[$eUnitId])) {
continue;
}
$eHeroUnits[$eUnitId] = $unarray[$eUnitId];
}
if (!$eHeroUnits) {
echo "<option value='" . (int) $hero['unit'] . "'>#" . (int) $hero['unit'] . "</option>";
}
foreach ($eHeroUnits as $eUnitId => $eUnitName) {
echo "<option value='" . $eUnitId . "'"
. ((int) $hero['unit'] === $eUnitId ? " selected" : "") . ">"
. $eUnitName . "</option>";
}
?>
</select></div>
</div></div>
<div class="form-row"><label> Health</label><div class="field"><input name="hhealth" type="text" value="<?php echo round($hero['health']);?>" style="width:80px;"> %</div></div>
@@ -162,11 +193,33 @@ function go_url(url){ location=url; return false; }
<div class="card">
<h3>📈 Current Stats</h3>
<div class="body" style="font-size:12px;line-height:1.8;">
<div>Level: <b><?php echo $hero['level'];?></b> | Points: <b><?php echo $hero['atk']+$hero['di']+$hero['dc'];?></b></div>
<?php
// punctele nefolosite, nu suma statisticilor calculate (era gresit)
$eMaxLevel = isset($hero_levels) ? max(array_keys($hero_levels)) - 1 : 119;
$eUsed = (int)$hero['attack'] + (int)$hero['defence'] + (int)$hero['attackbonus']
+ (int)$hero['defencebonus'] + (int)$hero['regeneration'] + (int)($hero['resources'] ?? 0);
$eTotal = 5 + ($hero['level'] * 5);
$eFree = max(0, $eTotal - $eUsed);
?>
<div>Level: <b><?php echo $hero['level'];?></b> / <?php echo $eMaxLevel; ?>
| Points used: <b><?php echo $eUsed; ?></b> of <b><?php echo $eTotal; ?></b>
(free: <b><?php echo $eFree; ?></b>)</div>
<div>Offence: <b><?php echo $hero['atk'];?></b> (Lv <?php echo $hero['attack'];?>)</div>
<div>Defence: <b><?php echo $hero['di']."/".$hero['dc'];?></b> (Lv <?php echo $hero['defence'];?>)</div>
<div>Off-Bonus: <b><?php echo ($hero['ob']-1)*100;?>%</b> | Def-Bonus: <b><?php echo ($hero['db']-1)*100;?>%</b></div>
<div>Regen: <b><?php echo $hero['regeneration']*5*SPEED;?>/day</b></div>
<?php if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4) {
$eResPts = (int)($hero['resources'] ?? 0);
$eResType = (int)($hero['res_type'] ?? 0);
$ePerAll = defined('HERO_RES_PER_POINT_ALL') ? (int) HERO_RES_PER_POINT_ALL : 3;
$ePerOne = defined('HERO_RES_PER_POINT_ONE') ? (int) HERO_RES_PER_POINT_ONE : 10;
$eNames = [0=>'all resources',1=>'lumber',2=>'clay',3=>'iron',4=>'crop'];
$eAmount = ($eResType>=1 && $eResType<=4)
? (int) round($eResPts * $ePerOne * SPEED)
: (int) round($eResPts * $ePerAll * SPEED);
?>
<div>Resources: <b><?php echo $eAmount; ?>/h</b> (<?php echo $eNames[$eResType] ?? 'all resources'; ?>, Lv <?php echo $eResPts; ?>)</div>
<?php } ?>
</div>
</div>
@@ -175,14 +228,25 @@ function go_url(url){ location=url; return false; }
<div class="body">
<?php if($isMax):?>
<div style="text-align:center;padding:8px;background:#fef3c7;border:1px solid #fde68a;border-radius:6px;color:#92400e;font-size:12px;margin-bottom:10px;">
Hero este Level 99 nu mai poți adăuga puncte.
Hero is at the maximum level (<?php echo isset($hero_levels) ? max(array_keys($hero_levels)) - 1 : 119; ?>) no more points can be added.
</div>
<?php endif;?>
<table class="stat-table">
<thead><tr><th>Attribute</th><th style="width:80px;text-align:center;">Current</th><th style="width:120px;text-align:center;">Add</th><th style="width:60px;text-align:center;">New</th></tr></thead>
<tbody>
<?php
$attrs=[['hatk','Offence',$hero['attack']],['hdef','Defence',$hero['defence']],['hob','Off-Bonus',$hero['attackbonus']],['hdb','Def-Bonus',$hero['defencebonus']],['hrege','Regeneration',$hero['regeneration']]];
$attrs = [
['hatk', 'Offence', $hero['attack']],
['hdef', 'Defence', $hero['defence']],
['hob', 'Off-Bonus', $hero['attackbonus']],
['hdb', 'Def-Bonus', $hero['defencebonus']],
['hrege', 'Regeneration', $hero['regeneration']],
];
// al 6-lea atribut exista doar cu functiile T4 pornite
if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4) {
$attrs[] = ['hres', 'Resources', (int)($hero['resources'] ?? 0)];
}
foreach($attrs as $a){
$plusBtn = $isMax? "<button type='button' class='btn-step' disabled>+</button>" : "<button type='button' class='btn-step' onclick=\"return changeValue(1,'{$a[0]}')\">+</button>";
echo '<tr><td>'.$a[1].'</td><td style="text-align:center;">'.$a[2].'</td><td><div class="ctrl"><span id="'.$a[0].'0"><button type="button" class="btn-step" disabled></button></span><div class="val-box" id="'.$a[0].'2">0</div><span id="'.$a[0].'1">'.$plusBtn.'</span></div></td><td><input id="'.$a[0].'" name="'.$a[0].'" type="hidden" value="0"><span id="'.$a[0].'2v">0</span></td></tr>';
@@ -190,6 +254,22 @@ function go_url(url){ location=url; return false; }
?>
</tbody>
</table>
<?php if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4) { ?>
<div class="form-row" style="margin-top:10px;">
<label>Produced resource</label>
<div class="field">
<select name="hrestype" style="padding:6px 8px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;color:#0f172a;font-size:13px;">
<?php
$eResOpts = [0=>'All resources',1=>'Lumber',2=>'Clay',3=>'Iron',4=>'Crop'];
$eCur = (int)($hero['res_type'] ?? 0);
foreach ($eResOpts as $eVal => $eLabel) {
echo "<option value='" . $eVal . "'" . ($eCur === $eVal ? " selected" : "") . ">" . $eLabel . "</option>";
}
?>
</select>
</div>
</div>
<?php } ?>
<div style="text-align:center;margin-top:10px;font-size:12px;">Level nou: <b><span id="hlvl">0</span></b></div>
</div>
</div>
+6
View File
@@ -35,6 +35,12 @@ $t4SlotNames = [1=>'Helmet',2=>'Body',3=>'Right hand',4=>'Left hand',5=>'Shoes',
?>
<style>
.t4a-card{background:#fff;border:1px solid #e5e7eb;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.04);margin-bottom:12px;}
/* FIX: pe tema inchisa a panoului (admin_dark.css se incarca ultimul) cardurile
albe mosteneau text deschis si nu se citea nimic. Fortam culori inchise. */
.t4a-card, .t4a-card div, .t4a-card span, .t4a-card b, .t4a-card label,
.t4a-card td, .t4a-card p, .t4a-card li{color:#1f2937;}
.t4a-card select, .t4a-card input[type=text], .t4a-card input[type=number]{color:#0f172a;background:#fff;}
.t4a-table td{color:#1f2937;}
.t4a-card h3{margin:0;padding:9px 14px;background:#f8fafc;border-bottom:1px solid #e5e7eb;font-size:12px;text-transform:uppercase;color:#475569;letter-spacing:.4px;font-weight:600;}
.t4a-card .body{padding:14px;}
.t4a-table{width:100%;border-collapse:collapse;font-size:13px;}
+20 -3
View File
@@ -132,16 +132,33 @@ if ($hero !== false) {
<tr><td>Off-Bonus</td><td><?php echo ($h['ob']-1)*100; ?>%</td><td><?php echo $h['attackbonus']; ?></td></tr>
<tr><td>Def-Bonus</td><td><?php echo ($h['db']-1)*100; ?>%</td><td><?php echo $h['defencebonus']; ?></td></tr>
<tr><td>Regeneration</td><td><?php echo min(100,$h['regeneration'])*5*SPEED; ?>/Day</td><td><?php echo $h['regeneration']; ?></td></tr>
<?php if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4) {
$hResPoints = (int) ($h['resources'] ?? 0);
$hResType = (int) ($h['res_type'] ?? 0);
$hPerAll = defined('HERO_RES_PER_POINT_ALL') ? (int) HERO_RES_PER_POINT_ALL : 3;
$hPerOne = defined('HERO_RES_PER_POINT_ONE') ? (int) HERO_RES_PER_POINT_ONE : 10;
$hResNames = [0 => 'all', 1 => 'lumber', 2 => 'clay', 3 => 'iron', 4 => 'crop'];
$hResAmount = ($hResType >= 1 && $hResType <= 4)
? (int) round($hResPoints * $hPerOne * SPEED)
: (int) round($hResPoints * $hPerAll * SPEED);
?>
<tr><td>Resources</td><td><?php echo $hResAmount; ?>/h (<?php echo $hResNames[$hResType] ?? 'all'; ?>)</td><td><?php echo $hResPoints; ?></td></tr>
<?php } ?>
<tr>
<?php
// 1. puncte rămase - nu lăsa negativ
$used = (int)$h['attack'] + (int)$h['defence'] + (int)$h['attackbonus'] + (int)$h['defencebonus'] + (int)$h['regeneration'];
$count_level_exp = max(0, 500 - $used);
$used = (int)$h['attack'] + (int)$h['defence'] + (int)$h['attackbonus']
+ (int)$h['defencebonus'] + (int)$h['regeneration'] + (int)($h['resources'] ?? 0);
// totalul de puncte vine din tabelul de niveluri: 5 initiale + 5 per nivel
$hMaxLevel = isset($hero_levels) ? max(array_keys($hero_levels)) - 1 : 119;
$hMaxPoints = 5 + ($hMaxLevel * 5);
$count_level_exp = max(0, $hMaxPoints - $used);
if ($h['points'] > $count_level_exp) $h['points'] = $count_level_exp;
// 2. procent XP - protejat pentru level 100
$level = (int)$h['level'];
if ($level >= 100 || !isset($hero_levels[$level+1])) {
if ($level >= $hMaxLevel || !isset($hero_levels[$level+1])) {
$expPct = 100;
} else {
$curr = $hero_levels[$level] ?? 0;
+25 -2
View File
@@ -54,7 +54,10 @@ if (isset($_POST['id'], $_POST['hid'])) {
// Input curat - cast individual, NU escape global
$hunit = (int)($_POST['hunit'] ?? 0);
$hlvl = max(0, min(100, (int)($_POST['hlvl'] ?? 0)));
// plafonul vine din tabelul de niveluri (ultimul index e santinela), ca sa
// urmeze automat extinderea facuta pentru al 6-lea atribut
$hMaxLevel = isset($hero_levels) ? max(array_keys($hero_levels)) - 1 : 119;
$hlvl = max(0, min($hMaxLevel, (int)($_POST['hlvl'] ?? 0)));
$exp = (int)($_POST['exp'] ?? 0);
$hhealth = (float)($_POST['hhealth'] ?? 100);
$hatk = (int)($_POST['hatk'] ?? 0);
@@ -62,6 +65,22 @@ if (isset($_POST['id'], $_POST['hid'])) {
$hob = (int)($_POST['hob'] ?? 0);
$hdb = (int)($_POST['hdb'] ?? 0);
$hrege = (int)($_POST['hrege'] ?? 0);
$hres = (int)($_POST['hres'] ?? 0);
$hrestype = (int)($_POST['hrestype'] ?? 0);
// atributele nu pot depasi 100 fiecare (la fel ca in joc)
foreach (['hatk','hdef','hob','hdb','hrege','hres'] as $hAttr) {
if ($$hAttr < 0) { $$hAttr = 0; }
if ($$hAttr > 100) { $$hAttr = 100; }
}
if ($hrestype < 0 || $hrestype > 4) { $hrestype = 0; }
// Coloanele T4 se scriu doar daca exista: pe un server care nu a rulat
// add-hero-resources.sql, interogarea ar esua si s-ar pierde TOATA salvarea.
$hHasResCols = false;
$hColCheck = mysqli_query($database->dblink, "SHOW COLUMNS FROM " . TB_PREFIX . "hero LIKE 'resources'");
if ($hColCheck && mysqli_num_rows($hColCheck) > 0) { $hHasResCols = true; }
$experience = isset($hero_levels[$hlvl]) ? (int)$hero_levels[$hlvl] : 0;
$hnameEsc = $database->escape($hname);
@@ -77,7 +96,11 @@ if (isset($_POST['id'], $_POST['hid'])) {
defence = $hdef,
attackbonus = $hob,
defencebonus = $hdb,
regeneration = $hrege
regeneration = $hrege"
. ($hHasResCols ? ",
resources = $hres,
res_type = $hrestype" : "")
. "
WHERE heroid = $hid AND uid = $id";
$return = $database->query($q);
+11 -2
View File
@@ -204,10 +204,19 @@ trait AutomationHero {
$herolevel = $hdata['level'];
$newLevel = - 1;
$scorePoints = false;
for ($i = $herolevel + 1; $i < 100; $i++){
// Nivelul maxim se ia din tabelul de experienta, nu mai e scris in cod:
// ultimul index e o santinela care repeta valoarea nivelului maxim real.
// Asa, extinderea tabelului (facuta pentru al 6-lea atribut, "Resources")
// ridica automat si plafonul de nivel.
$maxLevel = max(array_keys($hero_levels)) - 1;
for ($i = $herolevel + 1; $i <= $maxLevel; $i++){
if($hdata['experience'] >= $hero_levels[$i]){
$newLevel = $i;
if ($i < 99) $scorePoints = true;
// punctele se acorda pentru FIECARE nivel, inclusiv ultimul:
// 5 initiale + 119 niveluri x 5 = 600, adica exact cat trebuie
// pentru 6 atribute duse la maximul de 100
$scorePoints = true;
}
}
+1 -2
View File
@@ -20,8 +20,7 @@
## --------------------------------------------------------------------------- ##
#################################################################################
$hero_levels = array(0 => 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15300, 17100, 19000, 21000, 23100, 25300, 27600, 30000, 32500, 35100, 37800, 40600, 43500, 46500, 49600, 52800, 56100, 59500, 63000, 66600, 70300, 74100, 78000, 82000, 86100, 90300, 94600, 99000, 103500, 108100, 112800, 117600, 122500, 127500, 132600, 137800, 143100, 148500, 154000, 159600, 165300, 171100, 177000, 183000, 189100, 195300, 201600, 208000, 214500, 221100, 227800,
234600, 241500, 248500, 255600, 262800, 270100, 277500, 285000, 292600, 300300, 308100, 316000, 324000, 332100, 340300, 348600, 357000, 365500, 374100, 382800, 391600, 400500, 409500, 418600, 427800, 437100, 446500, 456000, 465600, 475300, 485100, 495000, 495000);
$hero_levels = array(0 => 0, 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15300, 17100, 19000, 21000, 23100, 25300, 27600, 30000, 32500, 35100, 37800, 40600, 43500, 46500, 49600, 52800, 56100, 59500, 63000, 66600, 70300, 74100, 78000, 82000, 86100, 90300, 94600, 99000, 103500, 108100, 112800, 117600, 122500, 127500, 132600, 137800, 143100, 148500, 154000, 159600, 165300, 171100, 177000, 183000, 189100, 195300, 201600, 208000, 214500, 221100, 227800, 234600, 241500, 248500, 255600, 262800, 270100, 277500, 285000, 292600, 300300, 308100, 316000, 324000, 332100, 340300, 348600, 357000, 365500, 374100, 382800, 391600, 400500, 409500, 418600, 427800, 437100, 446500, 456000, 465600, 475300, 485100, 495000, 505000, 515100, 525300, 535600, 546000, 556500, 567100, 577800, 588600, 599500, 610500, 621600, 632800, 644100, 655500, 667000, 678600, 690300, 702100, 714000, 714000);
//ROMAN UNITS
+5 -3
View File
@@ -221,13 +221,15 @@ $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) {
<div class="t4h-panel">
<table class="t4h-tbl">
<?php
$maxExp = 495000;
// plafonul vine din tabelul de niveluri, nu mai e o valoare fixa
$t4MaxLevel = max(array_keys($hero_levels)) - 1;
$maxExp = $hero_levels[$t4MaxLevel];
$curLevel = (int) $hero_info['level'];
$curExp = (int) $hero_info['experience'];
$expCurrent = $hero_levels[$curLevel] ?? 0;
$expNext = $hero_levels[$curLevel + 1] ?? $maxExp;
if ($curExp < $maxExp && $expNext > $expCurrent && $curLevel < 100) {
if ($curExp < $maxExp && $expNext > $expCurrent && $curLevel < $t4MaxLevel) {
$percent = ($curExp - $expCurrent) / ($expNext - $expCurrent) * 100;
$percent = max(0, min(100, $percent));
} else {
@@ -243,7 +245,7 @@ $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) {
<tr>
<td class="t4h-name"><?php echo defined('TZ_HERO_LEVEL') ? TZ_HERO_LEVEL : 'Hero level'; ?></td>
<td class="t4h-val"><?php echo $curLevel; ?></td>
<td class="t4h-barcell" colspan="3"><div class="t4h-bar"><i style="width:<?php echo max(0, min(100, $curLevel)); ?>%"></i></div></td>
<td class="t4h-barcell" colspan="3"><div class="t4h-bar"><i style="width:<?php echo (int) max(0, min(100, $curLevel / max(1, $t4MaxLevel) * 100)); ?>%"></i></div></td>
</tr>
</table>
</div>
+6 -2
View File
@@ -302,12 +302,16 @@ if ($hour > 1759 || $hour < 500) {
#goldHeader {
position: absolute;
left: 380px; /* << AICI ESTE CERCUL VERDE - muta 370-400 daca e nevoie */
top: 18px; /* centrat pe bara gri */
/* Centrare pe verticala in bara gri: ancoram la mijloc si compensam
inaltimea proprie. Asa ramane centrat si acum, cand sunt doua
randuri (aur + argint), nu impins spre partea de jos. */
top: 50%;
transform: translateY(-50%);
width: auto;
min-width: 100px;
height: auto;
min-height: 22px;
line-height: 22px;
line-height: 16px;
text-align: center;
font-size: 11px;
font-weight: bold;