/** * Gives effective strength usable for attack with given weapon (has usage for bows and crossbows). * * @param WeaponlikeCode $weaponlikeCode * @param Strength $currentStrength * @return Strength * @throws UnknownBow * @throws UnknownRangedWeapon */ public function getApplicableStrength(WeaponlikeCode $weaponlikeCode, Strength $currentStrength) { if (!$weaponlikeCode->isShootingWeapon()) { return $currentStrength; } assert($weaponlikeCode instanceof RangedWeaponCode); /** @var RangedWeaponCode $weaponlikeCode */ if ($weaponlikeCode->isBow()) { $strengthValue = min($currentStrength->getValue(), $this->tables->getBowsTable()->getMaximalApplicableStrengthOf($weaponlikeCode)); return Strength::getIt($strengthValue); } assert($weaponlikeCode->isCrossbow()); // crossbow as a machine does not apply shooter strength, just its own - see PPH page 94 right column return Strength::getIt($this->tables->getCrossbowsTable()->getRequiredStrengthOf($weaponlikeCode)); }