/// <summary> /// Initialize the game server. /// </summary> public void Init() { RegisterMessageTypes(); InitServerEvents(); Server.Start(); var serverControl = new CommandSelection <ServerControl>() { Descriptions = { { ServerControl.Shutdown, "Stop server" } } }; serverControl.On(ServerControl.Shutdown, Shutdown); serverControl.Draw(); }
public string Process(string request) { var prefix = new StringBuilder(); var output = new StringBuilder(); Dictionary <string, ICommandHandler> handlers = new Dictionary <string, ICommandHandler>(); handlers.Add("ECHO", new EchoCommandHandler()); handlers.Add("PING", new PingCommandHandler()); var command = CommandSelection.SelectCommand(request); if (shouldAtTimeStamp) { prefix.Append(DateTime.Now.ToLongTimeString()); prefix.Append(" "); } try { output = prefix.Append(handlers[command].Handle(request)); } catch { Console.WriteLine("Bad request"); } if (shouldUpperLetters) { Console.WriteLine(output.ToString().ToUpper()); } else { Console.WriteLine(output); } return(""); }
public void SelectPreviousCommand() { if (command > 0) { command--; } else { command = CommandSelection.Run; } switch (command) { case CommandSelection.Attack: SetAttackScroll(); break; case CommandSelection.Defend: SetDefendScroll(); break; case CommandSelection.Move: SetMoveScroll(); break; case CommandSelection.Item: SetItemScroll(); break; case CommandSelection.Run: SetRunScroll(); break; default: break; } }
public void SelectNextCommand() { if (command <= CommandSelection.Item) { command++; } else { command = 0; } switch (command) { case CommandSelection.Attack: SetAttackScroll(); break; case CommandSelection.Defend: SetDefendScroll(); break; case CommandSelection.Move: SetMoveScroll(); break; case CommandSelection.Item: SetItemScroll(); break; case CommandSelection.Run: SetRunScroll(); break; default: break; } }