Total Complexity | 11 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php declare(strict_types=1); |
||
7 | final class Turn |
||
8 | { |
||
9 | private $currentPlayer; |
||
10 | private $since; |
||
11 | private $canPlay; |
||
12 | private $canDefend; |
||
13 | |||
14 | public function __construct(int $player, DateTimeInterface $since, bool $play = true) |
||
15 | { |
||
16 | $this->currentPlayer = $player; |
||
17 | $this->since = $since; |
||
18 | $this->canPlay = $play; |
||
19 | $this->canDefend = !$play; |
||
20 | } |
||
21 | |||
22 | public function prohibitsPlaying(int $player, DateTimeInterface $when): bool |
||
23 | { |
||
24 | return $this->currentPlayer !== $player || |
||
25 | !$this->canPlay || |
||
26 | $when->getTimestamp() - $this->since->getTimestamp() >= 20; |
||
27 | } |
||
28 | |||
29 | public function prohibitsAttacking(int $player, DateTimeInterface $when): bool |
||
|
|||
30 | { |
||
31 | return $this->currentPlayer !== $player; |
||
32 | } |
||
33 | |||
34 | public function prohibitsDefending(int $player, DateTimeInterface $when): bool |
||
35 | { |
||
36 | return $this->currentPlayer !== $player || |
||
37 | !$this->canDefend || |
||
38 | $when->getTimestamp() - $this->since->getTimestamp() >= 20; |
||
39 | } |
||
40 | |||
41 | public function endCardPlayingPhaseFor(int $thePlayer): Turn |
||
42 | { |
||
43 | // @todo |
||
44 | $this->canPlay = false; |
||
45 | return $this; |
||
46 | } |
||
47 | |||
48 | public function endCombatPhase(): Turn |
||
49 | { |
||
50 | // @todo add time |
||
51 | $this->canDefend = false; |
||
52 | $this->canPlay = true; |
||
53 | return $this; |
||
54 | } |
||
55 | |||
56 | public function of(int $thePlayer, DateTimeInterface $since): Turn |
||
59 | } |
||
60 | } |
||
61 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.