public void DoCommand(Command command) { switch (command.type) { case CommandType.DESCRIBE: DescribeCommand describeCommand = (DescribeCommand)command; describeCommand.Execute(mapController, describeCommand.id != null ? FindEntity(describeCommand.id) : null); break; case CommandType.SELECT: SelectCommand selectCommand = (SelectCommand)command; selectCommand.Execute(mapController, GetPlayerById(selectCommand.playerId)); break; case CommandType.PERFORMACTION: PerformActionCommand performActionCommand = (PerformActionCommand)command; performActionCommand.Execute(mapController, GetPlayerById(performActionCommand.playerId), GetPlayerById(performActionCommand.playerId).selectedEntity); break; case CommandType.ENDTURN: EndTurnCommand endTurnCommand = (EndTurnCommand)command; endTurnCommand.Execute(turnController); break; default: break; } }
public async Task write_to_console() { await DescribeCommand.WriteToConsole(theParts); theParts[1].As <ConsoleWritingPart>() .DidWriteToConsole.ShouldBeTrue(); }
public async Task write_text() { var writer = new StringWriter(); await DescribeCommand.WriteText(theParts, writer); writer.ToString().ShouldContain(theParts[0].As <DescribedPart>().Body); writer.ToString().ShouldContain(theParts[0].Title); writer.ToString().ShouldContain(theParts[1].As <DescribedPart>().Body); writer.ToString().ShouldContain(theParts[1].Title); }
public void write_to_html() { var document = DescribeCommand.GenerateHtmlDocument(theParts); var html = document.ToString(); html.ShouldContain(theParts[0].As <DescribedPart>().Body); html.ShouldContain(theParts[0].Title); html.ShouldContain(theParts[1].As <DescribedPart>().Body); html.ShouldContain(theParts[1].Title); html.ShouldContain(theParts[2].Key); html.ShouldContain($"id=\"{theParts[2].Key}\""); }
public static Command ArrayToCommand(CommandType commandType, string[] inputs) { Command command = null; switch (commandType) { case CommandType.DESCRIBE: if (inputs[1].ToLower() == "all") { command = new DescribeCommand(1); } else if (inputs.Length > 2) { command = new DescribeCommand(1, new Coordinate(Int32.Parse(inputs[1]), Int32.Parse(inputs[2]))); } else { command = new DescribeCommand(1, inputs[1]); } break; case CommandType.SELECT: command = new SelectCommand(1, inputs[1]); break; case CommandType.PERFORMACTION: command = new PerformActionCommand(1, new Coordinate(Int32.Parse(inputs[1]), Int32.Parse(inputs[2])), new Mine(), ActionType.BUILD); break; case CommandType.ENDTURN: command = new EndTurnCommand(1); break; default: break; } return(command); }