using System; using System.Collections.Generic; using RobotAndDonkey.Game.Board; using RobotAndDonkey.Game.Execution; using RobotAndDonkey.Game.Execution.Results; using RobotAndDonkey.Game.GameState; using RobotAndDonkey.Game.Intents; namespace RobotAndDonkey.Game.Modifiers; public record RainModifier(EModifierDuration Duration) : Modifier(EModifierKind.Cell, EModifierId.Rain, Duration) { protected override RainModifier CreateInstance() => new(Duration); public override void OnAdded(Entity owner, List newIntents) { if (owner is not Cell cell) throw new NotSupportedException("Rain is only allowed in cells."); cell.Type = cell.Type switch { ECellType.Grass => ECellType.Mud, ECellType.Rocky => ECellType.Dry, _ => throw new NotSupportedException("Rain only works on Rocky and Grass") }; } public override void OnRemoved(Entity owner, List newIntents) { if (owner is not Cell cell) throw new NotSupportedException("Rain is only allowed in cells."); cell.Type = cell.Type switch { ECellType.Mud => ECellType.Grass, ECellType.Dry => ECellType.Rocky, _ => throw new NotSupportedException("Rain can only be removed from Dry and Mud") }; } public override string ToolTip => "Humidity was reduced from this land, reducing fertility and maybe drying out."; }