/** * @test */ public function I_can_get_unused_skill_points_from_next_levels() { $skills = new PsychicalSkills(); $professionLevels = $this->createProfessionLevels($firstLevelWill = 123, $firstLevelIntelligence = 456, $nextLevelsWill = 321, $nextLevelsIntelligence = 654); self::assertSame($nextLevelsWill + $nextLevelsIntelligence, $skills->getUnusedNextLevelsPsychicalSkillPointsValue($professionLevels)); $skills->addPsychicalSkill($this->createPsychicalSkill($rankFromFirstLevel = 2, 1, Mythology::class)); self::assertSame($nextLevelsWill + $nextLevelsIntelligence, $skills->getUnusedNextLevelsPsychicalSkillPointsValue($professionLevels)); $skills->addPsychicalSkill($this->createPsychicalSkill($aRankFromNextLevel = 3, 2, Technology::class)); $skills->addPsychicalSkill($this->createPsychicalSkill($anotherRankFromNextLevel = 1, 3, Zoology::class)); self::assertSame($nextLevelsWill + $nextLevelsIntelligence - (array_sum(range(1, $aRankFromNextLevel)) + array_sum(range(1, $anotherRankFromNextLevel))), $skills->getUnusedNextLevelsPsychicalSkillPointsValue($professionLevels), 'Expected ' . ($nextLevelsWill + $nextLevelsIntelligence - (array_sum(range(1, $aRankFromNextLevel)) + array_sum(range(1, $anotherRankFromNextLevel))))); }
private static function createPsychicalSkillEntities(Tables $tables, ProfessionFirstLevel $firstLevel) { $psychicalSkillClasses = self::getListOfSkillClasses(PsychicalSkill::class); $psychicalSkillPoint = PsychicalSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(3, Heritage::getIt(5)), $tables); $requiredRankValue = new PositiveIntegerObject(1); $psychicalSkillList = array_map(function ($psychicalSkillClass) use($firstLevel, $psychicalSkillPoint, $requiredRankValue) { /** @var PsychicalSkill $psychicalSkill */ $psychicalSkill = new $psychicalSkillClass($firstLevel); $psychicalSkill->addSkillRank($psychicalSkillPoint); return $psychicalSkill; }, $psychicalSkillClasses); $psychicalSkills = new PsychicalSkills(); foreach ($psychicalSkillList as $psychicalSkill) { $psychicalSkills->addPsychicalSkill($psychicalSkill); } $psychicalSkillPoint = PsychicalSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(4, Heritage::getIt(3)), $tables); $psychicalSkillRank = new PsychicalSkillRank(new Technology($firstLevel), PsychicalSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(4, Heritage::getIt(5)), $tables), new PositiveIntegerObject(1)); return array_merge($psychicalSkillList, [$psychicalSkills, $psychicalSkillPoint, $psychicalSkillRank]); }