fvtt-pegasus-rpg/modules/pegasus-combat.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-02 07:38:59 +01:00
import { PegasusUtility } from "./pegasus-utility.js";
/* -------------------------------------------- */
export class PegasusCombat extends Combat {
/* -------------------------------------------- */
async rollInitiative(ids, formula = undefined, messageOptions = {} ) {
ids = typeof ids === "string" ? [ids] : ids;
for (let cId = 0; cId < ids.length; cId++) {
2021-12-20 11:54:19 +01:00
const c = this.combatants.get(ids[cId]);
let id = c._id || c.id;
2022-01-28 10:05:54 +01:00
let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, id ) : -1;
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initBonus } ]);
2021-12-02 07:38:59 +01:00
}
return this;
}
2022-01-28 10:05:54 +01:00
/* -------------------------------------------- */
_onUpdate(changed, options, userId) {
}
/* -------------------------------------------- */
2022-02-17 19:17:24 +01:00
static async decInitBy10( combatantId, value) {
2022-01-28 10:05:54 +01:00
const combatant = game.combat.combatants.get(combatantId)
let initValue = combatant.initiative + value
2022-02-17 19:17:24 +01:00
await game.combat.setInitiative(combatantId, initValue)
while (game.combat.turn > 0) {
await game.combat.previousTurn()
}
console.log("COMBAT", game.combat )
2022-01-28 10:05:54 +01:00
}
2021-12-02 07:38:59 +01:00
}