58 lines
1.8 KiB
C#
58 lines
1.8 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" when args.Length == 1:
|
|
Console.WriteLine("usage:");
|
|
Console.WriteLine(" new blank: standard map, no units");
|
|
Console.WriteLine(" new standard: standard map, standard units");
|
|
break;
|
|
|
|
case "new" when args[1] == "blank":
|
|
var world = MultiversalDiplomacy.Model.World.WithStandardMap();
|
|
var handler = new GameScriptHandler(world);
|
|
Console.WriteLine("Created an empty game");
|
|
return handler;
|
|
|
|
case "new" when args[1] == "standard":
|
|
world = GameController.InitializeWorld();
|
|
handler = new GameScriptHandler(world);
|
|
Console.WriteLine("Created a standard game");
|
|
return handler;
|
|
|
|
default:
|
|
Console.WriteLine("Unrecognized command");
|
|
break;
|
|
}
|
|
|
|
return this;
|
|
}
|
|
} |