def main(argv): """ Method that gets executed to run a game of colonies. :param argv: Passed argument list to program. File to parse. :type argv: list """ if len(argv) < 2: logger.error("ERROR - Need to supply file as input.") return # Parse the provided file into a Board object. sample_game_board = Board() Parser.parse_file(argv[1], sample_game_board) # Play a game of Colonies with the newly created board. console = Console(sample_game_board) console.play()
def test_parse_file(self): """ Test the parser by constructing a Board from a file. Validate that all expected Pieces and Players have been created. """ # Make input file directory location os-agnostic. test_level_path = os.path.join('source', 'game', 'tests', 'resources', 'test_level_1') # Parse the test file into a Board object. sample_game_board = Board() Parser.parse_file(test_level_path, sample_game_board) # Validate that board is the correct size and all related objects are created. assert sample_game_board.width is 5 assert sample_game_board.height is 5 assert len(sample_game_board.pieces) is 5 assert len(sample_game_board.players) is 4 assert len(sample_game_board.zones) is 1