game.map_content = content
if type(game.map_geometry) == MapGeometrySquare:
game.tui.movement_keys = {
- 'w': 'UP',
- 'a': 'LEFT',
- 's': 'DOWN',
- 'd': 'RIGHT',
+ game.tui.keys['square_move_up']: 'UP',
+ game.tui.keys['square_move_left']: 'LEFT',
+ game.tui.keys['square_move_down']: 'DOWN',
+ game.tui.keys['square_move_right']: 'RIGHT',
}
elif type(game.map_geometry) == MapGeometryHex:
game.tui.movement_keys = {
- 'w': 'UPLEFT',
- 'e': 'UPRIGHT',
- 'd': 'RIGHT',
- 'c': 'DOWNRIGHT',
- 'x': 'DOWNLEFT',
- 's': 'LEFT',
+ game.tui.keys['hex_move_upleft']: 'UPLEFT',
+ game.tui.keys['hex_move_upright']: 'UPRIGHT',
+ game.tui.keys['hex_move_right']: 'RIGHT',
+ game.tui.keys['hex_move_downright']: 'DOWNRIGHT',
+ game.tui.keys['hex_move_downleft']: 'DOWNLEFT',
+ game.tui.keys['hex_move_left']: 'LEFT',
}
cmd_MAP.argtypes = 'string:map_geometry yx_tuple:pos string'
self.is_intro = is_intro
def __init__(self, host, port):
+ import os
+ import json
self.host = host
self.port = port
self.mode_play = self.Mode('play')
self.queue = queue.Queue()
self.login_name = None
self.switch_mode('waiting_for_server')
+ self.keys = {
+ 'switch_to_chat': 'C',
+ 'switch_to_play': 'P',
+ 'switch_to_annotate': 'E',
+ 'switch_to_portal': 'p',
+ 'switch_to_study': '?',
+ 'switch_to_edit': 'E',
+ 'flatten': 'f',
+ 'hex_move_upleft': 'w',
+ 'hex_move_upright': 'e',
+ 'hex_move_right': 'd',
+ 'hex_move_downright': 'c',
+ 'hex_move_downleft': 'x',
+ 'hex_move_left': 's',
+ 'square_move_up': 'w',
+ 'square_move_left': 'a',
+ 'square_move_down': 's',
+ 'square_move_right': 'd',
+ }
+ if os.path.isfile('config.json'):
+ with open('config.json', 'r') as f:
+ keys_conf = json.loads(f.read())
+ for k in keys_conf:
+ self.keys[k] = keys_conf[k]
curses.wrapper(self.loop)
def flash(self):
self.log_msg(" /P or /play - switch to play mode");
self.log_msg(" /? or /study - switch to study mode");
self.log_msg("commands common to study and play mode:");
- if type(self.game.map_geometry) == MapGeometrySquare:
- self.log_msg(" w,a,s,d - move");
- elif type(self.game.map_geometry) == MapGeometryHex:
- self.log_msg(" e,d,c,x,s,w - move");
- self.log_msg(" C - switch to chat mode");
+ self.log_msg(" %s - move" % ','.join(self.movement_keys));
+ self.log_msg(" %s - switch to chat mode" % self.keys['switch_to_chat']);
self.log_msg("commands specific to play mode:");
- self.log_msg(" E - write following ASCII character");
- self.log_msg(" f - flatten surroundings");
- self.log_msg(" ? - switch to study mode");
+ self.log_msg(" %s - write following ASCII character" % self.keys['switch_to_edit']);
+ self.log_msg(" %s - flatten surroundings" % self.keys['flatten']);
+ self.log_msg(" %s - switch to study mode" % self.keys['switch_to_study']);
self.log_msg("commands specific to study mode:");
- self.log_msg(" E - annotate terrain");
- self.log_msg(" P - switch to play mode");
+ self.log_msg(" %s - annotate terrain" % self.keys['switch_to_annotate']);
+ self.log_msg(" %s - switch to play mode" % self.keys['switch_to_play']);
def loop(self, stdscr):
self.switch_mode('play')
self.input_ = ''
elif self.mode == self.mode_study:
- if key == 'C':
+ if key == self.keys['switch_to_chat']:
self.switch_mode('chat')
- elif key == 'P':
+ elif key == self.keys['switch_to_play']:
self.switch_mode('play')
- elif key == 'A':
+ elif key == self.keys['switch_to_annotate']:
self.switch_mode('annotate', keep_position=True)
- elif key == 'p':
+ elif key == self.keys['switch_to_portal']:
self.switch_mode('portal', keep_position=True)
elif key in self.movement_keys:
move_explorer(self.movement_keys[key])
elif self.mode == self.mode_play:
- if key == 'C':
+ if key == self.keys['switch_to_chat']:
self.switch_mode('chat')
- elif key == '?':
+ elif key == self.keys['switch_to_study']:
self.switch_mode('study')
- if key == 'E':
+ if key == self.keys['switch_to_edit']:
self.switch_mode('edit')
- elif key == 'f':
+ elif key == self.keys['flatten']:
self.send('TASK:FLATTEN_SURROUNDINGS')
elif key in self.movement_keys:
self.send('TASK:MOVE ' + self.movement_keys[key])