2.2.0 release #38

Merged
mike merged 8 commits from develop into main 2023-11-21 04:02:09 +00:00
3 changed files with 27 additions and 31 deletions
Showing only changes of commit 9eb7f4c5ea - Show all commits

View File

@ -1,6 +1,6 @@
import { api } from './api.js'
import { requestTokenRoll } from './helpers.js'
import { havocResult, shapeChangeOnDismiss } from './powerEffects.js'
import { shapeChangeOnDismiss } from './powerEffects.js'
import { log, shim } from './shim.js'
const moduleName = 'swade-mb-helpers'
@ -25,7 +25,6 @@ Hooks.on('ready', () => {
Hooks.on('socketlib.ready', () => {
const socket = socketlib.registerModule('swade-mb-helpers')
socket.register('havocResult', havocResult)
socket.register('requestTokenRoll', requestTokenRoll)
shim._socket = socket
})

View File

@ -1,4 +1,5 @@
import { CONST, log, shim } from './shim.js'
import { requestRollFromTokens } from './helpers.js'
class PowerEffect {
constructor (token, targets) {
@ -556,13 +557,32 @@ class HavocEffect extends TargetedPowerEffect {
async prepResult () {
this.raise = (this.buttons === 'raise')
this.effectDocs.unshift(shim.getStatus('SWADE.Distr', 'Distracted'))
}
async applyResult () {
await super.applyResult()
for (const target of this.targets) {
await havocResult(target.id, this.raise)
await shim.wait(1000)
const resistMods = function (token) {
const mods = []
if (token.actor.effects.find(e => e.name === 'Flying')) {
mods.push({ label: 'Flying', value: -2 })
}
return mods
}
const options = {
title: 'Resisting Havoc!',
flavour: 'Havoc!',
mods: [],
modCallback: resistMods
}
if (this.raise) {
options.mods.push({ label: 'vs. Raise', value: -2 })
}
await requestRollFromTokens(this.targets, 'attribute', 'strength', options)
}
}
@ -1441,30 +1461,3 @@ export async function shapeChangeOnDismiss (data) {
await token.update(update)
}
}
export async function havocResult (tokenId, isRaise) {
const token = shim.canvas.tokens.get(tokenId)
if (!token) {
log('Unable to find token with id ', tokenId)
return
}
const owner = shim.warpgateUtil.firstOwner(token.document)
if (owner !== shim.user) {
shim.socket.executeAsUser(havocResult, owner.id, tokenId, isRaise)
return
}
const effect = shim.getStatus('SWADE.Distr', 'Distracted')
await shim.applyActiveEffects(token, [effect])
log(`apply ${effect.label} to ${token.document.name}, raise: ${isRaise}`)
const opts = {
flavour: 'Resist Havoc',
additionalMods: []
}
if (isRaise) {
opts.additionalMods.push({ label: 'vs. Raise', value: -2 })
}
if (token.actor.effects.find(e => e.name === 'Flying')) {
opts.additionalMods.push({ label: 'Flying', value: -2 })
}
token.actor.rollAttribute('strength', opts)
}

View File

@ -116,6 +116,10 @@ export class shim {
await warpgate.mutate(token.document, mutation, {}, mutateOptions)
}
static wait (ms) {
return warpgate.wait(ms)
}
static warpgateMenu (menuData, menuOptions) {
return warpgate.menu(menuData, menuOptions)
}