/**
  * @param WeaponlikeCode $weaponlikeCode
  * @return array|string[]
  */
 private function getWeaponTypesByWeaponCode(WeaponlikeCode $weaponlikeCode)
 {
     $types = [];
     if ($weaponlikeCode->isMelee()) {
         $types[] = self::MELEE;
     }
     if ($weaponlikeCode->isShootingWeapon()) {
         $types[] = self::SHOOTING;
     }
     if ($weaponlikeCode->isThrowingWeapon()) {
         $types[] = self::THROWING;
     }
     return $types;
 }
Ejemplo n.º 2
0
 /**
  * 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));
 }