diff --git a/src/RavenNest.Blazor/Controllers/ItemsController.cs b/src/RavenNest.Blazor/Controllers/ItemsController.cs index ec861a3d..16541de0 100644 --- a/src/RavenNest.Blazor/Controllers/ItemsController.cs +++ b/src/RavenNest.Blazor/Controllers/ItemsController.cs @@ -46,6 +46,18 @@ public async Task> Get() return itemCollection; } + [HttpGet("delta/{timestamp}")] + public async Task> Get(DateTime timestamp) + { + if (itemManager == null) + { + return new ItemCollection(); + } + + var itemCollection = itemManager.GetAllItems(timestamp); + return itemCollection; + } + /// /// Get all redeemable items /// diff --git a/src/RavenNest.BusinessLogic/Game/Managers/ItemManager.cs b/src/RavenNest.BusinessLogic/Game/Managers/ItemManager.cs index 208f1c39..b4179a36 100644 --- a/src/RavenNest.BusinessLogic/Game/Managers/ItemManager.cs +++ b/src/RavenNest.BusinessLogic/Game/Managers/ItemManager.cs @@ -38,6 +38,22 @@ public ItemCollection GetAllItems() return InvalidateCache(); } + public ItemCollection GetAllItems(DateTime timestamp) + { + var items = gameData.GetItems(); + var collection = new ItemCollection(); + foreach (var item in items) + { + if (item.Hidden || item.Modified < timestamp) + { + continue; + } + + collection.Add(ModelMapper.Map(gameData, item)); + } + return collection; + } + public Item GetItem(Guid itemId) { var dataItem = gameData.GetItem(itemId); @@ -96,6 +112,8 @@ private void AddItem(Item item) item.RequiredCraftingLevel = GameMath.MaxLevel + 1; } + entity.Modified = DateTime.UtcNow; + gameData.Add(entity); InvalidateCache(); } @@ -166,6 +184,13 @@ private void UpdateItem(Item item, DataModels.Item dataItem) dataItem.Level = item.Level; dataItem.ArmorPower = item.ArmorPower; + dataItem.WeaponAim = item.WeaponAim; + dataItem.WeaponPower = item.WeaponPower; + dataItem.MagicPower = item.MagicPower; + dataItem.MagicAim = item.MagicAim; + dataItem.RangedPower = item.RangedPower; + dataItem.RangedAim = item.RangedAim; + dataItem.Category = (int)item.Category; dataItem.Craftable = item.Craftable; dataItem.FemaleModelId = item.FemaleModelId; @@ -188,11 +213,8 @@ private void UpdateItem(Item item, DataModels.Item dataItem) dataItem.ShopSellPrice = item.ShopSellPrice; dataItem.Soulbound = item.Soulbound; dataItem.Type = (int)item.Type; - dataItem.WeaponAim = item.WeaponAim; - dataItem.WeaponPower = item.WeaponPower; dataItem.WoodCost = item.WoodCost; - - + dataItem.Modified = DateTime.UtcNow; InvalidateCache(); } diff --git a/src/RavenNest.DataModels/Item.cs b/src/RavenNest.DataModels/Item.cs index 8cdee1fe..f395cead 100644 --- a/src/RavenNest.DataModels/Item.cs +++ b/src/RavenNest.DataModels/Item.cs @@ -50,5 +50,6 @@ public partial class Item : Entity public long ShopSellPrice { get => shopSellPrice; set => Set(ref shopSellPrice, value); } private bool soulbound; public bool Soulbound { get => soulbound; set => Set(ref soulbound, value); } private bool hidden; public bool Hidden { get => hidden; set => Set(ref hidden, value); } + private DateTime? modified; public DateTime? Modified { get => modified; set => Set(ref modified, value); } } } diff --git a/src/RavenNest.Models/Item.cs b/src/RavenNest.Models/Item.cs index 1e9ad153..e460113f 100644 --- a/src/RavenNest.Models/Item.cs +++ b/src/RavenNest.Models/Item.cs @@ -40,5 +40,6 @@ public class Item public long ShopSellPrice { get; set; } public List CraftingRequirements { get; set; } public bool Soulbound { get; set; } + public DateTime? Modified { get; set; } } }