game.tui.query_info()
player = game.get_thing(game.player_id, False)
if player.position in game.portals:
- host, port = game.portals[player.position].split(':')
- game.tui.teleport_target_host = host
- game.tui.teleport_target_port = port
+ #host, port = game.portals[player.position].split(':')
+ game.tui.teleport_target_host = game.portals[player.position]
+ game.tui.teleport_target_port = 5000
game.tui.switch_mode('teleport')
game.turn_complete = True
game.tui.do_refresh = True
self.log = []
self.do_refresh = True
self.queue = queue.Queue()
+ self.login_name = None
self.switch_mode('waiting_for_server')
curses.wrapper(self.loop)
if self.mode.name == 'waiting_for_server':
self.log_msg('@ waiting for server …')
elif self.mode.name == 'login':
- self.log_msg('@ enter username')
+ if self.login_name:
+ self.send('LOGIN ' + quote(self.login_name))
+ else:
+ self.log_msg('@ enter username')
elif self.mode.name == 'teleport':
self.log_msg("@ May teleport to %s:%s" % (self.teleport_target_host,
self.teleport_target_port));
if len(self.input_) > max_length:
self.input_ = self.input_[:max_length]
elif self.mode == self.mode_login and key == '\n':
+ self.login_name = self.input_
self.send('LOGIN ' + quote(self.input_))
self.input_ = ""
elif self.mode == self.mode_chat and key == '\n':
this.websocket.onopen = function(event) {
window.setInterval(function() { server.send(['PING']) }, 30000);
tui.log_msg("@ server connected! :)");
- tui.init_login();
+ tui.switch_mode(mode_login);
};
this.websocket.onclose = function(event) {
tui.log_msg("@ server disconnected :(");
};
};
},
- init_login: function() {
- this.log_msg("@ please enter your username:");
- this.switch_mode(mode_login);
- },
switch_mode: function(mode, keep_pos=false) {
if (mode == mode_study && !keep_pos && game.player_id in game.things) {
explorer.position = game.things[game.player_id].position;
this.recalc_input_lines();
}
}
- if (mode == mode_portal && explorer.position in game.portals) {
+ if (mode == mode_login) {
+ if (this.login_name) {
+ server.send(['LOGIN', this.login_name]);
+ } else {
+ this.log_msg("? need login name");
+ }
+ } else if (mode == mode_portal && explorer.position in game.portals) {
let portal = game.portals[explorer.position]
- this.inputEl.value = portal;
- this.recalc_input_lines();
+ this.inputEl.value = portal;
+ this.recalc_input_lines();
} else if (mode == mode_teleport) {
tui.log_msg("@ May teleport to: " + tui.teleport_target);
tui.log_msg("@ Enter 'YES!' to entusiastically affirm.");
event.preventDefault();
}
if (tui.mode == mode_login && event.key == 'Enter') {
+ tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
- tui.switch_mode(mode_login);
+ tui.empty_input();
} else if (tui.mode == mode_portal && event.key == 'Enter') {
explorer.set_portal(tui.inputEl.value);
tui.switch_mode(mode_study, true);