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 00000000..a243590c Binary files /dev/null and b/img/hero/res_all.png differ diff --git a/img/hero/silver.png b/img/hero/silver.png new file mode 100644 index 00000000..7bc38cf7 Binary files /dev/null and b/img/hero/silver.png differ