/** * @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()}"); } }
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 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()}"); } }