From: xangelo Date: Wed, 6 Sep 2023 17:25:27 +0000 (-0400) Subject: feat: display equippable hand option only X-Git-Tag: v0.3.3~1 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=d7569d31080cb8d55c5e57bae9a16f6a676c12ff;p=risinglegends.git feat: display equippable hand option only When you are equipping items it will only show you the equip button for the hand that you have available --- diff --git a/src/server/views/inventory.ts b/src/server/views/inventory.ts index 6026775..88e3c8c 100644 --- a/src/server/views/inventory.ts +++ b/src/server/views/inventory.ts @@ -121,21 +121,30 @@ function renderInventoryItem(item: EquippedItemDetails , action: (item: Equipped } function renderInventorySection(inventory: EquippedItemDetails[]): string { + const used_slots = inventory.filter(i => i.is_equipped).map(i => i.equipment_slot); + return inventory.map(item => { return renderInventoryItem(item, item => { if(item.is_equipped) { return ``; } else { - if(item.equipment_slot === 'ANY_HAND') { - return ` -`; - } - else if(item.equipment_slot === 'LEFT_HAND') { - return ``; - } - else if(item.equipment_slot === 'RIGHT_HAND') { - return ``; + if(['ANY_HAND', 'LEFT_HAND', 'RIGHT_HAND'].includes(item.equipment_slot)) { + const str: string[] = [ + ``, + `` + ]; + + if(used_slots.includes('LEFT_HAND') && !used_slots.includes('RIGHT_HAND')) { + return str[1]; + } + else if(used_slots.includes('RIGHT_HAND') && !used_slots.includes('LEFT_HAND')) { + return str[0]; + } + else if(used_slots.includes('LEFT_HAND') && used_slots.includes('RIGHT_HAND')) { + return ""; + } + return str.join(""); } else { return ``;