diff --git a/module/cards/hench-card.mjs b/module/cards/hench-card.mjs index e57dd77..1994bef 100644 --- a/module/cards/hench-card.mjs +++ b/module/cards/hench-card.mjs @@ -13,6 +13,7 @@ export class HenchCardDataModel extends foundry.abstract.TypeDataModel { return { cue: new StringField({required: true, blank: true, initial: ""}), zone: new StringField({required: true, blank: false, initial: CARD_ZONES.DECK, options: CARD_ZONES}), + note: new StringField({required: false, blank: true, initial: ""}), }; } diff --git a/module/cards/hench-cards.mjs b/module/cards/hench-cards.mjs index e55229c..66d99e8 100644 --- a/module/cards/hench-cards.mjs +++ b/module/cards/hench-cards.mjs @@ -134,6 +134,7 @@ export class HenchCards extends Cards { return { _id: c._id, ['system.zone']: zone, + ['system.note']: "", sort: destIndex }; } diff --git a/module/sheets/hench-cards-sheet.mjs b/module/sheets/hench-cards-sheet.mjs index 64eba3e..a784b49 100644 --- a/module/sheets/hench-cards-sheet.mjs +++ b/module/sheets/hench-cards-sheet.mjs @@ -25,9 +25,9 @@ export class HenchCardsSheet extends CardsConfig { } }); - html.find('.hench-cards-action-play').on('click', async (event) => { + html.find('.hench-cards-action-spread-play').on('click', async (event) => { const element = event.currentTarget; - const index = element.dataset.cardIndex; + const index = parseInt(element.dataset.cardIndex); // play the card! const card = this.document.spread[index]; @@ -36,6 +36,23 @@ export class HenchCardsSheet extends CardsConfig { await this.document.sendCards(this.document.spread, CARD_ZONES.DECK, CONST.CARD_DRAW_MODES.BOTTOM); }); + html.find('.hench-cards-action-hold-play').on('click', async (event) => { + const element = event.currentTarget; + const index = parseInt(element.dataset.cardIndex); + + // play the card! + const card = this.document.held[index]; + this.playCard(card); + await this.document.sendCards(this.document.held.slice(index, index + 1), CARD_ZONES.DISCARD, CONST.CARD_DRAW_MODES.TOP); + }); + + html.find('.hench-cards-action-spread-hold').on('click', async (event) => { + const element = event.currentTarget; + const index = parseInt(element.dataset.cardIndex); + + await this.document.sendCards(this.document.spread.slice(index, index + 1), CARD_ZONES.HELD); + }); + html.find('.hench-card-action-play-held').on('click', async (event) => { // play the card! const card = this.document.held[0]; @@ -66,6 +83,23 @@ export class HenchCardsSheet extends CardsConfig { const discard = new HenchDiscardView(this.document); discard.render(true); }); + + html.find('.hench-cards-held-note').on('change', async (event) => { + const element = event.currentTarget; + const id = element.dataset.cardId; + + const value = element.value; + const subPath = element.dataset.field; + + const mutation = [ + { + _id: id, + [subPath]: value, + } + ]; + + await this.document.updateCards(mutation); + }); } /** @override */ diff --git a/templates/cards/cards.hbs b/templates/cards/cards.hbs index c874cf2..3412cc6 100644 --- a/templates/cards/cards.hbs +++ b/templates/cards/cards.hbs @@ -29,11 +29,6 @@ - {{#topCard document "HELD"}} -
- -
- {{/topCard}}
@@ -62,10 +57,44 @@
+
+ Spread +
{{#each document.spread}} -
- +
+ +
+
+ + Hold + +
+
+ + Play + +
+
+
+ {{else}} +
+ {{/each}} +
+
+
+
+
+
+ Held Cards +
+
+ {{#each document.held}} +
+ +
+ +
{{else}}