mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-16 08:11:00 +00:00
fix warsim
This commit is contained in:
+73
-6
@@ -575,7 +575,8 @@ class Battle {
|
|||||||
$offhero, $hero_strenght, $deffhero,
|
$offhero, $hero_strenght, $deffhero,
|
||||||
$DefenderID,
|
$DefenderID,
|
||||||
$calvaryLookup, $catapultLookup, $ramsLookup,
|
$calvaryLookup, $catapultLookup, $ramsLookup,
|
||||||
$dp, $cdp
|
$dp, $cdp,
|
||||||
|
$AttackerID
|
||||||
);
|
);
|
||||||
|
|
||||||
$ap = $attForces['ap'];
|
$ap = $attForces['ap'];
|
||||||
@@ -949,7 +950,8 @@ class Battle {
|
|||||||
$offhero, $hero_strenght, $deffhero,
|
$offhero, $hero_strenght, $deffhero,
|
||||||
$DefenderID,
|
$DefenderID,
|
||||||
$calvaryLookup, $catapultLookup, $ramsLookup,
|
$calvaryLookup, $catapultLookup, $ramsLookup,
|
||||||
$dp, $cdp
|
$dp, $cdp,
|
||||||
|
$AttackerID = 0
|
||||||
) {
|
) {
|
||||||
|
|
||||||
global $unitsbytype;
|
global $unitsbytype;
|
||||||
@@ -1086,6 +1088,39 @@ class Battle {
|
|||||||
$cap *= $simHero['ob'];
|
$cap *= $simHero['ob'];
|
||||||
|
|
||||||
$ap += $hero_strenght;
|
$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) {
|
if ($deffhero > 0) {
|
||||||
@@ -1094,6 +1129,19 @@ class Battle {
|
|||||||
|
|
||||||
$dp *= $dfdhero['ob'];
|
$dp *= $dfdhero['ob'];
|
||||||
$cdp *= $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
|
// apararea: aceeasi functie calculeaza ambele parti, in functie de rolul
|
||||||
// jucatorului in lupta.
|
// jucatorului in lupta.
|
||||||
if (class_exists('AllianceBonus') && AllianceBonus::enabled()) {
|
if (class_exists('AllianceBonus') && AllianceBonus::enabled()) {
|
||||||
$metalOwner = 0;
|
|
||||||
|
|
||||||
if (isset($Attacker) && (int) $Attacker > 0) {
|
// BUG REPARAT: aici se folosea (int) $Attacker, dar $Attacker e ARRAYUL
|
||||||
global $database;
|
// de unitati, nu un id de sat. In PHP, (int) pe un array da 1, deci se
|
||||||
$metalOwner = (int) $database->getVillageField((int) $Attacker, 'owner');
|
// 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) {
|
if ($metalOwner > 0) {
|
||||||
|
|||||||
@@ -4298,3 +4298,18 @@ tz_def('TZ_RPT_F_LOST', 'Lost');
|
|||||||
tz_def('TZ_HERO_REGEN_TOTAL', 'Health regeneration');
|
tz_def('TZ_HERO_REGEN_TOTAL', 'Health regeneration');
|
||||||
tz_def('TZ_HERO_REGEN_BASE', 'base');
|
tz_def('TZ_HERO_REGEN_BASE', 'base');
|
||||||
tz_def('TZ_HERO_REGEN_ITEMS', 'from items');
|
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');
|
||||||
|
|||||||
@@ -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_TOTAL', 'Régénération des points de vie');
|
||||||
tz_def('TZ_HERO_REGEN_BASE', 'de base');
|
tz_def('TZ_HERO_REGEN_BASE', 'de base');
|
||||||
tz_def('TZ_HERO_REGEN_ITEMS', 'des objets');
|
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');
|
||||||
|
|||||||
@@ -4038,3 +4038,18 @@ tz_def('TZ_RPT_F_LOST', 'Pierdut');
|
|||||||
tz_def('TZ_HERO_REGEN_TOTAL', 'Regenerarea vietii');
|
tz_def('TZ_HERO_REGEN_TOTAL', 'Regenerarea vietii');
|
||||||
tz_def('TZ_HERO_REGEN_BASE', 'de baza');
|
tz_def('TZ_HERO_REGEN_BASE', 'de baza');
|
||||||
tz_def('TZ_HERO_REGEN_ITEMS', 'din iteme');
|
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');
|
||||||
|
|||||||
+67
@@ -141,6 +141,73 @@ if(count($target) > 0) {
|
|||||||
include("Templates/Simulator/def_end.tpl");
|
include("Templates/Simulator/def_end.tpl");
|
||||||
echo "<div class=\"clear\"></div>";
|
echo "<div class=\"clear\"></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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')
|
||||||
|
. ': <b>+' . number_format($wsStrength) . '</b>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$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')
|
||||||
|
. ': <b>+' . (int) $wsPer . '</b> / ' . 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')
|
||||||
|
. ': <b>+' . (int) $wsBon[HB_VS_NATARS] . '%</b>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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')
|
||||||
|
. ': <b>+' . round(($wsMetal - 1) * 100) . '%</b>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($wsLines) {
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
#ws_own{margin:6px 0 10px 0;padding:5px 9px;border-left:3px solid #7db72f;
|
||||||
|
background:#f4faec;font-size:11px;color:#444;max-width:600px}
|
||||||
|
#ws_own .ws_t{font-weight:bold;color:#333;margin-right:4px}
|
||||||
|
#ws_own span.ws_i{display:inline-block;margin-right:12px;white-space:nowrap}
|
||||||
|
</style>
|
||||||
|
<div id="ws_own">
|
||||||
|
<span class="ws_t"><?php echo defined('TZ_WS_APPLIED') ? TZ_WS_APPLIED
|
||||||
|
: 'Automatically included in this simulation:'; ?></span>
|
||||||
|
<?php foreach ($wsLines as $wsLine) { ?>
|
||||||
|
<span class="ws_i"><?php echo $wsLine; ?></span>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<table id="select" cellpadding="1" cellspacing="1">
|
<table id="select" cellpadding="1" cellspacing="1">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user