import { PowerEffect } from './basePowers.js'; export class SlothSpeedEffect extends PowerEffect { get name() { return 'Sloth/Speed'; } get hasAdditionalRecipients() { return (this?.data?.direction ?? 'Speed') == 'Speed'; } get additionalRecipientCost() { return 1; } get additionalRecipientText() { return `${super.additionalRecipientText} (speed only)`; } get icon() { return this?.data?.direction === 'Sloth' ? 'icons/magic/control/debuff-energy-snare-brown.webp' : 'icons/skills/movement/figure-running-gray.webp'; } get duration() { return this?.data?.direction === 'Sloth' ? 0 : 5; } get isTargeted() { return true; } get basePowerPoints() { return 2; } get hasAoe() { return true; } get modifiers() { const mods = super.modifiers; mods.push({ sortOrder: -2, name: 'Sloth or Speed?', id: 'direction', type: 'radio', default: 'Sloth', epic: false, choices: { Sloth: 'Sloth', Speed: 'Speed' }, effects: { Sloth: null, Speed: null }, values: { Sloth: 0, Speed: 0 }, }); mods.push({ type: 'select', default: 'none', name: 'Area of Effect (Sloth Only)', id: 'aoe', epic: false, choices: { none: 'None', mbt: 'Medium Blast Template', lbt: 'Large Blast Template', }, effects: { none: null, mbt: null, lbt: null }, values: { none: 0, mbt: 2, lbt: 3 }, }); mods.push({ name: 'Dash (Speed only)', id: 'dash', type: 'checkbox', default: false, epic: false, effect: false, value: 2, }); mods.push({ name: 'Quickness (Speed only)', id: 'quickness', type: 'checkbox', default: false, epic: false, effect: false, value: 2, }); mods.push({ name: 'Strong (Sloth only)', id: 'strong', type: 'checkbox', default: false, value: 1, epic: false, effect: false, }); return mods; } getPrimaryEffectChanges() { const changes = [ { key: 'system.stats.speed.value', value: -1, priority: 0, mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, }, ]; return [...super.getPrimaryEffectChanges(), ...changes]; } async primaryDocForTarget(doc, target) { const newDoc = await super.primaryDocForTarget(doc, target); const modValue = this.data.direction === 'Sloth' ? -0.5 : 1; const idx = newDoc.changes.length - 1; newDoc.changes[idx].value = Math.ceil(target.actor.system.stats.speed.value * modValue); return newDoc; } get effectName() { let name = `${this.data.raise ? 'major' : 'minor'} ${this.data.direction}`; const parts = []; if (this.data.direction === 'Sloth' && this.data.strong) { parts.push('strong'); } if (this.data.direction === 'Speed') { if (this.data.dash) { parts.push('dash'); } if (this.data.quickness) { parts.push('quickness'); } } if (parts.length > 0) { name = `${name} (${parts.join(', ')})`; } return name; } get description() { let desc = super.description; if (this.data.direction === 'Sloth') { desc += `

Target's pace is reduced by half (round up). `; if (this.data.raise) { desc += `For the target, movement is also an action. `; } desc += `

The target tries to shake off the effects at the end of subsequent turns with a Spirit roll${this.data.strong ? ' at -2' : ''}.

`; } else { desc += `

Target's pace is doubled. `; if (this.data.raise) { desc += `The target also ignores the -2 running penalty. `; } if (this.data.dash) { desc += `When running, the target runs as if they rolled the maximum on their running die. `; } if (this.data.quickness) { desc += `The target's total Multi-Action penalty each turn is reduced by 2.`; } desc += '

'; } return desc; } get primaryEffectButtons() { const buttons = super.primaryEffectButtons; if (this.data.direction === 'Sloth') { const mods = []; if (this.data.strong) { mods.push({ label: 'Strong', value: -2 }); } buttons.push({ label: `Shake off (Spirit${this.data.strong ? ' -2' : ''})`, type: 'trait', rollType: 'attribute', rollDesc: 'Spirit', flavor: 'Success shakes off the effects of sloth', mods, }); } return buttons; } }