Example #1
0
 // !patrol a2 b2, !patrol a2
 private bool TryParsePatrolCommand(List <string> args, ref Command command)
 {
     // 1 or 2 args. if only one => patrol between current position and target
     if (args.Count < 1 || MapPosition.TryParse(args[0], out var firstPosition) == false)
     {
         return(false);
     }
     command.position = firstPosition;
     if (args.Count >= 2 && MapPosition.TryParse(args[1], out var secondPosition))
     {
         command.secondPosition = secondPosition;
     }
     return(true);
 }
Example #2
0
 // !build a2 tower left, !build a2 tower, !build a2
 private bool TryParseBuildCommand(List <string> args, ref Command command)
 {
     if (args.Count < 1 || MapPosition.TryParse(args[0], out command.position) == false)
     {
         return(false);
     }
     if (args.Count > 1 && Enum.TryParse <BuildingType>(args[1], true, out var buildingType))
     {
         command.buildingType = buildingType;
     }
     if (args.Count > 2 && Enum.TryParse <TileDirection>(args[2], true, out var direction))
     {
         command.direction = direction;
     }
     return(true);
 }
Example #3
0
 // !move a2
 private bool TryParseMoveCommand(List <string> args, ref Command command) => args.Count >= 1 && MapPosition.TryParse(args[0], out command.position);