diff --git a/pages/spell.php b/pages/spell.php index 94a927af..65ecab56 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -682,6 +682,7 @@ class SpellPage extends GenericPage $lv = $spellLoot->getResult(); $extraCols = $spellLoot->extraCols; $extraCols[] = '$Listview.extraCols.percent'; + $lvName = '$LANG.tab_contains'; if ($extraItem && $this->subject->canCreateItem()) { @@ -691,8 +692,10 @@ class SpellPage extends GenericPage { if (($bar = $this->subject->getField('effect'.$i.'CreateItemId')) && isset($foo[$bar])) { + $lvName = '$LANG.tab_bonusloot'; $lv[$bar] = $foo[$bar]; - $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; + $lv[$bar]['percent'] = $extraItem['additionalCreateChance']; + $lv[$bar]['pctstack'] = $this->buildPctStack($extraItem['additionalCreateChance'] / 100, $extraItem['additionalMaxNum']); $lv[$bar]['condition'][0][$this->typeId][] = [[CND_SPELL, $extraItem['requiredSpecialization']]]; $this->extendGlobalIds(Type::SPELL, $extraItem['requiredSpecialization']); $extraCols[] = '$Listview.extraCols.condition'; @@ -706,7 +709,7 @@ class SpellPage extends GenericPage $this->lvTabs[] = [ItemList::$brickFile, array( 'data' => array_values($lv), - 'name' => '$LANG.tab_contains', + 'name' => $lvName, 'id' => 'contains', 'hiddenCols' => ['side', 'slot', 'source', 'reqlevel'], 'extraCols' => array_unique($extraCols) @@ -1244,6 +1247,27 @@ class SpellPage extends GenericPage return sprintf($this->powerTpl, $this->typeId, User::$localeId, Util::toJSON($power, JSON_AOWOW_POWER)); } + private function buildPctStack(float $baseChance, int $maxStack) : string + { + // note: pctStack does not contain absolute values but chances relative to the overall drop chance + // e.g.: dropChance is 17% then [1 => 50, 2 => 25, 3 => 25] displays > Stack of 1: 8%; Stack of 2: 4%; Stack of 3: 4% + $maxStack = $maxStack ?: 1; + $pctStack = []; + for ($i = 1; $i <= $maxStack; $i++) + { + $pctStack[$i] = (($baseChance ** $i) * 100) / $baseChance ; + + // remove chance from previous stacks + for ($j = 1; $j < $i; $j++) + $pctStack[$j] -= ($pctStack[$i] / ($i - 1)); + } + + // cleanup tiny fractions + $pctStack = array_filter($pctStack, function($x) use ($baseChance) { return $x * $baseChance >= 0.01; }); + + return json_encode($pctStack, JSON_NUMERIC_CHECK); + } + private function appendReagentItem(&$reagentResult, $_iId, $_qty, $_mult, $_level, $_path, $alreadyUsed) { if (in_array($_iId, $alreadyUsed)) diff --git a/static/js/locale_dede.js b/static/js/locale_dede.js index beb6b531..7545a8e7 100644 --- a/static/js/locale_dede.js +++ b/static/js/locale_dede.js @@ -3176,6 +3176,7 @@ var LANG = { tab_weaponskills: "Waffenfertigkeit", tab_world: "Welt", tab_zones: "Gebiete", + tab_bonusloot: "Bonusbeute", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "Anzahl von positiven Bewertungen erhalten", deletethisreply_stc: "Antwort löschen", diff --git a/static/js/locale_enus.js b/static/js/locale_enus.js index a6cc5434..d73d08a9 100644 --- a/static/js/locale_enus.js +++ b/static/js/locale_enus.js @@ -3225,6 +3225,7 @@ var LANG = { tab_weaponskills: "Weapon Skills", tab_world: "World", tab_zones: "Zones", + tab_bonusloot: "Bonus Loot", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "Number of upvotes received", deletethisreply_stc: "Delete this reply", diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index f27652f9..edb956cf 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -3176,6 +3176,7 @@ var LANG = { tab_weaponskills: "Habilidades con armas", tab_world: "Mundo", tab_zones: "Zonas", + tab_bonusloot: "Bonus de botín", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "Número de valoraciones positivas recibidas ", deletethisreply_stc: "Borrar esta respuesta", diff --git a/static/js/locale_frfr.js b/static/js/locale_frfr.js index 14fe9c52..a95a006a 100644 --- a/static/js/locale_frfr.js +++ b/static/js/locale_frfr.js @@ -3177,6 +3177,7 @@ var LANG = { tab_weaponskills: "Compétences d'armes", tab_world: "Monde", tab_zones: "Zones", + tab_bonusloot: "Butin bonus", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "Nombre de votes positifs reçus", deletethisreply_stc: "Effacer cette réponse", diff --git a/static/js/locale_ruru.js b/static/js/locale_ruru.js index fab148e2..71537c5f 100644 --- a/static/js/locale_ruru.js +++ b/static/js/locale_ruru.js @@ -3177,6 +3177,7 @@ var LANG = { tab_weaponskills: "Оружейные навыки", tab_world: "Игровой мир", tab_zones: "Местности", + tab_bonusloot: "Доп. добыча", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "Голосов получено", deletethisreply_stc: "Удалить этот ответ", diff --git a/static/js/locale_zhcn.js b/static/js/locale_zhcn.js index a764949b..610ae33d 100644 --- a/static/js/locale_zhcn.js +++ b/static/js/locale_zhcn.js @@ -3224,6 +3224,7 @@ var LANG = { tab_weaponskills: "武器技能", tab_world: "世界", tab_zones: "地区", + tab_bonusloot: "奖励战利品", // aowow - custom from BONUS_LOOT_LABEL numberofupvotesreceived_tip: "收到顶票数量", deletethisreply_stc: "删除本评论",