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