From 701e7b08580c428b0d5276ef705ce31eb10d85ac Mon Sep 17 00:00:00 2001 From: Zenny Date: Mon, 2 Mar 2026 18:17:57 -0800 Subject: [PATCH] Fix receiving items from boxes --- Zennysoft.Game.Ma/src/game/Game.cs | 20 ++++++++++---------- Zennysoft.Game.Ma/src/items/ItemDatabase.cs | 3 +++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 9d0a4e3bb..121f382c6 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -461,37 +461,37 @@ public partial class Game : Node3D, IGame case ItemTag.ContainsAccessory: var accessory = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(accessory); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {accessory}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {accessory.ItemName}."); break; case ItemTag.ContainsArmor: var armor = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(armor); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {armor}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {armor.ItemName}."); break; case ItemTag.ContainsWeapon: var weapon = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(weapon); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {weapon}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {weapon.ItemName}."); break; case ItemTag.ContainsBox: var box = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(box); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {box}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {box.ItemName}."); break; case ItemTag.RandomSpell: var effectItem = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(effectItem); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {effectItem}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {effectItem.ItemName}."); break; case ItemTag.ContainsRestorative: var restorative = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(restorative); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {restorative}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {restorative.ItemName}."); break; case ItemTag.DropTo1HPAndGainRareItem: var rareItem = _effectService.DropTo1HPAndGainRareItem(); _player.Inventory.TryAdd(rareItem); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {rareItem} but cost dear life."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {rareItem.ItemName} but cost dear life."); break; case ItemTag.TradeOneRandomItem: var itemsWithoutBox = _player.Inventory.Items.Where(x => x != boxItem).ToList(); @@ -502,7 +502,7 @@ public partial class Game : Node3D, IGame _player.Inventory.Remove(randomItem); var newItem = _effectService.GetRandomItemOfType(); _player.Inventory.TryAdd(newItem); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {newItem}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {newItem.ItemName}."); break; case ItemTag.TradeAllRandomItems: var newInventory = _effectService.TradeAllRandomItems(boxItem); @@ -515,11 +515,11 @@ public partial class Game : Node3D, IGame case ItemTag.ContainsUnobtainedItem: var unobtainedItem = _effectService.GetUnobtainedItem(); _player.Inventory.TryAdd(unobtainedItem); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {unobtainedItem}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {unobtainedItem.ItemName}."); break; case ItemTag.ContainsBasicItem: var basicItem = _effectService.GetBasicItem(); - InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {basicItem}."); + InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {basicItem.ItemName}."); break; case ItemTag.UnequipAllItems: _player.Unequip(_player.EquipmentComponent.EquippedWeapon.Value); diff --git a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs index efa9a61ad..c33df3055 100644 --- a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs +++ b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs @@ -71,6 +71,7 @@ public class ItemDatabase var armorInfo = GD.Load($"res://src/items/armor/resources/{armor}".TrimSuffix(".remap")); var armorScene = ResourceLoader.Load("res://src/items/armor/Armor.tscn").Instantiate(); armorScene.Stats = armorInfo; + armorScene.Init(); if (!database.Contains(armorScene)) database.Add(armorScene); } @@ -80,6 +81,7 @@ public class ItemDatabase var weaponInfo = GD.Load($"res://src/items/weapons/resources/{weapon}".TrimSuffix(".remap")); var weaponScene = ResourceLoader.Load("res://src/items/weapons/Weapon.tscn").Instantiate(); weaponScene.Stats = weaponInfo; + weaponScene.Init(); if (!database.Contains(weaponScene)) database.Add(weaponScene); } @@ -89,6 +91,7 @@ public class ItemDatabase var accessoryInfo = GD.Load($"res://src/items/accessory/resources/{accessory}".TrimSuffix(".remap")); var accessoryScene = ResourceLoader.Load("res://src/items/accessory/Accessory.tscn").Instantiate(); accessoryScene.Stats = accessoryInfo; + accessoryScene.Init(); if (!database.Contains(accessoryScene)) database.Add(accessoryScene); }