ported from perforce
This commit is contained in:
31
RobotAndDonkey.Game/Execution/Commands/BuyCardsCommand.cs
Normal file
31
RobotAndDonkey.Game/Execution/Commands/BuyCardsCommand.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using RobotAndDonkey.Game.Execution.Requests;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
using RobotAndDonkey.Game.Intents;
|
||||
|
||||
namespace RobotAndDonkey.Game.Execution.Commands;
|
||||
|
||||
public sealed record BuyCardsCommand(Guid RequestId, int[] Cards) : Command(RequestId, typeof(ImproveRequest), typeof(GambleRequest))
|
||||
{
|
||||
protected override void CreateIntents(CoreLoop coreLoop, List<Intent> intents)
|
||||
{
|
||||
var gamble = coreLoop.RunPhase == ERunPhase.Gamble;
|
||||
foreach (var index in Cards)
|
||||
{
|
||||
if (index < 0)
|
||||
continue;
|
||||
|
||||
if (gamble && index < coreLoop.BoosterPack.Count)
|
||||
intents.Add(new BuyPatch(coreLoop.BoosterPack[index], true));
|
||||
else if (!gamble && index < coreLoop.Shop.Count)
|
||||
intents.Add(new BuyPatch(coreLoop.Shop[index], false));
|
||||
}
|
||||
|
||||
if (coreLoop.RunPhase == ERunPhase.Gamble)
|
||||
intents.Add(new NextPhase(ERunPhase.Improve));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Buy cards command {string.Join(", ", Cards.Select(c => c.ToString()))}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user