From 4eebce1a6f7671145fefd429bc073d96c00004da Mon Sep 17 00:00:00 2001 From: walcutt Date: Sun, 29 Dec 2024 17:04:12 -0500 Subject: [PATCH] Display messages when cards are played --- module/sheets/hench-cards-sheet.mjs | 31 +++++++++++++++++++++++++++++ todo.md | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/module/sheets/hench-cards-sheet.mjs b/module/sheets/hench-cards-sheet.mjs index d3c5eba..64eba3e 100644 --- a/module/sheets/hench-cards-sheet.mjs +++ b/module/sheets/hench-cards-sheet.mjs @@ -30,12 +30,16 @@ export class HenchCardsSheet extends CardsConfig { const index = element.dataset.cardIndex; // play the card! + const card = this.document.spread[index]; + this.playCard(card); await this.document.sendCards(this.document.spread.slice(index, index + 1), CARD_ZONES.DISCARD, CONST.CARD_DRAW_MODES.TOP); await this.document.sendCards(this.document.spread, CARD_ZONES.DECK, CONST.CARD_DRAW_MODES.BOTTOM); }); html.find('.hench-card-action-play-held').on('click', async (event) => { // play the card! + const card = this.document.held[0]; + this.playCard(card) await this.document.sendCards(this.document.held.slice(0, 1), CARD_ZONES.DISCARD, CONST.CARD_DRAW_MODES.TOP); }); @@ -72,4 +76,31 @@ export class HenchCardsSheet extends CardsConfig { return opts; } + + async playCard(card) { + const user = game.users.current; + + const content = ` +
+
+ +
+
+ + ${card.system.cue} + +
+
+ `; + const flavor = ` + plays the ${card.name}: + `; + + + const chatMessage = await ChatMessage.create({ + content: content, + flavor: flavor, + type: CONST.CHAT_MESSAGE_STYLES.OOC, + }); + } } \ No newline at end of file diff --git a/todo.md b/todo.md index f20996a..cc7de45 100644 --- a/todo.md +++ b/todo.md @@ -13,6 +13,6 @@ - [x] Add deck page - [x] Allow drawing, playing, discarding cards - [x] Allow deck editing -- [] Send messages for played cards +- [X] Send messages for played cards - [] ? Macro for stress -- [] Set up default data \ No newline at end of file +- [x] Set up default data \ No newline at end of file