1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Stratadox\CardGame\Match; |
4
|
|
|
|
5
|
|
|
use BadMethodCallException; |
6
|
|
|
use Stratadox\CardGame\Deck\CardId; |
7
|
|
|
use Stratadox\CardGame\Match\Event\CardWasDrawn; |
8
|
|
|
use Stratadox\CardGame\Match\Event\SpellVanishedToTheVoid; |
9
|
|
|
|
10
|
|
|
final class SpellTemplate implements CardTemplate |
11
|
|
|
{ |
12
|
|
|
private $card; |
13
|
|
|
private $cost; |
14
|
|
|
|
15
|
|
|
public function __construct(CardId $card, Mana $cost) |
16
|
|
|
{ |
17
|
|
|
$this->card = $card; |
18
|
|
|
$this->cost = $cost; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function playingEvents( |
22
|
|
|
MatchId $match, |
23
|
|
|
int $player, |
24
|
|
|
int $offset |
25
|
|
|
): array { |
26
|
|
|
return [new SpellVanishedToTheVoid($match, $player, $offset)]; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function drawingEvents( |
30
|
|
|
MatchId $match, |
31
|
|
|
int $player, |
32
|
|
|
int $offset |
33
|
|
|
): array { |
34
|
|
|
return [new CardWasDrawn($match, $this->card, $player, $offset)]; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function attackingEvents( |
38
|
|
|
MatchId $match, |
39
|
|
|
int $player, |
40
|
|
|
int $offset |
41
|
|
|
): array { |
42
|
|
|
return []; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function defendingEvents( |
46
|
|
|
MatchId $match, |
47
|
|
|
int $player, |
48
|
|
|
int $offset |
49
|
|
|
): array { |
50
|
|
|
return []; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function dyingEvents( |
54
|
|
|
MatchId $match, |
55
|
|
|
int $player, |
56
|
|
|
int $offset |
57
|
|
|
): array { |
58
|
|
|
return []; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function regroupingEvents( |
62
|
|
|
MatchId $match, |
63
|
|
|
int $player, |
64
|
|
|
int $offset |
65
|
|
|
): array { |
66
|
|
|
return []; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function playingMove(int $position): Location |
70
|
|
|
{ |
71
|
|
|
return Location::inVoid(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function attackingMove(int $position): Location |
75
|
|
|
{ |
76
|
|
|
throw new BadMethodCallException('Spells cannot attack.'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function defendingMove(int $position): Location |
80
|
|
|
{ |
81
|
|
|
throw new BadMethodCallException('Spells cannot defend.'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function regroupingMove(int $position): Location |
85
|
|
|
{ |
86
|
|
|
throw new BadMethodCallException('Spells cannot regroup.'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function cost(): Mana |
90
|
|
|
{ |
91
|
|
|
return $this->cost; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|