| 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 |  |  |     protected function hydrateWithOptions() | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $this->setKey($this->options['key']) | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             ->setName($this->options['name']) | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |             ->setTranslationDomain($this->options['translation_domain']) | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             ->setPlayerTypes($this->options['player_types']) | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             ->setInducementTypes($this->options['inducement_options']) | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |             ->setRerollCost($this->options['reroll_cost']) | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |             ->setCanHaveApothecary($this->options['can_have_apothecary']); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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 |  |  |     public function getPlayerTypes(): ?array | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         return $this->playerTypes; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      * @return bool | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     public function canHaveApothecary():bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  |         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 |  |  |     public function getRerollCost():int | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |         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 |  |  |     public function setKey(string $key): self | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |         $this->key = $key; | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |      * @param string $name | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |     public function setName(string $name): self | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |         $this->name = $name; | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |      * @param string $translationDomain | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     public function setTranslationDomain(string $translationDomain): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->translationDomain = $translationDomain; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 128 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |      * @param array $playerTypes | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     public function setPlayerTypes(array $playerTypes): self | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |         $this->playerTypes = $playerTypes; | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |      * @param array $inducementTypes | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     public function setInducementTypes(array $inducementTypes): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $this->inducementTypes = $inducementTypes; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  |         return $this; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 149 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 151 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |      * @param int $rerollCost | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     public function setRerollCost(int $rerollCost): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $this->rerollCost = $rerollCost; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 158 |  |  |         return $this; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                        
                                                                
            
                                    
            
            
                | 162 |  |  |      * @param bool $canHaveApothecary | 
            
                                                                        
                                                                
            
                                    
            
            
                | 163 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     public function setCanHaveApothecary(bool $canHaveApothecary): self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $this->canHaveApothecary = $canHaveApothecary; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 168 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     public function __toString(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 173 |  |  |         return $this->name; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 174 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 176 |  |  |     public function configureOptions(OptionsResolver $resolver):void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $resolver->setDefaults([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             '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 |  |  |             ->setRequired('key') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             ->setRequired('name') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             ->setRequired('translation_domain') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             ->setAllowedTypes('key', ['string']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             ->setAllowedTypes('name', ['string']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             ->setAllowedTypes('translation_domain', ['string']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             ->setAllowedTypes('player_types', ['array']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             ->setAllowedTypes('inducement_options', ['array']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             ->setAllowedTypes('reroll_cost', ['int']) | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 196 |  |  |             ->setAllowedTypes('can_have_apothecary', ['bool']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 199 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 200 |  |  |  |