public function __construct(ProfessionLevels $professionLevels) { $this->nextLevelsStrength = Strength::getIt($professionLevels->getNextLevelsStrengthModifier()); $this->nextLevelsAgility = Agility::getIt($professionLevels->getNextLevelsAgilityModifier()); $this->nextLevelsKnack = Knack::getIt($professionLevels->getNextLevelsKnackModifier()); $this->nextLevelsWill = Will::getIt($professionLevels->getNextLevelsWillModifier()); $this->nextLevelsIntelligence = Intelligence::getIt($professionLevels->getNextLevelsIntelligenceModifier()); $this->nextLevelsCharisma = Charisma::getIt($professionLevels->getNextLevelsCharismaModifier()); }
/** * @param ProfessionZeroLevel $zeroLevel * @param ProfessionFirstLevel $firstLevel * * @return ProfessionLevels */ private function createProfessionLevelsWith(ProfessionZeroLevel $zeroLevel, ProfessionFirstLevel $firstLevel) { $professionLevels = new ProfessionLevels($zeroLevel, $firstLevel); self::assertSame($firstLevel, $professionLevels->getFirstLevel()); self::assertEquals([$zeroLevel, $firstLevel], $professionLevels->getSortedProfessionLevels()); return $professionLevels; }
private function checkLevelsAgainstExperiences(ProfessionLevels $professionLevels, Memories $memories, ExperiencesTable $experiencesTable) { $highestLevelRank = $professionLevels->getCurrentLevel()->getLevelRank(); $requiredExperiences = $experiencesTable->toTotalExperiences(new LevelBonus($highestLevelRank->getValue(), $experiencesTable)); $availableExperiences = $memories->getExperiences($experiencesTable); if ($availableExperiences->getValue() < $requiredExperiences->getValue()) { throw new Exceptions\InsufficientExperiences("Given level {$highestLevelRank} needs at least {$requiredExperiences} experiences, got only {$availableExperiences}"); } }
/** * @param Race $race * @param GenderCode $genderCode * @param Tables $tables * @param ExceptionalityProperties $exceptionalityProperties * @param ProfessionLevels $professionLevels * @return Size * @throws Exceptions\TooLowStrengthAdjustment */ private function createFirstLevelSize(Race $race, GenderCode $genderCode, Tables $tables, ExceptionalityProperties $exceptionalityProperties, ProfessionLevels $professionLevels) { // the race bonus is NOT count for adjustment, doesn't count to size change respectively $sizeModifierByStrength = $this->getSizeModifierByStrength($exceptionalityProperties->getStrength()->getValue() + $professionLevels->getFirstLevelStrengthModifier()); $raceSize = $race->getSize($genderCode, $tables); return Size::getIt($raceSize + $sizeModifierByStrength); }
/** * @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()); }
/** * @return array */ public static function createEntities() { $professionLevels = new ProfessionLevels(ProfessionZeroLevel::createZeroLevel(Commoner::getIt()), ProfessionFirstLevel::createFirstLevel($profession = Theurgist::getIt())); $professionLevels->addLevel(ProfessionNextLevel::createNextLevel($profession, LevelRank::getIt(2), Strength::getIt(1), Agility::getIt(0), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(1), Charisma::getIt(0))); return [ProfessionZeroLevel::createZeroLevel(Commoner::getIt()), ProfessionFirstLevel::createFirstLevel(Fighter::getIt()), ProfessionNextLevel::createNextLevel(Wizard::getIt(), LevelRank::getIt(2), Strength::getIt(1), Agility::getIt(1), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(0), Charisma::getIt(0)), $professionLevels]; }
private function getNextLevelsPhysicalPropertiesSum(ProfessionLevels $professionLevels) { return $professionLevels->getNextLevelsStrengthModifier() + $professionLevels->getNextLevelsAgilityModifier(); }
/** * @test * @dataProvider provideProfessionLevelsWithTooLowPropertyIncrease * @expectedException \DrdPlus\Skills\Exceptions\HigherSkillRanksFromNextLevelsThanPossible * @param ProfessionLevels $professionLevels */ public function I_can_not_increase_skills_by_next_levels_more_than_provides_property_increments(ProfessionLevels $professionLevels) { $nextLevel = $professionLevels->getProfessionNextLevels()->last(); $physicalSkills = $this->createPhysicalSkillsByNextLevelPropertyIncrease($nextLevel); $psychicalSkills = $this->createPsychicalSkillsByNextLevelPropertyIncrease($nextLevel); $combinedSkills = $this->createCombinedSkillsByNextLevelPropertyIncrease($nextLevel); $backgroundSkillPoints = $this->createBackgroundSkillPoints($professionLevels->getFirstLevel()->getProfession()); Skills::createSkills($professionLevels, $backgroundSkillPoints, new Tables(), $physicalSkills, $psychicalSkills, $combinedSkills); }
private function getNextLevelsPsychicalPropertiesSum(ProfessionLevels $professionLevels) { return $professionLevels->getNextLevelsWillModifier() + $professionLevels->getNextLevelsIntelligenceModifier(); }
private static function checkNextLevelsPayment(array $nextLevelsPayment, ProfessionLevels $professionLevels) { foreach ($nextLevelsPayment as $skillsType => $nextLevelPayment) { $increasedPropertySum = 0; /** @var string[][] $nextLevelPayment */ foreach ($nextLevelPayment['relatedProperties'] as $relatedProperty) { switch ($relatedProperty) { case Strength::STRENGTH: $increasedPropertySum += $professionLevels->getNextLevelsStrengthModifier(); break; case Agility::AGILITY: $increasedPropertySum += $professionLevels->getNextLevelsAgilityModifier(); break; case Knack::KNACK: $increasedPropertySum += $professionLevels->getNextLevelsKnackModifier(); break; case Will::WILL: $increasedPropertySum += $professionLevels->getNextLevelsWillModifier(); break; case Intelligence::INTELLIGENCE: $increasedPropertySum += $professionLevels->getNextLevelsIntelligenceModifier(); break; case Charisma::CHARISMA: $increasedPropertySum += $professionLevels->getNextLevelsCharismaModifier(); break; } } $maxSkillPoint = self::getSkillPointByPropertyIncrease($increasedPropertySum); if ($nextLevelPayment['spentNextLevelsSkillPoints'] > $maxSkillPoint) { /** @noinspection PhpToStringImplementationInspection */ throw new Exceptions\HigherSkillRanksFromNextLevelsThanPossible("Skills from next levels of type '{$skillsType}' have higher ranks than possible." . " Max increase by next levels can be {$maxSkillPoint} by {$increasedPropertySum} increase" . ' of related properties (' . implode(', ', $nextLevelPayment['relatedProperties']) . ')' . ', got ' . $nextLevelPayment['spentNextLevelsSkillPoints']); } } }
public static function createSkillsEntity(Tables $tables) { return Skills::createSkills(ProfessionLevels::createIt(ProfessionFirstLevel::createFirstLevel($profession = Fighter::getIt()), [ProfessionNextLevel::createNextLevel($profession, LevelRank::getIt(2), Strength::getIt(0), Agility::getIt(1), Knack::getIt(0), Will::getIt(0), Intelligence::getIt(1), Charisma::getIt(0))]), BackgroundSkillPoints::getIt(2, Heritage::getIt(7)), $tables, new PhysicalSkills(), new PsychicalSkills(), new CombinedSkills()); }
private function getNextLevelsCombinedPropertiesSum(ProfessionLevels $professionLevels) { return $professionLevels->getNextLevelsKnackModifier() + $professionLevels->getNextLevelsCharismaModifier(); }