diff --git a/module/actor-sheet.js b/module/actor-sheet.js index eb03e6d..f692c25 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -136,6 +136,10 @@ export class SoSActorSheet extends ActorSheet { this.actor.resetDeck(); this.render(true); }); + html.find('.discard-card').click((event) => { + const cardName = $(event.currentTarget).data("discard"); + this.actor.discardEdge( cardName ); + }); html.find('.consequence-severity').click((event) => { const li = $(event.currentTarget).parents(".item"); const item = this.actor.getOwnedItem(li.data("item-id")); diff --git a/module/actor.js b/module/actor.js index 64575c5..a302fc0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -85,6 +85,12 @@ export class SoSActor extends Actor { this.saveDeck(); } + /* -------------------------------------------- */ + discardEdge( cardName ) { + this.cardDeck.discardEdge( cardName ); + this.saveDeck(); + } + /* -------------------------------------------- */ resetDeck( ) { this.cardDeck.resetDeck(); @@ -221,7 +227,8 @@ export class SoSActor extends Actor { modifierList: SoSUtility.fillRange(-10, +10), tnList: SoSUtility.fillRange(6, 20), consequencesList: duplicate( this.getApplicableConsequences() ), - malusConsequence: 0 + malusConsequence: 0, + bonusConsequence: 0 } let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData); new SoSFlipDialog(flipData, html).render(true); @@ -238,7 +245,8 @@ export class SoSActor extends Actor { actor: this, modifierList: SoSUtility.fillRange(-10, +10), tnList: SoSUtility.fillRange(6, 20), - malusConsequence: 0 + malusConsequence: 0, + bonusConsequence: 0 } 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); diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index a3a461f..91b9734 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -76,6 +76,13 @@ export class SoSCardDeck { } } + /* -------------------------------------------- */ + discardEdge( cardName ) { + let newEdge = this.data.cardEdge.filter( card => card.cardName != cardName); + this.data.cardEdge = newEdge; // New edge list + this.data.discard.push( { cardName: cardName }); // And push in the discard pile + } + /* -------------------------------------------- */ drawEdge( edgeNumber = 1 ) { for (let i=0; i` + } + return html; + } + /* -------------------------------------------- */ getDiscardTopHTML( ) { let html = ""; diff --git a/module/sos-flip-dialog.js b/module/sos-flip-dialog.js index 4110fe8..0cd68a2 100644 --- a/module/sos-flip-dialog.js +++ b/module/sos-flip-dialog.js @@ -36,6 +36,7 @@ export class SoSFlipDialog extends Dialog { scoreBase = this.flipData.stat.value; } scoreBase += this.flipData.malusConsequence; + scoreBase += this.flipData.bonusConsequence; $('#score-base').text( scoreBase); } @@ -46,7 +47,7 @@ export class SoSFlipDialog extends Dialog { $("#view-deck").append(await flipData.actor.cardDeck.getDeckHTML()); $('.view-edge').remove(); - $("#view-edge").append(await flipData.actor.cardDeck.getEdgeHTML()); + $("#view-edge").append(await flipData.actor.cardDeck.getEdgeHTMLForFlip()); this.updateScoreBase(); @@ -55,6 +56,7 @@ export class SoSFlipDialog extends Dialog { flipData.modifier = $('#modifier').val(); flipData.tn = (flipData.target) ? flipData.target.actor.data.data.scores.defense.value : $('#tn').val(); flipData.edgeName = event.currentTarget.attributes['data-edge-card'].value; + flipData.edgeLuck = $('#edge-luck').is(":checked"); flipData.cardOrigin = "Edge"; if ( flipData.mode == 'skill' || flipData.mode == 'weapon') { flipData.stat = duplicate( flipData.statList[ $('#statSelect').val() ] ); @@ -67,8 +69,8 @@ export class SoSFlipDialog extends Dialog { } /* -------------------------------------------- */ - updateConsequence(event) { - this.flipData.consequencesSelected = $('#consequenceSelect').val(); + updateConsequenceMalus(event) { + this.flipData.consequencesSelected = $('#consequenceSelectMalus').val(); let malusConsequence = 0; for (let consequenceId of this.flipData.consequencesSelected) { let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId); @@ -80,6 +82,20 @@ export class SoSFlipDialog extends Dialog { this.updateScoreBase(); } + /* -------------------------------------------- */ + updateConsequenceBonus(event) { + this.flipData.consequencesSelected = $('#consequenceSelectBonus').val(); + let bonusConsequence = 0; + for (let consequenceId of this.flipData.consequencesSelected) { + let consequence = this.flipData.consequencesList.find( item => item._id == consequenceId); + console.log(consequence, consequenceId); + bonusConsequence += SoSUtility.getConsequenceBonus( consequence.data.severity ); + } + $('#consequence-bonus').text(bonusConsequence); + this.flipData.bonusConsequence = bonusConsequence; + this.updateScoreBase(); + } + /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); @@ -90,9 +106,6 @@ export class SoSFlipDialog extends Dialog { function onLoad() { let flipData = dialog.flipData; - //RdDItemSort.setCoutReveReel(rollData.selectedSort); - //$("#diffLibre").val(Misc.toInt(rollData.diffLibre)); - //$("#diffConditions").val(Misc.toInt(rollData.diffConditions)); dialog.updateFlip(flipData); } @@ -103,8 +116,11 @@ export class SoSFlipDialog extends Dialog { this.updateFlip(dialog.flipData ); } ); - html.find('#consequenceSelect').change((event) => { - this.updateConsequence( event ); + html.find('#consequenceSelectMalus').change((event) => { + this.updateConsequenceMalus( event ); + } ); + html.find('#consequenceSelectBonus').change((event) => { + this.updateConsequenceBonus( event ); } ); html.find('.class-view-deck').click((event) => { diff --git a/module/sos-utility.js b/module/sos-utility.js index 6e16575..2f7c36a 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -4,6 +4,8 @@ import { SoSDialogCombatActions } from "./sos-dialog-combat-actions.js"; /* -------------------------------------------- */ const severity2malus = { "none": 0, "light": -1, "moderate": -2, "severe": -3, "critical": -4}; +/* -------------------------------------------- */ +const severity2bonus = { "none": 0, "light": 1, "moderate": 2, "severe": 3, "critical": 4}; /* -------------------------------------------- */ export class SoSUtility extends Entity { @@ -98,6 +100,10 @@ export class SoSUtility extends Entity { static getConsequenceMalus(severity) { return severity2malus[severity] ?? 0; } + /* -------------------------------------------- */ + static getConsequenceBonus(severity) { + return severity2bonus[severity] ?? 0; + } /* -------------------------------------------- */ static computeEncumbrance( items) { diff --git a/styles/simple.css b/styles/simple.css index 6e2d732..8036d10 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1022,6 +1022,24 @@ ul, li { font-weight: bold; } +.card-button { + box-shadow: inset 0px 1px 0px 0px #a6827e; + background: linear-gradient(to bottom, #21374afc 5%, #152833ab 100%); + background-color: #7d5d3b00; + border-radius: 3px; + border: 2px ridge #846109; + display: inline-block; + cursor: pointer; + color: #ffffff; + font-family: Neuropol; + font-size: 0.7rem; + padding: 4px 12px 0px 12px; + text-decoration: none; + text-shadow: 0px 1px 0px #4d3534; + position: relative; + margin:2px; +} + .chat-card-button { box-shadow: inset 0px 1px 0px 0px #a6827e; background: linear-gradient(to bottom, #21374afc 5%, #152833ab 100%); @@ -1032,7 +1050,7 @@ ul, li { cursor: pointer; color: #ffffff; font-family: Neuropol; - font-size: 0.9rem; + font-size: 0.8rem; padding: 4px 12px 0px 12px; text-decoration: none; text-shadow: 0px 1px 0px #4d3534; @@ -1040,10 +1058,12 @@ ul, li { margin:5px; } +.card-button:hover, .chat-card-button:hover { background: linear-gradient(to bottom, #800000 5%, #3e0101 100%); background-color: red; } +.card-button:active, .chat-card-button:active { position:relative; top:1px; diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 7d414a7..1905dd5 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -71,18 +71,23 @@ -
- -

Current deck size : {{data.deckSize}} cards

- Reset full deck and edges - Draw a new Edge card - Reset deck only (ie after a Joker) -
+
+

Current deck size : {{data.deckSize}} cards

+

Edge cards :

- {{#each data.edgecard as |card key|}} - - {{/each}} +
+ {{#each data.edgecard as |card key|}} +
+ + Discard +
+ {{/each}} +
diff --git a/templates/dialog-flip.html b/templates/dialog-flip.html index 7cc34f0..946ba94 100644 --- a/templates/dialog-flip.html +++ b/templates/dialog-flip.html @@ -2,47 +2,57 @@

Flip Dialog !

-
- -
- {{#if (eq mode 'stat')}} -

- Stat Only Flip : {{localize stat.label}} : {{stat.value}} - -

- -

Final Score : 0

-
- {{else}} -

- Select Stat - -

- -

Skill Flip : {{skill.name}} ({{skill.data.value}})

-

Final Score : 0

-
- {{/if}} -
-
-
- + {{#select statList}} + {{#each statList as |stat key|}} + {{/each}} {{/select}} - -

Consequences malus : 0

+ + +

Skill Flip : {{skill.name}} ({{skill.data.value}})

+

Final Score : 0

+
+ {{/if}} +
+
+
+ +

Consequences Malus : 0

+
+
+
+
+ +

Consequences Bonus : 0

+
- +
{{#if target}}

Target : {{target.actor.name}} - Defense : {{target.actor.data.data.scores.defense.value}}/{{target.actor.data.data.scores.defense.critical}}

@@ -64,9 +74,7 @@ {{/select}} {{/if}} -
-
- +
-
+
+
+ +
-
+
-
+