Test Setup Failed
Push — master ( 647a95...23a558 )
by Jesse
02:13
created

UnitTemplate::regroupingMove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\CardGame\Match;
4
5
// @todo remove reference to foreign context
6
use Stratadox\CardGame\Deck\CardId;
7
use Stratadox\CardGame\Match\Event\CardWasDrawn;
8
use Stratadox\CardGame\Match\Event\UnitDied;
9
use Stratadox\CardGame\Match\Event\UnitMovedIntoPlay;
10
use Stratadox\CardGame\Match\Event\UnitMovedToAttack;
11
use Stratadox\CardGame\Match\Event\UnitRegrouped;
12
13
final class UnitTemplate implements CardTemplate
14
{
15
    private $card;
16
    private $cost;
17
18
    public function __construct(CardId $card, Mana $cost)
19
    {
20
        $this->card = $card;
21
        $this->cost = $cost;
22
    }
23
24
    public function playingEvents(
25
        MatchId $match,
26
        int $player,
27
        int $offset
28
    ): array {
29
        return [new UnitMovedIntoPlay($match, $this->card, $player, $offset)];
30
    }
31
32
    public function drawingEvents(
33
        MatchId $match,
34
        int $player,
35
        int $offset
36
    ): array {
37
        return [new CardWasDrawn($match, $this->card, $player, $offset)];
38
    }
39
40
    public function attackingEvents(
41
        MatchId $match,
42
        int $player,
43
        int $offset
44
    ): array {
45
        return [new UnitMovedToAttack($match, $player, $offset)];
46
    }
47
48
    public function defendingEvents(
49
        MatchId $match,
50
        int $player,
51
        int $offset
52
    ): array {
53
        // @todo add UnitMovedToDefend?
54
        return [];
55
    }
56
57
    public function dyingEvents(
58
        MatchId $match,
59
        int $player,
60
        int $offset
61
    ): array {
62
        return [new UnitDied($match, $player, $offset)];
63
    }
64
65
    public function regroupingEvents(
66
        MatchId $match,
67
        int $player,
68
        int $offset
69
    ): array {
70
        return [new UnitRegrouped($match, $player, $offset)];
71
    }
72
73
    public function playingMove(int $position): Location
74
    {
75
        return Location::inPlay($position);
76
    }
77
78
    public function attackingMove(int $position): Location
79
    {
80
        return Location::attackingAt($position);
81
    }
82
83
    public function defendingMove(int $position): Location
84
    {
85
        return Location::defendingAgainst($position);
86
    }
87
88
    public function regroupingMove(int $position): Location
89
    {
90
        return Location::inPlay($position);
91
    }
92
93
    public function cost(): Mana
94
    {
95
        return $this->cost;
96
    }
97
}
98