Skip to content

Commit

Permalink
Fix localization of poor quality weapon
Browse files Browse the repository at this point in the history
Apply poor quality weapon modifier to NPC rolls

Signed-off-by: Marcloure <[email protected]>
  • Loading branch information
Marcloure authored and StasTserk committed Oct 20, 2024
1 parent 406afe2 commit 10d7e1e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions module/rolls/npcSkillRoll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getSplitPoolText,
getSplitPoolRoll,
NpcEventHandlerOptions,
mergePartials,
} from './rolls';
import { byName, notifyError } from '../helpers';
import { Npc } from '../actors/Npc';
Expand Down Expand Up @@ -68,6 +69,34 @@ export async function handleNpcWeaponRoll({
'The weapon that is being cast appears to be missing from the character sheet.'
);
}

const quality = (weapon as MeleeWeapon | RangedWeapon).system.quality;

let weaponPreset: Partial<RollDialogData> = {};
if (quality === 'superior') {
weaponPreset = {
diceModifiers: [
{
dice: 1,
label: game.i18n.localize('BW.weapon.superiorQuality'),
optional: false,
},
],
};
} else if (quality === 'poor') {
weaponPreset = {
obModifiers: [
{
obstacle: 1,
label: game.i18n.localize('BW.weapon.poorQuality'),
optional: false,
},
],
};
}

dataPreset = mergePartials(weaponPreset, dataPreset);

const extraInfo =
weapon.type === 'melee weapon'
? await (weapon as MeleeWeapon).getWeaponMessageData(
Expand Down
2 changes: 1 addition & 1 deletion module/rolls/rollWeapon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function handleWeaponRoll({
obModifiers: [
{
obstacle: 1,
label: game.i18n.localize('BW.weapon.superiorQuality'),
label: game.i18n.localize('BW.weapon.poorQuality'),
optional: false,
},
],
Expand Down

0 comments on commit 10d7e1e

Please sign in to comment.