Enhance fip
This commit is contained in:
@ -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`;
|
||||
|
Reference in New Issue
Block a user