From b22b8022f14940bdffd08d20c74dfe9aa4cc8e8f Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 25 Jan 2021 11:16:45 +0100 Subject: [PATCH] Enhance fip --- module/actor.js | 1 + module/sos-card-deck.js | 26 ++++++++++++++++++++------ module/sos-flip-dialog.js | 4 ++-- templates/actor-sheet.html | 6 ++++-- templates/chat-flip.html | 2 +- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/module/actor.js b/module/actor.js index c0268fc..fbfb60b 100644 --- a/module/actor.js +++ b/module/actor.js @@ -161,6 +161,7 @@ export class SoSActor extends Actor { modifierList: SoSUtility.fillRange(-10, +10), tnList: SoSUtility.fillRange(6, 20) } + flipData.statList['nostat'] = { label: "No stat (ie defaulting skills)", value: 0, cardsuit: "none" } let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData); new SoSFlipDialog(flipData, html).render(true); } diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index e187573..8c301f8 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -97,6 +97,7 @@ export class SoSCardDeck { /* -------------------------------------------- */ getCardValue( cardName ) { console.log(cardName); + if (cardName[0] == 'j' ) return 0; // Joker case let parsed = cardName.match( /\w(\d\d)/i ); let value = Number( parsed[1] ); if ( value > 10 ) value -= 10; @@ -104,11 +105,24 @@ export class SoSCardDeck { } /* -------------------------------------------- */ isCardFace(cardName) { + if (cardName[0] == 'j' ) return false; // Joker case let parsed = cardName.match( /\w(\d\d)/i ); let value = Number( parsed[1] ); return (value > 10) ? true : false; } + /* -------------------------------------------- */ + setJoker( flipData ) { + console.log("THIS IS A JOKER !!!!"); + flipData.cardSlot[0].total = 0; + flipData.cardSlot[0].card1Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[0].card1.cardName}.webp`; + flipData.isJoker = true; + } + /* -------------------------------------------- */ + isJoker( cardName) { + return cardName[0] == 'j'; + } + /* -------------------------------------------- */ async doFlipFromDeckOrEdge( flipData ) { flipData.cardSlot = [ { total: 0}]; @@ -125,10 +139,7 @@ export class SoSCardDeck { let cardsuit = this.getCardSuit(flipData.cardSlot[0].card1.cardName); if ( cardsuit == 'joker' ) { - console.log("THIS IS A JOKER !!!!"); - flipData.cardSlot[0].total = 0; - flipData.cardSlot[0].isJoker = true; - flipData.cardSlot[0].card1Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[0].card1.cardName}.webp`; + this.setJoker( flipData ); } else { console.log("First card : ", flipData.cardSlot[0].card1); @@ -139,6 +150,7 @@ export class SoSCardDeck { flipData.cardSlot[0].card2 = false; if ( flipData.cardSlot[0].isFace1 ) { flipData.cardSlot[0].card2 = this.drawFromDeck(); + flipData.isJoker = this.isJoker(flipData.cardSlot[0].card2.cardName); flipData.cardSlot[0].value2 = this.getCardValue(flipData.cardSlot[0].card2.cardName); flipData.cardSlot[0].isFace2 = this.isCardFace(flipData.cardSlot[0].card2.cardName); flipData.cardSlot[0].card2Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[0].card2.cardName}.webp`; @@ -149,17 +161,19 @@ export class SoSCardDeck { // Trump check flipData.cardSlot[0].cardsuit = cardsuit; - if ( cardsuit == flipData.stat.cardsuit ) { + if ( ! flipData.isJoker && cardsuit == flipData.stat.cardsuit ) { // This is a trump ! flipData.cardSlot[1] = { total: 0 }; flipData.isTrump = true; flipData.cardSlot[1].card1 = this.drawFromDeck(); + flipData.isJoker = this.isJoker(flipData.cardSlot[1].card1.cardName); flipData.cardSlot[1].card1Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[1].card1.cardName}.webp`; flipData.cardSlot[1].cardsuit = this.getCardSuit(flipData.cardSlot[1].card1.cardName); flipData.cardSlot[1].value1 = this.getCardValue(flipData.cardSlot[1].card1.cardName); flipData.cardSlot[1].isFace1 = this.isCardFace(flipData.cardSlot[1].card1.cardName); - if ( flipData.cardSlot[1].isFace1 ) { + if ( !flipData.isJoker && flipData.cardSlot[1].isFace1 ) { flipData.cardSlot[1].card2 = this.drawFromDeck(); + flipData.isJoker = this.isJoker(flipData.cardSlot[1].card2.cardName); flipData.cardSlot[1].value2 = this.getCardValue(flipData.cardSlot[1].card2.cardName); flipData.cardSlot[1].isFace2 = this.isCardFace(flipData.cardSlot[1].card2.cardName); flipData.cardSlot[1].card2Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[1].card2.cardName}.webp`; diff --git a/module/sos-flip-dialog.js b/module/sos-flip-dialog.js index 078d1f7..4a6a148 100644 --- a/module/sos-flip-dialog.js +++ b/module/sos-flip-dialog.js @@ -69,8 +69,8 @@ export class SoSFlipDialog extends Dialog { flipData.modifier = html.find('#modifier').val(); flipData.tn = html.find('#tn').val(); if ( flipData.mode == 'skill') { - console.log("SKILL STAT : ", html.find('#statSelect').val() ); - flipData.stat = duplicate( flipData.statList[ html.find('#statSelect').val() ] ); + let statKey = $('#statSelect').val(); + flipData.stat = duplicate( flipData.statList[ statKey ] ); } flipData.cardOrigin = "Deck"; flipData.tn = html.find('#tn').val(); diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 7f75fdf..fd101d6 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -73,8 +73,10 @@
- Edge cards : - Draw edge cards +

Edge cards :

+ Reset full deck and edges + Draw a new Edge card + Reset deck only (ie after a Joker)
{{#each data.edgecard as |card key|}} diff --git a/templates/chat-flip.html b/templates/chat-flip.html index dd9367b..07f2e5b 100644 --- a/templates/chat-flip.html +++ b/templates/chat-flip.html @@ -15,7 +15,7 @@ {{#if isJoker}} - + {{else}}