Skip to content

Commit

Permalink
Use existing IsAmmunition property
Browse files Browse the repository at this point in the history
  • Loading branch information
radzki committed Mar 22, 2024
1 parent 68891cc commit c23b6b8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/GameLogic/PlayerActions/Items/MoveItemAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,12 @@ private async ValueTask<Movement> CanMoveAsync(Player player, Item item, byte to
static bool IsOneHandedOrShield(ItemDefinition definition) =>
(definition.ItemSlot!.ItemSlots.Contains(RightHandSlot) && definition.ItemSlot.ItemSlots.Contains(LeftHandSlot)) || definition.Group == 6;

static bool RightHandOccupied(ItemDefinition definition) => definition != null;

// Bolts = 7, Arrows = 15
static bool IsArrowOrBolt(ItemDefinition definition) =>
definition.Group == 4 && (definition.Number == 7 || definition.Number == 15);
var rightHandItemDefinition = storage.GetItem(RightHandSlot)?.Definition!;

if ((toSlot == LeftHandSlot
&& itemDefinition.Width >= 2
&& RightHandOccupied(storage.GetItem(RightHandSlot)?.Definition!)
&& !IsArrowOrBolt(storage.GetItem(RightHandSlot)?.Definition!))
&& rightHandItemDefinition != null
&& !rightHandItemDefinition.IsAmmunition)
|| (toSlot == RightHandSlot
&& IsOneHandedOrShield(itemDefinition)
&& storage.GetItem(LeftHandSlot)?.Definition!.Width >= 2))
Expand Down

0 comments on commit c23b6b8

Please sign in to comment.