Compare commits

..

No commits in common. "5167978f8c26422923fcb2ba5a4713747e8e61a5" and "2745d12d29fb263013ae9bb33037dbc0f38260c3" have entirely different histories.

3 changed files with 3 additions and 59 deletions

View File

@ -27,9 +27,8 @@ public class GameScriptHandler(World world, bool strict = false) : IScriptHandle
// "---" submits the orders for validation to allow for assertions about it // "---" submits the orders for validation to allow for assertions about it
if (input == "---") { if (input == "---") {
Console.WriteLine("Submitting orders for validation");
// TODO submit orders // TODO submit orders
return new ValidatedOrdersScriptHandler(World, Strict); // TODO return a new handler that handles asserts
} }
// A block of orders for a single power beginning with "{name}:" // A block of orders for a single power beginning with "{name}:"
@ -44,6 +43,8 @@ public class GameScriptHandler(World world, bool strict = false) : IScriptHandle
return null; return null;
} }
Console.WriteLine($"{CurrentPower}: {input}");
return this; return this;
} }

View File

@ -44,7 +44,6 @@ public class SetupScriptHandler(World world, bool strict = false) : IScriptHandl
case "begin": case "begin":
case "---": case "---":
Console.WriteLine("Starting game");
return new GameScriptHandler(World, Strict); return new GameScriptHandler(World, Strict);
case "list" when args.Length == 1: case "list" when args.Length == 1:

View File

@ -1,56 +0,0 @@
using System.Text.RegularExpressions;
using MultiversalDiplomacy.Model;
namespace MultiversalDiplomacy.Script;
public class ValidatedOrdersScriptHandler(World world, bool strict = false) : IScriptHandler
{
public string Prompt => "valid> ";
public World World { get; private set; } = world;
/// <summary>
/// Whether unsuccessful commands should terminate the script.
/// </summary>
public bool Strict { get; } = strict;
public IScriptHandler? HandleInput(string input)
{
var args = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (args.Length == 0)
{
return this;
}
var command = args[0];
switch (command)
{
case "assert" when args.Length == 1:
Console.WriteLine("Usage:");
break;
case "assert":
string assertion = input["assert ".Length..];
OrderRegex re = new(World);
Regex prov = new($"{re.Province} (.*)");
Match match = prov.Match(assertion);
if (!match.Success) {
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;
default:
// noop on comments that begin with #
if (command.StartsWith('#')) break;
Console.WriteLine($"Unrecognized command: {command}");
if (Strict) return null;
break;
}
return this;
}
}