Files
zfxaction25/RobotAndDonkey.Game/Intents/Intent.cs
2026-04-19 00:43:27 +02:00

33 lines
1022 B
C#

using RobotAndDonkey.Game.Cards;
using RobotAndDonkey.Game.Execution.Results;
using RobotAndDonkey.Game.GameState;
using RobotAndDonkey.Game.Modifiers;
using System;
using System.Collections.Generic;
namespace RobotAndDonkey.Game.Intents;
public abstract class Intent(int energyCost = 0)
{
public virtual void Run(Guid requestId, CoreLoop coreLoop, List<Intent> newIntents, List<Result> results)
{
if (EnergyCost != 0)
{
coreLoop.Currency.Energy -= EnergyCost;
results.Add(new CurrencyResult(requestId, coreLoop.Currency));
}
}
public virtual bool IsValid(CoreLoop coreLoop)
{
return DebuffSources.Count == 0 && coreLoop.Currency.Energy >= Math.Max(0, EnergyCost);
}
public int EnergyCost { get; set; } = energyCost;
public HashSet<Modifier> DebuffSources { get; } = [];
public virtual bool Immune { get; }
public override string ToString() => $"Costs {EnergyCost}" + (DebuffSources.Count > 0 ? ", debuffed" : "");
}