Some important fix and view

Some important fix and view
This commit is contained in:
novgorodschi catalin
2026-08-11 08:31:17 +03:00
parent ba9bb0f6f6
commit ac262db66f
10 changed files with 575 additions and 87 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ function go_url(url){ location=url; return false; }
| Points used: <b><?php echo $eUsed; ?></b><?php echo ADM_OF; ?><b><?php echo $eTotal; ?></b><?php echo ADM_FREE; ?><b><?php echo $eFree; ?></b>)</div>
<div><?php echo ADM_OFFENCE; ?><b><?php echo $hero['atk'];?></b> (Lv <?php echo $hero['attack'];?>)</div>
<div><?php echo ADM_DEFENCE; ?><b><?php echo $hero['di']."/".$hero['dc'];?></b> (Lv <?php echo $hero['defence'];?>)</div>
<div><?php echo ADM_OFF_BONUS; ?><b><?php echo ($hero['ob']-1)*100;?>%</b><?php echo ADM_DEF_BONUS; ?><b><?php echo ($hero['db']-1)*100;?>%</b></div>
<div><?php echo ADM_OFF_BONUS; ?><b><?php echo round(($hero['ob']-1)*100, 1);?>%</b><?php echo ADM_DEF_BONUS; ?><b><?php echo round(($hero['db']-1)*100, 1);?>%</b></div>
<div><?php echo ADM_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);
+2 -2
View File
@@ -128,8 +128,8 @@ if ($hero !== false) {
<tr><th><?php echo ADM_DETAILS; ?></th><th><?php echo ADM_POINT; ?></th><th><?php echo ADM_LEVEL_2; ?></th></tr>
<tr><td><?php echo ADM_OFFENCE_2; ?></td><td><?php echo $h['atk']; ?></td><td><?php echo $h['attack']; ?></td></tr>
<tr><td><?php echo ADM_DEFENCE_2; ?></td><td><?php echo $h['di']."/".$h['dc']; ?></td><td><?php echo $h['defence']; ?></td></tr>
<tr><td><?php echo ADM_OFF_BONUS_2; ?></td><td><?php echo ($h['ob']-1)*100; ?>%</td><td><?php echo $h['attackbonus']; ?></td></tr>
<tr><td><?php echo ADM_DEF_BONUS_2; ?></td><td><?php echo ($h['db']-1)*100; ?>%</td><td><?php echo $h['defencebonus']; ?></td></tr>
<tr><td><?php echo ADM_OFF_BONUS_2; ?></td><td><?php echo round(($h['ob']-1)*100, 1); ?>%</td><td><?php echo $h['attackbonus']; ?></td></tr>
<tr><td><?php echo ADM_DEF_BONUS_2; ?></td><td><?php echo round(($h['db']-1)*100, 1); ?>%</td><td><?php echo $h['defencebonus']; ?></td></tr>
<tr><td><?php echo ADM_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);
+54 -10
View File
@@ -461,6 +461,18 @@ class HeroItems
$p = TB_PREFIX;
/**
* FIX: eroul care se INTORCEA dintr-o aventura aparea ca fiind acasa.
*
* Ciclul unei aventuri e: status 0 (oferta) -> status 1 (dus, miscare
* sort_type 20) -> la sosire status devine 2 si se creeaza miscarea de
* intoarcere (sort_type 21). Numaram doar status = 1, deci pe tot
* drumul de intoarcere eroul "disparea": bara de sus scria "Hero at
* home", iar pagina de echipare lasa schimbarea itemelor desi eroul
* era inca pe drum. Adaugam si miscarea de intoarcere.
*/
$advBack = defined('MOVEMENT_ADVENTURE_BACK') ? (int) MOVEMENT_ADVENTURE_BACK : 21;
// ATENTIE: aliasul pentru miscarea de intoarcere NU poate fi "returning" -
// e cuvant rezervat in MariaDB (clauza RETURNING) si strica query-ul.
// Un singur query, cu motive separate, ca interfata sa poata afisa
@@ -471,6 +483,10 @@ class HeroItems
WHERE uid = ? AND COALESCE(intraining, 0) = 0) AS hero_exists,
(SELECT COUNT(*) FROM {$p}hero_adventure
WHERE uid = ? AND status = 1) AS adventure,
(SELECT COUNT(*) FROM {$p}movement m
INNER JOIN {$p}vdata v ON v.wref = m.`to`
WHERE v.owner = ? AND m.proc = 0
AND m.sort_type = {$advBack}) AS adv_return,
(SELECT IFNULL(SUM(e.hero), 0) FROM {$p}enforcement e
INNER JOIN {$p}vdata v ON v.wref = e.`from`
WHERE v.owner = ?) AS reinforcement,
@@ -490,9 +506,9 @@ class HeroItems
return self::$awayCache[$uid] = '';
}
$stmt->bind_param('iiiii', $uid, $uid, $uid, $uid, $uid);
$stmt->bind_param('iiiiii', $uid, $uid, $uid, $uid, $uid, $uid);
$stmt->execute();
$stmt->bind_result($heroExists, $adventure, $reinforcement, $outgoing, $atkReturn);
$stmt->bind_result($heroExists, $adventure, $advReturn, $reinforcement, $outgoing, $atkReturn);
$stmt->fetch();
$stmt->close();
@@ -504,7 +520,10 @@ class HeroItems
// conteaza - inca nu exista cu adevarat.
if ((int) $heroExists === 0) {
$reason = 'nohero';
} elseif ((int) $adventure > 0) {
} elseif (((int) $adventure + (int) $advReturn) > 0) {
// "adventure" acopera ambele picioare ale drumului: dus si intors.
// Contractul metodei ramane neschimbat, deci 37_items.tpl continua
// sa afiseze acelasi mesaj - doar ca acum si pe drumul de intoarcere.
$reason = 'adventure';
} elseif (((int) $outgoing + (int) $atkReturn) > 0) {
$reason = 'attack';
@@ -539,7 +558,13 @@ class HeroItems
return self::$locationCache[$uid];
}
$info = array('reason' => $this->heroAwayReason($uid), 'target' => 0, 'endtime' => 0, 'sort' => 0);
$info = array(
'reason' => $this->heroAwayReason($uid),
'target' => 0,
'endtime' => 0,
'sort' => 0,
'returning' => false, // true = se intoarce acasa
);
if ($info['reason'] === '' || $info['reason'] === 'nohero') {
return self::$locationCache[$uid] = $info;
@@ -548,14 +573,24 @@ class HeroItems
$p = TB_PREFIX;
$q = '';
$advOut = defined('MOVEMENT_ADVENTURE_OUT') ? (int) MOVEMENT_ADVENTURE_OUT : 20;
$advBack = defined('MOVEMENT_ADVENTURE_BACK') ? (int) MOVEMENT_ADVENTURE_BACK : 21;
if ($info['reason'] === 'adventure') {
// LEFT JOIN, nu INNER: daca randul de miscare a fost deja procesat,
// vrem macar destinatia, nu sa pierdem tot randul.
$q = "SELECT a.wref AS target, IFNULL(m.endtime, 0) AS endtime, IFNULL(m.sort_type, 0) AS sort_type
FROM {$p}hero_adventure a
LEFT JOIN {$p}movement m ON m.moveid = a.moveid
WHERE a.uid = ? AND a.status = 1
/**
* Citim direct miscarea, nu randul din hero_adventure: la
* intoarcere randul e deja status = 2, deci ar fi invizibil.
* Satul jucatorului e `from` la dus si `to` la intors, de aceea
* IF() alege coloana potrivita pentru verificarea proprietarului.
* Destinatia afisata e mereu `to` - locul aventurii la dus,
* satul de acasa la intoarcere.
*/
$q = "SELECT m.`to` AS target, m.endtime, m.sort_type
FROM {$p}movement m
INNER JOIN {$p}vdata v ON v.wref = IF(m.sort_type = {$advBack}, m.`to`, m.`from`)
WHERE v.owner = ? AND m.proc = 0 AND m.sort_type IN ({$advOut}, {$advBack})
ORDER BY m.endtime ASC
LIMIT 1";
} elseif ($info['reason'] === 'attack') {
@@ -597,6 +632,15 @@ class HeroItems
$info['target'] = (int) $target;
$info['endtime'] = (int) $endtime;
$info['sort'] = (int) $sortType;
/**
* Drumul de intoarcere, indiferent de unde:
* sort_type 21 = intoarcere din aventura
* sort_type 4 = intoarcere din atac SAU erou rechemat dintr-o
* intarire (ambele produc aceeasi miscare, deci
* nu pot fi deosebite - textul e generic)
*/
$info['returning'] = ($info['sort'] === $advBack || $info['sort'] === 4);
}
$stmt->close();
+13 -5
View File
@@ -4370,8 +4370,16 @@ tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Comma-separated player names that cannot be
//////////////////////////////////////////////////////////////////////////////////////////////////////
// COMPONENTA HERO DIN BARA DE SUS
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('HERO_HEADER_AT_HOME', 'Hero at home');
tz_def('HERO_HEADER_DEAD', 'Hero is dead');
tz_def('HERO_HEADER_TRAINING', 'Hero in training');
tz_def('HERO_HEADER_NOHERO', 'No hero yet');
tz_def('TZ_HEALTH', 'Health');
tz_def('HERO_HEADER_AT_HOME', 'Hero at home');
tz_def('HERO_HEADER_DEAD', 'Hero is dead');
tz_def('HERO_HEADER_TRAINING', 'Hero in training');
tz_def('HERO_HEADER_NOHERO', 'No hero yet');
tz_def('HERO_HEADER_ADVENTURE', 'Hero on adventure');
tz_def('HERO_HEADER_ATTACK', 'Hero is with the army');
tz_def('HERO_HEADER_REINFORCE', 'Hero is reinforcing');
tz_def('HERO_HEADER_IN', 'in');
tz_def('HERO_HEADER_RETURN_ADV', 'Hero returning from adventure');
tz_def('HERO_HEADER_RETURN_HOME', 'Hero returning home');
tz_def('HERO_HEADER_PER_HOUR', 'per hour');
tz_def('TZ_HEALTH', 'Health');
+12 -5
View File
@@ -4313,8 +4313,15 @@ tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Noms de joueurs separes par des virgules qu
//////////////////////////////////////////////////////////////////////////////////////////////////////
// COMPONENTA HERO DIN BARA DE SUS
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('HERO_HEADER_AT_HOME', 'Le heros est chez lui');
tz_def('HERO_HEADER_DEAD', 'Le heros est mort');
tz_def('HERO_HEADER_TRAINING', 'Heros en formation');
tz_def('HERO_HEADER_NOHERO', 'Pas encore de heros');
tz_def('TZ_HEALTH', 'Sante');
tz_def('HERO_HEADER_AT_HOME', 'Le heros est chez lui');
tz_def('HERO_HEADER_DEAD', 'Le heros est mort');
tz_def('HERO_HEADER_TRAINING', 'Heros en formation');
tz_def('HERO_HEADER_NOHERO', 'Pas encore de heros');
tz_def('HERO_HEADER_ADVENTURE', 'Le heros est en aventure');
tz_def('HERO_HEADER_ATTACK', 'Le heros est parti avec l\'armee');
tz_def('HERO_HEADER_REINFORCE', 'Le heros est en renfort');
tz_def('HERO_HEADER_IN', 'dans');
tz_def('HERO_HEADER_RETURN_ADV', 'Le heros revient de l\'aventure');
tz_def('HERO_HEADER_RETURN_HOME', 'Le heros rentre chez lui');
tz_def('HERO_HEADER_PER_HOUR', 'par heure');
tz_def('TZ_HEALTH', 'Sante');
+10 -6
View File
@@ -2790,7 +2790,7 @@ tz_def('HERO_AUC_SELL_FAIL', 'Acest obiect nu poate fi listat (obiectele ech
tz_def('HERO_AUC_SELL_OK', 'Obiectul tau a fost listat.');
tz_def('HERO_AUC_SOLD', 'Licitatia ta s-a vandut:');
tz_def('HERO_AUC_START_PRICE', 'Pret de pornire');
tz_def('HERO_AUC_TIME_LEFT', 'Se incheie in');
tz_def('HERO_AUC_TIME_LEFT', 'Se incheie');
tz_def('HERO_AUC_WON', 'Ai castigat licitatia pentru');
tz_def('HERO_AUC_YOUR_MAX', 'Maximul tau');
@@ -4110,8 +4110,12 @@ tz_def('ADM_PROTECTED_PLAYERS_TIP', 'Nume de jucatori separate prin virgula, car
//////////////////////////////////////////////////////////////////////////////////////////////////////
// COMPONENTA HERO DIN BARA DE SUS
//////////////////////////////////////////////////////////////////////////////////////////////////////
tz_def('HERO_HEADER_AT_HOME', 'Eroul este acasa');
tz_def('HERO_HEADER_DEAD', 'Eroul este mort');
tz_def('HERO_HEADER_TRAINING', 'Eroul este in antrenament');
tz_def('HERO_HEADER_NOHERO', 'Inca nu ai erou');
tz_def('TZ_HEALTH', 'Sanatate');
tz_def('HERO_HEADER_AT_HOME', 'Eroul este acasa');
tz_def('HERO_HEADER_DEAD', 'Eroul este mort');
tz_def('HERO_HEADER_TRAINING', 'Eroul este in antrenament');
tz_def('HERO_HEADER_NOHERO', 'Inca nu ai erou');
tz_def('HERO_HEADER_ADVENTURE', 'Eroul este in aventura');
tz_def('HERO_HEADER_ATTACK', 'Eroul este plecat cu armata');
tz_def('HERO_HEADER_REINFORCE', 'Eroul este intr-o intarire');
tz_def('HERO_HEADER_IN', 'in');
tz_def('TZ_HEALTH', 'Sanatate');
+295 -46
View File
@@ -88,6 +88,173 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
}
?>
<style type="text/css">
/* ---------------------------------------------------------------------------
Stiluri locale pentru pagina de licitatii. Toate clasele au prefixul
"t4auc-" ca sa nu atinga nimic altceva din interfata.
--------------------------------------------------------------------------- */
/* --- Casa de schimb: cele doua celule egale pe inaltime, continut centrat --- */
.t4auc-ex td { vertical-align: middle; }
.t4auc-ex-cell { width: 50%; padding: 12px 10px; }
.t4auc-ex-inner {
max-width: 290px;
margin: 0 auto; /* centrat pe orizontala in celula */
text-align: left;
}
.t4auc-balance {
display: flex;
justify-content: center;
gap: 18px;
margin: 0 0 12px 0;
padding: 0 0 10px 0;
border-bottom: 1px solid #dcd9d3;
}
.t4auc-bal {
display: flex;
align-items: center;
gap: 5px;
font-size: 12px;
white-space: nowrap;
}
.t4auc-bal b { font-size: 13px; }
/* Aceleasi monede desenate ca in bara de sus (header.tpl) */
.t4auc-coin { display: block; width: 18px; height: 18px; flex: 0 0 18px; }
.t4auc-coin .t4auc-coinBg { fill: #f6f5f2; stroke: #b8b6b1; stroke-width: 1; }
.t4auc-coin-gold .t4auc-coinDisc { fill: #e3b427; stroke: #9a7512; stroke-width: .8; }
.t4auc-coin-gold .t4auc-coinShine { fill: #f7e08a; }
.t4auc-coin-silver .t4auc-coinDisc { fill: #cdd2d6; stroke: #7e858b; stroke-width: .8; }
.t4auc-coin-silver .t4auc-coinShine { fill: #eef1f3; }
.t4auc-form {
display: flex;
align-items: center;
gap: 7px;
margin: 0 0 9px 0;
}
.t4auc-num {
width: 76px;
padding: 3px 5px;
text-align: right;
border: 1px solid #b9b6b0;
border-radius: 3px;
font-size: 12px;
}
.t4auc-rate {
color: #8a877f;
font-size: 11px;
white-space: nowrap;
}
.t4auc-hint {
margin: 10px 0 0 0;
color: #8a877f;
font-size: 11px;
line-height: 1.45;
}
.t4auc-merchant { max-width: 100%; max-height: 230px; }
/* --- Butoane --- */
.t4auc-btn {
display: inline-block;
padding: 4px 12px;
font-size: 11px;
font-weight: bold;
color: #3f5f22;
cursor: pointer;
white-space: nowrap;
background: #e4f0d0;
background: linear-gradient(#fbfdf6, #dcebc6);
border: 1px solid #a3bf7c;
border-radius: 4px;
}
.t4auc-btn:hover {
background: #d6e8bd;
background: linear-gradient(#ffffff, #cfe4b0);
border-color: #8bab61;
}
.t4auc-btn:active {
background: linear-gradient(#d5e6b8, #e9f3da);
border-color: #8bab61;
}
/* --- Tabelul de licitatii deschise ---------------------------------------
Latimile sunt stranse la minimul in care incape headerul, ca tabelul sa nu
mai depaseasca zona de continut (~505px) si sa nu mai apara scroll
orizontal. Total: 78+96+66+46+66+74 = 426px + padding. */
.t4auc-tbl th { text-align: center; }
/* fara white-space:nowrap pe th: "Se incheie in" se rupe pe doua randuri
in loc sa forteze latirea coloanei */
.t4auc-tbl td, .t4auc-tbl th { padding: 4px 3px; }
.t4auc-col-item { width: 78px; text-align: center; }
.t4auc-col-tier { width: 96px; text-align: center; }
.t4auc-col-qty { width: 66px; text-align: center; }
.t4auc-col-price { width: 46px; text-align: center; }
.t4auc-col-time { width: 66px; text-align: center; }
.t4auc-col-bid { width: 74px; text-align: center; }
/* Obiect: iconita sus, numele dedesubt cu scris palid */
.t4auc-itemname {
display: block;
margin-top: 2px;
color: #9b978f;
font-size: 10px;
line-height: 1.3;
word-wrap: break-word;
}
/* Tier: numarul sus, abilitatea dedesubt cu scris mai pal */
.t4auc-tier {
display: inline-block;
min-width: 30px;
padding: 1px 6px;
font-size: 11px;
font-weight: bold;
color: #5c5850;
background: #eceae5;
border: 1px solid #cfccc5;
border-radius: 3px;
}
.t4auc-ability {
display: block;
margin-top: 3px;
color: #9b978f; /* palid, ca sa nu concureze cu numele obiectului */
font-size: 9px;
line-height: 1.3;
word-wrap: break-word;
}
/* Oferta: casuta SUS, butonul DEDESUBT - una langa alta cereau ~116px,
stivuite incap in 74px */
.t4auc-bidform { margin: 0; text-align: center; }
.t4auc-bidnum {
display: block;
width: 56px;
margin: 0 auto 3px auto;
padding: 2px 4px;
text-align: right;
border: 1px solid #b9b6b0;
border-radius: 3px;
font-size: 11px;
}
.t4auc-bidform .t4auc-btn { padding: 3px 9px; }
</style>
<?php if ($t4Msg !== '') { ?>
<p class="message" style="font-weight:bold;"><?php echo $t4Msg; ?></p>
<?php } ?>
@@ -100,41 +267,76 @@ $t4Gold = (int) $session->gold;
$t4RateG2S = HeroItems::silverPerGold();
$t4RateS2G = HeroItems::silverForOneGold();
?>
<table id="distribution" cellpadding="1" cellspacing="1">
<?php
/**
* Aceleasi monede desenate ca in bara de sus, ca sa nu existe doua
* reprezentari diferite pentru aur si argint. Culorile vin din blocul
* <style> de mai sus, nu din atribute inline.
*/
if (!function_exists('t4AucCoin')) {
function t4AucCoin($tone, $title)
{
return '<svg viewBox="0 0 24 24" class="t4auc-coin t4auc-coin-' . $tone . '" role="img">'
. '<title>' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '</title>'
. '<circle cx="12" cy="12" r="11" class="t4auc-coinBg" />'
. '<ellipse cx="12" cy="16.1" rx="6.2" ry="2.3" class="t4auc-coinDisc" />'
. '<ellipse cx="12" cy="13.1" rx="6.2" ry="2.3" class="t4auc-coinDisc" />'
. '<ellipse cx="12" cy="10.1" rx="6.2" ry="2.3" class="t4auc-coinDisc" />'
. '<ellipse cx="12" cy="10.1" rx="2.6" ry="0.9" class="t4auc-coinShine" />'
. '</svg>';
}
}
$t4LblGold = defined('GOLD') ? GOLD : 'Gold';
$t4LblSilver = defined('HERO_SILVER') ? HERO_SILVER : 'Silver';
?>
<table id="distribution" class="t4auc-ex" cellpadding="1" cellspacing="1">
<thead>
<tr><th colspan="2"><?php echo defined('HERO_EXCHANGE') ? HERO_EXCHANGE : 'Exchange office'; ?></th></tr>
</thead>
<tbody>
<tr>
<td style="width:290px;vertical-align:top;">
<p style="margin:0 0 6px 0;">
<b><?php echo HERO_SILVER; ?>:</b> <?php echo $t4Silver; ?>
&nbsp;&nbsp;
<b><?php echo defined('GOLD') ? GOLD : 'Gold'; ?>:</b> <?php echo $t4Gold; ?>
</p>
<td class="t4auc-ex-cell">
<div class="t4auc-ex-inner">
<form action="" method="POST" style="margin:0 0 5px 0;">
<input type="hidden" name="t4action" value="g2s">
<input type="number" name="amount" min="1" max="100000" value="1" style="width:70px">
<?php echo defined('GOLD') ? GOLD : 'Gold'; ?>
<input type="submit" value="<?php echo defined('HERO_EXCHANGE_G2S') ? HERO_EXCHANGE_G2S : 'Gold to silver'; ?>">
<small>(1 : <?php echo $t4RateG2S; ?>)</small>
</form>
<div class="t4auc-balance">
<span class="t4auc-bal">
<?php echo t4AucCoin('silver', $t4LblSilver); ?>
<b><?php echo number_format((int) $t4Silver); ?></b>
</span>
<span class="t4auc-bal">
<?php echo t4AucCoin('gold', $t4LblGold); ?>
<b><?php echo number_format((int) $t4Gold); ?></b>
</span>
</div>
<form action="" method="POST" style="margin:0;">
<input type="hidden" name="t4action" value="s2g">
<input type="number" name="amount" min="1" max="100000000" value="<?php echo $t4RateS2G; ?>" style="width:70px">
<?php echo HERO_SILVER; ?>
<input type="submit" value="<?php echo defined('HERO_EXCHANGE_S2G') ? HERO_EXCHANGE_S2G : 'Silver to gold'; ?>">
<small>(<?php echo $t4RateS2G; ?> : 1)</small>
</form>
<form action="" method="POST" class="t4auc-form">
<input type="hidden" name="t4action" value="g2s">
<input type="number" name="amount" min="1" max="100000" value="1" class="t4auc-num">
<?php echo t4AucCoin('gold', $t4LblGold); ?>
<button type="submit" class="t4auc-btn"><?php
echo defined('HERO_EXCHANGE_G2S') ? HERO_EXCHANGE_G2S : 'Gold to silver';
?></button>
<span class="t4auc-rate">1 : <?php echo $t4RateG2S; ?></span>
</form>
<p style="margin:6px 0 0 0;color:#777;font-size:11px;">
<?php echo defined('HERO_EXCHANGE_HINT') ? HERO_EXCHANGE_HINT
: 'You type the amount you give. Silver left over below one unit of gold stays with you.'; ?>
</p>
<form action="" method="POST" class="t4auc-form">
<input type="hidden" name="t4action" value="s2g">
<input type="number" name="amount" min="1" max="100000000" value="<?php echo $t4RateS2G; ?>" class="t4auc-num">
<?php echo t4AucCoin('silver', $t4LblSilver); ?>
<button type="submit" class="t4auc-btn"><?php
echo defined('HERO_EXCHANGE_S2G') ? HERO_EXCHANGE_S2G : 'Silver to gold';
?></button>
<span class="t4auc-rate"><?php echo $t4RateS2G; ?> : 1</span>
</form>
<p class="t4auc-hint">
<?php echo defined('HERO_EXCHANGE_HINT') ? HERO_EXCHANGE_HINT
: 'You type the amount you give. Silver left over below one unit of gold stays with you.'; ?>
</p>
</div>
</td>
<td style="text-align:center;vertical-align:middle;">
<td class="t4auc-ex-cell" style="text-align:center;">
<?php
/**
* Negustorul casei de licitatii, pe trib.
@@ -178,49 +380,96 @@ $t4RateS2G = HeroItems::silverForOneGold();
$t4MerchantFile = 'merchant.png';
}
?>
<img src="img/hero/<?php echo $t4MerchantFile; ?>" alt=""
style="max-width:280px;max-height:300px;">
<img class="t4auc-merchant" src="img/hero/<?php echo $t4MerchantFile; ?>" alt="">
</td>
</tr>
</tbody>
</table>
<table id="distribution" cellpadding="1" cellspacing="1">
<?php
/**
* Tier-ul obiectului vine din catalogul de iteme ($heroItemCatalog), acolo
* unde e definit si bonusul - deci o singura sursa de adevar, nu o lista
* paralela care s-ar desincroniza la prima modificare de balans.
*/
if (!function_exists('t4AucItemTier')) {
function t4AucItemTier($itemid)
{
global $heroItemCatalog;
return isset($heroItemCatalog[(int) $itemid]['tier'])
? (int) $heroItemCatalog[(int) $itemid]['tier']
: 0;
}
}
$t4LblTier = defined('HERO_AUC_TIER') ? HERO_AUC_TIER : 'Tier';
/**
* Eticheta scurta pentru coloana de pret: HERO_AUC_PRICE e "Pret curent" /
* "Current price" si latea coloana degeaba. Daca HERO_AUC_PRICE_SHORT nu e
* definita inca, ramanem pe cea lunga - nu vrem sa apara brusc engleza
* intr-o interfata romaneasca.
*/
$t4LblPrice = defined('HERO_AUC_PRICE_SHORT') ? HERO_AUC_PRICE_SHORT : HERO_AUC_PRICE;
?>
<table id="distribution" class="t4auc-tbl" cellpadding="1" cellspacing="1">
<thead>
<tr><th colspan="5"><?php echo HERO_AUC_OPEN; ?></th></tr>
<tr><th colspan="6"><?php echo HERO_AUC_OPEN; ?></th></tr>
<tr>
<td><b><?php echo HERO_AUC_ITEM; ?></b></td>
<td><b><?php echo HERO_QUANTITY; ?></b></td>
<td><b><?php echo HERO_AUC_PRICE; ?></b></td>
<td><b><?php echo HERO_AUC_TIME_LEFT; ?></b></td>
<td><b><?php echo HERO_AUC_BID; ?></b></td>
<th class="t4auc-col-item"><?php echo HERO_AUC_ITEM; ?></th>
<th class="t4auc-col-tier"><?php echo $t4LblTier; ?></th>
<th class="t4auc-col-qty"><?php echo HERO_QUANTITY; ?></th>
<th class="t4auc-col-price"><?php echo $t4LblPrice; ?></th>
<th class="t4auc-col-time"><?php echo HERO_AUC_TIME_LEFT; ?></th>
<th class="t4auc-col-bid"><?php echo HERO_AUC_BID; ?></th>
</tr>
</thead>
<tbody>
<?php if (count($t4Open)) { ?>
<?php foreach ($t4Open as $t4A) { ?>
<?php
$t4ItemId = (int) $t4A['itemid'];
$t4Tier = t4AucItemTier($t4ItemId);
$t4Ability = heroItemBonusText($t4ItemId);
?>
<tr>
<td title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4A['itemid'])); ?>"><span class="heroT4Item item<?php echo (int) $t4A['itemid']; ?>"></span> <?php echo $t4A['name']; ?>
<?php if ((int) $t4A['seller'] === 0) { ?><small>(<?php echo HERO_AUC_SELLER_NPC; ?>)</small><?php } ?>
<td class="t4auc-col-item" title="<?php echo htmlspecialchars($t4Ability); ?>">
<span class="heroT4Item item<?php echo $t4ItemId; ?>"></span>
<span class="t4auc-itemname">
<?php echo $t4A['name']; ?><?php if ((int) $t4A['seller'] === 0) { ?> (<?php echo HERO_AUC_SELLER_NPC; ?>)<?php } ?>
</span>
</td>
<td style="text-align:center;"><?php echo (int) $t4A['quantity']; ?></td>
<td style="text-align:right;"><?php echo number_format((int) $t4A['silver_current']); ?></td>
<td><span id="timer<?php echo ++$session->timer; ?>"><?php echo $generator->getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?></span></td>
<td style="width:170px;text-align:center;">
<td class="t4auc-col-tier" style="text-align:center;">
<?php if ($t4Tier > 0) { ?>
<span class="t4auc-tier"><?php echo $t4LblTier; ?> <?php echo $t4Tier; ?></span>
<?php } else { ?>
<span class="t4auc-tier">&ndash;</span>
<?php } ?>
<?php if ($t4Ability !== '') { ?>
<span class="t4auc-ability"><?php echo htmlspecialchars($t4Ability); ?></span>
<?php } ?>
</td>
<td class="t4auc-col-qty"><?php echo (int) $t4A['quantity']; ?></td>
<td class="t4auc-col-price"><?php echo number_format((int) $t4A['silver_current']); ?></td>
<td class="t4auc-col-time">
<span id="timer<?php echo ++$session->timer; ?>"><?php echo $generator->getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?></span>
</td>
<td class="t4auc-col-bid">
<?php if ((int) $t4A['seller'] !== $session->uid) { ?>
<form action="" method="POST" style="margin:0;">
<form action="" method="POST" class="t4auc-bidform">
<input type="hidden" name="t4action" value="bid">
<input type="hidden" name="aucid" value="<?php echo (int) $t4A['id']; ?>">
<input type="text" name="maxbid" size="6" style="text-align:right;"
<input type="text" name="maxbid" class="t4auc-bidnum"
value="<?php echo (int) $t4A['silver_current'] + ((int) $t4A['bidder'] > 0 ? 1 : 0); ?>">
<input type="submit" value="<?php echo HERO_AUC_BID; ?>">
<button type="submit" class="t4auc-btn"><?php echo HERO_AUC_BID; ?></button>
</form>
<?php } else { ?>-<?php } ?>
<?php } else { ?>&ndash;<?php } ?>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr><td colspan="5"><?php echo HERO_AUC_NONE; ?></td></tr>
<tr><td colspan="6"><?php echo HERO_AUC_NONE; ?></td></tr>
<?php } ?>
</tbody>
</table>
+25 -2
View File
@@ -150,14 +150,37 @@ $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) {
<table class="t4h-tbl">
<?php
/**
* BUG FIX: Bonus atac / Bonus aparare aratau "1.2%" in loc de "20%".
*
* 'ob' si 'db' NU sunt procente, ci MULTIPLICATORI de lupta:
* ob = 1 + 0.002 * attackbonus
* adica 100 de puncte (maximul) inseamna 1.2, deci +20%. Tabelul le
* tiparea direct cu semnul %, asa ca multiplicatorul aparea ca procent.
*
* Doar afisarea era gresita: Battle.php foloseste aceeasi formula
* (getBattleHero: 1 + 0.010 * (bonus / 5), identic cu 1 + 0.002 * bonus)
* si inmulteste corect atacul/apararea cu ea, deci luptele s-au calculat
* mereu bine. Panoul de Admin facea deja conversia asta.
*
* Rotunjim la o zecimala fiindca 0.002 nu e exact in binar:
* (1.2 - 1) * 100 da 19.999999999999996.
*/
$t4BonusPct = function ($multiplier) {
$pct = round(((float) $multiplier - 1) * 100, 1);
// 20 in loc de 20.0, dar pastram 19.8 cand chiar are zecimala
return ($pct == (int) $pct) ? (string) (int) $pct : (string) $pct;
};
// nume afisat, valoarea, punctele investite si cheia pentru (+)
$t4Rows = array(
array(OFFENCE, $t4ItemStrength > 0
? $hero_info['atk'] . ' <span class="t4h-item">+' . number_format($t4ItemStrength) . '</span>'
: $hero_info['atk'], (int) $hero_info['attack'], 'off'),
array(DEFENCE, $hero_info['dc'] . '/' . $hero_info['di'], (int) $hero_info['defence'], 'deff'),
array(OFF_BONUS, $hero_info['ob'] . '%', (int) $hero_info['attackbonus'], 'obonus'),
array(DEF_BONUS, $hero_info['db'] . '%', (int) $hero_info['defencebonus'], 'dbonus'),
array(OFF_BONUS, $t4BonusPct($hero_info['ob']) . '%', (int) $hero_info['attackbonus'], 'obonus'),
array(DEF_BONUS, $t4BonusPct($hero_info['db']) . '%', (int) $hero_info['defencebonus'], 'dbonus'),
array(REGENERATION, ($hero_info['regeneration'] * 5 * SPEED) . '/' . DAY, (int) $hero_info['regeneration'], 'reg'),
);
+122 -10
View File
@@ -147,10 +147,11 @@ if ($tzHeroExists && $tzCurExp < $tzMaxExp && $tzExpNext > $tzExpCur && $tzHeroL
* Metoda are cache static pe uid, deci daca o mai cheama cineva pe aceeasi
* pagina nu se duce a doua oara la baza de date.
*/
$tzHeroAway = '';
$tzHeroTarget = 0;
$tzHeroEndtime = 0;
$tzHeroSort = 0;
$tzHeroAway = '';
$tzHeroTarget = 0;
$tzHeroEndtime = 0;
$tzHeroSort = 0;
$tzHeroReturning = false;
if ($tzHeroExists && !$tzHeroDead && !$tzHeroTraining && class_exists('HeroItems')) {
@@ -158,11 +159,12 @@ if ($tzHeroExists && !$tzHeroDead && !$tzHeroTraining && class_exists('HeroItems
if (method_exists($tzAwayObject, 'heroLocation')) {
$tzLoc = $tzAwayObject->heroLocation($tzHeroUid);
$tzHeroAway = (string) $tzLoc['reason'];
$tzHeroTarget = (int) $tzLoc['target'];
$tzHeroEndtime = (int) $tzLoc['endtime'];
$tzHeroSort = (int) $tzLoc['sort'];
$tzLoc = $tzAwayObject->heroLocation($tzHeroUid);
$tzHeroAway = (string) $tzLoc['reason'];
$tzHeroTarget = (int) $tzLoc['target'];
$tzHeroEndtime = (int) $tzLoc['endtime'];
$tzHeroSort = (int) $tzLoc['sort'];
$tzHeroReturning = !empty($tzLoc['returning']);
} else {
@@ -203,6 +205,13 @@ if (!$tzHeroExists) {
$tzHeroState = 'dead';
} elseif ($tzHeroTraining) {
$tzHeroState = 'training';
} elseif ($tzHeroReturning) {
/**
* O singura stare pentru toate intoarcerile acasa: din aventura, din
* atac sau dupa rechemarea dintr-o intarire. Motivul brut ramane in
* $tzHeroAway, ca sa alegem textul potrivit mai jos.
*/
$tzHeroState = 'returning';
} elseif ($tzHeroAway !== '') {
$tzHeroState = $tzHeroAway;
} else {
@@ -255,6 +264,38 @@ if ($tzHeroT4 && class_exists('HeroItems')) {
$tzHeroSilver = (int) $GLOBALS['t4SilverValue'];
}
/**
* ---------------------------------------------------------------------------
* 6b. Resursa produsa de erou (atributul T4 "Resources")
* ---------------------------------------------------------------------------
* Aceleasi formule ca in 37_hero.tpl, ca sa nu apara doua cifre diferite
* pentru acelasi lucru:
* res_type 0 -> produce din TOATE, cate HERO_RES_PER_POINT_ALL / punct
* res_type 1..4 -> o singura resursa, HERO_RES_PER_POINT_ONE / punct
* Totul inmultit cu SPEED, ca in pagina Resedintei.
*
* Coloanele "resources" si "res_type" lipsesc pe serverele care n-au rulat
* inca add-hero-resources.sql, de aceea sunt citite cu ?? 0.
*/
$tzResPoints = $tzHeroExists ? (int) ($tzHeroRow['resources'] ?? 0) : 0;
$tzResType = $tzHeroExists ? (int) ($tzHeroRow['res_type'] ?? 0) : 0;
$tzResPerAll = defined('HERO_RES_PER_POINT_ALL') ? (int) HERO_RES_PER_POINT_ALL : 3;
$tzResPerOne = defined('HERO_RES_PER_POINT_ONE') ? (int) HERO_RES_PER_POINT_ONE : 10;
$tzResSpeed = defined('SPEED') ? SPEED : 1;
$tzResSingle = ($tzResType >= 1 && $tzResType <= 4);
$tzResAmount = $tzResSingle
? (int) round($tzResPoints * $tzResPerOne * $tzResSpeed)
: (int) round($tzResPoints * $tzResPerAll * $tzResSpeed);
$tzResNames = array(
1 => (defined('LUMBER') ? LUMBER : 'Lumber'),
2 => (defined('CLAY') ? CLAY : 'Clay'),
3 => (defined('IRON') ? IRON : 'Iron'),
4 => (defined('CROP') ? CROP : 'Crop'),
);
/**
* ---------------------------------------------------------------------------
* 7. Link-urile catre Resedinta Eroului
@@ -375,6 +416,10 @@ $tzTxtAdventure = defined('HERO_HEADER_ADVENTURE') ? HERO_HEADER_ADVENTURE : 'H
$tzTxtAttack = defined('HERO_HEADER_ATTACK') ? HERO_HEADER_ATTACK : 'Hero is with the army';
$tzTxtReinforce = defined('HERO_HEADER_REINFORCE') ? HERO_HEADER_REINFORCE : 'Hero is reinforcing';
$tzTxtIn = defined('HERO_HEADER_IN') ? HERO_HEADER_IN : 'in';
$tzTxtRetAdv = defined('HERO_HEADER_RETURN_ADV') ? HERO_HEADER_RETURN_ADV : 'Hero returning from adventure';
$tzTxtRetHome = defined('HERO_HEADER_RETURN_HOME') ? HERO_HEADER_RETURN_HOME : 'Hero returning home';
$tzTxtResources = defined('RESOURCES') ? RESOURCES : 'Resources';
$tzTxtPerHour = defined('HERO_HEADER_PER_HOUR') ? HERO_HEADER_PER_HOUR : 'per hour';
$tzTxtVillage = defined('VILLAGE') ? VILLAGE : 'Village';
$tzTxtLevel = defined('LEVEL') ? LEVEL : 'Level';
$tzTxtHealth = defined('TZ_HEALTH') ? TZ_HEALTH : 'Health';
@@ -389,7 +434,18 @@ $tzHeroNameSafe = htmlspecialchars($tzHeroName, ENT_QUOTES, 'UTF-8');
$tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
?>
<link rel="stylesheet" href="css/hero_header.css" type="text/css" />
<?php
/**
* ?v=<data fisierului>: fara asta, browserul pastra CSS-ul vechi din cache
* dupa fiecare deploy. Efectul e insidios - HTML-ul nou apare, dar regulile
* noi lipsesc, asa ca elementele isi pierd pozitia (position:absolute fara
* left/top cade in coltul din stanga sus) si SVG-urile raman negre, fiindca
* fill-ul vine din CSS. filemtime se schimba singur la fiecare incarcare.
*/
$tzCssVer = @filemtime('css/hero_header.css');
?>
<link rel="stylesheet" type="text/css"
href="css/hero_header.css<?php echo $tzCssVer ? '?v=' . $tzCssVer : ''; ?>" />
<div id="tzHeroBox" class="<?php echo $tzHeroDead ? 'tzHeroDeadState' : ''; ?>">
@@ -438,6 +494,18 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
<path d="M12 5.2v14c3.5-1.2 6.1-3.7 6.1-7.3V7.5z" class="tzHeroShieldDark" />
</svg>
<?php } elseif ($tzHeroState === 'returning') { ?>
<!-- casa cu sageata care intra in ea: eroul e pe drumul spre casa,
indiferent daca vine din aventura, din atac sau dintr-o
intarire de la care a fost rechemat -->
<svg viewBox="0 0 24 24" class="tzHeroIco" aria-hidden="true">
<circle cx="12" cy="12" r="11" class="tzHeroIcoBg" />
<path class="tzHeroRoof" d="M13.5 5.6 6.9 11.2h1.9v5.9h9.2v-5.9h1.9z" />
<rect x="10.4" y="12.1" width="6.3" height="5" class="tzHeroWall" />
<path class="tzHeroBackArrow" d="M3.2 13.6h6.4v-2.4l4 3.6-4 3.6v-2.4H3.2z" />
</svg>
<?php } elseif ($tzHeroState === 'training') { ?>
<!-- clepsidra: eroul e in antrenament, inca nu e disponibil -->
@@ -488,6 +556,10 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
'attack' => $tzTxtAttack,
'reinforcement' => $tzTxtReinforce,
'home' => $tzTxtAtHome,
// din aventura stim sigur de unde vine; la sort_type 4 nu se
// poate deosebi atacul de rechemarea dintr-o intarire, deci
// textul ramane generic
'returning' => ($tzHeroAway === 'adventure') ? $tzTxtRetAdv : $tzTxtRetHome,
];
?>
<b><?php echo $tzStateLabels[$tzHeroState]; ?></b>
@@ -582,6 +654,46 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8');
</span>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<!-- ============ STANGA JOS: resursa produsa de erou -> 37.tpl ============ -->
<?php echo tzHeroSlotOpen($tzLinkHero, 'tzHeroSlot tzHeroRes', $tzHeroClickable); ?>
<?php
/**
* Exact aceleasi iconite ca in 37_hero.tpl, ca sa nu existe doua
* seturi de grafica pentru acelasi lucru:
* - "toate" -> img/hero/res_all.png (iconita combinata)
* - 1..4 -> clasele r1..r4, care decupeaza sprite-ul
* img/a/res2.gif din graphic pack, peste img/x.gif
*/
if ($tzResSingle) {
echo '<img class="tzHeroResOne r' . $tzResType . '" src="img/x.gif" alt="" />';
} else {
echo '<img class="tzHeroResAll" src="img/hero/res_all.png" alt="" />';
}
?>
<span class="tzHeroTip tzHeroTipRes">
<?php if ($tzResPoints <= 0) { ?>
<b><?php echo $tzTxtResources; ?>: 0</b>
<?php } elseif ($tzResSingle) { ?>
<b><?php echo $tzResNames[$tzResType]; ?>:
+<?php echo number_format($tzResAmount); ?> <?php echo $tzTxtPerHour; ?></b>
<?php } else { ?>
<?php
/**
* res_type 0 inseamna ca eroul produce suma asta din FIECARE
* resursa, nu impartita intre ele - de aceea o listam pe fiecare
* rand, in loc s-o repetam si in titlu.
*/
?>
<b><?php echo $tzTxtResources; ?> <?php echo $tzTxtPerHour; ?></b>
<?php foreach ($tzResNames as $tzResName) { ?>
<i><?php echo $tzResName; ?>: +<?php echo number_format($tzResAmount); ?></i>
<?php } ?>
<?php } ?>
</span>
<?php echo $tzHeroClickable ? '</a>' : '</span>'; ?>
<!-- ============ DREAPTA JOS: argint -> 37_auction.tpl ============ -->
<?php echo tzHeroSlotOpen($tzLinkAuc, 'tzHeroSlot tzHeroSilver', $tzHeroClickable); ?>
<!-- Teanc de monede desenat, in acelasi stil ca iconita de casa.
+41
View File
@@ -164,6 +164,9 @@ div#mtop {
.tzHeroPost { fill: #8a6a3f; }
.tzHeroSign { fill: #d8c9a6; stroke: #8a6a3f; stroke-width: .8; }
/* Intoarcere acasa: sageata care intra in casa */
.tzHeroBackArrow { fill: #4b8f3a; stroke: #2f6b21; stroke-width: .7; }
/* Antrenament: clepsidra */
.tzHeroGlassFrame { fill: #8a6a3f; }
.tzHeroGlass { fill: #dfe6ea; stroke: #8f9aa1; stroke-width: .7; }
@@ -210,6 +213,43 @@ div#mtop {
.tzHeroAdvOn .tzHeroAdvNum { color: #ffffff; }
.tzHeroAdvOff .tzHeroAdvNum { color: #6b6964; }
/* =========================================================================
Stanga jos: resursa produsa de erou
=========================================================================
Aliniat cu casa de deasupra (acelasi left: 10px) si pe aceeasi linie cu
argintul din dreapta (acelasi top: 45px), ca cele patru cercuri mici sa
formeze un dreptunghi in jurul inelului. */
.tzHeroRes {
left: 10px;
top: 45px;
width: 24px;
height: 24px;
border-radius: 50%;
background: #f6f5f2;
border: 1px solid #b8b6b1;
box-sizing: border-box;
text-align: center;
}
.tzHeroRes img {
display: inline-block;
vertical-align: top;
}
/* iconita combinata "toate resursele" (img/hero/res_all.png, 25x21) */
.tzHeroRes img.tzHeroResAll {
height: 16px;
width: auto;
margin-top: 3px;
}
/* o singura resursa: latimea si inaltimea vin din regula img.r1..r4 a
graphic pack-ului (18x12 din sprite-ul res2.gif), aici doar centram */
.tzHeroRes img.tzHeroResOne {
margin-top: 5px;
}
/* =========================================================================
Dreapta jos: argintul / casa de licitatii
========================================================================= */
@@ -284,3 +324,4 @@ div#mtop {
.tzHeroTipCenter { left: 58px; top: 44px; }
.tzHeroTipAdv { left: 29px; top: 4px; }
.tzHeroTipSilver { left: 29px; top: 2px; }
.tzHeroTipRes { left: 29px; top: 2px; }