Skip to content

Commit

Permalink
Fixed empty hand syndrome.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Dec 1, 2023
1 parent 0c63863 commit 429e87d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public function handleHands(Character $character, ?InventorySlot $slotToEquip, s
return $character->refresh();
}

if (in_array($slotForPosition->item->type, self::TWO_HANDED)) {
if (in_array($slotForPosition->item->type, self::TWO_HANDED) ||
in_array($slotToEquip->item->type, self::TWO_HANDED))
{
if ($this->inventoryItemComparison->compareItems($slotToEquip->item, $slotForPosition->item)) {
$this->equipItemService->setCharacter($character)->unequipBothHands();

Expand All @@ -70,7 +72,7 @@ public function handleHands(Character $character, ?InventorySlot $slotToEquip, s
}
}

return $character;
return $character->refresh();
}

protected function equipItem(Character $character, InventorySlot $slotToEquip, string $position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,25 @@ protected function processPositions(Character $character): void {

$oppositeHand = EquippablePositions::getOppisitePosition($currentSlot->position);

$typesForPosition = EquippablePositions::typesForPositions($oppositeHand);

if ($currentSlot->item->type === WeaponTypes::WEAPON) {
$typesForPosition = [ArmourTypes::SHIELD];
}

if ($currentSlot->item->type === ArmourTypes::SHIELD) {
$index = array_search(ArmourTypes::SHIELD, $typesForPosition);

if ($index !== false) {
unset($typesForPosition[$index]);
}
}

$bestSlot = $this->fetchBestItemForPositionFromInventory
->fetchBestItemForPosition(EquippablePositions::typesForPositions($oppositeHand), $hasSpecialEquipped);
->fetchBestItemForPosition($typesForPosition, $hasSpecialEquipped);

if (!is_null($bestSlot)) {

$this->handleHands->setCurrentlyEquipped($this->currentlyEquippedSlots)
->handleHands($character, $bestSlot, $oppositeHand);
}
Expand Down

0 comments on commit 429e87d

Please sign in to comment.