/** * @param ProfessionCode $professionCode * @return Profession * @throws Exceptions\ProfessionNotFound */ public static function getItByCode(ProfessionCode $professionCode) { $baseClassName = implode(array_map('ucfirst', explode('_', $professionCode->getValue()))); /** @var Profession $className */ $className = __NAMESPACE__ . '\\' . $baseClassName; if (!class_exists($className)) { throw new Exceptions\ProfessionNotFound('No profession found by code ' . ValueDescriber::describe($professionCode)); } return $className::getIt(); }
/** * @param ProfessionCode $professionCode * @param BaseProperties $baseProperties * @param Height $height * @return int * @throws \DrdPlus\Properties\Combat\Exceptions\UnknownProfession */ private function calculateValue(ProfessionCode $professionCode, BaseProperties $baseProperties, Height $height) { $modifierByHeight = SumAndRound::ceiledThird($height->getValue()) - 2; switch ($professionCode->getValue()) { case ProfessionCode::FIGHTER: return $baseProperties->getAgility()->getValue() + $modifierByHeight; case ProfessionCode::THIEF: case ProfessionCode::RANGER: // same as a thief return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getKnack()->getValue()) + $modifierByHeight; case ProfessionCode::WIZARD: case ProfessionCode::THEURGIST: // same as a wizard return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getIntelligence()->getValue()) + $modifierByHeight; case ProfessionCode::PRIEST: return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getCharisma()->getValue()) + $modifierByHeight; default: throw new Exceptions\UnknownProfession('Unknown profession of code ' . ValueDescriber::describe($professionCode->getValue())); } }