ported from perforce
This commit is contained in:
33
RobotAndDonkey.Game/Intents/Intent.cs
Normal file
33
RobotAndDonkey.Game/Intents/Intent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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" : "");
|
||||
}
|
||||
Reference in New Issue
Block a user