34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using RobotAndDonkey.Game.Cards;
|
|
using RobotAndDonkey.Game.Execution.Results;
|
|
using RobotAndDonkey.Game.GameState;
|
|
|
|
namespace RobotAndDonkey.Game.Intents;
|
|
|
|
public class BuyPatch(Card card, bool free) : CardIntent(card, free ? 0 : card.ShopCost)
|
|
{
|
|
public override void Run(Guid requestId, CoreLoop coreLoop, List<Intent> newIntents, List<Result> results)
|
|
{
|
|
coreLoop.Shop.Remove(Card);
|
|
coreLoop.PatchDeck.Add(Card);
|
|
results.Add(new ShopResult(requestId, coreLoop.Shop.ToArray()));
|
|
results.Add(new DeckResult(requestId, coreLoop.PatchDeck.ToArray()));
|
|
base.Run(requestId, coreLoop, newIntents, results);
|
|
}
|
|
|
|
public override bool IsValid(CoreLoop coreLoop)
|
|
{
|
|
if (!Free && !coreLoop.Shop.Contains(Card))
|
|
return false;
|
|
|
|
if (Free && !coreLoop.BoosterPack.Contains(Card))
|
|
return false;
|
|
|
|
return base.IsValid(coreLoop);
|
|
}
|
|
|
|
public bool Free { get; } = free;
|
|
|
|
public override bool Immune => true;
|
|
|
|
public override string ToString() => $"Buy {Card.Name}, " + base.ToString();
|
|
} |