From bd026427117f2b90fb79ee96f1ea3b908aade74b Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Sat, 1 Aug 2026 17:24:51 +0300 Subject: [PATCH] fix warsim --- GameEngine/Battle.php | 79 ++++++++++++++++++++++++++++++++++++++---- GameEngine/Lang/en.php | 15 ++++++++ GameEngine/Lang/fr.php | 15 ++++++++ GameEngine/Lang/ro.php | 15 ++++++++ warsim.php | 67 +++++++++++++++++++++++++++++++++++ 5 files changed, 185 insertions(+), 6 deletions(-) diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index b9bcf69c..fd4a67a2 100644 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -575,7 +575,8 @@ class Battle { $offhero, $hero_strenght, $deffhero, $DefenderID, $calvaryLookup, $catapultLookup, $ramsLookup, - $dp, $cdp + $dp, $cdp, + $AttackerID ); $ap = $attForces['ap']; @@ -949,7 +950,8 @@ class Battle { $offhero, $hero_strenght, $deffhero, $DefenderID, $calvaryLookup, $catapultLookup, $ramsLookup, - $dp, $cdp + $dp, $cdp, + $AttackerID = 0 ) { global $unitsbytype; @@ -1086,6 +1088,39 @@ class Battle { $cap *= $simHero['ob']; $ap += $hero_strenght; + + /** + * SIMULATOR: aplicam si efectele echipamentului eroului. + * + * Ramura reala de mai sus foloseste eroul din baza de date; aici + * eroul e sintetic, construit din procentele introduse manual, deci + * itemele lipseau complet si simularea dadea alt rezultat decat + * lupta adevarata. + * + * Le luam de la jucatorul care ruleaza simularea: forta din arme si + * scuturi (fight_strength), bonusul pe tipul de unitate al armei si + * cornul de vanatoare contra Natarilor. + */ + if (class_exists('HeroBattleBonus') && HeroBattleBonus::enabled()) { + global $session; + + $simUid = isset($session->uid) ? (int) $session->uid : 0; + + if ($simUid > 0) { + $ap += (int) HeroBattleBonus::statBonus($simUid); + + list($simAp, $simCap) = HeroBattleBonus::unitOffense($simUid, $Attacker, $calvaryLookup); + $ap += $simAp; + $cap += $simCap; + + $simNatar = HeroBattleBonus::natarMultiplier($simUid, $DefenderID); + + if ($simNatar > 1.0) { + $ap *= $simNatar; + $cap *= $simNatar; + } + } + } } if ($deffhero > 0) { @@ -1094,6 +1129,19 @@ class Battle { $dp *= $dfdhero['ob']; $cdp *= $dfdhero['ob']; + + // Aceleasi iteme conteaza si cand simulezi apararea. + if (class_exists('HeroBattleBonus') && HeroBattleBonus::enabled()) { + global $session; + + $simUid = isset($session->uid) ? (int) $session->uid : 0; + + if ($simUid > 0) { + $simDef = (int) HeroBattleBonus::unitDefense($simUid, $Attacker); + $dp += $simDef; + $cdp += $simDef; + } + } } } @@ -1105,11 +1153,30 @@ class Battle { // apararea: aceeasi functie calculeaza ambele parti, in functie de rolul // jucatorului in lupta. if (class_exists('AllianceBonus') && AllianceBonus::enabled()) { - $metalOwner = 0; - if (isset($Attacker) && (int) $Attacker > 0) { - global $database; - $metalOwner = (int) $database->getVillageField((int) $Attacker, 'owner'); + // BUG REPARAT: aici se folosea (int) $Attacker, dar $Attacker e ARRAYUL + // de unitati, nu un id de sat. In PHP, (int) pe un array da 1, deci se + // citea proprietarul satului 1 - un jucator la intamplare sau nimeni. + // Bonusul de Metalurgie nu ajungea niciodata la cine trebuie. + // + // Atacatorul vine acum ca parametru ($AttackerID). Daca lipseste (de + // exemplu in simulator), cadem pe eroul atacator, care poarta si el uid-ul. + $metalOwner = (int) $AttackerID; + + if ($metalOwner <= 0 && !empty($atkhero['uid'])) { + $metalOwner = (int) $atkhero['uid']; + } + + // SIMULATOR: nu exista nici sat atacator, nici erou din baza de date, + // asa ca luam bonusurile aliantei jucatorului care ruleaza simularea. + // Intr-o lupta reala $AttackerID e mereu setat, deci ramura asta nu se + // atinge acolo. + if ($metalOwner <= 0 && ($offhero > 0 || $deffhero > 0 || $hero_strenght > 0)) { + global $session; + + if (isset($session->uid)) { + $metalOwner = (int) $session->uid; + } } if ($metalOwner > 0) { diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 8ff7c57c..3889cc33 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -4298,3 +4298,18 @@ tz_def('TZ_RPT_F_LOST', 'Lost'); tz_def('TZ_HERO_REGEN_TOTAL', 'Health regeneration'); tz_def('TZ_HERO_REGEN_BASE', 'base'); tz_def('TZ_HERO_REGEN_ITEMS', 'from items'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// MINUNEA LUMII A NATARILOR +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WW_NATARS', 'Natars'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY', 'Natars\' World Wonder start'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY_TOOLTIP', 'How many days after the construction plans appear the Natars start building their own World Wonder. Scaled by server speed. 0 disables it.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// SIMULATOR - bonusuri proprii incluse automat +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WS_APPLIED', 'Automatically included in this simulation:'); +tz_def('TZ_WS_ITEM_STRENGTH', 'Equipment strength'); +tz_def('TZ_WS_ITEM_UNIT', 'Weapon bonus'); +tz_def('TZ_WS_VS_NATARS', 'Against Natars'); diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index 794dc482..b7026996 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -4241,3 +4241,18 @@ tz_def('TZ_RPT_F_LOST', 'Perdu'); tz_def('TZ_HERO_REGEN_TOTAL', 'Régénération des points de vie'); tz_def('TZ_HERO_REGEN_BASE', 'de base'); tz_def('TZ_HERO_REGEN_ITEMS', 'des objets'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// MINUNEA LUMII A NATARILOR +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WW_NATARS', 'Natars'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY', 'Debut de la Merveille des Natars'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY_TOOLTIP', 'Combien de jours apres l\'apparition des plans de construction les Natars commencent leur propre Merveille du Monde. Ajuste selon la vitesse du serveur. 0 desactive.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// SIMULATOR - bonusuri proprii incluse automat +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WS_APPLIED', 'Inclus automatiquement dans cette simulation :'); +tz_def('TZ_WS_ITEM_STRENGTH', 'Force de l\'equipement'); +tz_def('TZ_WS_ITEM_UNIT', 'Bonus d\'arme'); +tz_def('TZ_WS_VS_NATARS', 'Contre les Natars'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index 21218516..25fad1e8 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -4038,3 +4038,18 @@ tz_def('TZ_RPT_F_LOST', 'Pierdut'); tz_def('TZ_HERO_REGEN_TOTAL', 'Regenerarea vietii'); tz_def('TZ_HERO_REGEN_BASE', 'de baza'); tz_def('TZ_HERO_REGEN_ITEMS', 'din iteme'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// MINUNEA LUMII A NATARILOR +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WW_NATARS', 'Natari'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY', 'Pornirea Minunii Natarilor'); +tz_def('CONF_SERV_NATARS_WW_START_DELAY_TOOLTIP', 'Dupa cate zile de la aparitia planurilor incep Natarii propria Minune a Lumii. Se scaleaza cu viteza serverului. 0 dezactiveaza.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// SIMULATOR - bonusuri proprii incluse automat +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('TZ_WS_APPLIED', 'Incluse automat in aceasta simulare:'); +tz_def('TZ_WS_ITEM_STRENGTH', 'Forta echipamentului'); +tz_def('TZ_WS_ITEM_UNIT', 'Bonus de arma'); +tz_def('TZ_WS_VS_NATARS', 'Contra Natarilor'); diff --git a/warsim.php b/warsim.php index cbf3f856..3b6812f2 100644 --- a/warsim.php +++ b/warsim.php @@ -141,6 +141,73 @@ if(count($target) > 0) { include("Templates/Simulator/def_end.tpl"); echo "
"; } + +/** + * Ce bonusuri PROPRII a folosit simularea. + * + * Simulatorul preia automat itemele echipate ale eroului si bonusurile + * aliantei. Fara acest panou le-ar aplica in tacere, iar jucatorul n-ar avea + * cum sa stie daca rezultatul le include sau nu. + */ +$wsLines = array(); + +if (class_exists('HeroBattleBonus') && HeroBattleBonus::enabled() && !empty($session->uid)) { + + $wsStrength = (int) HeroBattleBonus::statBonus($session->uid); + + if ($wsStrength > 0) { + $wsLines[] = (defined('TZ_WS_ITEM_STRENGTH') ? TZ_WS_ITEM_STRENGTH : 'Equipment strength') + . ': +' . number_format($wsStrength) . ''; + } + + $wsMap = HeroBattleBonus::unitBonusMap($session->uid); + + if (!empty($wsMap)) { + foreach ($wsMap as $wsUnit => $wsPer) { + // Numele unitatilor sunt constante de limba (U1..U90), nu campuri + // in unitdata.php - acolo sunt doar valorile de lupta. + $wsConst = 'U' . (int) $wsUnit; + $wsName = defined($wsConst) ? constant($wsConst) : $wsConst; + + $wsLines[] = (defined('TZ_WS_ITEM_UNIT') ? TZ_WS_ITEM_UNIT : 'Weapon bonus') + . ': +' . (int) $wsPer . ' / ' . htmlspecialchars($wsName, ENT_QUOTES, 'UTF-8'); + } + } + + $wsBon = HeroBattleBonus::bonuses($session->uid); + + if ($wsBon && defined('HB_VS_NATARS') && !empty($wsBon[HB_VS_NATARS])) { + $wsLines[] = (defined('TZ_WS_VS_NATARS') ? TZ_WS_VS_NATARS : 'Against Natars') + . ': +' . (int) $wsBon[HB_VS_NATARS] . '%'; + } +} + +if (class_exists('AllianceBonus') && AllianceBonus::enabled() && !empty($session->uid)) { + $wsMetal = AllianceBonus::multiplier($session->uid, AllianceBonus::METALLURGY); + + if ($wsMetal > 1.0) { + $wsLines[] = (defined('ALLYBONUS_METALLURGY') ? ALLYBONUS_METALLURGY : 'Metallurgy') + . ': +' . round(($wsMetal - 1) * 100) . '%'; + } +} + +if ($wsLines) { +?> + +
+ + + + +
+