diff --git a/Admin/Templates/editHero.tpl b/Admin/Templates/editHero.tpl index b06d914f..3082d58e 100644 --- a/Admin/Templates/editHero.tpl +++ b/Admin/Templates/editHero.tpl @@ -205,7 +205,7 @@ function go_url(url){ location=url; return false; } | Points used: )
(Lv )
(Lv )
-
%%
+
%%
/day
- % - % + % + % /Day 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(); diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index b56aaa50..399ee391 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -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'); + diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index f78331e0..319e7cad 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -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'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index 8b86074b..ea51939e 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -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'); diff --git a/Templates/Build/37_auction.tpl b/Templates/Build/37_auction.tpl index f4b464ec..dc36422c 100644 --- a/Templates/Build/37_auction.tpl +++ b/Templates/Build/37_auction.tpl @@ -88,6 +88,173 @@ foreach ($t4HeroItems->getInventory($session->uid) as $t4Row) { } ?> + +

@@ -100,41 +267,76 @@ $t4Gold = (int) $session->gold; $t4RateG2S = HeroItems::silverPerGold(); $t4RateS2G = HeroItems::silverForOneGold(); ?> - + de mai sus, nu din atribute inline. + */ +if (!function_exists('t4AucCoin')) { +function t4AucCoin($tone, $title) +{ + return '' + . '' . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '' + . '' + . '' + . '' + . '' + . '' + . ''; +} +} + +$t4LblGold = defined('GOLD') ? GOLD : 'Gold'; +$t4LblSilver = defined('HERO_SILVER') ? HERO_SILVER : 'Silver'; +?> +
- -
-

- : -    - : -

+
+
-
- - - - - (1 : ) -
+
+ + + + + + + + +
-
- - - - - ( : 1) -
+
+ + + + + 1 : +
-

- -

+
+ + + + + : 1 +
+ +

+ +

+
+ - +
- + +
- + - - - - - + + + + + + + - - - - - + + + + - +
- () + + + + () + getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?> + + 0) { ?> + + + + + + + + + getTimeFormat(max(0, $t4A['time_end'] - $t4Now)); ?> + uid) { ?> -
+ - - +
- - +
diff --git a/Templates/Build/37_hero.tpl b/Templates/Build/37_hero.tpl index 1f0b70e6..b0bd5cc8 100644 --- a/Templates/Build/37_hero.tpl +++ b/Templates/Build/37_hero.tpl @@ -150,14 +150,37 @@ $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) { 0 ? $hero_info['atk'] . ' +' . number_format($t4ItemStrength) . '' : $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'), ); diff --git a/Templates/hero_header.tpl b/Templates/hero_header.tpl index 445b135b..f8aa9e2a 100644 --- a/Templates/hero_header.tpl +++ b/Templates/hero_header.tpl @@ -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'); ?> - +: 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'); +?> +
@@ -438,6 +494,18 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8'); + + + + + @@ -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, ]; ?> @@ -582,6 +654,46 @@ $tzHeroVillageSafe = htmlspecialchars($tzHeroVillage, ENT_QUOTES, 'UTF-8'); ' : ''; ?> + + + + 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 ''; + } else { + echo ''; + } + ?> + + + + : 0 + + : + + + + + + + : + + + + + ' : ''; ?> +