/**
  * @param LevelRank $levelRank
  * @throws \DrdPlus\Person\ProfessionLevels\Exceptions\MinimumLevelExceeded
  * @throws \DrdPlus\Person\ProfessionLevels\Exceptions\MaximumLevelExceeded
  */
 protected function checkLevelRank(LevelRank $levelRank)
 {
     if ($levelRank->getValue() < self::MINIMUM_NEXT_LEVEL) {
         throw new Exceptions\MinimumLevelExceeded('Next level can not be lesser than ' . self::MINIMUM_NEXT_LEVEL . ", got {$levelRank->getValue()}");
     }
     if ($levelRank->getValue() > self::MAXIMUM_NEXT_LEVEL) {
         throw new Exceptions\MaximumLevelExceeded('Level can not be greater than ' . self::MAXIMUM_NEXT_LEVEL . ", got {$levelRank->getValue()}");
     }
 }
 /**
  * @test
  * @dataProvider provideIncrementedProperty
  * @expectedException \DrdPlus\Person\ProfessionLevels\Exceptions\InvalidZeroLevelPropertyValue
  * @param Strength $strength
  * @param Agility $agility
  * @param Knack $knack
  * @param Will $will
  * @param Intelligence $intelligence
  * @param Charisma $charisma
  */
 public function I_can_not_create_it_with_property_increment(Strength $strength, Agility $agility, Knack $knack, Will $will, Intelligence $intelligence, Charisma $charisma)
 {
     $professionZeroLevel = ProfessionZeroLevel::createZeroLevel($commoner = Commoner::getIt());
     $reflection = new \ReflectionClass(ProfessionZeroLevel::class);
     /** @see \DrdPlus\Person\ProfessionLevels\ProfessionLevel::__construct */
     $constructor = $reflection->getMethod('__construct');
     $constructor->setAccessible(true);
     $constructor->invokeArgs($professionZeroLevel, [$commoner, LevelRank::getIt(0), $strength, $agility, $knack, $will, $intelligence, $charisma]);
 }
 /**
  * @test
  */
 public function I_can_create_it()
 {
     $zeroLevel = $this->createZeroLevel();
     $firstLevel = $this->createFirstLevel('fighter');
     $withFirstLevelOnly = new ProfessionLevels($zeroLevel, $firstLevel);
     self::assertNotNull($withFirstLevelOnly);
     $anotherInstance = ProfessionLevels::createIt($zeroLevel, $firstLevel);
     self::assertEquals($withFirstLevelOnly, $anotherInstance);
     $yetAnotherInstance = ProfessionLevels::createIt($zeroLevel, $firstLevel);
     self::assertNotSame($anotherInstance, $yetAnotherInstance);
     $withExplicitlyEmptyNextLevels = ProfessionLevels::createIt($zeroLevel, $firstLevel, []);
     self::assertEquals($withFirstLevelOnly, $withExplicitlyEmptyNextLevels);
     $withNextLevels = ProfessionLevels::createIt($zeroLevel, $firstLevel, $nextLevels = [ProfessionNextLevel::createNextLevel(Fighter::getIt(), LevelRank::getIt(2), Strength::getIt(1), Agility::getIt(0), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(1), Charisma::getIt(0))]);
     self::assertNotEquals($withFirstLevelOnly, $withNextLevels);
 }
 protected function checkLevelRank(LevelRank $levelRank)
 {
     if ($levelRank->getValue() !== 0) {
         throw new Exceptions\InvalidZeroLevelRank("Zero level has to have level rank 0, got {$levelRank->getValue()}");
     }
 }
 /**
  * @param string $propertyCodeTooHigh
  *
  * @test
  * @dataProvider providePropertyCodeOneByOne
  * @expectedException \DrdPlus\Person\ProfessionLevels\Exceptions\TooHighNextLevelPropertyIncrement
  */
 public function I_can_not_create_next_level_with_too_high_property_increment($propertyCodeTooHigh)
 {
     ProfessionNextLevel::createNextLevel($this->createProfession(ProfessionCode::FIGHTER), $levelRank = LevelRank::getIt(2), Strength::getIt($propertyCodeTooHigh === Strength::STRENGTH ? 2 : 0), Agility::getIt($propertyCodeTooHigh === Agility::AGILITY ? 2 : 0), Knack::getIt($propertyCodeTooHigh === Knack::KNACK ? 2 : 0), Will::getIt($propertyCodeTooHigh === Will::WILL ? 2 : 0), Intelligence::getIt($propertyCodeTooHigh === Intelligence::INTELLIGENCE ? 2 : 0), Charisma::getIt($propertyCodeTooHigh === Charisma::CHARISMA ? 2 : 0));
 }
 /**
  * @return array
  */
 public static function createEntities()
 {
     $professionLevels = new ProfessionLevels(ProfessionZeroLevel::createZeroLevel(Commoner::getIt()), ProfessionFirstLevel::createFirstLevel($profession = Theurgist::getIt()));
     $professionLevels->addLevel(ProfessionNextLevel::createNextLevel($profession, LevelRank::getIt(2), Strength::getIt(1), Agility::getIt(0), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(1), Charisma::getIt(0)));
     return [ProfessionZeroLevel::createZeroLevel(Commoner::getIt()), ProfessionFirstLevel::createFirstLevel(Fighter::getIt()), ProfessionNextLevel::createNextLevel(Wizard::getIt(), LevelRank::getIt(2), Strength::getIt(1), Agility::getIt(1), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(0), Charisma::getIt(0)), $professionLevels];
 }
 /**
  * @param LevelRank $levelRank
  * @param Strength $strength
  * @param Agility $agility
  * @param Knack $knack
  * @param Will $will
  * @param Intelligence $intelligence
  * @param Charisma $charisma
  * @throws Exceptions\InvalidNextLevelPropertiesSum
  */
 private function checkPropertySumIncrement(LevelRank $levelRank, Strength $strength, Agility $agility, Knack $knack, Will $will, Intelligence $intelligence, Charisma $charisma)
 {
     if ($levelRank->isNextLevel()) {
         // note: first level properties are covered by one-by-one tests
         $sumOfProperties = $this->sumProperties($strength, $agility, $knack, $will, $intelligence, $charisma);
         if ($sumOfProperties !== $this->getExpectedSumOfNextLevelProperties()) {
             throw new Exceptions\InvalidNextLevelPropertiesSum("Sum of {$levelRank->getValue()}. level properties should be " . $this->getExpectedSumOfNextLevelProperties() . ', got ' . $sumOfProperties);
         }
     }
 }
 protected function checkLevelRank(LevelRank $levelRank)
 {
     if ($levelRank->getValue() !== 1) {
         throw new Exceptions\InvalidFirstLevelRank("First level has to have level rank 1, got {$levelRank->getValue()}");
     }
 }
 public static function createSkillsEntity(Tables $tables)
 {
     return Skills::createSkills(ProfessionLevels::createIt(ProfessionFirstLevel::createFirstLevel($profession = Fighter::getIt()), [ProfessionNextLevel::createNextLevel($profession, LevelRank::getIt(2), Strength::getIt(0), Agility::getIt(1), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(1), Charisma::getIt(0))]), BackgroundSkillPoints::getIt(2, Heritage::getIt(7)), $tables, new PhysicalSkills(), new PsychicalSkills(), new CombinedSkills());
 }
 /**
  * @param int $prohibitedValue
  * @test
  * @dataProvider provideProhibitedLevelValue
  * @expectedException \DrdPlus\Person\ProfessionLevels\Exceptions\InvalidLevelRank
  */
 public function I_can_not_create_negative_level($prohibitedValue)
 {
     LevelRank::getIt($prohibitedValue);
 }