From abf453a2c75d1f6051d60a6bd4d552f6b4652a55 Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 10 Jul 2023 14:00:28 -0400 Subject: [PATCH] refactor: make `ShopItem` a subset of `InventoryItem` The `ShopItem` type takes the `InventoryItem` type and removes the unnecessary params and adds its own. That way we maintain the parity between the two but enforce a much simpler mental model of the inheritance hierarchy. --- src/shared/inventory.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shared/inventory.ts b/src/shared/inventory.ts index ed28fd1..925446d 100644 --- a/src/shared/inventory.ts +++ b/src/shared/inventory.ts @@ -9,8 +9,9 @@ export type WeaponEquipmentSlot = 'LEFT_HAND' | 'RIGHT_HAND' | 'TWO_HANDED' | 'A export type EquipmentSlot = ArmourEquipmentSlot | WeaponEquipmentSlot; -export type ShopItem = { - id: number; +export type InventoryItem = { + item_id: string; + player_id: string; name: string; type: InventoryType; profession: Profession; @@ -34,10 +35,11 @@ export type ShopItem = { currentAp: number; maxAp: number; affectedSkills: SkillID[]; - location_id: number; } -export type InventoryItem = Omit & { - item_id: string; - player_id: string; +// shop items have a numeric id since they're tracked in a separate spreadsheet +// and they are also tied to a specific location +export type ShopItem = Omit & { + id: number; + location_id: number; }; -- 2.25.1