WIP commit for additional recipients
This commit is contained in:
parent
592d0c5406
commit
baa9d51c18
@ -28,9 +28,7 @@ class PowerEffect {
|
|||||||
|
|
||||||
createEffectDocument (icon, name, changes = null) {
|
createEffectDocument (icon, name, changes = null) {
|
||||||
if (changes === null) {
|
if (changes === null) {
|
||||||
changes = [
|
changes = []
|
||||||
{ key: 'flags.swade-mb-helpers.hasPower', value: 1,
|
|
||||||
priority: 0, mode: foundry.CONST.ACTIVE_EFFECT_MODES.OVERRIDE } ]
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
icon,
|
icon,
|
||||||
@ -66,10 +64,10 @@ class PowerEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get name () { return 'Unknown Power' }
|
get name () { return 'Unknown Power' }
|
||||||
|
get effectName () { return this.name }
|
||||||
get icon () { return 'icons/magic/symbols/question-stone-yellow.webp' }
|
get icon () { return 'icons/magic/symbols/question-stone-yellow.webp' }
|
||||||
get duration () { return 5 }
|
get duration () { return 5 }
|
||||||
get basePowerPoints () { return 0 }
|
get basePowerPoints () { return 0 }
|
||||||
get powerPoints () { return this.basePowerPoints }
|
|
||||||
get usePrimaryEffect () { return true }
|
get usePrimaryEffect () { return true }
|
||||||
get modifiers () {
|
get modifiers () {
|
||||||
return [
|
return [
|
||||||
@ -169,6 +167,7 @@ class PowerEffect {
|
|||||||
await this.parseValues()
|
await this.parseValues()
|
||||||
await this.apply()
|
await this.apply()
|
||||||
await this.sideEffects()
|
await this.sideEffects()
|
||||||
|
await this.chatMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +206,16 @@ class PowerEffect {
|
|||||||
return docs
|
return docs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPrimaryEffectChanges () {
|
||||||
|
const changes = [
|
||||||
|
{ key: 'flags.swade-mb-helpers.powerAffected', value: 1,
|
||||||
|
priority: 0, mode: foundry.CONST.ACTIVE_EFFECT_MODES.OVERRIDE } ]
|
||||||
|
return changes
|
||||||
|
}
|
||||||
|
|
||||||
async createPrimaryEffect (maintId) {
|
async createPrimaryEffect (maintId) {
|
||||||
const doc = this.createEffectDocument(this.icon, this.name, [])
|
const doc = this.createEffectDocument(this.icon, this.effectName,
|
||||||
|
this.getPrimaryEffectChanges())
|
||||||
doc.flags[moduleName].maintId = maintId
|
doc.flags[moduleName].maintId = maintId
|
||||||
doc.duration.seconds = 594
|
doc.duration.seconds = 594
|
||||||
return doc
|
return doc
|
||||||
@ -257,12 +264,60 @@ class PowerEffect {
|
|||||||
|
|
||||||
async sideEffects () {
|
async sideEffects () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get powerPoints () {
|
||||||
|
let total = this.basePowerPoints
|
||||||
|
for (const mod of this.modifiers) {
|
||||||
|
if (this.data.mods.has(mod.id)) {
|
||||||
|
total += mod.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
class BurrowEffect extends PowerEffect {
|
async chatMessage () {
|
||||||
|
let text = `Cast ${this.name}`
|
||||||
|
if (this.targets.length > 0) {
|
||||||
|
text += ` on ${this.targets.map(t => t.name).join(', ')}`
|
||||||
|
}
|
||||||
|
return ChatMessage.create({
|
||||||
|
flavor: `Calculated cost: ${this.powerPoints} pp`,
|
||||||
|
speaker: ChatMessage.getSpeaker(this.source.actor),
|
||||||
|
content: text,
|
||||||
|
whisper: ChatMessage.getWhisperRecipients('GM', game.user.name),
|
||||||
|
}, { chatBubble: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class AdditionalRecipientsMixin extends PowerEffect {
|
||||||
|
get additionalRecipientCost () { return 1 }
|
||||||
|
get menuInputs () {
|
||||||
|
const inputs = super.menuInputs
|
||||||
|
if (this.targets.length > 1) {
|
||||||
|
inputs[2].label += ` (${this.targets.length - 1} additional recipients ` +
|
||||||
|
` +${this.additionalRecipientCost} ea.)`
|
||||||
|
}
|
||||||
|
return inputs
|
||||||
|
}
|
||||||
|
|
||||||
|
get powerPoints () {
|
||||||
|
let pp = super.powerPoints
|
||||||
|
if (this.targets.length > 1) {
|
||||||
|
pp += (this.targets.length - 1) * this.additionalRecipientCost
|
||||||
|
}
|
||||||
|
return pp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BurrowEffect extends PowerEffect, AdditionalRecipientsMixin {
|
||||||
get name () { return 'Burrow' }
|
get name () { return 'Burrow' }
|
||||||
get duration () { return 5 }
|
get duration () { return 5 }
|
||||||
get icon () { return 'icons/magic/earth/projectile-stone-landslide.webp' }
|
get icon () { return 'icons/magic/earth/projectile-stone-landslide.webp' }
|
||||||
|
get effectName () {
|
||||||
|
return `${this.name} (${this.data.raise ? 'half' : 'full'} pace)`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PowerClasses = {
|
export const PowerClasses = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user