46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
|
namespace MultiversalDiplomacy.Script;
|
||
|
|
||
|
/// <summary>
|
||
|
/// A script handler for the interactive repl.
|
||
|
/// </summary>
|
||
|
public class ReplScriptHandler : IScriptHandler
|
||
|
{
|
||
|
public string Prompt => "5dp> ";
|
||
|
|
||
|
public IScriptHandler? HandleInput(string input)
|
||
|
{
|
||
|
var args = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||
|
if (args.Length == 0)
|
||
|
{
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
var command = args[0];
|
||
|
switch (command)
|
||
|
{
|
||
|
case "help":
|
||
|
case "?":
|
||
|
Console.WriteLine("commands:");
|
||
|
Console.WriteLine(" help, ?: print this message");
|
||
|
Console.WriteLine(" stab: stab");
|
||
|
Console.WriteLine(" new: start a new game");
|
||
|
break;
|
||
|
|
||
|
case "stab":
|
||
|
Console.WriteLine("stab");
|
||
|
break;
|
||
|
|
||
|
case "new":
|
||
|
var world = GameController.InitializeWorld();
|
||
|
var handler = new GameScriptHandler(world);
|
||
|
Console.WriteLine("Started a new game");
|
||
|
return handler;
|
||
|
|
||
|
default:
|
||
|
Console.WriteLine("Unrecognized command");
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
}
|
||
|
}
|