home · contact · privacy
Don't generate objects at illegal positions. Plus, refactor.
[plomrogue2-experiments] / server.py
1 #!/usr/bin/env python3
2 import sys
3 import os
4 import server_.game
5
6
7 if len(sys.argv) != 2:
8     print('wrong number of arguments, expected one (game file)')
9     exit(1)
10 game_file_name = sys.argv[1]
11 game = server_.game.Game(game_file_name)
12 if os.path.exists(game_file_name):
13     if not os.path.isfile(game_file_name):
14         print('game file name does not refer to a valid game file')
15     else:
16         with open(game_file_name, 'r') as f:
17             lines = f.readlines()
18         for i in range(len(lines)):
19             line = lines[i]
20             print("FILE INPUT LINE %5s: %s" % (i, line), end='')
21             game.io.handle_input(line, store=False)
22 else:
23     game.io.handle_input('GEN_WORLD Hex Y:16,X:16 bar')
24 game.io.run_loop_with_server()