/** * @test * @dataProvider provideBasePropertyValues * @param $strength * @param $agility * @param $knack * @param $will * @param $intelligence * @param $charisma */ public function I_can_get_every_property_both_limited_and_unlimited($strength, $agility, $knack, $will, $intelligence, $charisma) { $race = CommonHuman::getIt(); $female = GenderCode::getIt(GenderCode::FEMALE); $exceptionalityProperties = $this->createExceptionalityProperties($strength, $agility, $knack, $will, $intelligence, $charisma); $professionLevels = $this->createProfessionLevels(); $weightInKgAdjustment = WeightInKg::getIt(12.3); $heightInCmAdjustment = HeightInCm::getIt(123.45); $age = Age::getIt(32); $tables = new Tables(); $firstLevelProperties = new FirstLevelProperties($race, $female, $exceptionalityProperties, $professionLevels, $weightInKgAdjustment, $heightInCmAdjustment, $age, $tables); self::assertSame($exceptionalityProperties, $firstLevelProperties->getExceptionalityProperties()); $expectedStrength = min($strength, 3) - 1; /* female */ self::assertInstanceOf(Strength::class, $firstLevelProperties->getFirstLevelStrength()); self::assertSame($expectedStrength, $firstLevelProperties->getFirstLevelStrength()->getValue()); self::assertSame(max(0, $strength - 3), $firstLevelProperties->getStrengthLossBecauseOfLimit()); $expectedAgility = min($agility, 3); self::assertInstanceOf(Agility::class, $firstLevelProperties->getFirstLevelAgility()); self::assertEquals($expectedAgility, $firstLevelProperties->getFirstLevelAgility()->getValue()); self::assertSame(max(0, $agility - 3), $firstLevelProperties->getAgilityLossBecauseOfLimit()); $expectedKnack = min($knack, 3); self::assertInstanceOf(Knack::class, $firstLevelProperties->getFirstLevelKnack()); self::assertEquals($expectedKnack, $firstLevelProperties->getFirstLevelKnack()->getValue()); self::assertSame(max(0, $knack - 3), $firstLevelProperties->getKnackLossBecauseOfLimit()); $expectedWill = min($will, 3); self::assertInstanceOf(Will::class, $firstLevelProperties->getFirstLevelWill()); self::assertEquals($expectedWill, $firstLevelProperties->getFirstLevelWill()->getValue()); self::assertSame(max(0, $will - 3), $firstLevelProperties->getWillLossBecauseOfLimit()); $expectedIntelligence = min($intelligence, 3); self::assertInstanceOf(Intelligence::class, $firstLevelProperties->getFirstLevelIntelligence()); self::assertEquals($expectedIntelligence, $firstLevelProperties->getFirstLevelIntelligence()->getValue()); self::assertSame(max(0, $intelligence - 3), $firstLevelProperties->getIntelligenceLossBecauseOfLimit()); $expectedCharisma = min($charisma, 3) + 1; /* female */ self::assertInstanceOf(Charisma::class, $firstLevelProperties->getFirstLevelCharisma()); self::assertEquals($expectedCharisma, $firstLevelProperties->getFirstLevelCharisma()->getValue()); self::assertSame(max(0, $charisma - 3), $firstLevelProperties->getCharismaLossBecauseOfLimit()); $expectedSize = -1; /* female */ if ($strength === 0) { $expectedSize--; } else { if ($strength > 1) { $expectedSize++; } } self::assertInstanceOf(Size::class, $firstLevelProperties->getFirstLevelSize()); self::assertSame($expectedSize, $firstLevelProperties->getFirstLevelSize()->getValue()); self::assertSame($weightInKgAdjustment, $firstLevelProperties->getFirstLevelWeightInKgAdjustment()); self::assertEquals(WeightInKg::getIt(70 + $weightInKgAdjustment->getValue()), $firstLevelProperties->getFirstLevelWeightInKg()); self::assertSame($heightInCmAdjustment, $firstLevelProperties->getFirstLevelHeightInCmAdjustment()); self::assertSame($heightInCm = HeightInCm::getIt(180 + $heightInCmAdjustment->getValue()), $firstLevelProperties->getFirstLevelHeightInCm()); self::assertEquals(new Height($heightInCm, $tables->getDistanceTable()), $firstLevelProperties->getFirstLevelHeight()); self::assertSame($age, $firstLevelProperties->getFirstLevelAge()); }
/** * @param Race $race * @param GenderCode $genderCode * @param ExceptionalityProperties $exceptionalityProperties * @param ProfessionLevels $professionLevels * @param WeightInKg $weightInKgAdjustment * @param HeightInCm $heightInCm * @param Age $age * @param Tables $tables * @throws Exceptions\TooLowStrengthAdjustment */ public function __construct(Race $race, GenderCode $genderCode, ExceptionalityProperties $exceptionalityProperties, ProfessionLevels $professionLevels, WeightInKg $weightInKgAdjustment, HeightInCm $heightInCm, Age $age, Tables $tables) { $this->firstLevelProperties = new FirstLevelProperties($race, $genderCode, $exceptionalityProperties, $professionLevels, $weightInKgAdjustment, $heightInCm, $age, $tables); $this->nextLevelsProperties = new NextLevelsProperties($professionLevels); $this->strength = Strength::getIt($this->firstLevelProperties->getFirstLevelStrength()->getValue() + $this->nextLevelsProperties->getNextLevelsStrength()->getValue()); $this->agility = Agility::getIt($this->firstLevelProperties->getFirstLevelAgility()->getValue() + $this->nextLevelsProperties->getNextLevelsAgility()->getValue()); $this->knack = Knack::getIt($this->firstLevelProperties->getFirstLevelKnack()->getValue() + $this->nextLevelsProperties->getNextLevelsKnack()->getValue()); $this->will = Will::getIt($this->firstLevelProperties->getFirstLevelWill()->getValue() + $this->nextLevelsProperties->getNextLevelsWill()->getValue()); $this->intelligence = Intelligence::getIt($this->firstLevelProperties->getFirstLevelIntelligence()->getValue() + $this->nextLevelsProperties->getNextLevelsIntelligence()->getValue()); $this->charisma = Charisma::getIt($this->firstLevelProperties->getFirstLevelCharisma()->getValue() + $this->nextLevelsProperties->getNextLevelsCharisma()->getValue()); // delivered properties $this->toughness = new Toughness($this->getStrength(), $race->getRaceCode(), $race->getSubraceCode(), $tables->getRacesTable()); $this->endurance = new Endurance($this->getStrength(), $this->getWill()); $this->speed = new Speed($this->getStrength(), $this->getAgility(), $this->getHeight()); $this->senses = new Senses($this->getKnack(), RaceCode::getIt($race->getRaceCode()), SubRaceCode::getIt($race->getSubraceCode()), $tables->getRacesTable()); // aspects of visage $this->beauty = new Beauty($this->getAgility(), $this->getKnack(), $this->getCharisma()); $this->dangerousness = new Dangerousness($this->getStrength(), $this->getWill(), $this->getCharisma()); $this->dignity = new Dignity($this->getIntelligence(), $this->getWill(), $this->getCharisma()); /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ $this->fightNumber = new FightNumber(ProfessionCode::getIt($professionLevels->getFirstLevel()->getProfession()->getValue()), $this, $this->getHeight()); $this->attack = new Attack($this->getAgility()); $this->shooting = new Shooting($this->getKnack()); $this->defenseNumber = new DefenseNumber($this->getAgility()); $this->defenseAgainstShooting = new DefenseNumberAgainstShooting($this->getDefenseNumber(), $this->getSize()); $this->woundsLimit = new WoundBoundary($this->getToughness(), $tables->getWoundsTable()); $this->fatigueLimit = new FatigueBoundary($this->getEndurance(), $tables->getFatigueTable()); }