/** * @param ExceptionalityFate $exceptionalityFate , * @param int $forHeritageSpentBackgroundPoints , * @param int $forBackgroundSkillPointsSpentBackgroundPoints * @param int $forBelongingsSpentBackgroundPoints * @return Background */ public static function createIt(ExceptionalityFate $exceptionalityFate, $forHeritageSpentBackgroundPoints, $forBackgroundSkillPointsSpentBackgroundPoints, $forBelongingsSpentBackgroundPoints) { $backgroundPoints = BackgroundPoints::getIt($exceptionalityFate); $heritage = Heritage::getIt($forHeritageSpentBackgroundPoints); $backgroundSkillPoints = BackgroundSkillPoints::getIt($forBackgroundSkillPointsSpentBackgroundPoints, $heritage); $belongingsValue = BelongingsValue::getIt($forBelongingsSpentBackgroundPoints, $heritage); return new static($backgroundPoints, $heritage, $backgroundSkillPoints, $belongingsValue); }
/** * @test * @dataProvider provideSkillType * @param string $skillType */ public function I_can_get_skill_points($skillType) { $backgroundSkillPoints = BackgroundSkillPoints::getIt($spentBackgroundPoints = 7, $heritage = $this->createHeritage($heritageValue = 456)); $tables = $this->mockery(Tables::class)->shouldReceive('getBackgroundSkillsTable')->atLeast()->once()->andReturn($backgroundSkillsTable = $this->mockery(\stdClass::class))->getMock(); $backgroundSkillsTable->shouldReceive('getSkillPoints')->with($spentBackgroundPoints, ProfessionCode::FIGHTER, $skillType)->atLeast()->once()->andReturn($result = 'foo')->getMock(); /** @var Tables $tables */ self::assertSame($result, $backgroundSkillPoints->getSkillPoints($this->createProfession(ProfessionCode::FIGHTER), $skillType, $tables)); switch ($skillType) { case SkillTypeCode::PHYSICAL: self::assertSame($result, $backgroundSkillPoints->getPhysicalSkillPoints($this->createProfession(ProfessionCode::FIGHTER), $tables)); break; case SkillTypeCode::PSYCHICAL: self::assertSame($result, $backgroundSkillPoints->getPsychicalSkillPoints($this->createProfession(ProfessionCode::FIGHTER), $tables)); break; case SkillTypeCode::COMBINED: self::assertSame($result, $backgroundSkillPoints->getCombinedSkillPoints($this->createProfession(ProfessionCode::FIGHTER), $tables)); break; } }
private static function createCombinedSkillEntities(Tables $tables, ProfessionFirstLevel $firstLevel) { $combinedSkillClasses = self::getListOfSkillClasses(CombinedSkill::class); $combinedSkillPoint = CombinedSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(3, Heritage::getIt(5)), $tables); $requiredRankValue = new PositiveIntegerObject(1); $combinedSkillList = array_map(function ($combinedSkillClass) use($firstLevel, $combinedSkillPoint, $requiredRankValue) { /** @var CombinedSkill $combinedSkill */ $combinedSkill = new $combinedSkillClass($firstLevel); $combinedSkill->addSkillRank($combinedSkillPoint); return $combinedSkill; }, $combinedSkillClasses); $combinedSkills = new CombinedSkills(); foreach ($combinedSkillList as $combinedSkill) { $combinedSkills->addCombinedSkill($combinedSkill); } $combinedSkillPoint = CombinedSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(3, Heritage::getIt(5)), $tables); $combinedSkillRank = new CombinedSkillRank(new Cooking($firstLevel), CombinedSkillPoint::createFromFirstLevelBackgroundSkillPoints($firstLevel, BackgroundSkillPoints::getIt(4, Heritage::getIt(5)), $tables), new PositiveIntegerObject(1)); return array_merge($combinedSkillList, [$combinedSkills, $combinedSkillPoint, $combinedSkillRank]); }