Tirage des tarots

This commit is contained in:
2023-02-07 19:55:33 +01:00
parent 1923a63ebf
commit 04039513bc
35 changed files with 334 additions and 56 deletions

View File

@ -1,5 +1,4 @@
/* -------------------------------------------- */
import { MaleficesCombat } from "./malefices-combat.js";
import { MaleficesCommands } from "./malefices-commands.js";
@ -89,6 +88,14 @@ export class MaleficesUtility {
}
return actor
}
/* -------------------------------------------- */
static drawDeckCard(msgId) {
if (game.user.isGM) {
game.system.malefices.currentTirage.addCard(msgId)
} else {
game.socket.emit( "system.fvtt-malefices", {name: "msg-draw-card", data: {msgId: msgId}})
}
}
/* -------------------------------------------- */
static async chatListeners(html) {
@ -102,6 +109,11 @@ export class MaleficesUtility {
rollData.isReroll = true
this.rollMalefices(rollData)
})
html.on("click", '.draw-tarot-card', event => {
let messageId = MaleficesUtility.findChatMessageId(event.currentTarget)
this.drawDeckCard(messageId)
})
}
/* -------------------------------------------- */
@ -185,21 +197,10 @@ export class MaleficesUtility {
/* -------------------------------------------- */
static async onSocketMesssage(msg) {
console.log("SOCKET MESSAGE", msg.name)
if (msg.name == "msg_update_roll") {
this.updateRollData(msg.data)
}
if (msg.name == "msg_gm_process_attack_defense") {
this.processSuccessResult(msg.data)
}
if (msg.name == "msg_gm_item_drop" && game.user.isGM) {
let actor = game.actors.get(msg.data.actorId)
let item
if (msg.data.isPack) {
item = await fromUuid("Compendium." + msg.data.isPack + "." + msg.data.itemId)
} else {
item = game.items.get(msg.data.itemId)
if (msg.name == "msg-draw-card") {
if ( game.user.isGM && game.system.malefices.currentTirage) {
game.system.malefices.currentTirage.addCard(msg.data.msgId)
}
this.addItemDropToActor(actor, item)
}
}
@ -331,11 +332,17 @@ export class MaleficesUtility {
switch (rollMode) {
case "blindroll": return this.getUsers(user => user.isGM);
case "gmroll": return this.getWhisperRecipientsAndGMs(name);
case "useronly": return this.getWhisperRecipientsOnly(name);
case "selfroll": return [game.user.id];
}
return undefined;
}
/* -------------------------------------------- */
static getWhisperRecipientsOnly(name) {
let recep1 = ChatMessage.getWhisperRecipients(name) || [];
return recep1
}
/* -------------------------------------------- */
static getWhisperRecipientsAndGMs(name) {
let recep1 = ChatMessage.getWhisperRecipients(name) || [];
return recep1.concat(ChatMessage.getWhisperRecipients('GM'));
@ -369,7 +376,7 @@ export class MaleficesUtility {
}
/* -------------------------------------------- */
static createChatMessage(name, rollMode, chatOptions) {
static async createChatMessage(name, rollMode, chatOptions) {
switch (rollMode) {
case "blindroll": // GM only
if (!game.user.isGM) {
@ -387,7 +394,7 @@ export class MaleficesUtility {
break;
}
chatOptions.alias = chatOptions.alias || name;
return ChatMessage.create(chatOptions);
return await ChatMessage.create(chatOptions);
}
/* -------------------------------------------- */
@ -413,8 +420,8 @@ export class MaleficesUtility {
}
/* -------------------------------------------- */
static createChatWithRollMode(name, chatOptions) {
return this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions)
static async createChatWithRollMode(name, chatOptions) {
return await this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions)
}
/* -------------------------------------------- */