mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-13 08:06:06 +00:00
Add Hero T4 Item Description
Add Hero T4 Item Description
This commit is contained in:
@@ -321,3 +321,78 @@ if (!function_exists('heroItemTribe')) {
|
||||
return intdiv((int) $heroItemCatalog[$itemid]['unit'] - 1, 10) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable effect line for an item, GENERATED from its bonus array so
|
||||
* tooltips can never drift from the actual battle/speed mechanics. Values
|
||||
* are shown as effective for THIS server (speed scaling applied, same rule
|
||||
* as HeroItems::scaledBonusValue). Uses HB_TXT_* lang constants with English
|
||||
* fallbacks, so it works before/without a translation pass.
|
||||
*/
|
||||
if (!function_exists('heroItemBonusText')) {
|
||||
function heroItemBonusText($itemid) {
|
||||
global $heroItemCatalog;
|
||||
if (!isset($heroItemCatalog[$itemid])) {
|
||||
return '';
|
||||
}
|
||||
$def = $heroItemCatalog[$itemid];
|
||||
|
||||
$txt = function ($const, $fallback) {
|
||||
return defined($const) ? constant($const) : $fallback;
|
||||
};
|
||||
// Effective value on this server (mirrors HeroItems::scaledBonusValue).
|
||||
$scale = function ($value) use ($def) {
|
||||
if (!array_key_exists('x2_on_speed', $def) || !defined('SPEED') || SPEED < 3) {
|
||||
return (int) $value;
|
||||
}
|
||||
return $def['x2_on_speed'] ? (int) $value * 2 : (int) floor($value / 2);
|
||||
};
|
||||
|
||||
$parts = array();
|
||||
foreach ($def['bonus'] as $type => $value) {
|
||||
switch ($type) {
|
||||
case HB_FIGHT: $parts[] = '+' . $scale($value) . ' ' . $txt('HB_TXT_FIGHT', 'fighting strength'); break;
|
||||
case HB_UNIT_BONUS:
|
||||
$u = (int) $value['unit'];
|
||||
$uname = defined('U' . $u) ? constant('U' . $u) : 'unit ' . $u;
|
||||
$parts[] = '+' . (int) $value['per_unit'] . ' ' . $txt('HB_TXT_UNIT_OFF', 'attack') . ' / +'
|
||||
. (int) $value['per_unit'] . ' ' . $txt('HB_TXT_UNIT_DEF', 'defense') . ' '
|
||||
. $txt('HB_TXT_PER', 'per') . ' ' . $uname;
|
||||
break;
|
||||
case HB_VS_NATARS: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_VS_NATARS', 'strength vs Natars'); break;
|
||||
case HB_RAID: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_RAID', 'raided resources'); break;
|
||||
case HB_RETURN_SPEED: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_RETURN', 'troop return speed'); break;
|
||||
case HB_SPEED_OWN: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_SPEED_OWN', 'speed between own villages'); break;
|
||||
case HB_SPEED_ALLY: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_SPEED_ALLY', 'speed between ally villages'); break;
|
||||
case HB_XP: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_XP', 'experience'); break;
|
||||
case HB_REGEN_HP: $parts[] = '+' . $scale($value) . ' ' . $txt('HB_TXT_REGEN', 'HP per day'); break;
|
||||
case HB_CP: $parts[] = '+' . $scale($value) . ' ' . $txt('HB_TXT_CP', 'culture points per day'); break;
|
||||
case HB_TRAIN_CAV: $parts[] = '-' . $scale($value) . '% ' . $txt('HB_TXT_TRAIN_CAV', 'cavalry training time'); break;
|
||||
case HB_TRAIN_INF: $parts[] = '-' . $scale($value) . '% ' . $txt('HB_TXT_TRAIN_INF', 'infantry training time'); break;
|
||||
case HB_DMG_REDUCE: $parts[] = '-' . $scale($value) . ' ' . $txt('HB_TXT_DMG', 'damage taken by the hero'); break;
|
||||
case HB_TROOP_SPEED_20: $parts[] = '+' . $scale($value) . '% ' . $txt('HB_TXT_SPEED20', 'troop speed beyond 20 tiles'); break;
|
||||
case HB_MOUNT_SPEED: $parts[] = '+' . $scale($value) . ' ' . $txt('HB_TXT_MOUNT', 'fields/hour while mounted'); break;
|
||||
case HB_HORSE_SPEED: $parts[] = $scale($value) . ' ' . $txt('HB_TXT_HORSE', 'fields/hour hero speed'); break;
|
||||
case HB_HEAL_SELF: $parts[] = $txt('HB_TXT_OINTMENT', 'Heals 1% hero health per unit (max 99%)'); break;
|
||||
case HB_SCROLL: $parts[] = '+' . (int) $value . ' ' . $txt('HB_TXT_SCROLL', 'hero experience each'); break;
|
||||
case HB_BUCKET: $parts[] = $txt('HB_TXT_BUCKET', 'Instantly revives the hero at no cost'); break;
|
||||
case HB_LOYALTY: $parts[] = $txt('HB_TXT_TABLET', '+1% own village loyalty each (max 125%)'); break;
|
||||
case HB_RESET: $parts[] = $txt('HB_TXT_BOOK', 'Resets the hero attribute points'); break;
|
||||
case HB_ARTWORK: $parts[] = $txt('HB_TXT_ARTWORK', 'Culture points equal to your daily production'); break;
|
||||
case HB_HEAL_TROOP: $parts[] = $txt('HB_TXT_BANDAGE_A', 'Heals') . ' ' . (int) $value . '% ' . $txt('HB_TXT_BANDAGE_B', "of the hero's fallen troops after battle"); break;
|
||||
case HB_CAGE: $parts[] = $txt('HB_TXT_CAGE', 'Captures 1 oasis animal per cage'); break;
|
||||
}
|
||||
}
|
||||
|
||||
$out = implode(', ', $parts);
|
||||
if (!empty($def['requires_horse'])) {
|
||||
$out .= ' (' . $txt('HB_TXT_NEEDS_HORSE', 'requires an equipped horse') . ')';
|
||||
}
|
||||
if (isset($def['unit'])) {
|
||||
$u = (int) $def['unit'];
|
||||
$uname = defined('U' . $u) ? constant('U' . $u) : 'unit ' . $u;
|
||||
$out .= ' (' . $txt('HB_TXT_ONLY', 'only for a') . ' ' . $uname . ' ' . $txt('HB_TXT_HERO', 'hero') . ')';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2789,3 +2789,35 @@ tz_def('TZ_RT_AUC_EXPIRED', 'Auction expired');
|
||||
tz_def('HERO_ADV_MOV_OUT', 'Hero on an adventure');
|
||||
tz_def('HERO_ADV_MOV_BACK', 'Hero returning from an adventure');
|
||||
tz_def('HERO_ADV_MOV_SHORT', 'Adventure');
|
||||
|
||||
/* T4 hero port - tooltip effect fragments (heroItemBonusText) */
|
||||
tz_def('HB_TXT_FIGHT', 'fighting strength');
|
||||
tz_def('HB_TXT_UNIT_OFF', 'attack');
|
||||
tz_def('HB_TXT_UNIT_DEF', 'defense');
|
||||
tz_def('HB_TXT_PER', 'per');
|
||||
tz_def('HB_TXT_VS_NATARS', 'strength vs Natars');
|
||||
tz_def('HB_TXT_RAID', 'raided resources');
|
||||
tz_def('HB_TXT_RETURN', 'troop return speed');
|
||||
tz_def('HB_TXT_SPEED_OWN', 'speed between own villages');
|
||||
tz_def('HB_TXT_SPEED_ALLY', 'speed between ally villages');
|
||||
tz_def('HB_TXT_XP', 'experience');
|
||||
tz_def('HB_TXT_REGEN', 'HP per day');
|
||||
tz_def('HB_TXT_CP', 'culture points per day');
|
||||
tz_def('HB_TXT_TRAIN_CAV', 'cavalry training time');
|
||||
tz_def('HB_TXT_TRAIN_INF', 'infantry training time');
|
||||
tz_def('HB_TXT_DMG', 'damage taken by the hero');
|
||||
tz_def('HB_TXT_SPEED20', 'troop speed beyond 20 tiles');
|
||||
tz_def('HB_TXT_MOUNT', 'fields/hour while mounted');
|
||||
tz_def('HB_TXT_HORSE', 'fields/hour hero speed');
|
||||
tz_def('HB_TXT_OINTMENT', 'Heals 1% hero health per unit (max 99%)');
|
||||
tz_def('HB_TXT_SCROLL', 'hero experience each');
|
||||
tz_def('HB_TXT_BUCKET', 'Instantly revives the hero at no cost');
|
||||
tz_def('HB_TXT_TABLET', '+1% own village loyalty each (max 125%)');
|
||||
tz_def('HB_TXT_BOOK', 'Resets the hero attribute points');
|
||||
tz_def('HB_TXT_ARTWORK', 'Culture points equal to your daily production');
|
||||
tz_def('HB_TXT_BANDAGE_A', 'Heals');
|
||||
tz_def('HB_TXT_BANDAGE_B', "of the hero's fallen troops after battle");
|
||||
tz_def('HB_TXT_CAGE', 'Captures 1 oasis animal per cage');
|
||||
tz_def('HB_TXT_NEEDS_HORSE','requires an equipped horse');
|
||||
tz_def('HB_TXT_ONLY', 'only for a');
|
||||
tz_def('HB_TXT_HERO', 'hero');
|
||||
|
||||
@@ -65,7 +65,7 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
|
||||
<?php if (count($t4Open)) { ?>
|
||||
<?php foreach ($t4Open as $t4A) { ?>
|
||||
<tr>
|
||||
<td><span class="heroT4Item item<?php echo (int) $t4A['itemid']; ?>"></span> <?php echo $t4A['name']; ?>
|
||||
<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>
|
||||
<td style="text-align:center;"><?php echo (int) $t4A['quantity']; ?></td>
|
||||
@@ -98,7 +98,7 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
|
||||
<tbody>
|
||||
<?php foreach ($t4MyBids as $t4A) { ?>
|
||||
<tr>
|
||||
<td><?php echo $t4A['name']; ?> (<?php echo (int) $t4A['quantity']; ?>x)</td>
|
||||
<td title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4A['itemid'])); ?>"><?php echo $t4A['name']; ?> (<?php echo (int) $t4A['quantity']; ?>x)</td>
|
||||
<td style="text-align:right;"><?php echo HERO_AUC_PRICE; ?>: <?php echo number_format((int) $t4A['silver_current']); ?></td>
|
||||
<td style="text-align:right;"><?php echo HERO_AUC_YOUR_MAX; ?>: <?php echo number_format((int) $t4A['bid_max']); ?></td>
|
||||
<td><span id="timer<?php echo ++$session->timer; ?>"><?php echo $generator->getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?></span></td>
|
||||
@@ -116,7 +116,7 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
|
||||
<tbody>
|
||||
<?php foreach ($t4MySales as $t4A) { ?>
|
||||
<tr>
|
||||
<td><?php echo $t4A['name']; ?> (<?php echo (int) $t4A['quantity']; ?>x)</td>
|
||||
<td title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4A['itemid'])); ?>"><?php echo $t4A['name']; ?> (<?php echo (int) $t4A['quantity']; ?>x)</td>
|
||||
<td style="text-align:right;"><?php echo HERO_AUC_PRICE; ?>: <?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>
|
||||
</tr>
|
||||
@@ -137,7 +137,7 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) {
|
||||
<td>
|
||||
<select name="rowid">
|
||||
<?php foreach ($t4Sellable as $t4Row) { ?>
|
||||
<option value="<?php echo (int) $t4Row['id']; ?>">
|
||||
<option value="<?php echo (int) $t4Row['id']; ?>" title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4Row['itemid'])); ?>">
|
||||
<?php echo $t4Row['name']; ?><?php if ((int) $t4Row['quantity'] > 1) echo ' (' . (int) $t4Row['quantity'] . 'x)'; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
|
||||
@@ -53,7 +53,7 @@ $t4Equipped = $t4HeroItems->getEquipped($session->uid);
|
||||
<tr>
|
||||
<td style="width:110px;"><b><?php echo constant('HERO_SLOT_' . $t4Slot); ?></b></td>
|
||||
<?php if (isset($t4Equipped[$t4Slot])) { $t4Row = $t4Equipped[$t4Slot]; ?>
|
||||
<td><span class="heroT4Item item<?php echo (int) $t4Row['itemid']; ?>"></span> <?php echo $t4Row['name']; ?></td>
|
||||
<td title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4Row['itemid'])); ?>"><span class="heroT4Item item<?php echo (int) $t4Row['itemid']; ?>"></span> <?php echo $t4Row['name']; ?></td>
|
||||
<td style="width:60px;text-align:center;"><?php echo 'T' . (int) $t4Row['def']['tier']; ?></td>
|
||||
<td style="width:110px;text-align:center;">
|
||||
<form action="" method="POST" style="margin:0;">
|
||||
@@ -85,7 +85,7 @@ $t4Equipped = $t4HeroItems->getEquipped($session->uid);
|
||||
$t4IsBag = ((int) $t4Row['def']['slot'] === HSLOT_BAG);
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="heroT4Item item<?php echo (int) $t4Row['itemid']; ?>"></span> <?php echo $t4Row['name']; ?></td>
|
||||
<td title="<?php echo htmlspecialchars(heroItemBonusText((int) $t4Row['itemid'])); ?>"><span class="heroT4Item item<?php echo (int) $t4Row['itemid']; ?>"></span> <?php echo $t4Row['name']; ?></td>
|
||||
<td style="width:80px;text-align:center;">
|
||||
<?php echo $t4IsBag ? (int) $t4Row['quantity'] . 'x' : 'T' . (int) $t4Row['def']['tier']; ?>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user