Total Complexity | 11 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
5 | final class TurnPhase |
||
6 | { |
||
7 | private const DEFEND = 0; |
||
8 | private const PLAY = 1; |
||
9 | private const ATTACK = 2; |
||
10 | |||
11 | private $phase; |
||
12 | |||
13 | private function __construct(int $phase) |
||
14 | { |
||
15 | $this->phase = $phase; |
||
16 | } |
||
17 | |||
18 | public static function defend(): self |
||
19 | { |
||
20 | return new self(TurnPhase::DEFEND); |
||
21 | } |
||
22 | |||
23 | public static function play(): self |
||
24 | { |
||
25 | return new self(TurnPhase::PLAY); |
||
26 | } |
||
27 | |||
28 | public static function attack(): self |
||
29 | { |
||
30 | return new self(TurnPhase::ATTACK); |
||
31 | } |
||
32 | |||
33 | public function prohibitsDefending(): bool |
||
34 | { |
||
35 | return $this->phase !== TurnPhase::DEFEND; |
||
36 | } |
||
37 | |||
38 | public function prohibitsPlaying(): bool |
||
39 | { |
||
40 | return $this->phase !== TurnPhase::PLAY; |
||
41 | } |
||
42 | |||
43 | public function prohibitsAttacking(): bool |
||
44 | { |
||
45 | return $this->phase !== TurnPhase::ATTACK; |
||
46 | } |
||
47 | |||
48 | public function isAfterCombat(): bool |
||
49 | { |
||
50 | return $this->phase === TurnPhase::PLAY |
||
51 | || $this->phase === TurnPhase::ATTACK; |
||
52 | } |
||
53 | |||
54 | public function endCombat(): TurnPhase |
||
55 | { |
||
56 | return TurnPhase::play(); |
||
57 | } |
||
58 | |||
59 | public function endCardPlaying(): TurnPhase |
||
62 | } |
||
63 | } |
||
64 |