| Total Complexity | 10 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Coverage | 93.55% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class DiceGame |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Create hand and rolls all dices, returns hand with mixed images/integers. |
||
| 16 | * @return diceHand |
||
| 17 | */ |
||
| 18 | 2 | public function rollMixedHand(int $num): diceHand |
|
| 19 | { |
||
| 20 | 2 | $hand = new DiceHand(); |
|
| 21 | 2 | for ($i = 1; $i <= $num; $i++) { |
|
| 22 | 2 | if ($i % 2 === 1) { |
|
| 23 | 2 | $hand->add(new DiceGraphic()); |
|
| 24 | 2 | continue; |
|
| 25 | } |
||
| 26 | 2 | $hand->add(new Dice()); |
|
| 27 | } |
||
| 28 | |||
| 29 | 2 | $hand->roll(); |
|
| 30 | |||
| 31 | 2 | return $hand; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Create hand and rolls all dices, returns hand. |
||
| 36 | * @return diceHand |
||
| 37 | */ |
||
| 38 | 2 | public function rollHand(int $numDice): diceHand |
|
| 39 | { |
||
| 40 | // Skapar tärningshand |
||
| 41 | 2 | $hand = new DiceHand(); |
|
| 42 | 2 | for ($i = 1; $i <= $numDice; $i++) { |
|
| 43 | //Lägger antal tärningar i handen |
||
| 44 | 2 | $hand->add(new DiceGraphic()); |
|
| 45 | } |
||
| 46 | // Rullar tärningen |
||
| 47 | 2 | $hand->roll(); |
|
| 48 | |||
| 49 | 2 | return $hand; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Rolls number of dices used as parameter. |
||
| 54 | * @return string[] |
||
| 55 | */ |
||
| 56 | 2 | public function rollSeveral(int $num): array |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Calculates the value of game round. |
||
| 70 | * @return int |
||
| 71 | */ |
||
| 72 | 2 | public function gameRound(DiceHand $hand): int |
|
| 85 | } |
||
| 86 | } |
||
| 87 |