Gestion assistée pour les actions
This commit is contained in:
@@ -2,20 +2,39 @@ import { TeDeumUtility } from "../common/tedeum-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class TeDeumCombat extends Combat {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {} ) {
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
//console.log("Roll INIT !")
|
||||
ids = typeof ids === "string" ? [ids] : ids;
|
||||
for (let cId of ids) {
|
||||
const c = this.combatants.get(cId);
|
||||
let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, cId ) : -1;
|
||||
await this.updateEmbeddedDocuments("Combatant", [ { _id: cId, initiative: initBonus } ]);
|
||||
let initBonus = c.actor ? c.actor.getInitiativeScore(this.id, cId) : -1;
|
||||
await this.updateEmbeddedDocuments("Combatant", [{ _id: cId, initiative: initBonus }]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async modifyAction(combatantId, delta, isMainGauche = false) {
|
||||
let combatant = this.combatants.get(combatantId)
|
||||
if (!combatant) return;
|
||||
let ca = combatant.getFlag("world", "available-actions")
|
||||
if (!ca) {
|
||||
ca = { nbActions: 1, nbActionsMainGauche: 0 }
|
||||
}
|
||||
if (isMainGauche) {
|
||||
ca.nbActionsMainGauche += delta
|
||||
} else {
|
||||
ca.nbActions += delta
|
||||
}
|
||||
if (ca.nbActionsMainGauche < 0) ca.nbActionsMainGauche = 0
|
||||
if (ca.nbActions < 0) ca.nbActions = 0
|
||||
await combatant.setFlag("world", "available-actions", ca)
|
||||
await combatant.update({ name: `${combatant.token.name} (${ca.nbActions} / ${ca.nbActionsMainGauche})` })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async checkTurnPosition() {
|
||||
while (game.combat.turn > 0) {
|
||||
|
Reference in New Issue
Block a user