39 lines
972 B
C#
39 lines
972 B
C#
|
using MultiversalDiplomacy.Model;
|
||
|
|
||
|
namespace MultiversalDiplomacy.Script;
|
||
|
|
||
|
/// <summary>
|
||
|
/// A script handler for defining order sets.
|
||
|
/// </summary>
|
||
|
public class OrderSetScriptHandler : IScriptHandler
|
||
|
{
|
||
|
public OrderSetScriptHandler(GameScriptHandler parent, World world, string orderCommand)
|
||
|
{
|
||
|
this.parent = parent;
|
||
|
this.world = world;
|
||
|
this.orderSet = new() { orderCommand };
|
||
|
}
|
||
|
|
||
|
public string Prompt => "...> ";
|
||
|
|
||
|
private GameScriptHandler parent { get; }
|
||
|
|
||
|
private World world { get; }
|
||
|
|
||
|
private List<string> orderSet { get; }
|
||
|
|
||
|
public IScriptHandler? HandleInput(string input)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(input))
|
||
|
{
|
||
|
parent.World = GameController.SubmitOrderSet(world, string.Join('\n', orderSet));
|
||
|
Console.WriteLine("Submitted order set");
|
||
|
return parent;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
orderSet.Add(input);
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
}
|