temp commit
This commit is contained in:
parent
391b76ccbd
commit
b4089e4b71
@ -1,6 +1,7 @@
|
||||
import { log, module } from './globals.js'
|
||||
import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js'
|
||||
import { powerEffects } from './powerEffects.js'
|
||||
import { powers } from './powers.js'
|
||||
|
||||
export class api {
|
||||
static registerFunctions () {
|
||||
@ -14,6 +15,7 @@ export class api {
|
||||
rulesVersion: module.rulesVersion,
|
||||
fearTable: module.fearTableHelper,
|
||||
powerEffects,
|
||||
powers,
|
||||
requestRollFromTokens,
|
||||
requestFearRollFromTokens
|
||||
}
|
||||
|
||||
111
scripts/powers.js
Normal file
111
scripts/powers.js
Normal file
@ -0,0 +1,111 @@
|
||||
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: `<strong>Targets:</strong> ${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' }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user