Early-out on comments

This commit is contained in:
Tim Van Baak 2024-08-21 09:47:13 -07:00
parent e9c4d3d2d3
commit 55dfe0ca99
4 changed files with 5 additions and 11 deletions

View File

@ -18,7 +18,7 @@ public class AdjudicationQueryScriptHandler(World world, bool strict = false) :
public IScriptHandler? HandleInput(string input)
{
var args = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (args.Length == 0)
if (args.Length == 0 || input.StartsWith('#'))
{
return this;
}
@ -51,8 +51,6 @@ public class AdjudicationQueryScriptHandler(World world, bool strict = false) :
throw new NotImplementedException();
default:
// noop on comments that begin with #
if (command.StartsWith('#')) break;
Console.WriteLine($"Unrecognized command: \"{command}\"");
if (Strict) return null;
break;

View File

@ -24,6 +24,7 @@ public class GameScriptHandler(World world, bool strict = false) : IScriptHandle
CurrentPower = null;
return this;
}
if (input.StartsWith('#')) return this;
// "---" submits the orders and allows queries about the outcome
if (input == "---") {

View File

@ -12,7 +12,7 @@ public class ReplScriptHandler : IScriptHandler
public IScriptHandler? HandleInput(string input)
{
var args = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (args.Length == 0)
if (args.Length == 0 || input.StartsWith('#'))
{
return this;
}
@ -52,10 +52,7 @@ public class ReplScriptHandler : IScriptHandler
return new SetupScriptHandler(world);
default:
// noop on comments that begin with #
if (!command.StartsWith('#')) {
Console.WriteLine($"Unrecognized command: \"{command}\"");
}
Console.WriteLine($"Unrecognized command: \"{command}\"");
break;
}

View File

@ -24,7 +24,7 @@ public class SetupScriptHandler(World world, bool strict = false) : IScriptHandl
public IScriptHandler? HandleInput(string input)
{
var args = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (args.Length == 0)
if (args.Length == 0 || input.StartsWith('#'))
{
return this;
}
@ -88,8 +88,6 @@ public class SetupScriptHandler(World world, bool strict = false) : IScriptHandl
break;
default:
// noop on comments that begin with #
if (command.StartsWith('#')) break;
Console.WriteLine($"Unrecognized command: \"{command}\"");
if (Strict) return null;
break;