Total Complexity | 5 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
9 | class Battlefield |
||
10 | { |
||
11 | private $cards = []; |
||
12 | |||
13 | public function add(Card $card, MatchId $match, int $owner): void |
||
14 | { |
||
15 | $this->cards[$match->id()][$owner][] = $card; |
||
16 | } |
||
17 | |||
18 | public function remove(Card $cardToRemove, MatchId $match, int $owner): void |
||
19 | { |
||
20 | $this->cards[$match->id()][$owner] = array_filter( |
||
21 | $this->cards[$match->id()][$owner], |
||
22 | function (Card $card) use ($cardToRemove): bool { |
||
23 | return !$card->is($cardToRemove); |
||
24 | } |
||
25 | ); |
||
26 | } |
||
27 | |||
28 | /** @return Card[] */ |
||
29 | public function cardsInPlay(MatchId $match): array |
||
32 | } |
||
33 | |||
34 | /** @return Card[] */ |
||
35 | public function cardsInPlayFor(int $player, MatchId $match): array |
||
36 | { |
||
37 | return $this->cards[$match->id()][$player] ?? []; |
||
38 | } |
||
39 | |||
40 | /** @return Card[] */ |
||
41 | public function attackers(MatchId $match): array |
||
47 | } |
||
48 | ); |
||
49 | } |
||
50 | } |
||
51 |