export async function powers (options = {}) { const token = 'token' in options ? options.token : null if (token === undefined || token === null) { ui.notifications.error('Please select one token to be the caster') return } const targets = 'targets' in options ? Array.from(options.targets) : [] const item = 'item' in options ? options.item : null const swid = options?.name || item?.system.swid || null if (swid in PowerClasses) { const runner = new PowerClasses[name](token, targets) runner.powerEffect() return } ui.notifications.error(`No power effect found for ${name}`) } const PowerClasses = { 'burrow': BurrowEffect } class PowerEffect { constructor (token, targets) { this.source = token this.targets = targets this.modifiers = [ {name: 'Glow', id: 'glow', value: 1, advanced: false}, {name: 'Shroud', id: 'shroud', value: 1, advanced: false}, {name: 'Hinder', id: 'hinder', value: 1, advanced: false}, {name: 'Hurry', id: 'hurry', value: 1, advanced: false}, ] } get name () { return 'Unknown Power' } get icon () { return 'icons/magic/symbols/question-stone-yellow.webp' } get duration () { return 5 } get menuData () { return { inputs: this.menuInputs, buttons: this.menuButtons, } } get menuInputs () { const data = [ { type: 'header', label: `${this.name} Effect` }, { type: 'info', label: `Apply ${this.name} Effect` }, ] if (this.targets.length > 0) { data.push({ type: 'info', label: `Targets: ${this.targets.map(t => t.name).join(',')}` }) } for (const mod of this.modifiers) { data.push({ type: 'checkbox', label: ( `${mod.advanced ? '⭐ ' : ''}${mod.name} ` + `(${mod.value >= 0 ? '+' : ''}${mod.value}` ), }) } data.push({ type: 'header', label: '---------------' }) return data } get menuButtons () { const data = [ { label: 'Apply', value: 'apply' }, { label: 'Apply with Raise', value: 'raise' }, { label: 'Cancel', value: 'cancel' } ] return data } get menuOptions () { return { title: `${this.name} Effect`, defaultButton: 'Cancel', options: {} } } async powerEffect () { const { buttons, inputs } = await warpgate.menu( this.menuData, this.menuOptions ) this.choice = buttons this.values = inputs if (this.choice && this.choice !== 'cancel') { await this.parseValues() await this.apply() } } async parseValues () { } async applyResult () { } } class BurrowEffect extends PowerEffect { get name () { return 'Burrow' } get duration () { return 5 } get icon () { return 'icons/magic/earth/projectile-stone-landslide.webp' } }