home · contact · privacy
Allow selection of grid geometry via MAP command. A lot refactoring.
[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 %s: %s" % (i, line), end='')
21             game.io.handle_input(line, store=False)
22 else:
23     game.io.handle_input('MAP Hex Y:5,X:5')
24     game.io.handle_input('TERRAIN_LINE 0 "xxxxx"')
25     game.io.handle_input('TERRAIN_LINE 1 "x...x"')
26     game.io.handle_input('TERRAIN_LINE 2 "x.X.x"')
27     game.io.handle_input('TERRAIN_LINE 3 "x...x"')
28     game.io.handle_input('TERRAIN_LINE 4 "xxxxx"')
29     game.io.handle_input('THING_TYPE 0 human')
30     game.io.handle_input('THING_POS 0 Y:3,X:3')
31     game.io.handle_input('THING_TYPE 1 monster')
32     game.io.handle_input('THING_POS 1 Y:1,X:1')
33 game.io.run_loop_with_server()