game.things += [t] # TODO refactor into Thing.__init__?
game.sessions[connection_id] = t.id_
game.io.send('META ' + quote('you are now: ' + nick), connection_id)
+ game.io.send('PLAYER_ID %s' % t.id_, connection_id)
cmd_LOGIN.argtypes = 'string'
def cmd_QUERY(game, target_nick, msg, connection_id):
for (const thing_id in game.things) {
let t = game.things[thing_id];
map_lines[t[0]][t[1]] = '@';
- player_position = t;
+ if (game.player_id == thing_id) {
+ player_position = t;
+ }
}
let offset = [(terminal.rows / 2) - player_position[0],
terminal.cols / 4 - player_position[1]];
things: {},
turn: 0,
map: "",
- map_size: [0,0]
+ map_size: [0,0],
+ player_id: 0
}
let chat = {
} else if (tokens[0] === 'LOG') {
tui.log_msg(tokens[1], 1);
tui.refresh();
+ } else if (tokens[0] === 'PLAYER_ID') {
+ game.player_id = parseInt(tokens[1]);
} else if (tokens[0] === 'META') {
tui.log_msg(tokens[1]);
tui.refresh();