Started implementation of information about item used screen

This commit is contained in:
2026-03-02 01:57:43 -08:00
parent 46f0e78405
commit bc010a7d82
8 changed files with 182 additions and 38 deletions

View File

@@ -13,6 +13,7 @@ using System.Threading.Tasks;
using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter.Entity;
using System.Linq;
using Chickensoft.Collections;
[Meta(typeof(IAutoNode))]
public partial class Game : Node3D, IGame
@@ -82,6 +83,8 @@ public partial class Game : Node3D, IGame
[Signal] private delegate void OnLoadLevelRequestEventHandler();
public event Action<string> InventoryEventNotification;
public Game()
{
_container = new SimpleInjector.Container();
@@ -453,28 +456,43 @@ public partial class Game : Node3D, IGame
{
case ItemTag.DamagesPlayer:
_effectService.DamagesPlayer(boxItem.Stats.DamageToPlayer);
InventoryEventNotification.Invoke($"{boxItem.Stats.DamageToPlayer} damage done to self.");
GameRepo.CloseInventory();
break;
case ItemTag.ContainsAccessory:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<Accessory>());
var accessory = _effectService.GetRandomItemOfType<Accessory>();
_player.Inventory.TryAdd(accessory);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {accessory}.");
break;
case ItemTag.ContainsArmor:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<Armor>());
var armor = _effectService.GetRandomItemOfType<Armor>();
_player.Inventory.TryAdd(armor);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {armor}.");
break;
case ItemTag.ContainsWeapon:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<Weapon>());
var weapon = _effectService.GetRandomItemOfType<Weapon>();
_player.Inventory.TryAdd(weapon);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {weapon}.");
break;
case ItemTag.ContainsBox:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<BoxItem>());
var box = _effectService.GetRandomItemOfType<BoxItem>();
_player.Inventory.TryAdd(box);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {box}.");
break;
case ItemTag.RandomSpell:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<EffectItem>());
var effectItem = _effectService.GetRandomItemOfType<EffectItem>();
_player.Inventory.TryAdd(effectItem);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {effectItem}.");
break;
case ItemTag.ContainsRestorative:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<ConsumableItem>());
var restorative = _effectService.GetRandomItemOfType<ConsumableItem>();
_player.Inventory.TryAdd(restorative);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {restorative}.");
break;
case ItemTag.DropTo1HPAndGainRareItem:
_effectService.DropTo1HPAndGainRareItem<IBaseInventoryItem>();
var rareItem = _effectService.DropTo1HPAndGainRareItem<IBaseInventoryItem>();
_player.Inventory.TryAdd(rareItem);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {rareItem} but cost dear life.");
break;
case ItemTag.TradeOneRandomItem:
var itemsWithoutBox = _player.Inventory.Items.Where(x => x != boxItem).ToList();
@@ -485,6 +503,7 @@ public partial class Game : Node3D, IGame
_player.Inventory.Remove(randomItem);
var newItem = _effectService.GetRandomItemOfType<IBaseInventoryItem>();
_player.Inventory.TryAdd(newItem);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {newItem}.");
break;
case ItemTag.TradeAllRandomItems:
var newInventory = _effectService.TradeAllRandomItems(boxItem);
@@ -492,20 +511,26 @@ public partial class Game : Node3D, IGame
_player.Inventory.TryAdd(boxItem);
foreach (var item in newInventory)
_player.Inventory.TryAdd(item);
InventoryEventNotification.Invoke($"All items replaced.");
break;
case ItemTag.ContainsUnobtainedItem:
_effectService.GetUnobtainedItem();
var unobtainedItem = _effectService.GetUnobtainedItem();
_player.Inventory.TryAdd(unobtainedItem);
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {unobtainedItem}.");
break;
case ItemTag.ContainsBasicItem:
_effectService.GetBasicItem<IBaseInventoryItem>();
var basicItem = _effectService.GetBasicItem<IBaseInventoryItem>();
InventoryEventNotification.Invoke($"{boxItem.ItemName} contained {basicItem}.");
break;
case ItemTag.UnequipAllItems:
_player.Unequip(_player.EquipmentComponent.EquippedWeapon.Value);
_player.Unequip(_player.EquipmentComponent.EquippedArmor.Value);
_player.Unequip(_player.EquipmentComponent.EquippedAccessory.Value);
InventoryEventNotification.Invoke($"Equipment status reset.");
break;
case ItemTag.RestrictUnequip:
_effectService.GlueAllEquipment(_player);
InventoryEventNotification.Invoke($"Currently equipped items have become unmovable.");
break;
case ItemTag.EjectAllItems:
_player.EquipmentComponent.EquippedWeapon.Value.Glued = false;
@@ -519,6 +544,7 @@ public partial class Game : Node3D, IGame
foreach (var item in _player.Inventory.Items.ToList())
ThrowItem(item);
_player.Inventory.Items.Clear();
InventoryEventNotification.Invoke($"All items have been ejected from inventory.");
GameRepo.CloseInventory();
break;
}
@@ -528,24 +554,28 @@ public partial class Game : Node3D, IGame
{
if (_player.HealthComponent.AtFullHealth && consumableItem.RaiseHPAmount > 0)
{
_player.HealthComponent.RaiseMaximumHP(consumableItem.RaiseHPAmount);
_player.HealthComponent.RaiseMaximumHP(consumableItem.RaiseHPAmount, true);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"Raised maximum HP by {consumableItem.RaiseHPAmount}.");
}
if (_player.VTComponent.AtFullVT && consumableItem.RaiseVTAmount > 0)
else if (_player.VTComponent.AtFullVT && consumableItem.RaiseVTAmount > 0)
{
_player.VTComponent.RaiseMaximumVT(consumableItem.RaiseVTAmount);
_player.VTComponent.RaiseMaximumVT(consumableItem.RaiseVTAmount, true);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"Raised maximum VT by {consumableItem.RaiseVTAmount}.");
}
if (consumableItem.HealHPAmount > 0)
else if (consumableItem.HealHPAmount > 0)
{
var currentHP = _player.HealthComponent.CurrentHP;
_player.HealthComponent.Heal(consumableItem.HealHPAmount);
SfxDatabase.Instance.Play(SoundEffect.HealHP);
InventoryEventNotification.Invoke($"Restored {consumableItem.HealHPAmount} HP.");
}
if (consumableItem.HealVTAmount > 0)
else if (consumableItem.HealVTAmount > 0)
{
_player.VTComponent.Restore(consumableItem.HealVTAmount);
SfxDatabase.Instance.Play(SoundEffect.HealVT);
InventoryEventNotification.Invoke($"Restored {consumableItem.HealVTAmount} VT.");
}
}
@@ -555,114 +585,160 @@ public partial class Game : Node3D, IGame
{
case UsableItemTag.TeleportAllEnemiesToRoom:
_effectService.TeleportEnemiesToCurrentRoom(GetTree().GetNodesInGroup("enemy").OfType<IEnemy>().ToList());
SfxDatabase.Instance.Play(SoundEffect.RecallEnemies);
InventoryEventNotification.Invoke($"All enemies have been summoned.");
GameRepo.CloseInventory();
_player.PlaySpellFX(SpellFXEnum.DivinityRecall);
SfxDatabase.Instance.Play(SoundEffect.RecallEnemies);
break;
case UsableItemTag.KillHalfEnemiesInRoom:
_effectService.KillHalfEnemiesInRoom();
InventoryEventNotification.Invoke($"The balance has been achieved.");
GameRepo.CloseInventory();
break;
case UsableItemTag.TurnAllEnemiesIntoHealingItem:
_effectService.TurnAllEnemiesInRoomIntoHealingItem();
InventoryEventNotification.Invoke($"Enemies in current room have been converted.");
GameRepo.CloseInventory();
break;
case UsableItemTag.HealsAllInRoomToMaxHP:
_effectService.HealAllEnemiesAndPlayerInRoomToFull();
InventoryEventNotification.Invoke($"All present have been renewed.");
GameRepo.CloseInventory();
break;
case UsableItemTag.AbsorbHPFromAllEnemiesInRoom:
_effectService.AbsorbHPFromAllEnemiesInRoom();
var hpAbsorbed = _effectService.AbsorbHPFromAllEnemiesInRoom();
if (hpAbsorbed == 0)
{
InventoryEventNotification.Invoke($"No enemies present to absorb from or invalid location.");
GameRepo.CloseInventory();
return;
}
_player.HealthComponent.Heal(hpAbsorbed);
InventoryEventNotification.Invoke($"Enemies have surrendered {hpAbsorbed} to you.");
GameRepo.CloseInventory();
_player.PlaySpellFX(SpellFXEnum.Kyuuketsuki);
break;
case UsableItemTag.DealElementalDamageToAllEnemiesInRoom:
_effectService.DealElementalDamageToAllEnemiesInRoom(effectItem.Stats.ElementalDamageType);
InventoryEventNotification.Invoke($"All enemies present have taken {effectItem.Stats.ElementalDamageType} to you.");
GameRepo.CloseInventory();
break;
case UsableItemTag.SwapHPAndVT:
_effectService.SwapHPandVT();
InventoryEventNotification.Invoke($"HP and VT have been traded.");
GameRepo.CloseInventory();
break;
case UsableItemTag.RaiseCurrentWeaponAttack:
if (string.IsNullOrEmpty(_player.EquipmentComponent.EquippedWeapon.Value.ItemName))
return;
_effectService.RaiseCurrentWeaponAttack();
InventoryEventNotification.Invoke($"{_player.EquipmentComponent.EquippedWeapon.Value}'s attack has risen by 1.");
break;
case UsableItemTag.RaiseCurrentDefenseArmor:
if (string.IsNullOrEmpty(_player.EquipmentComponent.EquippedArmor.Value.ItemName))
return;
_effectService.RaiseCurrentArmorDefense();
InventoryEventNotification.Invoke($"{_player.EquipmentComponent.EquippedArmor.Value}'s defense has risen by 1.");
break;
case UsableItemTag.RaiseLevel:
_effectService.RaiseLevel();
InventoryEventNotification.Invoke($"Level increased to {_player.ExperiencePointsComponent.Level.Value}");
break;
case UsableItemTag.LowerLevel:
_effectService.LowerLevel();
InventoryEventNotification.Invoke($"Level decreased to {_player.ExperiencePointsComponent.Level.Value}");
break;
case UsableItemTag.LowerCurrentDefenseArmor:
if (string.IsNullOrEmpty(_player.EquipmentComponent.EquippedArmor.Value.ItemName))
return;
_effectService.LowerCurrentArmorDefense();
InventoryEventNotification.Invoke($"{_player.EquipmentComponent.EquippedArmor.Value}'s defense has been lowered by 1.");
break;
case UsableItemTag.RandomEffect:
_effectService.RandomEffect();
break;
case UsableItemTag.DoubleExp:
_effectService.DoubleExp();
InventoryEventNotification.Invoke($"EXP Rate has been doubled.");
GameRepo.CloseInventory();
_player.PlaySpellFX(SpellFXEnum.AnBradan);
break;
case UsableItemTag.TeleportToRandomLocation:
_effectService.TeleportToRandomRoom(_player);
InventoryEventNotification.Invoke($"Moving to a different room.");
GameRepo.CloseInventory();
break;
case UsableItemTag.WarpToExitIfFound:
_effectService.WarpToExit();
var warpedToExit = _effectService.WarpToExit();
if (warpedToExit)
InventoryEventNotification.Invoke($"Moved to exit room.");
else
InventoryEventNotification.Invoke($"Unable to locate exit room.");
GameRepo.CloseInventory();
break;
case UsableItemTag.IncreaseAttack:
_player.AttackComponent.RaiseMaximumAttack(effectItem.Stats.BonusAttack);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"Attack has permanently risen to {_player.AttackComponent.CurrentAttack.Value}.");
break;
case UsableItemTag.IncreaseDefense:
_player.DefenseComponent.RaiseMaximumDefense(effectItem.Stats.BonusDefense);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"Defense has permanently risen to {_player.DefenseComponent.CurrentDefense.Value}.");
break;
case UsableItemTag.IncreaseLuck:
_player.LuckComponent.IncreaseLuck(effectItem.Stats.BonusLuck);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"Luck increased.");
break;
case UsableItemTag.DecreaseAttack:
_player.AttackComponent.Reduce(effectItem.Stats.BonusAttack);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"Attack has been lowered to {_player.AttackComponent.CurrentAttack.Value}.");
break;
case UsableItemTag.DecreaseDefense:
_player.DefenseComponent.Reduce(effectItem.Stats.BonusDefense);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"Defense has been lowered to {_player.DefenseComponent.CurrentDefense.Value}.");
break;
case UsableItemTag.DecreaseLuck:
_player.LuckComponent.DecreaseLuck(effectItem.Stats.BonusLuck);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"Luck decreased.");
break;
case UsableItemTag.DecreaseAllStats:
_player.AttackComponent.Reduce(effectItem.Stats.BonusAttack);
_player.DefenseComponent.Reduce(effectItem.Stats.BonusDefense);
_player.LuckComponent.DecreaseLuck(effectItem.Stats.BonusLuck);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"All stats have been lowered.");
break;
case UsableItemTag.MeltAllEquipment:
_effectService.MeltAllEquipment(_player);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"All equipped items have dissolved.");
break;
case UsableItemTag.GlueAllEquipment:
_effectService.GlueAllEquipment(_player);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"All equipped items have become sticky.");
break;
case UsableItemTag.RestoreStats:
_effectService.RestoreParameters(_player);
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
InventoryEventNotification.Invoke($"All stats have been restored.");
break;
case UsableItemTag.LowerTargetTo1HP:
_player.HealthComponent.SetCurrentHealth(1);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
InventoryEventNotification.Invoke($"HP has been reduced to 1.");
break;
case UsableItemTag.DoubleStackedItems:
var stackableItems = _player.Inventory.Items.OfType<IStackable>().ToList();
stackableItems.ForEach(x => x.Count.OnNext(x.Count.Value * 2));
InventoryEventNotification.Invoke($"Items with inventory count have been doubled.");
break;
case UsableItemTag.IdentifyRandomItem:
var unidentifiedItems = _player.Inventory.Items.Where(x => x.ItemTag == ItemTag.MysteryItem).ToList();
@@ -671,7 +747,9 @@ public partial class Game : Node3D, IGame
var rng = new RandomNumberGenerator();
rng.Randomize();
var index = rng.RandiRange(0, unidentifiedItems.Count - 1);
_player.IdentifyItem(unidentifiedItems[index]);
var itemToIdentify = unidentifiedItems[index];
var identifiedItem = _player.IdentifyItem(itemToIdentify);
InventoryEventNotification.Invoke($"{itemToIdentify} identified to be {identifiedItem.ItemName}.");
break;
}
_player.EquipmentComponent.UpdateEquipment(_player.EquipmentComponent.EquippedWeapon.Value);

View File

@@ -2,6 +2,7 @@
namespace Zennysoft.Game.Ma;
using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.SaveFileBuilder;
using System;
@@ -43,4 +44,6 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
public event Action GameExitRequested;
public event Action GameLoaded;
public event Action<string> InventoryEventNotification;
}