def run(self):
        try:
            with open(self.mapJsonFileName) as json_file:
                mapJsonObject = loadJson(json_file)
            if(mapJsonObject is None):
                raise Exception
        except IOError:
            print("File " + self.mapJsonFileName + " does not exist")
            raise
            exit(1)
        except Exception:
            print("Failed to parse map json data")
            raise
            exit(1)

        self.visualizer = Visualizer(mapJsonObject, self.debug)

        while 1:
            while len(self.append_turn) != 0:
                self.visualizer.add_turn(self.append_turn.pop(0))
            turn = self.visualizer.run()
            if turn is not None:
                if self.scoreboard:
                    self.scoreboard.change_turn(turn)
Example #2
0
    description="Launches the visualizer")
parser.add_argument(
    "-f", "--logFile",
    help="Specifies a log file to use",
    default="src/gamerunner/log.json")
parser.add_argument(
    "-m", "--mapJson",
    help="The map file for the visualizer",
    default="src/gamerunner/map.json")
parser.add_argument("-d", "--debug", help="Turn on Debug", dest='debug', action='store_true')
parser.set_defaults(debug=False)
args = parser.parse_args()  # parse args

try:
    with open(args.mapJson) as json_file:
        mapJsonObject = loadJson(json_file)
    if(mapJsonObject is None):
        raise Exception
except IOError:
    print("File " + args.mapJson + " does not exist")
    raise
    exit(1)
except Exception:
    print("Failed to parse map json data")
    raise
    exit(1)

if (args.logFile is not None):
    try:
        teamJsonObject = None
        logJsonObject = []