| 1 | package io.github.mathieusoysal.yatzy_mod; | |
| 2 | ||
| 3 | import static io.github.mathieusoysal.yatzy_mod.YatzyModUtils.isItEqualsWhenDicesIsSorted; | |
| 4 | ||
| 5 | import java.util.List; | |
| 6 | ||
| 7 | import io.github.mathieusoysal.Dices; | |
| 8 | ||
| 9 | /** | |
| 10 | * The {@code YMLargeStraight} class represents the "Large Straight" category in | |
| 11 | * the Yatzy game. | |
| 12 | * | |
| 13 | * <p> | |
| 14 | * In the "Large Straight" category, the player scores 20 if the dice show the | |
| 15 | * values [2, 3, 4, 5, 6] in ascending order. Otherwise, the score is zero. | |
| 16 | * </p> | |
| 17 | * | |
| 18 | * @author MathieuSoysal | |
| 19 | * @see YatzyModInterface | |
| 20 | * @see YatzyModUtils | |
| 21 | */ | |
| 22 | class YMLargeStraight implements YatzyModInterface { | |
| 23 | private static final List<Integer> LARGE_STRAIGHT_LIST = List.of(2, 3, 4, 5, 6); | |
| 24 | ||
| 25 | /** | |
| 26 | * Calculates the score for the "Large Straight" category based on the dice | |
| 27 | * values. | |
| 28 | * The player scores 20 if the dice show the values [2, 3, 4, 5, 6] in | |
| 29 | * ascending order. | |
| 30 | * | |
| 31 | * @param dices The set of dice to calculate the score for. | |
| 32 | * @return The calculated score, which is 20 for a Large Straight, or zero if | |
| 33 | * not. | |
| 34 | */ | |
| 35 | @Override | |
| 36 | public int calculateScore(Dices dices) { | |
| 37 |
1
1. calculateScore : negated conditional → KILLED |
return isItEqualsWhenDicesIsSorted(dices, LARGE_STRAIGHT_LIST) ? 20 : 0; |
| 38 | } | |
| 39 | } | |
Mutations | ||
| 37 |
1.1 |