diff --git a/MultiversalDiplomacy/Script/ValidatedOrdersScriptHandler.cs b/MultiversalDiplomacy/Script/AdjudicationQueryScriptHandler.cs similarity index 79% rename from MultiversalDiplomacy/Script/ValidatedOrdersScriptHandler.cs rename to MultiversalDiplomacy/Script/AdjudicationQueryScriptHandler.cs index 5a48105..5ed7570 100644 --- a/MultiversalDiplomacy/Script/ValidatedOrdersScriptHandler.cs +++ b/MultiversalDiplomacy/Script/AdjudicationQueryScriptHandler.cs @@ -4,7 +4,7 @@ using MultiversalDiplomacy.Model; namespace MultiversalDiplomacy.Script; -public class ValidatedOrdersScriptHandler(World world, bool strict = false) : IScriptHandler +public class AdjudicationQueryScriptHandler(World world, bool strict = false) : IScriptHandler { public string Prompt => "valid> "; @@ -26,6 +26,10 @@ public class ValidatedOrdersScriptHandler(World world, bool strict = false) : IS var command = args[0]; switch (command) { + case "---": + Console.WriteLine("Ready for orders"); + return new GameScriptHandler(World, Strict); + case "assert" when args.Length == 1: Console.WriteLine("Usage:"); break; @@ -36,17 +40,20 @@ public class ValidatedOrdersScriptHandler(World world, bool strict = false) : IS Regex prov = new($"{re.Province} (.*)"); Match match = prov.Match(assertion); if (!match.Success) { - Console.WriteLine($"Could not parse province from {assertion}"); + Console.WriteLine($"Could not parse province from \"{assertion}\""); return Strict ? null : this; } // TODO look up order once orders are validated and adjudicated Console.WriteLine("Order lookup not implemented yet"); return null; + case "status": + throw new NotImplementedException(); + default: // noop on comments that begin with # if (command.StartsWith('#')) break; - Console.WriteLine($"Unrecognized command: {command}"); + Console.WriteLine($"Unrecognized command: \"{command}\""); if (Strict) return null; break; } diff --git a/MultiversalDiplomacy/Script/GameScriptHandler.cs b/MultiversalDiplomacy/Script/GameScriptHandler.cs index 76f43de..2e84b26 100644 --- a/MultiversalDiplomacy/Script/GameScriptHandler.cs +++ b/MultiversalDiplomacy/Script/GameScriptHandler.cs @@ -25,11 +25,22 @@ public class GameScriptHandler(World world, bool strict = false) : IScriptHandle return this; } - // "---" submits the orders for validation to allow for assertions about it + // "---" submits the orders and allows queries about the outcome if (input == "---") { - Console.WriteLine("Submitting orders for validation"); - // TODO submit orders - return new ValidatedOrdersScriptHandler(World, Strict); + Console.WriteLine("Submitting orders for adjudication"); + // TODO submit, validate, and adjudicate orders + // TODO pass validation, adjudication, and prev/next World to next handler + return new AdjudicationQueryScriptHandler(World, Strict); + } + + // "===" submits the orders and moves immediately to taking the next set of orders + // i.e. it's "---" twice + if (input == "===") { + Console.WriteLine("Submitting orders for adjudication"); + // TODO submit, validate, and adjudicate orders + // TODO replace World with updated world and return a new handler + Console.WriteLine("Ready for orders"); + return new GameScriptHandler(World, Strict); } // A block of orders for a single power beginning with "{name}:" diff --git a/MultiversalDiplomacy/Script/ReplScriptHandler.cs b/MultiversalDiplomacy/Script/ReplScriptHandler.cs index 4827621..932cb05 100644 --- a/MultiversalDiplomacy/Script/ReplScriptHandler.cs +++ b/MultiversalDiplomacy/Script/ReplScriptHandler.cs @@ -42,7 +42,7 @@ public class ReplScriptHandler : IScriptHandler case "map" when args.Length > 1: string mapType = args[1].Trim(); if (!Enum.TryParse(mapType, ignoreCase: true, out MapType map)) { - Console.WriteLine($"Unknown variant {mapType}"); + Console.WriteLine($"Unknown variant \"{mapType}\""); Console.WriteLine("Available variants:"); Console.WriteLine($" {string.Join(", ", Enum.GetNames().Select(s => s.ToLowerInvariant()))}"); break; @@ -54,7 +54,7 @@ public class ReplScriptHandler : IScriptHandler default: // noop on comments that begin with # if (!command.StartsWith('#')) { - Console.WriteLine($"Unrecognized command: {command}"); + Console.WriteLine($"Unrecognized command: \"{command}\""); } break; } diff --git a/MultiversalDiplomacy/Script/SetupScriptHandler.cs b/MultiversalDiplomacy/Script/SetupScriptHandler.cs index 7af700a..5981f82 100644 --- a/MultiversalDiplomacy/Script/SetupScriptHandler.cs +++ b/MultiversalDiplomacy/Script/SetupScriptHandler.cs @@ -45,6 +45,7 @@ public class SetupScriptHandler(World world, bool strict = false) : IScriptHandl case "begin": case "---": Console.WriteLine("Starting game"); + Console.WriteLine("Ready for orders"); return new GameScriptHandler(World, Strict); case "list" when args.Length == 1: @@ -89,7 +90,7 @@ public class SetupScriptHandler(World world, bool strict = false) : IScriptHandl default: // noop on comments that begin with # if (command.StartsWith('#')) break; - Console.WriteLine($"Unrecognized command: {command}"); + Console.WriteLine($"Unrecognized command: \"{command}\""); if (Strict) return null; break; }