/** * @param ProtectiveArmamentCode $protectiveArmamentCode * @param $armourer $armourer * @return int * @throws \DrdPlus\Skills\Physical\Exceptions\PhysicalSkillsDoNotKnowHowToUseThatArmament */ public function getMalusToFightNumberWithProtective(ProtectiveArmamentCode $protectiveArmamentCode, Armourer $armourer) { if ($protectiveArmamentCode instanceof ArmorCode) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return $armourer->getProtectiveArmamentRestrictionForSkill($protectiveArmamentCode, $this->determineCurrentSkillRank($this->getArmorWearing())); } if ($protectiveArmamentCode instanceof ShieldCode) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return $armourer->getProtectiveArmamentRestrictionForSkill($protectiveArmamentCode, $this->determineCurrentSkillRank($this->getShieldUsage())); } throw new Exceptions\PhysicalSkillsDoNotKnowHowToUseThatArmament("Given protective armament '{$protectiveArmamentCode}' is not usable by any physical skill"); }
/** * @test */ public function I_can_get_base_of_wounds_bonus_for_two_hand_holding_of_one_hand_melee_weapon() { $tables = $this->createTables(); $armourer = new Armourer($tables); self::assertSame(0, $armourer->getBaseOfWoundsBonusForHolding($this->createMeleeWeaponlikeCode('foo', 'bar'), false)); $bow = $this->createRangedWeaponCode('foo', 'bow'); $tables->shouldReceive('getWeaponlikeTableByWeaponlikeCode')->with($bow)->andReturn($rangedWeaponsTable = $this->createRangedWeaponsTable()); $rangedWeaponsTable->shouldReceive('getTwoHandedOf')->with($bow)->andReturn(true); self::assertSame(0, $armourer->getBaseOfWoundsBonusForHolding($bow, true)); $pike = $this->createMeleeWeaponCode('foo', 'staffOrSpear'); $tables->shouldReceive('getWeaponlikeTableByWeaponlikeCode')->with($pike)->andReturn($meleeWeaponlikesTable = $this->createMeleeWeaponlikesTable()); $meleeWeaponlikesTable->shouldReceive('getTwoHandedOf')->with($pike)->andReturn(true); self::assertSame(0, $armourer->getBaseOfWoundsBonusForHolding($pike, true)); $shortSword = $this->createMeleeWeaponCode('foo', 'sword'); $tables->shouldReceive('getWeaponlikeTableByWeaponlikeCode')->with($shortSword)->andReturn($meleeWeaponlikesTable = $this->createMeleeWeaponlikesTable()); $meleeWeaponlikesTable->shouldReceive('getTwoHandedOf')->with($shortSword)->andReturn(false); $tables->shouldReceive('getMeleeWeaponlikeTableByMeleeWeaponlikeCode')->with($shortSword)->andReturn($meleeWeaponlikesTable); $meleeWeaponlikesTable->shouldReceive('getLengthOf')->with($shortSword)->andReturn(1); self::assertSame(2, $armourer->getBaseOfWoundsBonusForHolding($shortSword, true)); }