(hand1, hand2)
| 115 | * @returns {number} 1 or 0 indicating Player 1's win or loss, respectively. |
| 116 | */ |
| 117 | export function compareHands(hand1, hand2) { |
| 118 | const handScore1 = handScoringHelper(hand1); |
| 119 | const handScore2 = handScoringHelper(hand2); |
| 120 | // In descending order of group size, decide if one hand is better. |
| 121 | for (let group = GAME_STATE.num_cards_per_hand - 1; group >= 0; group--) { |
| 122 | if (handScore1[group] > handScore2[group]) { |
| 123 | return 1; |
| 124 | } |
| 125 | if (handScore1[group] < handScore2[group]) { |
| 126 | return 0; |
| 127 | } |
| 128 | } |
| 129 | // Break a tie by flipping a fair coin. |
| 130 | if (Math.random() > 0.5) { |
| 131 | return 1; |
| 132 | } |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Returns an object representing one complete play of the game. |
no test coverage detected