| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Obblm\Core\Helper\Rule\Traits; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\Common\Collections\ArrayCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\Common\Collections\Criteria; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Common\Collections\Expr\CompositeExpression; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Obblm\Core\Contracts\PositionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Obblm\Core\Contracts\RosterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Obblm\Core\DataTransformer\StringToSkill; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Obblm\Core\Entity\Player; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Obblm\Core\Entity\PlayerVersion; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Obblm\Core\Entity\Team; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Obblm\Core\Exception\InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Obblm\Core\Exception\NotFoundKeyException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Obblm\Core\Helper\Rule\Inducement\StarPlayer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Obblm\Core\Helper\Rule\Roster\Roster; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Obblm\Core\Validator\Constraints\Team\AdditionalSkills; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /***************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * PLAYER METHODS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  ****************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | trait AbstractPlayerRuleTrait | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     abstract public function getRoster(Team $team):RosterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @param PlayerVersion $playerVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     public function playerIsDisposable(PlayerVersion $playerVersion):bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         return in_array('disposable', $playerVersion->getSkills()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     public function getPlayerPosition(Player $player):PositionInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             return $this->getRoster($player->getTeam())->getPosition($player->getPosition()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         } catch (NotFoundKeyException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             return $this->getStarPlayer($player->getName()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @param string $rosterKey | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function getAvailablePlayerForTeamCreation(Team $team) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         /** @var Roster $roster */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $positions = $this->getRoster($team)->getPositions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $options = $team->getCreationOptions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         if (isset($options['star_players_allowed']) && $options['star_players_allowed']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             $starPlayers = $this->getAvailableStarPlayers($team); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             foreach ($starPlayers as $starPlayer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |                 if ($starPlayer instanceof StarPlayer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                     $positions[$starPlayer->getKey()] = $starPlayer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         return $positions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @param string $roster | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function getAvailablePlayerKeyTypes(string $roster):array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         return array_keys($this->getRosters()->get($roster)->getPositions()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @param PlayerVersion $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param PositionInterface $position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @return PlayerVersion|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function setPlayerDefaultValues(PlayerVersion $version, PositionInterface $position): ?PlayerVersion | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $version->setCharacteristics($position->getCharacteristics()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             ->setActions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                 'td' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                 'cas' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 'pas' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                 'int' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                 'mvp' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             ->setSkills($position->getSkills()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             ->setValue($position->getCost()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             ->setSppLevel($this->getSppLevel($version)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         return $version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @param $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @return object|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @throws \Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function getInjury($key):?object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         if (!$this->getInjuries()->containsKey($key)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             throw new NotFoundKeyException($key, 'getInjuries', self::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         return $this->getInjuries()->get($key); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /************************** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * PLAYER EVOLUTION METHOD | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      *************************/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @param PlayerVersion $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * @return string|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     public function getSppLevel(PlayerVersion $version):?string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         if ($version->getSpp() && $version->getSpp() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             if ($this->getSppLevels()->containsKey($version->getSpp())) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 return $this->getSppLevels()->get($version->getSpp()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             return $this->getSppLevels()->last(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         return $this->getSppLevels()->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     public function getContextForRoll(array $roll):?array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $context = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         if (isset($roll['d6_1']) && isset($roll['d6_2'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $context = ['single']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             if ($roll['d6_1'] && $roll['d6_2']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 if ($roll['d6_1'] === $roll['d6_2']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |                     $context[] = 'double'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 if (($roll['d6_1'] + $roll['d6_2']) == 10) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                     $context[] = 'm_up'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                     $context[] = 'av_up'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                 if (($roll['d6_1'] + $roll['d6_2']) == 11) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                     $context[] = 'ag_up'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                 if (($roll['d6_1'] + $roll['d6_2']) == 12) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                     $context[] = 'st_up'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         return $context; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     public function getAvailableSkills(?PlayerVersion $version, $context = ['single', 'double']):?ArrayCollection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $criteria = Criteria::create(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         if ($version) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             if (!$version->getPlayer()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 throw new InvalidArgumentException(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $availableTypes = $this->getAvailableSkillsFor($version->getPlayer()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             $filers = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             if (in_array('single', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 $filers[] = Criteria::expr()->in('type', $availableTypes['single']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             if (in_array('double', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                 $filers[] = Criteria::expr()->in('type', $availableTypes['double']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             if (in_array('av_up', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |                 $filers[] = Criteria::expr()->eq('key', 'armor_increase'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             if (in_array('m_up', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |                 $filers[] = Criteria::expr()->eq('key', 'move_increase'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             if (in_array('ag_up', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 $filers[] = Criteria::expr()->eq('key', 'agility_increase'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             if (in_array('st_up', $context)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                 $filers[] = Criteria::expr()->eq('key', 'strength_increase'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             if (count($filers) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                 $composite = new CompositeExpression(CompositeExpression::TYPE_OR, $filers); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                 $criteria->where(Criteria::expr()->orX($composite)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         $criteria->orderBy(['key' => 'asc']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         return $this->getSkills()->matching($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     public function getPlayerVersionExtraCosts(PlayerVersion $version):int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $extraCost = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         $team = $version->getPlayer()->getTeam(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         if ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             !$team->getCreationOption('skills_allowed') || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             $team->getCreationOption('skills_allowed') && $team->getCreationOption('skills_allowed.choice') == AdditionalSkills::NOT_FREE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             foreach ($version->getAdditionalSkills() as $skill) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |                 $extraCost += $this->getSkillCostForPlayerVersion($version, $skill); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         return $extraCost; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     private function getSkillCostForPlayerVersion(PlayerVersion $version, $skill):int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         if (!$skill) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         $context = $this->getSkillContextForPlayerVersion($version, $skill); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         $rule = $this->getAttachedRule()->getRule(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         if (is_int($rule['experience_value_modifiers'][$context])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             return $rule['experience_value_modifiers'][$context]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         throw new NotFoundKeyException($context, 'experience_value_modifiers', $this); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |     public function getSkillContextForPlayerVersion(PlayerVersion $version, $skill):string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         if (is_string($skill)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             $skill = (new StringToSkill($this))->transform($skill); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         $position = $this->getPlayerPosition($version->getPlayer()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         if ($skill->getType() == 'c') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             return 'characteristics'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         if (in_array($skill->getType(), $position->getOption('available_skills_on_double'))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             return 'double'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         if (in_array($skill->getType(), $position->getOption('available_skills'))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             return 'single'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         throw new NotFoundKeyException($skill->getType(), 'skill_types', $this); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     abstract public function getSkills():ArrayCollection; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |     private function getAvailableSkillsFor(Player $player):array | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |         $position = $this->getRoster($player->getTeam())->getPosition($player->getPosition()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  |         return [ | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  |             'single' => $position->getOption('available_skills'), | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  |             'double' => $position->getOption('available_skills_on_double') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 251 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 252 |  |  |  |