forked from public/foundryvtt-wh4-lang-fr-fr
fix: correction des tests de Corruption pour la locale FR
- Remplacement des comparaisons localisées dans handleCorruptionResult par des chaînes anglaises en dur pour que les paliers de Corruption soient correctement appliqués - Correction de _onResist pour accepter les valeurs anglaises et françaises de sévérité de Corruption - Correction des liens @Corruption[modérée] → @Corruption[moderate] dans les scripts d'effets - Élargissement de la clause de garde dans xS2su09zcza9du09.js pour couvrir les valeurs anglaises et françaises - Ajout de AGENTS.md
This commit is contained in:
@@ -478,6 +478,79 @@ Hooks.on('ready', () => {
|
||||
"doom": "Maudit (-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 in French
|
||||
// ("minor" !== "mineur"). Since corruption severity strings ("minor"/"moderate"/"major")
|
||||
// are internal API constants, not user-facing text, we use hardcoded comparisons.
|
||||
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 French 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 French "Mineur".
|
||||
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));
|
||||
};
|
||||
}
|
||||
|
||||
if (game.user.isGM) {
|
||||
game.wfrp4e.warnDialog.render(true, { focus: true, left: 20, top: 20 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user