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