remove shim, better linting
This commit is contained in:
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { log, shim } from './shim.js'
|
||||
import { log, module } from './globals.js'
|
||||
import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js'
|
||||
import { powerEffects } from './powerEffects.js'
|
||||
|
||||
@@ -11,8 +11,8 @@ export class api {
|
||||
static globals () {
|
||||
const moduleName = 'swade-mb-helpers'
|
||||
game.modules.get(moduleName).api = {
|
||||
rulesVersion: shim.rulesVersion,
|
||||
fearTable: shim.fearTableHelper,
|
||||
rulesVersion: module.rulesVersion,
|
||||
fearTable: module.fearTableHelper,
|
||||
powerEffects,
|
||||
requestRollFromTokens,
|
||||
requestFearRollFromTokens
|
||||
|
||||
@@ -1,78 +1,14 @@
|
||||
export class CONST {
|
||||
static get SWADE () {
|
||||
return CONFIG.SWADE.CONST
|
||||
}
|
||||
export const moduleName = 'swade-mb-helpers'
|
||||
|
||||
static get FOUNDRY () {
|
||||
return foundry.CONST
|
||||
}
|
||||
|
||||
static get WARPGATE () {
|
||||
return warpgate.CONST
|
||||
}
|
||||
export function log (...args) {
|
||||
console.log('SWADE MB HELPERS |', ...args)
|
||||
}
|
||||
|
||||
export class shim {
|
||||
static get ActiveEffect () {
|
||||
return ActiveEffect
|
||||
}
|
||||
|
||||
static get CONFIG () {
|
||||
return CONFIG
|
||||
}
|
||||
|
||||
static get Actor () {
|
||||
return Actor
|
||||
}
|
||||
|
||||
static get ChatMessage () {
|
||||
return ChatMessage
|
||||
}
|
||||
|
||||
static get game () {
|
||||
return game
|
||||
}
|
||||
|
||||
static get canvas () {
|
||||
return game.canvas
|
||||
}
|
||||
|
||||
static get folders () {
|
||||
return game.folders
|
||||
}
|
||||
|
||||
static get controlled () {
|
||||
return canvas.tokens.controlled
|
||||
}
|
||||
|
||||
static get targets () {
|
||||
return game.user.targets
|
||||
}
|
||||
|
||||
static get user () {
|
||||
return game.user
|
||||
}
|
||||
|
||||
static get users () {
|
||||
return game.users
|
||||
}
|
||||
|
||||
static get notifications () {
|
||||
return ui.notifications
|
||||
}
|
||||
|
||||
static get actors () {
|
||||
return game.actors
|
||||
}
|
||||
|
||||
static get scenes () {
|
||||
return game.scenes
|
||||
}
|
||||
|
||||
export class module {
|
||||
static _socket = null
|
||||
|
||||
static get socket () {
|
||||
return shim._socket
|
||||
return module._socket
|
||||
}
|
||||
|
||||
static get rulesVersion () {
|
||||
@@ -85,8 +21,18 @@ export class shim {
|
||||
return 'system'
|
||||
}
|
||||
|
||||
static mergeObject (...args) {
|
||||
return mergeObject(...args)
|
||||
static async applyActiveEffects (token, effectDocuments) {
|
||||
const mutation = {
|
||||
embedded: { ActiveEffect: {} }
|
||||
}
|
||||
const mutateOptions = {
|
||||
permanent: true,
|
||||
description: effectDocuments[effectDocuments.length - 1]?.name
|
||||
}
|
||||
for (const effectDocument of effectDocuments) {
|
||||
mutation.embedded.ActiveEffect[effectDocument.name] = effectDocument
|
||||
}
|
||||
await warpgate.mutate(token.document, mutation, {}, mutateOptions)
|
||||
}
|
||||
|
||||
static getStatus (label, name, favorite = true) {
|
||||
@@ -118,61 +64,19 @@ export class shim {
|
||||
flags: {
|
||||
swade: {
|
||||
favorite: true,
|
||||
expiration: CONST.SWADE.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt
|
||||
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static async applyActiveEffects (token, effectDocuments) {
|
||||
const mutation = {
|
||||
embedded: { ActiveEffect: {} }
|
||||
}
|
||||
const mutateOptions = {
|
||||
permanent: true,
|
||||
description: effectDocuments[effectDocuments.length - 1]?.name
|
||||
}
|
||||
for (const effectDocument of effectDocuments) {
|
||||
mutation.embedded.ActiveEffect[effectDocument.name] = effectDocument
|
||||
}
|
||||
await warpgate.mutate(token.document, mutation, {}, mutateOptions)
|
||||
}
|
||||
|
||||
static wait (ms) {
|
||||
return warpgate.wait(ms)
|
||||
}
|
||||
|
||||
static warpgateMenu (menuData, menuOptions) {
|
||||
return warpgate.menu(menuData, menuOptions)
|
||||
}
|
||||
|
||||
static warpgateSpawn (...args) {
|
||||
return warpgate.spawn(...args)
|
||||
}
|
||||
|
||||
static warpgateSpawnAt (...args) {
|
||||
return warpgate.spawnAt(...args)
|
||||
}
|
||||
|
||||
static get warpgateUtil () {
|
||||
return warpgate.util
|
||||
}
|
||||
|
||||
static get fearTableHelper () {
|
||||
switch (shim.rulesVersion) {
|
||||
case 'swade': return coreFearDialog
|
||||
case 'swpf': return swpfFearDialog
|
||||
}
|
||||
throw new ReferenceError('No premium module active. No fear table found')
|
||||
}
|
||||
|
||||
static getActorFolderByPath (path) {
|
||||
const names = path.split('/')
|
||||
if (names[0] === '') {
|
||||
names.shift()
|
||||
}
|
||||
let name = names.shift()
|
||||
let folder = shim.folders.filter(
|
||||
let folder = game.folders.filter(
|
||||
f => f.type === 'Actor' && !f.folder
|
||||
).find(f => f.name === name)
|
||||
if (!folder) { return undefined }
|
||||
@@ -193,9 +97,9 @@ export class shim {
|
||||
const prefix = prefixStack.shift()
|
||||
const folder = folderStack.shift()
|
||||
for (const actor of folder.contents) {
|
||||
if (shim.user.isGM ||
|
||||
if (game.user.isGM ||
|
||||
actor.testUserPermission(
|
||||
shim.user, CONST.FOUNDRY.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER)
|
||||
game.user, foundry.CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER)
|
||||
) {
|
||||
actors[`${prefix}${actor.name}`] = actor
|
||||
}
|
||||
@@ -208,8 +112,12 @@ export class shim {
|
||||
}
|
||||
return actors
|
||||
}
|
||||
}
|
||||
|
||||
export function log (...args) {
|
||||
console.log('SWADE MB HELPERS |', ...args)
|
||||
static get fearTableHelper () {
|
||||
switch (module.rulesVersion) {
|
||||
case 'swade': return coreFearDialog // defined as global by the swade module
|
||||
case 'swpf': return swpfFearDialog // defined as global by the swpf module
|
||||
}
|
||||
throw new ReferenceError('No premium module active. No fear table found')
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,4 +1,4 @@
|
||||
import { shim } from './shim.js'
|
||||
import { module } from './globals.js'
|
||||
|
||||
export async function requestFearRollFromTokens (tokens, options = {}) {
|
||||
// tokens: list of tokens to request the roll from
|
||||
@@ -6,7 +6,7 @@ export async function requestFearRollFromTokens (tokens, options = {}) {
|
||||
// title: tile for the roll dialog. Will have "- {{ token name }}" appended
|
||||
// flavour: flavor text for the roll card. Defaults to title
|
||||
// fear: value of the fear modifier. Defaults to 0. Positive number.
|
||||
const requestingUser = shim.user
|
||||
const requestingUser = game.user
|
||||
const title = options?.title || `${requestingUser.name} requests a Fear check`
|
||||
const flavour = options?.flavour || options?.flavor || title
|
||||
const fear = options.fear || 0
|
||||
@@ -32,13 +32,13 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options
|
||||
// mods: list of modifiers {label: "", value: 0, ignore: false}
|
||||
// modCallback: callback function that takes a token and returns a list of
|
||||
// modifiers in the same format as modifiers, above
|
||||
const requestingUser = shim.user
|
||||
const requestingUser = game.user
|
||||
const title = options?.title || `${requestingUser.name} requests a ${rollDesc} roll`
|
||||
const flavour = options?.flavour || options?.flavor || title
|
||||
const targetNumber = options?.targetNumber || 4
|
||||
const promises = []
|
||||
for (const token of tokens) {
|
||||
const owner = shim.warpgateUtil.firstOwner(token.document)
|
||||
const owner = warpgate.util.firstOwner(token.document)
|
||||
const rollOpts = {
|
||||
title: `${title} - ${token.name}`,
|
||||
targetNumber,
|
||||
@@ -59,7 +59,7 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options
|
||||
if (additionalMods.length > 0) {
|
||||
rollOpts.additionalMods = additionalMods
|
||||
}
|
||||
promises.push(shim.socket.executeAsUser(requestTokenRoll, owner.id,
|
||||
promises.push(module.socket.executeAsUser(requestTokenRoll, owner.id,
|
||||
token.scene.id, token.id, rollType, rollDesc, rollOpts))
|
||||
}
|
||||
const results = (await Promise.allSettled(promises)).map(r => r.value)
|
||||
@@ -67,17 +67,17 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options
|
||||
const messageData = {
|
||||
flavor: flavour,
|
||||
speaker: { alias: 'Requested Roll Results' },
|
||||
whisper: [...shim.ChatMessage.getWhisperRecipients('GM'), requestingUser],
|
||||
whisper: [...ChatMessage.getWhisperRecipients('GM'), requestingUser],
|
||||
content: `<p>Results of ${rollDesc[0].toUpperCase()}${rollDesc.slice(1)} roll${contentExtra}:</p>
|
||||
<table><thead><tr><th>Token</th><th>Roll</th><th>Result</th></tr></thead><tbody>`,
|
||||
rolls: []
|
||||
}
|
||||
for (const result of results) {
|
||||
const token = shim.game.scenes.get(result.sceneId).tokens.get(result.tokenId)
|
||||
const token = game.scenes.get(result.sceneId).tokens.get(result.tokenId)
|
||||
const roll = (
|
||||
result.result instanceof shim.CONFIG.Dice.SwadeRoll
|
||||
result.result instanceof CONFIG.Dice.SwadeRoll
|
||||
? result.result
|
||||
: shim.CONFIG.Dice[result.result.class].fromData(result.result)
|
||||
: CONFIG.Dice[result.result.class].fromData(result.result)
|
||||
)
|
||||
roll.targetNumber = targetNumber
|
||||
let textResult = ''
|
||||
@@ -100,14 +100,14 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options
|
||||
}
|
||||
}
|
||||
messageData.content += '</tbody></table>'
|
||||
shim.ChatMessage.create(messageData, {})
|
||||
ChatMessage.create(messageData, {})
|
||||
return results
|
||||
}
|
||||
|
||||
export async function requestTokenRoll (
|
||||
sceneId, tokenId, rollType, rollDesc, options
|
||||
) {
|
||||
const scene = shim.scenes.get(sceneId)
|
||||
const scene = game.scenes.get(sceneId)
|
||||
const token = scene.tokens.get(tokenId)
|
||||
let rollFunc = 'rollAttribute'
|
||||
let rollId = rollDesc.toLowerCase()
|
||||
|
||||
+2
-4
@@ -2,9 +2,7 @@ import { api } from './api.js'
|
||||
import { requestTokenRoll } from './helpers.js'
|
||||
import { preDamageRollModifiers, preTraitRollModifiers } from './rollHelpers.js'
|
||||
import { shapeChangeOnDismiss } from './powerEffects.js'
|
||||
import { log, shim } from './shim.js'
|
||||
|
||||
const moduleName = 'swade-mb-helpers'
|
||||
import { log, module } from './globals.js'
|
||||
|
||||
function _checkModule (name) {
|
||||
if (!game.modules.get(name)?.active && game.user.isGM) {
|
||||
@@ -104,5 +102,5 @@ Hooks.on('ready', () => {
|
||||
Hooks.on('socketlib.ready', () => {
|
||||
const socket = socketlib.registerModule('swade-mb-helpers')
|
||||
socket.register('requestTokenRoll', requestTokenRoll)
|
||||
shim._socket = socket
|
||||
module._socket = socket
|
||||
})
|
||||
|
||||
+67
-67
@@ -1,4 +1,4 @@
|
||||
import { CONST, log, shim } from './shim.js'
|
||||
import { log, module } from './globals.js'
|
||||
import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js'
|
||||
|
||||
class PowerEffect {
|
||||
@@ -51,7 +51,7 @@ class PowerEffect {
|
||||
log('Error preparing menu for power effect: ' + e.toString())
|
||||
return
|
||||
}
|
||||
const { buttons, inputs } = await shim.warpgateMenu(
|
||||
const { buttons, inputs } = await warpgate.menu(
|
||||
this.menuData, this.menuOptions)
|
||||
this.buttons = buttons
|
||||
this.inputs = inputs
|
||||
@@ -70,15 +70,15 @@ class PowerEffect {
|
||||
|
||||
async applyResult () {
|
||||
for (const target of this.targets) {
|
||||
shim.applyActiveEffects(target, this.effectDocs)
|
||||
module.applyActiveEffects(target, this.effectDocs)
|
||||
}
|
||||
}
|
||||
|
||||
static modEffectDoc (icon, name, key, value, durationRounds) {
|
||||
return shim.createEffectDocument(icon, name, durationRounds, [
|
||||
return module.createEffectDocument(icon, name, durationRounds, [
|
||||
{
|
||||
key,
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value,
|
||||
priority: 0
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class TargetedPowerEffect extends PowerEffect {
|
||||
|
||||
async powerEffect () {
|
||||
if (this.targets.length < 1) {
|
||||
shim.notifications.error(`No target selected for ${this.name}`)
|
||||
ui.notifications.error(`No target selected for ${this.name}`)
|
||||
return
|
||||
}
|
||||
super.powerEffect()
|
||||
@@ -160,12 +160,12 @@ class LingeringDamagePowerEffect extends TargetedPowerEffect {
|
||||
super.globalModifierEffects()
|
||||
this.inputIndex += 1
|
||||
if (this.inputs[7]) { // lingering damage
|
||||
const doc = shim.createEffectDocument(
|
||||
const doc = module.createEffectDocument(
|
||||
'icons/magic/death/skull-poison-green.webp',
|
||||
`Lingering Damage (${this.name})`,
|
||||
1
|
||||
)
|
||||
doc.flags.swade.expiration = CONST.SWADE.STATUS_EFFECT_EXPIRATION.StartOfTurnPrompt
|
||||
doc.flags.swade.expiration = CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.StartOfTurnPrompt
|
||||
this.effectDocs.push(doc)
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class ArcaneProtectionEffect extends TargetedPowerEffect {
|
||||
const icon = 'icons/magic/defensive/shield-barrier-flaming-pentagon-blue.webp'
|
||||
const name = `${greater ? 'Greater ' : ''}Arcane Protection (${raise ? 'major, ' : ''}${amount})`
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(icon, name, this.durationRounds, []))
|
||||
module.createEffectDocument(icon, name, this.durationRounds, []))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,18 +226,18 @@ class BlindEffect extends TargetedPowerEffect {
|
||||
const changes = [
|
||||
{
|
||||
key: 'system.stats.globalMods.trait',
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value: '-2',
|
||||
priority: 0
|
||||
}
|
||||
]
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
icon, `minor Blindness (Vigor ${strong ? '-2 ' : ''}ends)`,
|
||||
this.durationRounds, changes))
|
||||
if (raise) {
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
icon, `major Blindness (Vigor ${strong ? '-2 ' : ''}ends)`,
|
||||
this.durationRounds, changes)
|
||||
)
|
||||
@@ -253,7 +253,7 @@ class BurrowEffect extends TargetedPowerEffect {
|
||||
const raise = (this.buttons === 'raise')
|
||||
const icon = 'icons/magic/earth/projectile-stone-landslide.webp'
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
icon,
|
||||
`${raise ? 'major' : 'minor'} ${this.name}`,
|
||||
this.durationRounds,
|
||||
@@ -345,16 +345,16 @@ class BoostLowerTraitEffect extends TargetedPowerEffect {
|
||||
if (mods.length > 0) {
|
||||
namePart = `${namePart} (${mods.join(', ')})`
|
||||
}
|
||||
const mode = CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD
|
||||
const mode = foundry.CONST.ACTIVE_EFFECT_MODES.ADD
|
||||
const modValue = (direction === 'Boost' ? '+2' : '-2')
|
||||
const minorEffect = shim.createEffectDocument(
|
||||
const minorEffect = module.createEffectDocument(
|
||||
icon, `minor ${namePart}`, durationRounds, [
|
||||
{ key: trait.diekey, mode, value: modValue, priority: 0 }
|
||||
])
|
||||
if (direction === 'Lower' && greater) {
|
||||
minorEffect.changes.push({ key: trait.modkey, mode, value: modValue, priority: 0 })
|
||||
}
|
||||
const majorEffect = shim.createEffectDocument(
|
||||
const majorEffect = module.createEffectDocument(
|
||||
icon, `major ${namePart}`, durationRounds, [
|
||||
{ key: trait.diekey, mode, value: modValue, priority: 0 }
|
||||
])
|
||||
@@ -392,13 +392,13 @@ class ConfusionEffect extends TargetedPowerEffect {
|
||||
async prepResult () {
|
||||
const greater = !!this.inputs[this.inputIndex]
|
||||
if (this.buttons === 'distracted' || this.buttons === 'raise') {
|
||||
this.effectDocs.push(shim.getStatus('SWADE.Distr', 'Distracted'))
|
||||
this.effectDocs.push(module.getStatus('SWADE.Distr', 'Distracted'))
|
||||
}
|
||||
if (this.buttons === 'vulnerable' || this.buttons === 'raise') {
|
||||
this.effectDocs.push(shim.getStatus('SWADE.Vuln', 'Vulnerable'))
|
||||
this.effectDocs.push(module.getStatus('SWADE.Vuln', 'Vulnerable'))
|
||||
}
|
||||
if (greater) {
|
||||
this.effectDocs.push(shim.getStatus('SWADE.Shaken', 'Shaken'))
|
||||
this.effectDocs.push(module.getStatus('SWADE.Shaken', 'Shaken'))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ class DarksightEffect extends TargetedPowerEffect {
|
||||
const greater = !!this.inputs[this.inputIndex]
|
||||
const icon = 'icons/magic/perception/eye-ringed-glow-angry-small-teal.webp'
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
icon,
|
||||
`${raise ? 'major' : 'minor'} ${this.name}${greater ? ' (greater)' : ''}`,
|
||||
this.durationRounds,
|
||||
@@ -433,7 +433,7 @@ class DisguiseEffect extends TargetedPowerEffect {
|
||||
const raise = this.buttons === 'raise'
|
||||
const icon = 'icons/skills/social/diplomacy-peace-alliance.webp'
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
icon,
|
||||
`${raise ? 'major' : 'minor'} ${this.name}`,
|
||||
this.durationRounds,
|
||||
@@ -463,7 +463,7 @@ class DeflectionEffect extends TargetedPowerEffect {
|
||||
async prepResult () {
|
||||
const effectName = `Deflection (${this.buttons === 'raise' ? 'all' : this.buttons})`
|
||||
const icon = 'icons/magic/defensive/shield-barrier-deflect-teal.webp'
|
||||
this.effectDocs.push(shim.createEffectDocument(icon, effectName, this.durationRounds))
|
||||
this.effectDocs.push(module.createEffectDocument(icon, effectName, this.durationRounds))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ class DetectConcealArcanaEffect extends TargetedPowerEffect {
|
||||
? 'icons/magic/perception/third-eye-blue-red.webp'
|
||||
: 'icons/magic/perception/silhouette-stealth-shadow.webp')
|
||||
const name = `${raise ? 'major ' : ''}${isDetect ? 'Detect' : 'Conceal'} Arcana${strong ? ' (strong)' : ''}`
|
||||
const effect = shim.createEffectDocument(icon, name, this.durationRounds, [])
|
||||
const effect = module.createEffectDocument(icon, name, this.durationRounds, [])
|
||||
this.effectDocs.push(effect)
|
||||
}
|
||||
}
|
||||
@@ -529,9 +529,9 @@ class EntangleEffect extends TargetedPowerEffect {
|
||||
const tough = !!this.inputs[this.inputIndex + 3]
|
||||
const effectSearch = (this.buttons === 'raise' ? 'SWADE.Bound' : 'SWADE.Entangled')
|
||||
const effectName = (this.buttons === 'raise' ? 'Bound' : 'Entangled')
|
||||
const effect = shim.getStatus(effectSearch, effectName)
|
||||
const effect = module.getStatus(effectSearch, effectName)
|
||||
const extraIcon = 'icons/magic/nature/root-vine-barrier-wall-brown.webp'
|
||||
const extraEffect = shim.createEffectDocument(extraIcon,
|
||||
const extraEffect = module.createEffectDocument(extraIcon,
|
||||
'Entangle Modifier', this.durationRounds, [])
|
||||
if (damage) {
|
||||
extraEffect.name = `${extraEffect.name} - ${damage} dmg`
|
||||
@@ -561,7 +561,7 @@ class FearEffect extends TargetedPowerEffect {
|
||||
|
||||
async applyResult () {
|
||||
await super.applyResult()
|
||||
await shim.wait(1000)
|
||||
await warpgate.wait(1000)
|
||||
const options = {
|
||||
title: 'Fear check!',
|
||||
flavor: 'Failure: roll on the Fear Table if wildcard, Panicked if extra',
|
||||
@@ -585,12 +585,12 @@ class HavocEffect extends TargetedPowerEffect {
|
||||
|
||||
async prepResult () {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.effectDocs.unshift(shim.getStatus('SWADE.Distr', 'Distracted'))
|
||||
this.effectDocs.unshift(module.getStatus('SWADE.Distr', 'Distracted'))
|
||||
}
|
||||
|
||||
async applyResult () {
|
||||
await super.applyResult()
|
||||
await shim.wait(1000)
|
||||
await warpgate.wait(1000)
|
||||
|
||||
const resistMods = function (token) {
|
||||
const mods = []
|
||||
@@ -639,7 +639,7 @@ class IntangibilityEffect extends TargetedPowerEffect {
|
||||
|
||||
async prepResult () {
|
||||
const icon = 'icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp'
|
||||
const effect = shim.createEffectDocument(icon, this.name, this.durationRounds, [])
|
||||
const effect = module.createEffectDocument(icon, this.name, this.durationRounds, [])
|
||||
this.effectDocs.push(effect)
|
||||
}
|
||||
}
|
||||
@@ -664,7 +664,7 @@ class InvisibilityEffect extends TargetedPowerEffect {
|
||||
}
|
||||
|
||||
async prepResult () {
|
||||
const effect = shim.getStatus('EFFECT.StatusInvisible', 'Invisible')
|
||||
const effect = module.getStatus('EFFECT.StatusInvisible', 'Invisible')
|
||||
effect.duration = { rounds: this.durationRounds }
|
||||
this.effectDocs.push(effect)
|
||||
}
|
||||
@@ -688,9 +688,9 @@ class ProtectionEffect extends TargetedPowerEffect {
|
||||
}
|
||||
|
||||
async prepResult () {
|
||||
const effect = shim.getStatus('SWADE.Protection', 'Protection')
|
||||
const effect = module.getStatus('SWADE.Protection', 'Protection')
|
||||
effect.duration = { rounds: this.durationRounds }
|
||||
const mode = CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD
|
||||
const mode = foundry.CONST.ACTIVE_EFFECT_MODES.ADD
|
||||
effect.changes = [
|
||||
{ key: 'system.stats.toughness.armor', mode, value: 2, priority: 0 }
|
||||
]
|
||||
@@ -737,7 +737,7 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
`${this.actorFolder}/${this.token.actor.name}`
|
||||
]
|
||||
for (const folderName of folderNames) {
|
||||
const folder = shim.getActorFolderByPath(folderName)
|
||||
const folder = module.getActorFolderByPath(folderName)
|
||||
if (folder) {
|
||||
log(`Found actor folder ${folderName}`)
|
||||
folders.push(folder)
|
||||
@@ -753,7 +753,7 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
const folders = await this.prepFolders()
|
||||
const actors = {}
|
||||
for (const folder of folders) {
|
||||
const folderActors = shim.getActorsInFolder(folder)
|
||||
const folderActors = module.getActorsInFolder(folder)
|
||||
for (const key in folderActors) {
|
||||
actors[key] = folderActors[key]
|
||||
}
|
||||
@@ -765,7 +765,7 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
const actors = await this.prepActors()
|
||||
this.cancel = false
|
||||
if (Object.keys(actors).length < 1) {
|
||||
shim.notifications.error('No summonables found')
|
||||
ui.notifications.error('No summonables found')
|
||||
this.cancel = true
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.actorId = (this.inputs[this.inputIndex])
|
||||
this.increasedDuration = (!!this.inputs[this.inputIndex + 1])
|
||||
this.actor = shim.actors.get(this.actorId)
|
||||
this.actor = game.actors.get(this.actorId)
|
||||
this.icon = this.targets[0].document.texture.src
|
||||
const targetActor = this.targets[0].actor
|
||||
this.protoDoc = await this.actor.getTokenDocument()
|
||||
@@ -819,14 +819,14 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
for (const stat of ['vigor', 'strength']) {
|
||||
effectChanges.push({
|
||||
key: `system.attributes.${stat}.die.sides`,
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value: '+2',
|
||||
priority: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
this.effectDocs.push(
|
||||
shim.createEffectDocument(
|
||||
module.createEffectDocument(
|
||||
this.icon,
|
||||
`Shape Change into ${this.protoDoc.name}`,
|
||||
this.durationRounds, effectChanges)
|
||||
@@ -879,7 +879,7 @@ class ShapeChangeEffect extends TargetedPowerEffect {
|
||||
log('protoDoc', this.protoDoc)
|
||||
log('spawnOptions', this.spawnOptions)
|
||||
log('spawnMutation', this.spawnMutation)
|
||||
const newTokenId = (await shim.warpgateSpawnAt(
|
||||
const newTokenId = (await warpgate.spawnAt(
|
||||
this.targets[0].center,
|
||||
this.protoDoc,
|
||||
this.spawnMutation,
|
||||
@@ -931,11 +931,11 @@ class SmiteEffect extends TargetedPowerEffect {
|
||||
}
|
||||
|
||||
async prepResult () {
|
||||
this.baseEffect = shim.getStatus('SWADE.Smite', 'Smite')
|
||||
this.baseEffect = module.getStatus('SWADE.Smite', 'Smite')
|
||||
}
|
||||
|
||||
async applyResult () {
|
||||
const mode = CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD
|
||||
const mode = foundry.CONST.ACTIVE_EFFECT_MODES.ADD
|
||||
const raise = (this.buttons === 'raise')
|
||||
const greater = !!this.inputs[this.inputIndex]
|
||||
const changeValue = (greater ? (raise ? '+6' : '+4') : (raise ? '+4' : '+2'))
|
||||
@@ -948,7 +948,7 @@ class SmiteEffect extends TargetedPowerEffect {
|
||||
]
|
||||
this.baseEffect.changes = changes
|
||||
this.baseEffect.name = effectName
|
||||
await shim.applyActiveEffects(token, [this.baseEffect].concat(this.effectDocs))
|
||||
await module.applyActiveEffects(token, [this.baseEffect].concat(this.effectDocs))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -995,11 +995,11 @@ class SlothSpeedEffect extends TargetedPowerEffect {
|
||||
`${nameMods.length > 0 ? ' (' : ''}` +
|
||||
`${nameMods.join(', ')}${nameMods.length > 0 ? ')' : ''}`)
|
||||
const name = `${isSloth ? 'Sloth' : 'Speed'}${nameModifier}`
|
||||
const effect = shim.createEffectDocument(
|
||||
const effect = module.createEffectDocument(
|
||||
icon, name, this.durationRounds, [
|
||||
{
|
||||
key: 'system.stats.speed.value',
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.MULTIPLY,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.MULTIPLY,
|
||||
value: (isSloth ? 0.5 : 2),
|
||||
priority: 0
|
||||
}])
|
||||
@@ -1038,7 +1038,7 @@ class SummonEffect extends PowerEffect {
|
||||
`${this.actorFolder}/${this.token.actor.name}`
|
||||
]
|
||||
for (const folderName of folderNames) {
|
||||
const folder = shim.getActorFolderByPath(folderName)
|
||||
const folder = module.getActorFolderByPath(folderName)
|
||||
if (folder) {
|
||||
log(`Found actor folder ${folderName}`)
|
||||
folders.push(folder)
|
||||
@@ -1054,7 +1054,7 @@ class SummonEffect extends PowerEffect {
|
||||
const folders = await this.prepFolders()
|
||||
const actors = {}
|
||||
for (const folder of folders) {
|
||||
const folderActors = shim.getActorsInFolder(folder)
|
||||
const folderActors = module.getActorsInFolder(folder)
|
||||
for (const key in folderActors) {
|
||||
actors[key] = folderActors[key]
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ class SummonEffect extends PowerEffect {
|
||||
this.menuData.buttons = this.menuData.buttons.filter(b => b.value !== 'raise')
|
||||
const actors = await this.prepActors()
|
||||
if (Object.keys(actors).length < 1) {
|
||||
shim.notifications.error('No summonables found')
|
||||
ui.notifications.error('No summonables found')
|
||||
throw new Error('No summonables found')
|
||||
}
|
||||
|
||||
@@ -1102,7 +1102,7 @@ class SummonEffect extends PowerEffect {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.actorId = (this.inputs[this.inputIndex])
|
||||
this.number = (this.inputs[this.inputIndex + 1])
|
||||
this.actor = shim.actors.get(this.actorId)
|
||||
this.actor = game.actors.get(this.actorId)
|
||||
this.icon = this.actor.prototypeToken.texture.src
|
||||
this.protoDoc = await this.actor.getTokenDocument()
|
||||
this.increasedTrait = !!(this.inputs[this.inputIndex + 2])
|
||||
@@ -1184,7 +1184,7 @@ class SummonEffect extends PowerEffect {
|
||||
traitMenuData.inputs.push({ type: 'header', label: 'Increase Skills (+1 each)' })
|
||||
traitMenuData.inputs = traitMenuData.inputs.concat(
|
||||
skillList.map((x) => { return { type: 'checkbox', label: x, options: false } }))
|
||||
const { buttons, inputs } = await shim.warpgateMenu(traitMenuData, traitMenuOptions)
|
||||
const { buttons, inputs } = await warpgate.menu(traitMenuData, traitMenuOptions)
|
||||
if (!buttons || buttons === 'cancel') {
|
||||
return
|
||||
}
|
||||
@@ -1199,11 +1199,11 @@ class SummonEffect extends PowerEffect {
|
||||
modKeys.push(`@Skill{${skillList[i]}}[system.die.sides]`)
|
||||
}
|
||||
}
|
||||
const effectDoc = shim.createEffectDocument(
|
||||
const effectDoc = module.createEffectDocument(
|
||||
this.ICON, 'Increased Trait', this.durationRounds)
|
||||
effectDoc.changes = modKeys.map(key => {
|
||||
return {
|
||||
key, mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD, value: '+2', priority: 0
|
||||
key, mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, value: '+2', priority: 0
|
||||
}
|
||||
})
|
||||
this.spawnMutation.embedded.ActiveEffect[effectDoc.name] = effectDoc
|
||||
@@ -1211,7 +1211,7 @@ class SummonEffect extends PowerEffect {
|
||||
|
||||
async applyResult () {
|
||||
await this.prepAdditional()
|
||||
await shim.warpgateSpawn(this.protoDoc, this.spawnMutation, {}, this.spawnOptions)
|
||||
await warpgate.spawn(this.protoDoc, this.spawnMutation, {}, this.spawnOptions)
|
||||
log('protoDoc', this.protoDoc)
|
||||
log('spawnOptions', this.spawnOptions)
|
||||
log('spawnMutation', this.spawnMutation)
|
||||
@@ -1287,7 +1287,7 @@ class SummonAllyEffect extends SummonEffect {
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
const { buttons, inputs } = await shim.warpgateMenu(edgeMenuData, edgeMenuOptions)
|
||||
const { buttons, inputs } = await warpgate.menu(edgeMenuData, edgeMenuOptions)
|
||||
if (!buttons || buttons === 'cancel') {
|
||||
return
|
||||
}
|
||||
@@ -1324,7 +1324,7 @@ class SummonAllyEffect extends SummonEffect {
|
||||
this.spawnMutation.embedded.Item[item.name] = doc
|
||||
}
|
||||
for (const effect of template.effects.values()) {
|
||||
const doc = shim.ActiveEffect.fromSource(effect)
|
||||
const doc = ActiveEffect.fromSource(effect)
|
||||
this.spawnMutation.embedded.ActiveEffect[effect.name] = doc
|
||||
}
|
||||
}
|
||||
@@ -1366,14 +1366,14 @@ class SummonAllyEffect extends SummonEffect {
|
||||
if (mirrorItem.type === 'skill') {
|
||||
effectChanges.push({
|
||||
key: `@Skill{${mirrorItem.name}}[system.die.sides]`,
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value: '-2',
|
||||
priority: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
this.spawnMutation.embedded.ActiveEffect['Mirror Self'] =
|
||||
shim.createEffectDocument(this.ICON, 'Mirror Self',
|
||||
module.createEffectDocument(this.ICON, 'Mirror Self',
|
||||
this.durationRounds, effectChanges)
|
||||
}
|
||||
}
|
||||
@@ -1412,7 +1412,7 @@ class SpiritualWeaponEffect extends SummonEffect {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.actorId = this.inputs[this.inputIndex]
|
||||
this.arcaneSkillSwid = this.inputs[this.inputIndex + 1]
|
||||
this.actor = shim.actors.get(this.actorId)
|
||||
this.actor = game.actors.get(this.actorId)
|
||||
this.icon = 'icons/weapons/hammers/hammer-double-glowing-yellow.webp'
|
||||
this.protoDoc = await this.actor.getTokenDocument()
|
||||
this.spawnOptions = {
|
||||
@@ -1545,7 +1545,7 @@ class ZombieEffect extends SummonEffect {
|
||||
this.raise = (this.buttons === 'raise')
|
||||
this.actorId = this.inputs[this.inputIndex]
|
||||
this.number = this.inputs[this.inputIndex + 1]
|
||||
this.actor = shim.actors.get(this.actorId)
|
||||
this.actor = game.actors.get(this.actorId)
|
||||
this.icon = this.actor.prototypeToken.texture.src
|
||||
this.protoDoc = await this.actor.getTokenDocument()
|
||||
this.increasedTrait = this.raise
|
||||
@@ -1586,7 +1586,7 @@ class ZombieEffect extends SummonEffect {
|
||||
}
|
||||
}
|
||||
if (this.armor) {
|
||||
const effectDoc = shim.createEffectDocument(
|
||||
const effectDoc = module.createEffectDocument(
|
||||
'icons/equipment/chest/breastplate-layered-leather-stitched.webp',
|
||||
'Rotting Armor',
|
||||
0)
|
||||
@@ -1594,7 +1594,7 @@ class ZombieEffect extends SummonEffect {
|
||||
delete effectDoc.flags.swade.expiration
|
||||
effectDoc.changes = [{
|
||||
key: 'system.stats.toughness.armor',
|
||||
mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value: '+2',
|
||||
priority: 0
|
||||
}]
|
||||
@@ -1638,7 +1638,7 @@ class ZombieEffect extends SummonEffect {
|
||||
traitMenuData.inputs.push({ type: 'header', label: 'Increase Skills (+1 each)' })
|
||||
traitMenuData.inputs = traitMenuData.inputs.concat(
|
||||
skillList.map((x) => { return { type: 'radio', label: x, options: ['trait', false] } }))
|
||||
const { buttons, inputs } = await shim.warpgateMenu(traitMenuData, traitMenuOptions)
|
||||
const { buttons, inputs } = await warpgate.menu(traitMenuData, traitMenuOptions)
|
||||
if (!buttons || buttons === 'cancel') {
|
||||
return
|
||||
}
|
||||
@@ -1653,11 +1653,11 @@ class ZombieEffect extends SummonEffect {
|
||||
modKeys.push(`@Skill{${skillList[i]}}[system.die.sides]`)
|
||||
}
|
||||
}
|
||||
const effectDoc = shim.createEffectDocument(
|
||||
const effectDoc = module.createEffectDocument(
|
||||
this.ICON, 'Increased Trait', this.durationRounds)
|
||||
effectDoc.changes = modKeys.map(key => {
|
||||
return {
|
||||
key, mode: CONST.FOUNDRY.ACTIVE_EFFECT_MODES.ADD, value: '+2', priority: 0
|
||||
key, mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, value: '+2', priority: 0
|
||||
}
|
||||
})
|
||||
this.spawnMutation.embedded.ActiveEffect[effectDoc.name] = effectDoc
|
||||
@@ -1720,7 +1720,7 @@ const PowerClasses = {
|
||||
export async function powerEffects (options = {}) {
|
||||
const token = 'token' in options ? options.token : []
|
||||
if (token === undefined || token === null) {
|
||||
shim.notifications.error('Please select one token')
|
||||
ui.notifications.error('Please select one token')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1736,16 +1736,16 @@ export async function powerEffects (options = {}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
shim.notifications.error(`No power effect found for ${name}`)
|
||||
ui.notifications.error(`No power effect found for ${name}`)
|
||||
}
|
||||
|
||||
export async function shapeChangeOnDismiss (data) {
|
||||
if (shim.user.id !== data.userId) { return }
|
||||
if (game.user.id !== data.userId) { return }
|
||||
const dismissedToken = data.actorData.prototypeToken
|
||||
const flags = dismissedToken.flags['swade-mb-helpers']?.shapeChange
|
||||
const srcTokenId = flags?.srcTokenId
|
||||
if (!srcTokenId) { return }
|
||||
const scene = shim.scenes.get(data.sceneId)
|
||||
const scene = game.scenes.get(data.sceneId)
|
||||
const token = scene.tokens.get(srcTokenId)
|
||||
if (!token) { return }
|
||||
const saved = token.flags['swade-mb-helpers']?.shapeChange?.saved
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { log, shim } from './shim.js'
|
||||
import { log, module } from './globals.js'
|
||||
|
||||
export async function preTraitRollModifiers (actor, trait, roll, modifiers, options) {
|
||||
const targets = Array.from(shim.targets)
|
||||
const token = shim.canvas.tokens.controlled.length > 0 ? shim.canvas.tokens.controlled[0] : null
|
||||
const targets = Array.from(game.user.targets)
|
||||
const token = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0] : null
|
||||
// log('ACTOR', actor)
|
||||
// log('TOKEN', token)
|
||||
// log('TRAIT', trait)
|
||||
@@ -60,8 +60,8 @@ export async function preTraitRollModifiers (actor, trait, roll, modifiers, opti
|
||||
}
|
||||
|
||||
export async function preDamageRollModifiers (actor, item, roll, modifiers, options) {
|
||||
const targets = Array.from(shim.targets)
|
||||
const token = shim.canvas.tokens.controlled.length > 0 ? shim.canvas.tokens.controlled[0] : null
|
||||
const targets = Array.from(game.user.targets)
|
||||
const token = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0] : null
|
||||
// log('ACTOR', actor)
|
||||
// log('TOKEN', token)
|
||||
// log('ITEM', item)
|
||||
@@ -97,7 +97,7 @@ function _addRangeModifiers (token, target, options, modifiers) {
|
||||
}
|
||||
const ranges = options.item.system.range.split('/').map(x => parseInt(x))
|
||||
const distance = getDistance(token, target)
|
||||
const rollmods = shim.CONFIG.SWADE.prototypeRollGroups.find(g => g.name === 'Range').modifiers
|
||||
const rollmods = CONFIG.SWADE.prototypeRollGroups.find(g => g.name === 'Range').modifiers
|
||||
log('ITEM RANGES:', ranges)
|
||||
if (distance <= ranges[0]) {
|
||||
// nothing here
|
||||
@@ -138,7 +138,7 @@ function getDistance (origin, target) {
|
||||
const ray = new Ray(origin, target)
|
||||
const originScale = getScaleDistanceMod(origin)
|
||||
const targetScale = getScaleDistanceMod(target)
|
||||
const flatDistance = shim.canvas.grid.measureDistances(
|
||||
const flatDistance = game.canvas.grid.measureDistances(
|
||||
[{ ray }], { gridSpaces: true })[0]
|
||||
const elevation = Math.abs(origin.document.elevation - target.document.elevation)
|
||||
const distance = Math.sqrt(elevation * elevation + flatDistance * flatDistance)
|
||||
@@ -176,7 +176,7 @@ function calcGangup (attacker, target, debug) {
|
||||
}
|
||||
const attackerHasFormationFighter = !!(_findItem(attacker.actor, 'edge', 'formation-fighter'))
|
||||
|
||||
const withinRangeOfToken = shim.canvas.tokens.placeables.filter(t =>
|
||||
const withinRangeOfToken = game.canvas.tokens.placeables.filter(t =>
|
||||
t.id !== attacker.id &&
|
||||
t.id !== target.id &&
|
||||
t.actor.system.status.isStunned === false &&
|
||||
|
||||
Reference in New Issue
Block a user