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 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()))}"; } }