Enhance fip

This commit is contained in:
sladecraven 2021-01-25 11:16:45 +01:00
parent 05a2b02482
commit b22b8022f1
5 changed files with 28 additions and 11 deletions

View File

@ -161,6 +161,7 @@ export class SoSActor extends Actor {
modifierList: SoSUtility.fillRange(-10, +10), modifierList: SoSUtility.fillRange(-10, +10),
tnList: SoSUtility.fillRange(6, 20) 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); let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
new SoSFlipDialog(flipData, html).render(true); new SoSFlipDialog(flipData, html).render(true);
} }

View File

@ -97,6 +97,7 @@ export class SoSCardDeck {
/* -------------------------------------------- */ /* -------------------------------------------- */
getCardValue( cardName ) { getCardValue( cardName ) {
console.log(cardName); console.log(cardName);
if (cardName[0] == 'j' ) return 0; // Joker case
let parsed = cardName.match( /\w(\d\d)/i ); let parsed = cardName.match( /\w(\d\d)/i );
let value = Number( parsed[1] ); let value = Number( parsed[1] );
if ( value > 10 ) value -= 10; if ( value > 10 ) value -= 10;
@ -104,11 +105,24 @@ export class SoSCardDeck {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isCardFace(cardName) { isCardFace(cardName) {
if (cardName[0] == 'j' ) return false; // Joker case
let parsed = cardName.match( /\w(\d\d)/i ); let parsed = cardName.match( /\w(\d\d)/i );
let value = Number( parsed[1] ); let value = Number( parsed[1] );
return (value > 10) ? true : false; 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 ) { async doFlipFromDeckOrEdge( flipData ) {
flipData.cardSlot = [ { total: 0}]; flipData.cardSlot = [ { total: 0}];
@ -125,10 +139,7 @@ export class SoSCardDeck {
let cardsuit = this.getCardSuit(flipData.cardSlot[0].card1.cardName); let cardsuit = this.getCardSuit(flipData.cardSlot[0].card1.cardName);
if ( cardsuit == 'joker' ) { if ( cardsuit == 'joker' ) {
console.log("THIS IS A JOKER !!!!"); this.setJoker( flipData );
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`;
} else { } else {
console.log("First card : ", flipData.cardSlot[0].card1); console.log("First card : ", flipData.cardSlot[0].card1);
@ -139,6 +150,7 @@ export class SoSCardDeck {
flipData.cardSlot[0].card2 = false; flipData.cardSlot[0].card2 = false;
if ( flipData.cardSlot[0].isFace1 ) { if ( flipData.cardSlot[0].isFace1 ) {
flipData.cardSlot[0].card2 = this.drawFromDeck(); 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].value2 = this.getCardValue(flipData.cardSlot[0].card2.cardName);
flipData.cardSlot[0].isFace2 = this.isCardFace(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`; 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 // Trump check
flipData.cardSlot[0].cardsuit = cardsuit; flipData.cardSlot[0].cardsuit = cardsuit;
if ( cardsuit == flipData.stat.cardsuit ) { if ( ! flipData.isJoker && cardsuit == flipData.stat.cardsuit ) {
// This is a trump ! // This is a trump !
flipData.cardSlot[1] = { total: 0 }; flipData.cardSlot[1] = { total: 0 };
flipData.isTrump = true; flipData.isTrump = true;
flipData.cardSlot[1].card1 = this.drawFromDeck(); 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].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].cardsuit = this.getCardSuit(flipData.cardSlot[1].card1.cardName);
flipData.cardSlot[1].value1 = this.getCardValue(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); 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.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].value2 = this.getCardValue(flipData.cardSlot[1].card2.cardName);
flipData.cardSlot[1].isFace2 = this.isCardFace(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`; flipData.cardSlot[1].card2Path = `systems/foundryvtt-shadows-over-sol/img/cards/${flipData.cardSlot[1].card2.cardName}.webp`;

View File

@ -69,8 +69,8 @@ export class SoSFlipDialog extends Dialog {
flipData.modifier = html.find('#modifier').val(); flipData.modifier = html.find('#modifier').val();
flipData.tn = html.find('#tn').val(); flipData.tn = html.find('#tn').val();
if ( flipData.mode == 'skill') { if ( flipData.mode == 'skill') {
console.log("SKILL STAT : ", html.find('#statSelect').val() ); let statKey = $('#statSelect').val();
flipData.stat = duplicate( flipData.statList[ html.find('#statSelect').val() ] ); flipData.stat = duplicate( flipData.statList[ statKey ] );
} }
flipData.cardOrigin = "Deck"; flipData.cardOrigin = "Deck";
flipData.tn = html.find('#tn').val(); flipData.tn = html.find('#tn').val();

View File

@ -73,8 +73,10 @@
<div class="flexrow"> <div class="flexrow">
<span class="flexcol"> <span class="flexcol">
<span class="edge-name">Edge cards : </span> <h3 class="edge-name">Edge cards : </h3>
<span class="edge-name"><a class="edge-draw">Draw edge cards</a></span> <span class="edge-name"><a class="reset-deck-full">Reset full deck and edges</a></span>
<span class="edge-name"><a class="draw-new-edge">Draw a new Edge card</a></span>
<span class="edge-name"><a class="reset-deck">Reset deck only (ie after a Joker)</a></span>
</span> </span>
<span class="edge-name"> <span class="edge-name">
{{#each data.edgecard as |card key|}} {{#each data.edgecard as |card key|}}

View File

@ -15,7 +15,7 @@
</table> </table>
{{#if isJoker}} {{#if isJoker}}
<label>This is a Critical Failure ! You deck has been resetted !</label> <label><strong>This is a Critical Failure ! </strong>You can discard some cards from your deck, then draw a new one and then shuffle the discard pile with the deck !</label>
{{else}} {{else}}
<div class="flexcol"> <div class="flexcol">
<label>Card(s) total value : {{cardTotal}}</label> <label>Card(s) total value : {{cardTotal}}</label>