82 lines
1.9 KiB
JavaScript

import { moduleName } from '../globals.js';
import { PowerEffect } from './basePowers.js';
export class ProtectionEffect extends PowerEffect {
get name() {
return 'Protection';
}
get duration() {
return 5;
}
get icon() {
return 'systems/swade/assets/icons/status/status_protection.svg';
}
get hasAdditionalRecipients() {
return true;
}
get additionalRecipientCost() {
return 1;
}
get basePowerPoints() {
return 1;
}
get isTargeted() {
return true;
}
async parseValues() {
await super.parseValues();
const doc = await PowerEffect.getStatus('SWADE.Protection', 'Protection', false);
doc.flags = mergeObject(doc.flags ?? {}, { [moduleName]: { powerEffect: true } });
this.data.effect = doc;
}
get modifiers() {
return [
...super.modifiers,
{
type: 'checkbox',
name: 'Shield Other',
id: 'other',
value: 1,
effect: true,
epic: false,
icon: 'icons/magic/defensive/shield-barrier-flaming-diamond-blue-yellow.webp',
changes: '',
},
];
}
get basePrimaryEffect() {
this.data.effect.changes = this.getPrimaryEffectChanges();
return this.data.effect;
}
getPrimaryEffectChanges() {
const mode = CONST.ACTIVE_EFFECT_MODES.ADD;
const key = `system.stats.toughness.${this.data.raise ? 'value' : 'armor'}`;
return [...super.getPrimaryEffectChanges(), { key, mode, value: 2, priority: 0 }];
}
get description() {
let text =
super.description +
`
<p>Grant the recipients 2 points of ${this.data.raise ? 'toughness' : 'armor'}
</p>
`;
if (this.data.other) {
text += `<p>If the protected creature is not the caster, and the protected
creature suffers wounds, the caster can take those wounds instead. If the
caster does this, they get a free reroll on the Soak roll, if one is attempted.</p>`;
}
return text;
}
}