/** * It is only the increment based on first level of specific profession. * There are other increments like race, size etc., solved in different library. * * @param BaseProperty $baseProperty * @param Profession $profession * @throws \DrdPlus\Person\ProfessionLevels\Exceptions\InvalidFirstLevelPropertyValue */ protected function checkPropertyIncrement(BaseProperty $baseProperty, Profession $profession) { $propertyFirstLevelModifier = static::getBasePropertyFirstLevelModifier($baseProperty->getCode(), $profession); if ($baseProperty->getValue() !== $propertyFirstLevelModifier) { throw new Exceptions\InvalidFirstLevelPropertyValue("On first level has to be {$baseProperty->getCode()} of value {$propertyFirstLevelModifier}" . ", got {$baseProperty->getValue()}"); } }
protected function checkPropertyIncrement(BaseProperty $baseProperty, Profession $profession) { if ($baseProperty->getValue() < 0) { throw new Exceptions\NegativeNextLevelProperty("Next level property increment can not be negative, got {$baseProperty->getValue()}"); } if ($baseProperty->getValue() > self::MAX_NEXT_LEVEL_PROPERTY_MODIFIER) { throw new Exceptions\TooHighNextLevelPropertyIncrement('Next level property increment has to be at most ' . self::MAX_NEXT_LEVEL_PROPERTY_MODIFIER . ", got {$baseProperty->getValue()}"); } }
/** * @param BaseProperty $baseProperty * @param Profession $profession * @throws Exceptions\InvalidZeroLevelPropertyValue */ protected function checkPropertyIncrement(BaseProperty $baseProperty, Profession $profession) { if ($baseProperty->getValue() !== 0) { throw new Exceptions\InvalidZeroLevelPropertyValue('Expected 0 as base property "increment" for zero level, got ' . $baseProperty->getValue()); } }
private function checkChosenProperty(ProfessionLevel $professionLevel, ExceptionalityFate $fate, BaseProperty $chosenProperty) { if ($chosenProperty->getValue() > $fate->getUpToSingleProperty()) { throw new Exceptions\InvalidValueOfChosenProperty("Requested {$chosenProperty->getCode()} value {$chosenProperty->getValue()} is higher than allowed" . " maximum {$fate->getUpToSingleProperty()} for profession {$professionLevel->getProfession()->getValue()}" . " and fate {$fate::getCode()}"); } }
/** * @param ProfessionLevel $newLevel * @param BaseProperty $propertyIncrement * @throws Exceptions\TooHighPrimaryPropertyIncrease * @throws Exceptions\TooHighSecondaryPropertyIncrease */ private function checkPropertyIncrementSequence(ProfessionLevel $newLevel, BaseProperty $propertyIncrement) { if ($propertyIncrement->getValue() > 0) { if ($newLevel->isPrimaryProperty($propertyIncrement->getCode())) { $this->checkPrimaryPropertyIncrementInARow($propertyIncrement); } else { $this->checkSecondaryPropertyIncrementInARow($propertyIncrement); } } }