using System; using System.Collections.Generic; using RobotAndDonkey.Game.Execution.Results; using RobotAndDonkey.Game.GameState; using RobotAndDonkey.Game.Modifiers; namespace RobotAndDonkey.Game.Intents; public class ModifyCurrency(Currency delta, bool canCorrupt = false) : Intent { public override void Run(Guid requestId, CoreLoop coreLoop, List newIntents, List results) { coreLoop.Currency.Energy += Delta.Energy; coreLoop.Currency.MaxCarry += Delta.MaxCarry; coreLoop.Currency.Carry += Delta.Carry; coreLoop.Currency.Delivery += Delta.Delivery; coreLoop.Currency.TapeLength += Delta.TapeLength; coreLoop.Currency.HandSize += Delta.HandSize; results.Add(new CurrencyResult(requestId, coreLoop.Currency)); base.Run(requestId, coreLoop, newIntents, results); } public override bool IsValid(CoreLoop coreLoop) { return base.IsValid(coreLoop) && coreLoop.Currency.Energy + Delta.Energy >= 0 && coreLoop.Currency.MaxCarry + Delta.MaxCarry >= 0 && coreLoop.Currency.Carry + Delta.Carry >= 0 && coreLoop.Currency.Delivery + Delta.Delivery >= 0 && coreLoop.Currency.TapeLength + Delta.TapeLength >= 0 && coreLoop.Currency.HandSize + Delta.HandSize >= 0; } public Currency Delta { get; set; } = delta; public bool CanCorrupt { get; set; } = canCorrupt; public override string ToString() => $"Currency delta: {Delta}, CanCorrupt={CanCorrupt} " + base.ToString(); }