/** * @param MovementTypesTable $movementTypesTable * @param string $movementTypeCode * @param SpeedTable $speedTable * @param string $terrainCode * @param TerrainDifficultyPercents $terrainDifficultyPercents * @param ImpassibilityOfTerrainTable $impassibilityOfTerrainTable * @return SpeedBonus * @throws \DrdPlus\Tables\Body\MovementTypes\Exceptions\UnknownMovementType * @throws \DrdPlus\Tables\Environments\Exceptions\UnknownTerrainCode * @throws \DrdPlus\Tables\Environments\Exceptions\InvalidTerrainCodeFormat */ public function getCurrentSpeedBonus(MovementTypesTable $movementTypesTable, $movementTypeCode, SpeedTable $speedTable, $terrainCode, TerrainDifficultyPercents $terrainDifficultyPercents, ImpassibilityOfTerrainTable $impassibilityOfTerrainTable) { $movementTypeBonus = $movementTypesTable->getSpeedBonus($movementTypeCode); $terrainMalus = $impassibilityOfTerrainTable->getSpeedMalusOnTerrain($terrainCode, $speedTable, $terrainDifficultyPercents); /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return new SpeedBonus($this->getValue() + $movementTypeBonus->getValue() + $terrainMalus->getValue(), $speedTable); }
/** * @param Endurance $endurance * @return TimeBonus * @throws \DrdPlus\Tables\Measurements\Time\Exceptions\CanNotConvertThatBonusToTime */ public function getRequiredTimeBonusToWalkAfterFullGallop(Endurance $endurance) { return $this->movementTypesTable->getRequiredTimeBonusToWalkAfterFullSprint($endurance); }
/** * @param int $missingStrength * @param AthleticsInterface $athletics * @param MovementTypesTable $movementTypesTable * @return Time|false Gives false if there is no fatigue from current load at all * @throws \DrdPlus\Tables\Body\FatigueByLoad\Exceptions\OverloadedAndCanNotMove * @throws \Granam\Integer\Tools\Exceptions\WrongParameterType * @throws \Granam\Integer\Tools\Exceptions\ValueLostOnCast */ public function getPeriodForPointOfFatigue($missingStrength, AthleticsInterface $athletics, MovementTypesTable $movementTypesTable) { $desiredRow = $this->getRowFittingToMissingStrength($missingStrength, $athletics); /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return $movementTypesTable->getPeriodForPointOfFatigue($desiredRow[self::WEARIES_LIKE]); }
/** * @test */ public function I_can_get_required_time_bonus_to_walk_after_full_gallop() { $speedTable = new SpeedTable(); $timeTable = new TimeTable(); $movementTypesTable = new MovementTypesTable($speedTable, $timeTable); $endurance = $this->createEndurance(12); self::assertEquals($movementTypesTable->getRequiredTimeBonusToWalkAfterFullSprint($endurance), (new RidingAnimalMovementTypesTable($speedTable = new SpeedTable(), new MovementTypesTable($speedTable, new TimeTable())))->getRequiredTimeBonusToWalkAfterFullGallop($endurance)); }
/** * @test */ public function I_can_get_required_time_of_walk_after_maximum_sprint() { $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable); $timeBonus = $movementTypesTable->getRequiredTimeBonusToWalkAfterFullSprint($this->createEndurance(456)); self::assertInstanceOf(TimeBonus::class, $timeBonus); self::assertSame(476, $timeBonus->getValue()); }