1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Obblm\Core\Helper\Rule\Roster; |
4
|
|
|
|
5
|
|
|
use Obblm\Core\Contracts\RosterInterface; |
6
|
|
|
use Obblm\Core\Helper\Optionable; |
7
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
8
|
|
|
|
9
|
|
|
abstract class AbstractRoster extends Optionable implements RosterInterface |
10
|
|
|
{ |
11
|
|
|
const DEFAULT_INDUCEMENT_OPTIONS = [ |
12
|
|
|
'discount_bribe' => false, |
13
|
|
|
'discount_halfling_master_chef' => false, |
14
|
|
|
'extra_apothecary' => true, |
15
|
|
|
'igor' => false |
16
|
|
|
]; |
17
|
|
|
|
18
|
|
|
protected $key; |
19
|
|
|
protected $name; |
20
|
|
|
protected $translationDomain; |
21
|
|
|
protected $playerTypes; |
22
|
|
|
protected $rerollCost; |
23
|
|
|
protected $canHaveApothecary; |
24
|
|
|
protected $inducementOptions; |
25
|
|
|
|
26
|
1 |
|
protected function hydrateWithOptions() |
27
|
|
|
{ |
28
|
1 |
|
$this->setKey($this->options['key']) |
29
|
1 |
|
->setName($this->options['name']) |
30
|
1 |
|
->setTranslationDomain($this->options['translation_domain']) |
31
|
1 |
|
->setPlayerTypes($this->options['player_types']) |
32
|
1 |
|
->setInducementTypes($this->options['inducement_options']) |
33
|
1 |
|
->setRerollCost($this->options['reroll_cost']) |
34
|
1 |
|
->setCanHaveApothecary($this->options['can_have_apothecary']); |
35
|
1 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return string |
39
|
|
|
*/ |
40
|
|
|
public function getKey(): string |
41
|
|
|
{ |
42
|
|
|
return $this->key; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getName(): string |
49
|
|
|
{ |
50
|
|
|
return $this->name; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function getTranslationDomain(): string |
57
|
|
|
{ |
58
|
|
|
return $this->translationDomain; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
1 |
|
public function getPlayerTypes(): ?array |
65
|
|
|
{ |
66
|
1 |
|
return $this->playerTypes; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return bool |
71
|
|
|
*/ |
72
|
1 |
|
public function canHaveApothecary():bool |
73
|
|
|
{ |
74
|
1 |
|
return $this->canHaveApothecary; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return bool |
79
|
|
|
*/ |
80
|
|
|
public function getCanHaveApothecary():bool |
81
|
|
|
{ |
82
|
|
|
return $this->canHaveApothecary; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return int |
87
|
|
|
*/ |
88
|
1 |
|
public function getRerollCost():int |
89
|
|
|
{ |
90
|
1 |
|
return $this->rerollCost; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return array |
95
|
|
|
*/ |
96
|
|
|
public function getInducementOptions():?array |
97
|
|
|
{ |
98
|
|
|
return $this->inducementOptions; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @param string $key |
103
|
|
|
* @return $this |
104
|
|
|
*/ |
105
|
1 |
|
public function setKey(string $key): self |
106
|
|
|
{ |
107
|
1 |
|
$this->key = $key; |
108
|
1 |
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param string $name |
113
|
|
|
* @return $this |
114
|
|
|
*/ |
115
|
1 |
|
public function setName(string $name): self |
116
|
|
|
{ |
117
|
1 |
|
$this->name = $name; |
118
|
1 |
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param string $translationDomain |
123
|
|
|
* @return $this |
124
|
|
|
*/ |
125
|
1 |
|
public function setTranslationDomain(string $translationDomain): self |
126
|
|
|
{ |
127
|
1 |
|
$this->translationDomain = $translationDomain; |
128
|
1 |
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param array $playerTypes |
133
|
|
|
* @return $this |
134
|
|
|
*/ |
135
|
1 |
|
public function setPlayerTypes(array $playerTypes): self |
136
|
|
|
{ |
137
|
1 |
|
$this->playerTypes = $playerTypes; |
138
|
1 |
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param array $inducementTypes |
143
|
|
|
* @return $this |
144
|
|
|
*/ |
145
|
1 |
|
public function setInducementTypes(array $inducementTypes): self |
146
|
|
|
{ |
147
|
1 |
|
$this->inducementTypes = $inducementTypes; |
|
|
|
|
148
|
1 |
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @param int $rerollCost |
153
|
|
|
* @return $this |
154
|
|
|
*/ |
155
|
1 |
|
public function setRerollCost(int $rerollCost): self |
156
|
|
|
{ |
157
|
1 |
|
$this->rerollCost = $rerollCost; |
158
|
1 |
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param bool $canHaveApothecary |
163
|
|
|
* @return $this |
164
|
|
|
*/ |
165
|
1 |
|
public function setCanHaveApothecary(bool $canHaveApothecary): self |
166
|
|
|
{ |
167
|
1 |
|
$this->canHaveApothecary = $canHaveApothecary; |
168
|
1 |
|
return $this; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function __toString(): string |
172
|
|
|
{ |
173
|
|
|
return $this->name; |
174
|
|
|
} |
175
|
|
|
|
176
|
1 |
|
public function configureOptions(OptionsResolver $resolver):void |
177
|
|
|
{ |
178
|
1 |
|
$resolver->setDefaults([ |
179
|
1 |
|
'key' => null, |
180
|
|
|
'name' => null, |
181
|
|
|
'translation_domain' => null, |
182
|
|
|
'player_types' => [], |
183
|
|
|
'inducement_options' => [], |
184
|
|
|
'reroll_cost' => 0, |
185
|
|
|
'can_have_apothecary' => true, |
186
|
|
|
]) |
187
|
1 |
|
->setRequired('key') |
188
|
1 |
|
->setRequired('name') |
189
|
1 |
|
->setRequired('translation_domain') |
190
|
1 |
|
->setAllowedTypes('key', ['string']) |
191
|
1 |
|
->setAllowedTypes('name', ['string']) |
192
|
1 |
|
->setAllowedTypes('translation_domain', ['string']) |
193
|
1 |
|
->setAllowedTypes('player_types', ['array']) |
194
|
1 |
|
->setAllowedTypes('inducement_options', ['array']) |
195
|
1 |
|
->setAllowedTypes('reroll_cost', ['int']) |
196
|
1 |
|
->setAllowedTypes('can_have_apothecary', ['bool']) |
197
|
|
|
; |
198
|
1 |
|
} |
199
|
|
|
} |
200
|
|
|
|