From f6c2f4d2b6736aac92e337c78a80e1a454749be1 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Wed, 8 Nov 2023 15:33:04 +0100 Subject: [PATCH] feat: add inventory/item data --- Server/DB/Documents/Character.cs | 1 + Server/DB/Documents/InventoryItem.cs | 20 ++++++++++++++++++++ Server/DB/Documents/ItemType.cs | 12 ++++++++++++ Server/DB/WonderkingContext.cs | 7 +++++-- Wonderking/Wonderking.csproj | 2 +- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Server/DB/Documents/InventoryItem.cs create mode 100644 Server/DB/Documents/ItemType.cs diff --git a/Server/DB/Documents/Character.cs b/Server/DB/Documents/Character.cs index ee9be2c..2c737c8 100644 --- a/Server/DB/Documents/Character.cs +++ b/Server/DB/Documents/Character.cs @@ -14,4 +14,5 @@ public class Character public Gender Gender { get; set; } public long Experience { get; set; } public byte Level { get; set; } + public ICollection InventoryItems { get; set; } } diff --git a/Server/DB/Documents/InventoryItem.cs b/Server/DB/Documents/InventoryItem.cs new file mode 100644 index 0000000..f85c981 --- /dev/null +++ b/Server/DB/Documents/InventoryItem.cs @@ -0,0 +1,20 @@ +namespace Server.DB.Documents; + +public class InventoryItem +{ + public Guid CharacterId { get; set; } + public Character Character { get; set; } + public Guid Id { get; set; } + public short ItemId { get; set; } + public ushort Count { get; set; } + public byte Slot { get; set; } + public ItemType ItemType { get; set; } + public byte Level { get; set; } + public byte Rarity { get; set; } + public byte AddOption { get; set; } + public byte AddOption2 { get; set; } + public byte AddOption3 { get; set; } + public short Option { get; set; } + public short Option2 { get; set; } + public short Option3 { get; set; } +} diff --git a/Server/DB/Documents/ItemType.cs b/Server/DB/Documents/ItemType.cs new file mode 100644 index 0000000..2b12c16 --- /dev/null +++ b/Server/DB/Documents/ItemType.cs @@ -0,0 +1,12 @@ +namespace Server.DB.Documents; + +public enum ItemType : byte +{ + WornEquipment = 0, + WornCashEquipment = 1, + Equipment = 2, + Etc = 3, + Cash = 4, + Warehouse = 5, + GiftBox = 6 +} diff --git a/Server/DB/WonderkingContext.cs b/Server/DB/WonderkingContext.cs index 2cc9720..807dfd8 100644 --- a/Server/DB/WonderkingContext.cs +++ b/Server/DB/WonderkingContext.cs @@ -32,10 +32,13 @@ public class WonderkingContext : DbContext builder.Property(b => b.Password).HasColumnType("bytea"); builder.Property(b => b.Salt).HasColumnType("bytea"); builder.HasKey(b => b.Id); - builder.HasMany(e => e.Characters).WithOne(e => e.Account).HasForeignKey(e => e.AccountId).IsRequired(); + builder.HasMany(e => e.Characters).WithOne(e => e.Account).HasForeignKey(e => e.AccountId) + .IsRequired(); }).Entity(builder => { builder.HasKey(c => c.Id); builder.Property(c => c.Name).HasColumnType("varchar(20)"); - }); + builder.HasMany(e => e.InventoryItems).WithOne(e => e.Character) + .HasForeignKey(e => e.CharacterId).IsRequired(); + }).Entity(builder => { builder.HasKey(i => i.Id); }); } diff --git a/Wonderking/Wonderking.csproj b/Wonderking/Wonderking.csproj index e8fbd2c..78f67e5 100644 --- a/Wonderking/Wonderking.csproj +++ b/Wonderking/Wonderking.csproj @@ -13,7 +13,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive