Enhance combat

This commit is contained in:
2021-02-04 22:55:57 +01:00
parent 63e552cc6a
commit 92f8fe4ee8
4 changed files with 127 additions and 17 deletions

View File

@ -30,8 +30,14 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
/* -------------------------------------------- */
onSocketMesssage( msg ) {
if (msg.name == 'msg_declare_actions' ) {
let combat = game.combats.get( msg.data.combatId); // Get the associated combat
combat.setupActorActions( msg.data );
if (game.user.isGM) {
let combat = game.combats.get( msg.data.combatId); // Get the associated combat
combat.setupActorActions( msg.data );
}
} else if (msg.name == 'msg_close_action') {
if (game.user.isGM) {
game.combat.closeAction( msg.data.uniqId );
}
}
}
@ -60,6 +66,11 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
return list;
}
/* -------------------------------------------- */
static updateCombat(combat, round, diff, id) {
combat.requestActions();
}
/* -------------------------------------------- */
static async openDeclareActions( event) {
event.preventDefault();
@ -71,12 +82,29 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js";
d.render(true);
}
/* -------------------------------------------- */
static closeAction(event) {
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;
// Delete message !
const toDelete = game.messages.filter(it => it.data.content.includes( uniqId ));
toDelete.forEach(it => it.delete());
if ( game.user.isGM ) {
game.combat.closeAction( uniqId );
} else {
game.socket.emit("system.foundryvtt-reve-de-dragon", {
name: "msg_close_action", data: { uniqId: uniqId} } );
}
}
/* -------------------------------------------- */
static async registerChatCallbacks(html) {
html.on("click", '#button-declare-actions', event => {
SoSUtility.openDeclareActions( event );
});
html.on("click", '#button-end-action', event => {
SoSUtility.closeAction( event );
});
}
}