When beetroot is in inventory the player can heal

This commit is contained in:
jonathan
2025-12-11 17:13:28 +01:00
parent f42c2c86b1
commit fef8380a57
16 changed files with 161 additions and 70 deletions
+11 -2
View File
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using Babushka.scripts.CSharp.Common.Fight.Actions;
using Babushka.scripts.CSharp.Common.Inventory;
@@ -59,9 +60,17 @@ public partial class FightWorld : Node
public required int maxHealth;
public required List<FighterAction> availableActions;
public const int MaxActionPoints = 1;
public int? health = null; // null => initialize to full health on spawn
public int actionPointsLeft;
private int? _healthBacking = null;
public int Health
{
get => _healthBacking ?? maxHealth;
set => _healthBacking = Math.Clamp(value, 0, maxHealth);
}
public FighterAction AutoSelectAction()
{
return availableActions.Random() ?? new FighterAction.Skip();
@@ -86,6 +95,7 @@ public partial class FightWorld : Node
// settings
[Export] private ItemResource? _itemToDropByEnemyGroup;
[Export] public ItemResource? itemBeetrootToEatForHealth;
public void ResetFightWorld()
{
@@ -200,7 +210,6 @@ public partial class FightWorld : Node
var enemy = new Fighter
{
type = type,
health = null,
maxHealth = GD.RandRange(8, 20),
availableActions =
[