client/src/shared/cardHelper.js
// Validates the hit against game rules
Validates the hit against game rules
Validates the hit against game rules
static validateHit(cards, previousHit, isFirstTurn, isRevolution) {
    if (isFirstTurn) {
      if (CardHelper.findTwoOfClubs(cards) === undefined) {
        return false;
      }
    }
    if (cards.length === 0 && previousHit.length === 0) {
      return false;
    }
    else if (cards.length === 0) {
      return true;
    }
    const firstValue = cards[0].value;
    for (let i = 1; i < cards.length; ++i) {
      if (cards[i].value !== firstValue) {
        return false;
      }
    }
    if (previousHit.length > 0) {
      let previousValue = previousHit[0].value;
      if (previousValue === 1 ||
        (CardHelper.compareGreatness(previousValue, firstValue, isRevolution) && firstValue !== 1) ||
        (cards.length < previousHit.length)) {
        return false;
      }
    }
    return true;
  }
static validateHit ( cards , previousHit , isFirstTurn , isRevolution ) { if ( isFirstTurn ) { if ( CardHelper . findTwoOfClubs ( cards ) === undefined ) { return false ; } } if ( cards . length === 0 && previousHit . length === 0 ) { return false ; } else if ( cards . length === 0 ) { return true ; } const firstValue = cards [ 0 ] . value ; for ( let i = 1 ; i < cards . length ; ++ i ) { if ( cards [ i ] . value !== firstValue ) { return false ; } } if ( previousHit . length > 0 ) { let previousValue = previousHit [ 0 ] . value ; if ( previousValue === 1 || ( CardHelper . compareGreatness ( previousValue , firstValue , isRevolution ) && firstValue !== 1 ) || ( cards . length < previousHit . length ) ) { return false ; } } return true ; }
Validates the hit against game rules
Validates the hit against game rules
// First hit of the game must contain the two of clubs // No cards is invalid hit if empty table... // but otherwise a valid hit if it wasn't the first hit of the game // If multiple cards was hit, they must be the same value // The value must be greater and the card count at least as high as in the previous hit