fix: 3 Laufzeitfehler portiert/gefunden beim Abgleich mit fr-fr Upstream
Prüfung der letzten fr-fr-Commits auf funktionale (nicht-inhaltliche)
Änderungen ergab drei Bugs derselben Klasse wie in fr-fr commits
c54a625a und 05cc3eb9 (Wörter, die versehentlich echte Code-Bezeichner
statt Anzeigetext ersetzt haben):
- scripts/0hgTyeaEhMBLwzUn.js: rief `game.wfrp4e.utility.postPeur(...)`
auf (französisches Leftover aus dem fr-fr-Fork, es gibt keine
Methode mit diesem Namen) und suchte den Trait per `.has("Peur")`.
Korrigiert zu `.postFear(...)` und `.has("Angst")` (unserer eigenen
Übersetzung von "Fear" in wfrp4e-core.items.json).
- scripts/V4PcjtHde941wv6J.js: `const Test = ...` wurde zwei Zeilen
später als `test.roll()` (kleingeschrieben) referenziert ->
ReferenceError bei jedem Auslösen dieses Effekts. Umbenannt zu
`const test`.
- modules/addon-register.js: der wfrp4e-System-Code in
handleCorruptionResult/_onResist vergleicht Corruption-Schweregrade
über game.i18n.localize() - das funktioniert nur zufällig auf
Englisch. Da unsere CORRUPTION.Minor/Moderate/Major bereits korrekt
als "Leicht"/"Mittel"/"Schwer" übersetzt sind, wurden Corruption-
Punkte aus fehlgeschlagenen Corruption-Proben nie korrekt
angewendet. Patch von fr-fr (commit c54a625a) übernommen und auf
unsere deutschen CORRUPTION-Keys angepasst.
modules/loadScripts.js neu gepackt (npm run build / scriptPacker.js).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -394,6 +394,81 @@ Hooks.on('ready', () => {
|
||||
"doom": "Unmöglich (-40)"
|
||||
}
|
||||
|
||||
// Patch handleCorruptionResult to use hardcoded English severity comparisons.
|
||||
// The system compares this.options.corruption against game.i18n.localize() values,
|
||||
// which works in English by coincidence ("minor" === "minor") but breaks for any
|
||||
// other locale ("minor" !== "Leicht"). Since corruption severity strings
|
||||
// ("minor"/"moderate"/"major") are internal API constants, not user-facing text,
|
||||
// we use hardcoded comparisons instead. Ported from the French module's fix
|
||||
// (foundryvtt-wh4-lang-fr-fr commit c54a625a), which hit the exact same bug.
|
||||
const TestWFRP = game.wfrp4e.rolls.TestWFRP;
|
||||
if (TestWFRP?.prototype?.handleCorruptionResult) {
|
||||
TestWFRP.prototype.handleCorruptionResult = async function () {
|
||||
const strength = this.options.corruption;
|
||||
const failed = this.failed;
|
||||
let corruption = 0;
|
||||
switch (strength) {
|
||||
case "minor":
|
||||
if (failed) corruption++;
|
||||
break;
|
||||
case "moderate":
|
||||
if (failed) corruption += 2;
|
||||
else if (this.result.SL < 2) corruption += 1;
|
||||
break;
|
||||
case "major":
|
||||
if (failed) corruption += 3;
|
||||
else if (this.result.SL < 2) corruption += 2;
|
||||
else if (this.result.SL < 4) corruption += 1;
|
||||
break;
|
||||
}
|
||||
if (this.context.reroll || this.context.fortuneUsedAddSL) {
|
||||
const prevFailed = this.context.previousResult.outcome === "failure";
|
||||
switch (strength) {
|
||||
case "minor":
|
||||
if (prevFailed) corruption--;
|
||||
break;
|
||||
case "moderate":
|
||||
if (prevFailed) corruption -= 2;
|
||||
else if (this.context.previousResult.SL < 2) corruption -= 1;
|
||||
break;
|
||||
case "major":
|
||||
if (prevFailed) corruption -= 3;
|
||||
else if (this.context.previousResult.SL < 2) corruption -= 2;
|
||||
else if (this.context.previousResult.SL < 4) corruption -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let newCorruption = Number(this.actor.system.status.corruption.value) + corruption;
|
||||
if (newCorruption < 0) newCorruption = 0;
|
||||
if (!this.context.reroll && !this.context.fortuneUsedAddSL)
|
||||
ChatMessage.create(game.wfrp4e.utility.chatDataSetup(game.i18n.format("CHAT.CorruptionFail", { name: this.actor.name, number: corruption }), "gmroll", false));
|
||||
else
|
||||
ChatMessage.create(game.wfrp4e.utility.chatDataSetup(game.i18n.format("CHAT.CorruptionReroll", { name: this.actor.name, number: corruption }), "gmroll", false));
|
||||
await this.actor.update({ "system.status.corruption.value": newCorruption });
|
||||
};
|
||||
}
|
||||
|
||||
// Patch _onResist to accept both raw English and localized German corruption severity.
|
||||
// The original validation compares `this.strength` against localized CORRUPTION.* keys,
|
||||
// which fails when the stored strength is an English API value like "minor" vs German "Leicht".
|
||||
const CorruptionMsgModel = CONFIG.ChatMessage.dataModels?.["corruption"];
|
||||
if (CorruptionMsgModel?._onResist) {
|
||||
CorruptionMsgModel._onResist = async function (ev, target) {
|
||||
const strength = this.strength.toLowerCase();
|
||||
const sMap = {
|
||||
"minor": "minor", "moderate": "moderate", "major": "major",
|
||||
[game.i18n.localize("CORRUPTION.Minor").toLowerCase()]: "minor",
|
||||
[game.i18n.localize("CORRUPTION.Moderate").toLowerCase()]: "moderate",
|
||||
[game.i18n.localize("CORRUPTION.Major").toLowerCase()]: "major",
|
||||
};
|
||||
const normalized = sMap[strength];
|
||||
if (!normalized) return ui.notifications.error("ErrorCorruption", { localize: true });
|
||||
const actors = warhammer.utility.targetedOrAssignedActors();
|
||||
if (!actors.length) return ui.notifications.error("ErrorCharAssigned", { localize: true });
|
||||
actors.forEach(a => a.corruptionDialog(normalized, this.skill));
|
||||
};
|
||||
}
|
||||
|
||||
game.wfrp4e.warnDialog.render(true, { focus: true, left: 20, top: 20 });
|
||||
//setTimeout( __check_fix_wrong_modules, 2000, true, false);
|
||||
setTimeout(__check_fix_wrong_modules, 20000, true, true);
|
||||
|
||||
Reference in New Issue
Block a user