From ef6d7c658f32f0e19838dac3e753ecfad488e954 Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Fri, 24 Jul 2026 11:00:40 +0300 Subject: [PATCH] Some Additional T4 Hero Fix Some Additional T4 Hero Fix --- GameEngine/HeroItems.php | 26 ++- GameEngine/Lang/en.php | 2 +- GameEngine/Lang/ro.php | 2 +- Templates/Build/37_auction.tpl | 6 +- Templates/Build/37_hero.tpl | 306 +++++++++++++++++++-------------- Templates/header.tpl | 39 ++++- img/hero/res_all.png | Bin 0 -> 3582 bytes img/hero/silver.png | Bin 0 -> 613 bytes 8 files changed, 236 insertions(+), 145 deletions(-) create mode 100644 img/hero/res_all.png create mode 100644 img/hero/silver.png diff --git a/GameEngine/HeroItems.php b/GameEngine/HeroItems.php index cded35b7..6cba9bbe 100644 --- a/GameEngine/HeroItems.php +++ b/GameEngine/HeroItems.php @@ -310,20 +310,32 @@ class HeroItems } /** - * Argint -> aur. $gold = cat aur vrei sa primesti. + * Argint -> aur. $silver = cat ARGINT dai (nu cat aur primesti). + * + * Asta e citirea naturala a campului din interfata si potriveste Travian: + * scrii suma pe care o dai, nu pe cea pe care o primesti. Se schimba doar + * multiplii intregi ai ratei; restul de argint sub o unitate de aur ramane + * la tine, nu se pierde. */ - public function exchangeSilverToGold($uid, $gold) + public function exchangeSilverToGold($uid, $silver) { - $uid = (int) $uid; - $gold = (int) $gold; + $uid = (int) $uid; + $silver = (int) $silver; - if ($gold <= 0 || $gold > 100000) { + if ($silver <= 0 || $silver > 100000000) { return self::EXCHANGE_INVALID; } - $silver = $gold * self::silverForOneGold(); + $rate = self::silverForOneGold(); + $gold = intdiv($silver, $rate); - return $this->runExchange($uid, $gold, $silver, false); + if ($gold <= 0) { + // sub rata de schimb nu se poate obtine nici macar o unitate de aur + return self::EXCHANGE_NOT_ENOUGH; + } + + // consumam exact cat acopera aurul primit, nu toata suma introdusa + return $this->runExchange($uid, $gold, $gold * $rate, false); } /** diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 16687243..b1a0c167 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -2824,7 +2824,7 @@ tz_def('HERO_EXCHANGE_S2G', 'Silver to gold'); tz_def('HERO_EXCHANGE_OK', 'Exchange completed.'); tz_def('HERO_EXCHANGE_NOTENOUGH', 'You do not have enough for this exchange.'); tz_def('HERO_EXCHANGE_FAIL', 'The exchange could not be completed.'); -tz_def('HERO_EXCHANGE_HINT', 'The amount you type is the gold given or received; silver is calculated at the rate shown.'); +tz_def('HERO_EXCHANGE_HINT', 'You type the amount you give. Silver left over below one unit of gold stays with you.'); tz_def('HERO_RES_PRODUCTION', 'Resources'); tz_def('HERO_RES_TYPE', 'Produced resource'); tz_def('HERO_RES_ALL', 'All resources'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index 31bf7571..06db3c8e 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -2809,7 +2809,7 @@ tz_def('HERO_EXCHANGE_S2G', 'Argint in aur'); tz_def('HERO_EXCHANGE_OK', 'Schimb efectuat.'); tz_def('HERO_EXCHANGE_NOTENOUGH', 'Nu ai suficient pentru acest schimb.'); tz_def('HERO_EXCHANGE_FAIL', 'Schimbul nu a putut fi efectuat.'); -tz_def('HERO_EXCHANGE_HINT', 'Valoarea introdusa e aurul dat sau primit; argintul se calculeaza la rata afisata.'); +tz_def('HERO_EXCHANGE_HINT', 'Introduci suma pe care o dai. Argintul ramas sub o unitate de aur ramane la tine.'); tz_def('HERO_RES_PRODUCTION', 'Resurse'); tz_def('HERO_RES_TYPE', 'Resursa produsa'); tz_def('HERO_RES_ALL', 'Toate resursele'); diff --git a/Templates/Build/37_auction.tpl b/Templates/Build/37_auction.tpl index 468c130d..f8e7b2c1 100644 --- a/Templates/Build/37_auction.tpl +++ b/Templates/Build/37_auction.tpl @@ -116,20 +116,22 @@ $t4RateS2G = HeroItems::silverForOneGold();
+ (1 : )
- + + ( : 1)

+ : 'You type the amount you give. Silver left over below one unit of gold stays with you.'; ?>

diff --git a/Templates/Build/37_hero.tpl b/Templates/Build/37_hero.tpl index 2cb214a0..d7fa2050 100644 --- a/Templates/Build/37_hero.tpl +++ b/Templates/Build/37_hero.tpl @@ -69,147 +69,187 @@ $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) { }; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- uid."\">"; - }else{ - echo "".$hero_info['name'].""; - } - ?> - ( getUnitName($hero_info['unit'])."\" title=\"".$technology->getUnitName($hero_info['unit'])."\" /> ".$technology->getUnitName($hero_info['unit']); ?> )
<?php echo $hero_info['atk']; ?> - -
<?php echo ($hero_info['di']) . " title="" /> - -
%<?php echo ($hero_info['ob']-1)*100; ?>% - -
%<?php echo ($hero_info['db']-1)*100; ?>% - -
/<?php echo ($hero_info['regeneration']*5*SPEED); ?>%/Day - -
- +/* Aspect in stilul T4 (vezi modelul cerut). Clasele au prefix "t4h-" ca sa nu + se amestece cu stilurile paginii; tabelul clasic "distribution" nu mai e + folosit AICI, dar restul paginilor raman neatinse. */ +.t4h-wrap{max-width:560px;font-size:12px} +/* colturi drepte si chenar, ca la tabelele originale din joc; fundalul gri si + barile verzi raman cum erau */ +.t4h-panel{background:#f2f2f2;border:1px solid #c9c9c9;padding:6px 8px;margin-bottom:8px} +.t4h-head{display:flex;justify-content:space-between;align-items:center;font-weight:bold;color:#333;margin-bottom:5px} +.t4h-tbl{width:100%;border-collapse:collapse} +.t4h-tbl td{padding:3px 5px;vertical-align:middle;background:none;border:1px solid #dcdcdc} +.t4h-name{width:112px;color:#333} +.t4h-val{width:78px;color:#000} +.t4h-barcell{width:100%} +.t4h-bar{background:#fff;border:1px solid #c9c9c9;height:13px;overflow:hidden} +.t4h-bar i{display:block;height:100%;background:#7db72f} +.t4h-bar.dark i{background:#3f7a12} +.t4h-up{width:34px;text-align:center;white-space:nowrap} +/* plusul se pierdea pe fundalul gri - acum e verde inchis si ingrosat */ +.t4h-up a{color:#1f7a1f;font-weight:bold;text-decoration:none;font-size:13px} +.t4h-up a:hover{color:#0f5c0f;text-decoration:underline} +.t4h-up .none{color:#b0b0b0} +.t4h-num{width:38px;text-align:right;font-weight:bold;color:#333} +/* toate cele 5 optiuni pe acelasi rand, aliniate (inclusiv cerealele) */ +.t4h-res form{display:flex;flex-wrap:wrap;align-items:center;gap:4px 10px} +.t4h-res label{display:inline-flex;align-items:center;gap:3px;white-space:nowrap;cursor:pointer} +.t4h-res .t4h-note{flex-basis:100%;margin-top:2px} +.t4h-res img.mini{vertical-align:middle;margin:0 2px} +.t4h-res img.t4h-resall{height:16px;width:auto} +.t4h-note{color:#777;font-size:11px;margin-top:4px} + + +
+ +
+
+ + " + . "uid . "\">" + . "" + . ""; + } else { + echo "" . $hero_info['name'] . ""; + } + ?> + + ( getUnitName($hero_info['unit']) . "\" title=\"" . $technology->getUnitName($hero_info['unit']) . "\" /> " + . $technology->getUnitName($hero_info['unit']); + ?> ) + + +
+ + + 'r1', 2 => 'r2', 3 => 'r3', 4 => 'r4']; - if ($t4ResType >= 1 && $t4ResType <= 4) { - echo ' '; - echo (int) round($t4ResPoints * $t4PerOne * SPEED); - } else { - foreach ($t4ResIcons as $t4Ico) { - echo ' ' - . (int) round($t4ResPoints * $t4PerAll * SPEED) . ' '; - } - } - ?> - / - - - - - - - - - - + // valoarea afisata: cat produce efectiv, dupa setarea curenta + $t4ResShown = ($t4ResType >= 1 && $t4ResType <= 4) + ? (int) round($t4ResPoints * $t4PerOne * SPEED) + : (int) round($t4ResPoints * $t4PerAll * SPEED); + + $t4Rows[] = array( + defined('HERO_RES_PRODUCTION') ? HERO_RES_PRODUCTION : 'Resources', + $t4ResShown, + $t4ResPoints, + 'res' + ); + } + + foreach ($t4Rows as $t4Row) { + list($t4Label, $t4Value, $t4Points, $t4Key) = $t4Row; + $t4Fill = max(0, min(100, $t4Points)); + ?> + + + + + + + - - - - - + - // fallback-uri ca să nu mai dea notice - $expCurrent = $hero_levels[$curLevel] ?? 0; - $expNext = $hero_levels[$curLevel + 1] ?? $maxExp; + +
+
+
+ array('img' => 'img/hero/res_all.png', 'amount' => (int) round($t4ResPoints * $t4PerAll * SPEED)), + 1 => array('icons' => array('r1'), 'amount' => (int) round($t4ResPoints * $t4PerOne * SPEED)), + 2 => array('icons' => array('r2'), 'amount' => (int) round($t4ResPoints * $t4PerOne * SPEED)), + 3 => array('icons' => array('r3'), 'amount' => (int) round($t4ResPoints * $t4PerOne * SPEED)), + 4 => array('icons' => array('r4'), 'amount' => (int) round($t4ResPoints * $t4PerOne * SPEED)), + ); + + foreach ($t4Opts as $t4Val => $t4Opt) { + ?> + + + +
+ +
+ + +
+
- -
-
- : - - - - - -
-
+
+
+ + + + + +
% +
+
+
+ +
+ + $expCurrent && $curLevel < 100) { + $percent = ($curExp - $expCurrent) / ($expNext - $expCurrent) * 100; + $percent = max(0, min(100, $percent)); + } else { + $percent = 100; + } + ?> + + + + + + + + + + + +
:
+
+ +
- if($curExp < $maxExp && $expNext > $expCurrent && $curLevel < 100){ - $percent = ($curExp - $expCurrent) / ($expNext - $expCurrent) * 100; - $percent = max(0, min(100, $percent)); - ?> -
:%<?php echo (int)$percent; ?>%:100%100%
0) { ?>
diff --git a/Templates/header.tpl b/Templates/header.tpl index 056d4778..68143eb2 100644 --- a/Templates/header.tpl +++ b/Templates/header.tpl @@ -189,6 +189,27 @@ if ($hour > 1759 || $hour < 500) { echo '' . GOLD . ' ' . $session->gold . ' ' . GOLD; } + + /** + * Argintul eroului, afisat langa aur (doar cu functiile T4 pornite). + * Valoarea sta pe randul eroului, in hero.silver. O tinem in + * $GLOBALS, nu intr-o variabila "static": intr-un fisier inclus, + * "static" nu persista intre includeri, deci nu ar fi un cache real. + */ + if (defined('NEW_FUNCTIONS_HERO_T4') && NEW_FUNCTIONS_HERO_T4 && class_exists('HeroItems')) { + + if (!isset($GLOBALS['t4SilverValue'])) { + $t4SilverItems = new HeroItems(); + $GLOBALS['t4SilverValue'] = (int) $t4SilverItems->getSilver($session->uid); + } + + $t4SilverLabel = defined('HERO_SILVER') ? HERO_SILVER : 'Silver'; + + echo '
' + . '' . $t4SilverLabel . '' + . ' ' . (int) $GLOBALS['t4SilverValue'] . ' ' . $t4SilverLabel + . '
'; + } ?> @@ -284,7 +305,8 @@ if ($hour > 1759 || $hour < 500) { top: 18px; /* centrat pe bara gri */ width: auto; min-width: 100px; - height: 22px; + height: auto; + min-height: 22px; line-height: 22px; text-align: center; font-size: 11px; @@ -297,6 +319,21 @@ if ($hour > 1759 || $hour < 500) { margin-right: 4px; } + /* ARGINT (erou T4) - pe rand propriu, chiar sub aur */ + #silverHeader { + display: block; + white-space: nowrap; + line-height: 16px; + margin-top: -4px; + } + + #silverHeader img { + vertical-align: middle; + margin-right: 4px; + width: 12px; + height: 12px; + } + diff --git a/img/hero/res_all.png b/img/hero/res_all.png new file mode 100644 index 0000000000000000000000000000000000000000..a243590c311effd5b6af2166fb7c406e93d82884 GIT binary patch literal 3582 zcmV5CK7;u>w(nf=VPBtW<3YDvchG zm;h>MWD<%%jS?xPDt4r{32jLMV*@3C8NA!rv)HpQZ|3dqZs(qJ`iEm<18LRYU-w+y z-|u|RIlue;{SE*ilgZFMd-mA)f7sr=8SC<~F(Ah5WuJ^Q)SMWwKI{2eGvt_xG({-P=$oRAa|apC(5KkCLgWIl~;T8|v$s!#PGL z%kwY)Y|rVK1C(YT*>-NuCaYKP{s2($Kfb-+wgn+QFP{bgGkw=`bflV43xPRTg+&Rg zh1rtZag(c7tPLBE5t5CrSU@I2Nj9rL511b~aKHlK1Hj*8uEty{GHELVh==ianK&?)df|;%S&~YelGe=hknM9lxlc7Tpge zcfglKg^^1*07DxYHEF}yag2`sIe_s`cH0mP-6YIo8A-@zp?NNsBbiJl&KT<&8yovW z$8qi@gwz3;r;O!cOamdrA|L?)H~}G?WBtIugFD~&uf@78zr!2bnsxOr3b!S5Y6_R^5pIFwUWFiLFh7Y2G-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=Ke1wifwk!wg}=HTZok=GWAmvW$4I2MSw3|RKqGp&M)HB+0u!& z#)RLwVkwq&Cq4v{vH&Qh&3na)pBf)oTnU1P(2qa>I57*8qj~s2biCw6fu{+KV8`r~ z{qIly$D!GaK$#3EPOTN#cPhHPBwqraL{|vB2LSl-{@UEbUop>UZGS`<{hke4KRUdK zvm*;I28eMAP>tECpcMG{Q8fsTSPnxFN?90u-2>nef*<7z-pRLLJM(1svHE&1lpp|N zw!p|tvEyM8lQjYWdjU3f!wt^Euf1L~Fvwhc zbDAe=e-r0oW4RWXk{fswK-{)taod8gqT}njx_9sV$xm{Z#j*f|0I;LIy=C3f#G`eV zwb6?r0{{-^sDh%kQgVE(V`?t<807*qoM6N<$ Ef_aq2(EtDd literal 0 HcmV?d00001 diff --git a/img/hero/silver.png b/img/hero/silver.png new file mode 100644 index 0000000000000000000000000000000000000000..7bc38cf76007f8a83e63991a201f67170fc5efe0 GIT binary patch literal 613 zcmV-r0-F7aP)g^a<7KBln_)sAd1ou!u1S<6u^dupS74+bXy;u~B z2ti_d3ZhU1A8I~q+MYJaiY(*wB-w4(&E4Ja?$?7s(C7K{;e&Fy9ABwas3b`O&+|yv zb!3_*GYkX8Vle{%K$c|}02lxOmSx!zMKQ@-cR|y%Wy>^|sbwwkgcMXo8Ion$NvG3o z@E7!CcJ{d-2w}{VO=?lgbzQJc6I{pPT9$P@6bMY+93L;F(`k~)WGI@Sn`0fp(A`U; zBQx+HFS6Oo)%EIyuirMOQ>oM@007=r)z8o7vpW;FC(a}EPaeB7*1NRw-i{~4f&R1o z=Q5d$3jl;DJBsM@`X1GEtNK_U_eqIC|qq&r#t}B%%TU#N%;BJRZ-l zXec_mvRXa{2*0x_ZDE80%9cKJ`ivx%R!eU&<~k0(Yd~z;2s@`bY!0;{VIJAx9NJDG=q@B*=nx;+H z8;vjkfTAb}I}Uy74+Qpj-s>{NFks*qAdVsACK3r+F0bW_#o`8I3{|UDhb%5G-Iw~L ze0#vVYg)zwALsEJM)P;PD|&6;*uR$)d#+DTO%`LZ7|G}JlyrA@>&XZ|^7_rjpkD}m za9xK6!+wwQz5ejjknhBLX`SYBIZl>k3IOm2Lxuaf%VuzH00000NkvXXu0mjfk#r&^ literal 0 HcmV?d00001