aku test2
This commit is contained in:
parent
e2eed52d07
commit
89b4849ed4
@ -129,6 +129,17 @@ const MITIGATION_ABILITIES = [
|
|||||||
'Addle' => ['dr' => 10, 'buffType' => 'debuff', 'statusId' => 1001203],
|
'Addle' => ['dr' => 10, 'buffType' => 'debuff', 'statusId' => 1001203],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function localizedMitigationName(string $key, string $language, string $fallback): string {
|
||||||
|
$names = [
|
||||||
|
'de' => [
|
||||||
|
'Reprisal' => 'Reflexion',
|
||||||
|
'Feint' => 'Zermürben',
|
||||||
|
'Addle' => 'Stumpfsinn',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return $names[$language][$key] ?? $fallback;
|
||||||
|
}
|
||||||
|
|
||||||
function resolveMitigations(string $buffStr, array $mitigIdMap): array {
|
function resolveMitigations(string $buffStr, array $mitigIdMap): array {
|
||||||
if ($buffStr === '') return [];
|
if ($buffStr === '') return [];
|
||||||
$result = [];
|
$result = [];
|
||||||
@ -208,6 +219,7 @@ foreach ($abilityNames as $gameId => $name) {
|
|||||||
foreach (MITIGATION_ABILITIES as $name => $meta) {
|
foreach (MITIGATION_ABILITIES as $name => $meta) {
|
||||||
if (isset($meta['statusId']) && !isset($mitigIdMap[$meta['statusId']])) {
|
if (isset($meta['statusId']) && !isset($mitigIdMap[$meta['statusId']])) {
|
||||||
$displayName = $abilityNames[(int)$meta['statusId']] ?? $name;
|
$displayName = $abilityNames[(int)$meta['statusId']] ?? $name;
|
||||||
|
$displayName = localizedMitigationName($name, $language, $displayName);
|
||||||
$mitigIdMap[$meta['statusId']] = array_merge(['key' => $name, 'name' => $displayName], $meta);
|
$mitigIdMap[$meta['statusId']] = array_merge(['key' => $name, 'name' => $displayName], $meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
window.App.language = normalizeLanguage(languageSelect.value);
|
window.App.language = normalizeLanguage(languageSelect.value);
|
||||||
localStorage.setItem('ff14-mitigator-language', window.App.language);
|
localStorage.setItem('ff14-mitigator-language', window.App.language);
|
||||||
setUrlState({ language: window.App.language });
|
setUrlState({ language: window.App.language });
|
||||||
|
window.dispatchEvent(new CustomEvent('ff14-language-change', { detail: { language: window.App.language } }));
|
||||||
if (window.App.reportCode) {
|
if (window.App.reportCode) {
|
||||||
loadReport(window.App.reportCode, window.App.fightId);
|
loadReport(window.App.reportCode, window.App.fightId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,6 +89,30 @@ function fmtNumber(n) {
|
|||||||
return Number(n).toLocaleString('de-DE');
|
return Number(n).toLocaleString('de-DE');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function currentLanguage() {
|
||||||
|
return window.App?.language || localStorage.getItem('ff14-mitigator-language') || 'en';
|
||||||
|
}
|
||||||
|
|
||||||
|
const ABILITY_DISPLAY_NAMES = {
|
||||||
|
de: {
|
||||||
|
'Addle': 'Stumpfsinn',
|
||||||
|
'Feint': 'Zermürben',
|
||||||
|
'Reprisal': 'Reflexion',
|
||||||
|
'Passage of Arms': 'Waffengang',
|
||||||
|
'Heart of Light': 'Herz des Lichts',
|
||||||
|
'Sacred Soil': 'Geweihte Erde',
|
||||||
|
'Tactician': 'Taktiker',
|
||||||
|
'Shake It Off': 'Abschütteln',
|
||||||
|
'Shield Samba': 'Schildsamba',
|
||||||
|
'Magick Barrier': 'Magiebarriere',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function localizedAbilityName(key, fallback = key) {
|
||||||
|
const lang = currentLanguage();
|
||||||
|
return ABILITY_DISPLAY_NAMES[lang]?.[key] ?? fallback ?? key;
|
||||||
|
}
|
||||||
|
|
||||||
// ── Rendering: Plan List ──────────────────────────────────────────────────────
|
// ── Rendering: Plan List ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function renderPlanList() {
|
function renderPlanList() {
|
||||||
@ -224,7 +248,8 @@ function renderMechanicList(plan) {
|
|||||||
: a.buffType === 'shield' ? 'badge-assign-shield'
|
: a.buffType === 'shield' ? 'badge-assign-shield'
|
||||||
: a.buffType === 'buff' ? 'badge-assign-buff'
|
: a.buffType === 'buff' ? 'badge-assign-buff'
|
||||||
: '';
|
: '';
|
||||||
const label = a.job ? `${escHtml(a.job)} · ${escHtml(a.ability)}` : escHtml(a.ability);
|
const ability = localizedAbilityName(a.ability, a.abilityName ?? a.ability);
|
||||||
|
const label = a.job ? `${escHtml(a.job)} · ${escHtml(ability)}` : escHtml(ability);
|
||||||
return `<span class="badge badge-assign ${cls}">${label}</span>`;
|
return `<span class="badge badge-assign ${cls}">${label}</span>`;
|
||||||
}).join('')
|
}).join('')
|
||||||
}
|
}
|
||||||
@ -366,6 +391,14 @@ function guessJob(abilityName, players) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mitigationDisplayName(mitigation) {
|
||||||
|
return mitigation?.name ?? mitigation?.key ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function mitigationKey(mitigation) {
|
||||||
|
return mitigation?.key ?? mitigation?.name ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
// ── AoE Events → Plan Mechanics ───────────────────────────────────────────────
|
// ── AoE Events → Plan Mechanics ───────────────────────────────────────────────
|
||||||
|
|
||||||
function aoeEventsToMechanics(aoeEvents, fightStart, phases, players, withMitigations) {
|
function aoeEventsToMechanics(aoeEvents, fightStart, phases, players, withMitigations) {
|
||||||
@ -387,10 +420,15 @@ function aoeEventsToMechanics(aoeEvents, fightStart, phases, players, withMitiga
|
|||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
for (const t of ev.targets) {
|
for (const t of ev.targets) {
|
||||||
for (const m of (t.mitigations ?? [])) {
|
for (const m of (t.mitigations ?? [])) {
|
||||||
const key = m.key ?? m.name;
|
const key = mitigationKey(m);
|
||||||
if (!seen.has(key)) {
|
if (!seen.has(key)) {
|
||||||
seen.add(key);
|
seen.add(key);
|
||||||
assignments.push({ ability: key, job: guessJob(key, players), buffType: m.buffType ?? '' });
|
assignments.push({
|
||||||
|
ability: key,
|
||||||
|
abilityName: mitigationDisplayName(m),
|
||||||
|
job: guessJob(key, players),
|
||||||
|
buffType: m.buffType ?? '',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,3 +594,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
renderPlanList();
|
renderPlanList();
|
||||||
renderPlanDetail(null);
|
renderPlanDetail(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('ff14-language-change', () => {
|
||||||
|
if (!activePlanId) return;
|
||||||
|
renderPlanDetail(getPlan(activePlanId));
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user