26 lines
841 B
C#
26 lines
841 B
C#
// HealCommand.cs
|
|
using System;
|
|
using TextRPG.PlayerSystem;
|
|
|
|
namespace TextRPG.Commands
|
|
{
|
|
public class HealCommand : Command
|
|
{
|
|
public override string Name => "heal";
|
|
public override string Description => "Heals the player by a given amount (max 50).";
|
|
public override string Usage => "heal <amount>";
|
|
|
|
public override void Execute(string[] args, Action<string> outputCallback)
|
|
{
|
|
if (args.Length == 0 || !int.TryParse(args[0], out int amount))
|
|
{
|
|
outputCallback($"Usage: {Usage}");
|
|
return;
|
|
}
|
|
|
|
amount = Math.Min(amount, 50);
|
|
Player.Instance.Heal(amount);
|
|
outputCallback($"You healed {amount} HP. Current health: {Player.Instance.CurrentHealth}/{Player.Instance.MaxHealth}");
|
|
}
|
|
}
|
|
} |