/** * @test */ public function I_can_create_any_profession_fom_generic_by_code() { foreach (ProfessionCode::getPossibleValues() as $professionCode) { $profession = Profession::getItByCode(ProfessionCode::getIt($professionCode)); $namespace = str_replace('Tests\\', '', __NAMESPACE__); $classBaseName = ucfirst($professionCode); self::assertInstanceOf($namespace . '\\' . $classBaseName, $profession); } }
/** * @return array */ protected function getExpectedDataHeaderNamesToTypes() { $professionsWithSkillTypes = []; foreach (ProfessionCode::getPossibleValues() as $professionCode) { foreach (SkillTypeCode::getPossibleValues() as $skillTypeCode) { $professionsWithSkillTypes["{$professionCode} {$skillTypeCode}"] = self::INTEGER; } } return $professionsWithSkillTypes; }
/** * @param ProfessionCode $professionCode * @param BaseProperties $baseProperties * @param Height $height * @return int * @throws \DrdPlus\Properties\Combat\Exceptions\UnknownProfession */ private function calculateValue(ProfessionCode $professionCode, BaseProperties $baseProperties, Height $height) { $modifierByHeight = SumAndRound::ceiledThird($height->getValue()) - 2; switch ($professionCode->getValue()) { case ProfessionCode::FIGHTER: return $baseProperties->getAgility()->getValue() + $modifierByHeight; case ProfessionCode::THIEF: case ProfessionCode::RANGER: // same as a thief return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getKnack()->getValue()) + $modifierByHeight; case ProfessionCode::WIZARD: case ProfessionCode::THEURGIST: // same as a wizard return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getIntelligence()->getValue()) + $modifierByHeight; case ProfessionCode::PRIEST: return SumAndRound::average($baseProperties->getAgility()->getValue(), $baseProperties->getCharisma()->getValue()) + $modifierByHeight; default: throw new Exceptions\UnknownProfession('Unknown profession of code ' . ValueDescriber::describe($professionCode->getValue())); } }
public static function registerSelf() { parent::registerSelf(); // ARMAMENTS static::registerCodeAsSubType(ArrowCode::getIt(ArrowCode::BASIC_ARROW)); static::registerCodeAsSubType(BodyArmorCode::getIt(BodyArmorCode::CHAINMAIL_ARMOR)); static::registerCodeAsSubType(DartCode::getIt(DartCode::BASIC_DART)); static::registerCodeAsSubType(HelmCode::getIt(HelmCode::BARREL_HELM)); static::registerCodeAsSubType(MeleeWeaponCode::getIt(MeleeWeaponCode::HAND)); static::registerCodeAsSubType(RangedWeaponCode::getIt(RangedWeaponCode::HEAVY_CROSSBOW)); static::registerCodeAsSubType(ShieldCode::getIt(ShieldCode::BUCKLER)); static::registerCodeAsSubType(SlingStoneCode::getIt(SlingStoneCode::SLING_STONE_HEAVIER)); static::registerCodeAsSubType(WeaponCategoryCode::getIt(WeaponCategoryCode::ARROW)); // BODY static::registerCodeAsSubType(ActivityAffectingHealingCode::getIt(ActivityAffectingHealingCode::LIGHT_ACTIVITY)); static::registerCodeAsSubType(AfflictionByWoundDomainCode::getIt(AfflictionByWoundDomainCode::PHYSICAL)); static::registerCodeAsSubType(ConditionsAffectingHealingCode::getIt(ConditionsAffectingHealingCode::BAD_CONDITIONS)); static::registerCodeAsSubType(RestConditionsCode::getIt(RestConditionsCode::FOUL_CONDITIONS)); static::registerCodeAsSubType(WoundsOriginCode::getIt(WoundsOriginCode::ELEMENTAL)); static::registerCodeAsSubType(WoundTypeCode::getIt(WoundTypeCode::CRUSH)); // COMBAT ACTIONS static::registerCodeAsSubType(CombatActionCode::getIt(CombatActionCode::ATTACKED_FROM_BEHIND)); static::registerCodeAsSubType(MeleeCombatActionCode::getIt(MeleeCombatActionCode::COVER_OF_ALLY)); static::registerCodeAsSubType(RangedCombatActionCode::getIt(RangedCombatActionCode::AIMED_SHOT)); // ENVIRONMENT static::registerCodeAsSubType(LightConditionsCode::getIt(LightConditionsCode::STRONG_DAYLIGHT)); static::registerCodeAsSubType(LightSourceCode::getIt(LightSourceCode::BALEFIRE)); static::registerCodeAsSubType(LightSourceEnvironmentCode::getIt(LightSourceEnvironmentCode::MIRROR_BEHIND_LIGHT_SOURCE)); static::registerCodeAsSubType(TerrainCode::getIt(TerrainCode::DESERT)); // SKILLS static::registerCodeAsSubType(CombinedSkillCode::getIt(CombinedSkillCode::BIG_HANDWORK)); static::registerCodeAsSubType(PhysicalSkillCode::getIt(PhysicalSkillCode::ATHLETICS)); static::registerCodeAsSubType(PsychicalSkillCode::getIt(PsychicalSkillCode::ASTRONOMY)); static::registerCodeAsSubType(SkillTypeCode::getIt(SkillTypeCode::COMBINED)); // OTHERS static::registerCodeAsSubType(ElementCode::getIt(ElementCode::AIR)); static::registerCodeAsSubType(GenderCode::getIt(GenderCode::FEMALE)); static::registerCodeAsSubType(ItemHoldingCode::getIt(ItemHoldingCode::MAIN_HAND)); static::registerCodeAsSubType(MovementTypeCode::getIt(MovementTypeCode::RUN)); static::registerCodeAsSubType(ProfessionCode::getIt(ProfessionCode::COMMONER)); static::registerCodeAsSubType(PropertyCode::getIt(PropertyCode::AGE)); static::registerCodeAsSubType(RaceCode::getIt(RaceCode::DWARF)); static::registerCodeAsSubType(RidingAnimalCode::getIt(RidingAnimalCode::BULL)); static::registerCodeAsSubType(RidingAnimalMovementCode::getIt(RidingAnimalMovementCode::CANTER)); static::registerCodeAsSubType(RidingAnimalPropertyCode::getIt(RidingAnimalPropertyCode::DEFIANCE)); static::registerCodeAsSubType(SubRaceCode::getIt(SubRaceCode::COMMON)); static::registerCodeAsSubType(TimeCode::getIt(TimeCode::DAY)); }
public function provideSkillPointToProfession() { $combinations = []; $rowIndex = 0; for ($backgroundSkillPoint = 0; $backgroundSkillPoint <= 8; $backgroundSkillPoint++) { $columnIndex = 0; foreach (ProfessionCode::getPossibleValues() as $professionCode) { foreach (SkillTypeCode::getPossibleValues() as $skillTypeCode) { $combinations[] = [$backgroundSkillPoint, $professionCode, $skillTypeCode, $this->getExpectedSkillPoints($rowIndex, $columnIndex)]; $columnIndex++; } } $rowIndex++; } return $combinations; }
/** * @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()); }
public function provideProfessionInfo() { return [[ProfessionCode::getIt(ProfessionCode::FIGHTER), $this->createBaseProperties($agility = 123, 0, 0, 0), $this->createHeight($height = -2), (int) ($agility + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::FIGHTER), $this->createBaseProperties($agility = 456, 0, 0, 0), $this->createHeight($height = 7), (int) ($agility + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::THIEF), $this->createBaseProperties($agility = 123, $knack = 234, 0, 0), $this->createHeight($height = -2), (int) (round(($agility + $knack) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::THIEF), $this->createBaseProperties($agility = 456, $knack = 567, 0, 0), $this->createHeight($height = 7), (int) (round(($agility + $knack) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::RANGER), $this->createBaseProperties($agility = 123, $knack = 234, 0, 0), $this->createHeight($height = -2), (int) (round(($agility + $knack) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::RANGER), $this->createBaseProperties($agility = 456, $knack = 567, 0, 0), $this->createHeight($height = 7), (int) (round(($agility + $knack) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::WIZARD), $this->createBaseProperties($agility = 123, 0, $intelligence = 234, 0), $this->createHeight($height = -2), (int) (round(($agility + $intelligence) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::WIZARD), $this->createBaseProperties($agility = 456, 0, $intelligence = 567, 0), $this->createHeight($height = 7), (int) (round(($agility + $intelligence) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::THEURGIST), $this->createBaseProperties($agility = 123, 0, $intelligence = 234, 0), $this->createHeight($height = -2), (int) (round(($agility + $intelligence) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::THEURGIST), $this->createBaseProperties($agility = 456, 0, $intelligence = 567, 0), $this->createHeight($height = 7), (int) (round(($agility + $intelligence) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::PRIEST), $this->createBaseProperties($agility = 123, 0, 0, $charisma = 234), $this->createHeight($height = -2), (int) (round(($agility + $charisma) / 2) + ceil($height / 3) - 2)], [ProfessionCode::getIt(ProfessionCode::PRIEST), $this->createBaseProperties($agility = 456, 0, 0, $charisma = 567), $this->createHeight($height = 7), (int) (round(($agility + $charisma) / 2) + ceil($height / 3) - 2)]]; }
/** * @return ProfessionCode */ public function getCode() { return ProfessionCode::getIt($this->getValue()); }