Total Complexity | 9 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
7 | final class OngoingMatch |
||
8 | { |
||
9 | public const PHASE_DEFEND = 'defend'; |
||
10 | public const PHASE_PLAY = 'play'; |
||
11 | public const PHASE_ATTACK = 'attack'; |
||
12 | |||
13 | private $id; |
||
14 | private $turn; |
||
15 | private $phase = self::PHASE_PLAY; |
||
16 | |||
17 | public function __construct(MatchId $match, int $whoStarts) |
||
18 | { |
||
19 | $this->id = $match; |
||
20 | $this->turn = $whoStarts; |
||
21 | } |
||
22 | |||
23 | public function id(): MatchId |
||
24 | { |
||
25 | return $this->id; |
||
26 | } |
||
27 | |||
28 | /** @return int[] */ |
||
29 | public function players(): array |
||
30 | { |
||
31 | return [0, 1]; |
||
32 | } |
||
33 | |||
34 | public function startTurnOf(int $player): void |
||
35 | { |
||
36 | $this->turn = $player; |
||
37 | $this->phase = self::PHASE_DEFEND; |
||
38 | } |
||
39 | |||
40 | public function itIsTheTurnOf(int $player): bool |
||
41 | { |
||
42 | return $this->turn === $player; |
||
43 | } |
||
44 | |||
45 | public function startDefendPhase(): void |
||
46 | { |
||
47 | $this->phase = self::PHASE_DEFEND; |
||
48 | } |
||
49 | |||
50 | public function startPlayPhase(): void |
||
51 | { |
||
52 | $this->phase = self::PHASE_PLAY; |
||
53 | } |
||
54 | |||
55 | public function startAttackPhase(): void |
||
58 | } |
||
59 | |||
60 | public function phase(): string |
||
63 | } |
||
64 | } |
||
65 |