/** * @test */ public function I_can_get_round_average_of_two_numbers() { $firstNumber = 1.5123; $secondNumber = 2.5123; $this->assertSame(2, SumAndRound::average($firstNumber, $secondNumber)); $firstNumber = 0.49999; $secondNumber = 2.4999; $this->assertSame(1, SumAndRound::average($firstNumber, $secondNumber)); }
/** * @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())); } }
/** * @param Strength $strength * @param Agility $agility * @param Height $height */ public function __construct(Strength $strength, Agility $agility, Height $height) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ parent::__construct(SumAndRound::average($strength->getValue(), $agility->getValue()) + SumAndRound::ceil($height->getValue() / 3) - 2); }
/** * @param Strength $strength * @param Will $will */ public function __construct(Strength $strength, Will $will) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ parent::__construct(SumAndRound::average($strength->getValue(), $will->getValue())); }
protected function calculateValue($firstPropertyValue, $secondPropertyValue, $charismaValue) { return SumAndRound::average($firstPropertyValue, $secondPropertyValue) + SumAndRound::half($charismaValue); }
/** * @param IntegerInterface $firstProperty * @param IntegerInterface $secondProperty * @param Charisma $charisma */ protected function __construct(IntegerInterface $firstProperty, IntegerInterface $secondProperty, Charisma $charisma) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ parent::__construct(SumAndRound::average($firstProperty->getValue(), $secondProperty->getValue()) + SumAndRound::half($charisma->getValue())); }