From 4748044ab37786d2e3fe9e3511aa083d255b365e Mon Sep 17 00:00:00 2001
From: Dennis Postma <dennis@directonline.io>
Date: Tue, 17 Dec 2024 16:59:52 +0100
Subject: [PATCH] Added equipment tables and columns in game & user schema

---
 package-lock.json         | 82 +++++----------------------------------
 prisma/schema/game.prisma | 30 ++++++++++++--
 prisma/schema/user.prisma | 73 ++++++++++++++++++++++++----------
 3 files changed, 87 insertions(+), 98 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index c1335ed..4bed3f5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -972,24 +972,6 @@
         "node": ">= 0.8"
       }
     },
-    "node_modules/call-bind": {
-      "version": "1.0.8",
-      "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz",
-      "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==",
-      "license": "MIT",
-      "dependencies": {
-        "call-bind-apply-helpers": "^1.0.0",
-        "es-define-property": "^1.0.0",
-        "get-intrinsic": "^1.2.4",
-        "set-function-length": "^1.2.2"
-      },
-      "engines": {
-        "node": ">= 0.4"
-      },
-      "funding": {
-        "url": "https://github.com/sponsors/ljharb"
-      }
-    },
     "node_modules/call-bind-apply-helpers": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz",
@@ -1004,13 +986,13 @@
       }
     },
     "node_modules/call-bound": {
-      "version": "1.0.2",
-      "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.2.tgz",
-      "integrity": "sha512-0lk0PHFe/uz0vl527fG9CgdE9WdafjDbCXvBbs+LUv000TVt2Jjhqbs4Jwm8gz070w8xXyEAxrPOMullsxXeGg==",
+      "version": "1.0.3",
+      "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz",
+      "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==",
       "license": "MIT",
       "dependencies": {
-        "call-bind": "^1.0.8",
-        "get-intrinsic": "^1.2.5"
+        "call-bind-apply-helpers": "^1.0.1",
+        "get-intrinsic": "^1.2.6"
       },
       "engines": {
         "node": ">= 0.4"
@@ -1178,23 +1160,6 @@
         "ms": "2.0.0"
       }
     },
-    "node_modules/define-data-property": {
-      "version": "1.1.4",
-      "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
-      "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
-      "license": "MIT",
-      "dependencies": {
-        "es-define-property": "^1.0.0",
-        "es-errors": "^1.3.0",
-        "gopd": "^1.0.1"
-      },
-      "engines": {
-        "node": ">= 0.4"
-      },
-      "funding": {
-        "url": "https://github.com/sponsors/ljharb"
-      }
-    },
     "node_modules/denque": {
       "version": "2.1.0",
       "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
@@ -1255,12 +1220,12 @@
       }
     },
     "node_modules/dunder-proto": {
-      "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.0.tgz",
-      "integrity": "sha512-9+Sj30DIu+4KvHqMfLUGLFYL2PkURSYMVXJyXe92nFRvlYq5hBjLEhblKB+vkd/WVlUYMWigiY07T91Fkk0+4A==",
+      "version": "1.0.1",
+      "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
+      "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
       "license": "MIT",
       "dependencies": {
-        "call-bind-apply-helpers": "^1.0.0",
+        "call-bind-apply-helpers": "^1.0.1",
         "es-errors": "^1.3.0",
         "gopd": "^1.2.0"
       },
@@ -1585,18 +1550,6 @@
         "node": ">=4"
       }
     },
-    "node_modules/has-property-descriptors": {
-      "version": "1.0.2",
-      "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
-      "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
-      "license": "MIT",
-      "dependencies": {
-        "es-define-property": "^1.0.0"
-      },
-      "funding": {
-        "url": "https://github.com/sponsors/ljharb"
-      }
-    },
     "node_modules/has-symbols": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
@@ -2468,23 +2421,6 @@
         "node": ">= 0.8.0"
       }
     },
-    "node_modules/set-function-length": {
-      "version": "1.2.2",
-      "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
-      "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
-      "license": "MIT",
-      "dependencies": {
-        "define-data-property": "^1.1.4",
-        "es-errors": "^1.3.0",
-        "function-bind": "^1.1.2",
-        "get-intrinsic": "^1.2.4",
-        "gopd": "^1.0.1",
-        "has-property-descriptors": "^1.0.2"
-      },
-      "engines": {
-        "node": ">= 0.4"
-      }
-    },
     "node_modules/setprototypeof": {
       "version": "1.2.0",
       "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
diff --git a/prisma/schema/game.prisma b/prisma/schema/game.prisma
index d8cedf9..009f11d 100644
--- a/prisma/schema/game.prisma
+++ b/prisma/schema/game.prisma
@@ -42,11 +42,33 @@ model SpriteAction {
 }
 
 model Item {
-  id          String          @id @default(uuid())
+  id          String                  @id @default(uuid())
   name        String
   description String?
-  stackable   Boolean         @default(false)
-  createdAt   DateTime        @default(now())
-  updatedAt   DateTime        @updatedAt
+  itemType    ItemType
+  stackable   Boolean                 @default(false)
+  rarity      ItemRarity              @default(COMMON)
+  createdAt   DateTime                @default(now())
+  updatedAt   DateTime                @updatedAt
   characters  CharacterItem[]
+  equipment   EquippedCharacterItem[]
+}
+
+enum ItemType {
+  WEAPON
+  HELMET
+  CHEST
+  LEGS
+  BOOTS
+  GLOVES
+  RING
+  NECKLACE
+}
+
+enum ItemRarity {
+  COMMON
+  UNCOMMON
+  RARE
+  EPIC
+  LEGENDARY
 }
diff --git a/prisma/schema/user.prisma b/prisma/schema/user.prisma
index 263c353..e9c1943 100644
--- a/prisma/schema/user.prisma
+++ b/prisma/schema/user.prisma
@@ -50,32 +50,44 @@ model CharacterHair {
   sprite                   Sprite?         @relation(fields: [spriteId], references: [id], onDelete: Cascade)
   spriteId                 String?
   characters               Character[]
-  // @TODO: Do we need addedAt and updatedAt?
 }
 
 model Character {
-  id              Int             @id @default(autoincrement())
-  userId          Int
-  user            User            @relation(fields: [userId], references: [id], onDelete: Cascade)
-  name            String          @unique
-  online          Boolean         @default(false)
-  hitpoints       Int             @default(100)
-  mana            Int             @default(100)
-  level           Int             @default(1)
-  experience      Int             @default(0)
-  alignment       Int             @default(50)
-  role            String          @default("player")
-  positionX       Int             @default(0)
-  positionY       Int             @default(0)
-  rotation        Int             @default(0)
+  id     Int     @id @default(autoincrement())
+  userId Int
+  user   User    @relation(fields: [userId], references: [id], onDelete: Cascade)
+  name   String  @unique
+  online Boolean @default(false)
+  role   String  @default("player")
+  chats  Chat[]
+
+  // Position
+  zoneId    Int  @default(1)
+  zone      Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade)
+  positionX Int  @default(0)
+  positionY Int  @default(0)
+  rotation  Int  @default(0)
+
+  // Customization
   characterTypeId Int?
-  characterType   CharacterType?  @relation(fields: [characterTypeId], references: [id], onDelete: Cascade)
+  characterType   CharacterType? @relation(fields: [characterTypeId], references: [id], onDelete: Cascade)
   characterHairId Int?
-  characterHair   CharacterHair?  @relation(fields: [characterHairId], references: [id], onDelete: Cascade)
-  zoneId          Int             @default(1)
-  zone            Zone            @relation(fields: [zoneId], references: [id], onDelete: Cascade)
-  chats           Chat[]
-  items           CharacterItem[]
+  characterHair   CharacterHair? @relation(fields: [characterHairId], references: [id], onDelete: Cascade)
+
+  // Inventory
+  items     CharacterItem[]
+  equipment EquippedCharacterItem[]
+
+  // Stats
+  alignment    Int @default(50)
+  hitpoints    Int @default(100)
+  mana         Int @default(100)
+  level        Int @default(1)
+  experience   Int @default(0)
+  strength     Int @default(10)
+  dexterity    Int @default(10)
+  intelligence Int @default(10)
+  wisdom       Int @default(10)
 }
 
 model CharacterItem {
@@ -86,3 +98,22 @@ model CharacterItem {
   item        Item      @relation(fields: [itemId], references: [id], onDelete: Cascade)
   quantity    Int
 }
+
+model EquippedCharacterItem {
+  id          Int                           @id @default(autoincrement())
+  characterId Int
+  character   Character                     @relation(fields: [characterId], references: [id], onDelete: Cascade)
+  itemId      String
+  item        Item                          @relation(fields: [itemId], references: [id], onDelete: Cascade)
+  quantity    Int
+  slot        EquippedCharacterItemSlotType
+}
+
+enum EquippedCharacterItemSlotType {
+  HEAD
+  BODY
+  ARMS
+  LEGS
+  NECK
+  RING
+}