| 1 | package io.github.mathieusoysal.yatzy_mod; | |
| 2 | ||
| 3 | import io.github.mathieusoysal.Dices; | |
| 4 | ||
| 5 | /** | |
| 6 | * The {@code YMFullHouse} class represents the "Full House" category in the | |
| 7 | * Yatzy game. | |
| 8 | * | |
| 9 | * <p> | |
| 10 | * In the "Full House" category, the player scores the sum of all dice if there | |
| 11 | * are two dice of one kind and three dice of another kind. Otherwise, the score | |
| 12 | * is zero. | |
| 13 | * </p> | |
| 14 | * | |
| 15 | * @author MathieuSoysal | |
| 16 | * @see YatzyModInterface | |
| 17 | * @see YatzyModUtils | |
| 18 | */ | |
| 19 | class YMFullHouse implements YatzyModInterface { | |
| 20 | ||
| 21 | /** | |
| 22 | * Calculates the score for the "Full House" category based on the sum of all | |
| 23 | * dice if the criteria are met. | |
| 24 | * To qualify as a Full House, there must be two dice of one kind and three dice | |
| 25 | * of another kind. | |
| 26 | * | |
| 27 | * @param dices The set of dice to calculate the score for. | |
| 28 | * @return The calculated score, which is the sum of all dice if it's a Full | |
| 29 | * House, or zero if not. | |
| 30 | * @see YatzyModUtils#containsExactFrequencyDice(int, Dices) | |
| 31 | */ | |
| 32 | @Override | |
| 33 | public int calculateScore(Dices dices) { | |
| 34 |
2
1. calculateScore : negated conditional → KILLED 2. calculateScore : negated conditional → KILLED |
if (containsTriplet(dices) && containsPair(dices)) |
| 35 |
1
1. calculateScore : replaced int return with 0 for io/github/mathieusoysal/yatzy_mod/YMFullHouse::calculateScore → KILLED |
return dices.getDicesIntStream().sum(); |
| 36 | else | |
| 37 | return 0; | |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * Checks if the given set of dice contains a pair of dice with the same value. | |
| 42 | * | |
| 43 | * @param dices The set of dice to check. | |
| 44 | * @return True if a pair is present; otherwise, false. | |
| 45 | * @see YatzyModUtils#containsExactFrequencyDice(int, Dices) | |
| 46 | */ | |
| 47 | private boolean containsPair(Dices dices) { | |
| 48 |
2
1. containsPair : replaced boolean return with true for io/github/mathieusoysal/yatzy_mod/YMFullHouse::containsPair → KILLED 2. containsPair : replaced boolean return with false for io/github/mathieusoysal/yatzy_mod/YMFullHouse::containsPair → KILLED |
return YatzyModUtils.containsExactFrequencyDice(2, dices); |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 | * Checks if the given set of dice contains three dice with the same value. | |
| 53 | * | |
| 54 | * @param dices The set of dice to check. | |
| 55 | * @return True if a triplet is present; otherwise, false. | |
| 56 | * @see YatzyModUtils#containsExactFrequencyDice(int, Dices) | |
| 57 | */ | |
| 58 | private boolean containsTriplet(Dices dices) { | |
| 59 |
2
1. containsTriplet : replaced boolean return with true for io/github/mathieusoysal/yatzy_mod/YMFullHouse::containsTriplet → KILLED 2. containsTriplet : replaced boolean return with false for io/github/mathieusoysal/yatzy_mod/YMFullHouse::containsTriplet → KILLED |
return YatzyModUtils.containsExactFrequencyDice(3, dices); |
| 60 | } | |
| 61 | } | |
Mutations | ||
| 34 |
1.1 2.2 |
|
| 35 |
1.1 |
|
| 48 |
1.1 2.2 |
|
| 59 |
1.1 2.2 |