/** * @test */ public function I_get_rounds_to_put_on_armor_related_to_its_protection() { $bodyArmorsTable = new BodyArmorsTable(); foreach (BodyArmorCode::getPossibleValues() as $bodyArmorCode) { if ($bodyArmorCode === BodyArmorCode::WITHOUT_ARMOR) { self::assertFalse($bodyArmorsTable->getRoundsToPutOnOf($bodyArmorCode)); } else { self::assertSame(SumAndRound::ceiledThird($bodyArmorsTable->getProtectionOf($bodyArmorCode)), $bodyArmorsTable->getRoundsToPutOnOf($bodyArmorCode)); } } }
/** * @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())); } }
/** * @test */ public function I_can_get_ceiled_third() { $number = 5; $this->assertSame(2, SumAndRound::ceiledThird($number)); $number = 2.9999; $this->assertSame(1, SumAndRound::ceiledThird($number)); $number = 98.7; $this->assertSame(33, SumAndRound::ceiledThird($number)); }