diff --git a/src/module/helpers.js b/src/module/helpers.js index a0f9fd5..e4ed4d7 100644 --- a/src/module/helpers.js +++ b/src/module/helpers.js @@ -255,6 +255,91 @@ export async function deleteToken(sceneId, tokenId) { } export function SwadeVAEbuttons(effect, buttons) { + if (effect?.name === 'Shaken') { + buttons.push({ + label: game.i18n.localize('SWADE.EffectCallbacks.Shaken.RollSpirit'), + callback: async function () { + const flavor = game.i18n.localize('SWADE.EffectCallbacks.Shaken.Flavor'); + const roll = await effect.parent.rollAttribute('spirit', { + title: flavor, + flavour: flavor, + additionalMods: [ + { + label: game.i18n.localize('SWADE.EffectCallbacks.Shaken.UnshakeModifier'), + value: effect.parent.system.attributes.spirit.unShakeBonus, + }, + ], + }); + if (roll?.successes ?? 0 >= 1) { + await effect.delete(); + ui.notifications.info('SWADE.EffectCallbacks.Shaken.Success', { + localize: true, + }); + } + }, + }); + buttons.push({ + label: game.i18n.localize('SWADE.BenniesSpend'), + callback: async () => { + const parent = effect.parent; + await parent?.spendBenny(); + await effect.delete(); + }, + }); + if (game.user?.isGM) { + buttons.push({ + label: game.i18n.localize('SWADE.BenniesSpendGM'), + callback: async () => { + const parent = effect.parent; + await game.user?.spendBenny(); + await effect.delete(); + }, + }); + } + } + if (effect?.name === 'Stunned') { + buttons.push({ + label: 'Vigor roll to remove Stunned', + callback: async () => { + const parent = effect.parent; + const flavour = game.i18n.localize('SWADE.EffectCallbacks.Stunned.Title'); + const roll = await parent.rollAttribute('vigor', { + title: flavour, + flavour, + additionalMods: [ + { + label: game.i18n.localize('SWADE.EffectCallbacks.Stunned.UnStunModifier'), + value: parent.system.attributes.vigor.unStunBonus, + }, + ], + }); + const result = roll?.successes ?? 0; + if (result < 1) { + // no roll or failure + ui.notifications.info('SWADE.EffectCallbacks.Stunned.Fail', { + localize: true, + }); + return; + } + //normal success, still vulnerable + if (result === 1) { + await effect.delete(); + ui.notifications.info('SWADE.EffectCallbacks.Stunned.Success', { + localize: true, + }); + return; + } + + if (result >= 2) { + await effect.delete(); + ui.notifications.info('SWADE.EffectCallbacks.Stunned.Raise', { + localize: true, + }); + return; + } + }, + }); + } if (['Bound', 'Entangled'].includes(effect?.name)) { buttons.push({ label: 'Break Free (Athletics)',