From: xangelo Date: Mon, 10 Jul 2023 18:00:28 +0000 (-0400) Subject: refactor: make `ShopItem` a subset of `InventoryItem` X-Git-Tag: v0.0.3~2 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=abf453a2c75d1f6051d60a6bd4d552f6b4652a55;p=risinglegends.git 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. --- 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; };