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()); }
/** * @test */ public function I_got_everything_empty_or_zeroed_from_empty_new_levels() { $professionLevels = new ProfessionLevels($zeroLevel = $this->createZeroLevel(), $firstLevel = $this->createFirstLevel(Fighter::FIGHTER)); self::assertSame(0, $professionLevels->getNextLevelsStrengthModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Strength::STRENGTH)); self::assertSame(0, $professionLevels->getNextLevelsAgilityModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Agility::AGILITY)); self::assertSame(0, $professionLevels->getNextLevelsKnackModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Knack::KNACK)); self::assertSame(0, $professionLevels->getNextLevelsWillModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Will::WILL)); self::assertSame(0, $professionLevels->getNextLevelsIntelligenceModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Intelligence::INTELLIGENCE)); self::assertSame(0, $professionLevels->getNextLevelsCharismaModifier()); self::assertSame(0, $professionLevels->getNextLevelsPropertyModifier(Charisma::CHARISMA)); self::assertCount(0, $professionLevels->getProfessionNextLevels()); self::assertEquals([$zeroLevel, $firstLevel], $professionLevels->getSortedProfessionLevels()); $levelsFromIteration = []; foreach ($professionLevels as $professionLevel) { $levelsFromIteration[] = $professionLevel; } self::assertEquals($levelsFromIteration, $professionLevels->getSortedProfessionLevels()); self::assertNull($professionLevels->getId()); }
private function getNextLevelsPhysicalPropertiesSum(ProfessionLevels $professionLevels) { return $professionLevels->getNextLevelsStrengthModifier() + $professionLevels->getNextLevelsAgilityModifier(); }
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']); } } }