game.tui.switch_mode('play')
if game.tui.mode.shows_info:
game.tui.query_info()
- player = game.get_thing(game.player_id)
- if player.position in game.portals:
- game.tui.teleport_target_host = game.portals[player.position]
- game.tui.switch_mode('teleport')
game.turn_complete = True
game.tui.do_refresh = True
cmd_GAME_STATE_COMPLETE.argtypes = ''
self.mode_waiting_for_server = self.Mode('waiting_for_server', 'Waiting for a server response.', is_intro=True)
self.mode_login = self.Mode('login', 'Pick your player name.', has_input_prompt=True, is_intro=True)
self.mode_post_login_wait = self.Mode('post_login_wait', 'Waiting for a server response.', is_intro=True)
- self.mode_teleport = self.Mode('teleport', 'Follow the instructions to re-connect and log-in to another server, or enter anything else to abort.', has_input_prompt=True)
self.mode_password = self.Mode('password', 'This mode allows you to change the password that you send to authorize yourself for editing password-protected map tiles. Hit return to confirm and leave.', has_input_prompt=True)
self.game = Game()
self.game.tui = self
'flatten': 'F',
'take_thing': 'z',
'drop_thing': 'u',
+ 'teleport': 'p',
'toggle_map_mode': 'M',
'hex_move_upleft': 'w',
'hex_move_upright': 'e',
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" % (self.teleport_target_host)),
- self.log_msg("@ Enter 'YES!' to enthusiastically affirm.");
self.restore_input_values()
def loop(self, stdscr):
content += "[%s] – drop carried thing\n" % self.keys['drop_thing']
if 'FLATTEN_SURROUNDINGS' in self.game.tasks:
content += "[%s] – flatten player's surroundings\n" % self.keys['flatten']
+ content += '[%s] – teleport to other space\n' % self.keys['teleport']
content += 'Other modes available from here:\n'
content += '[%s] – chat mode\n' % self.keys['switch_to_chat']
content += '[%s] – study mode\n' % self.keys['switch_to_study']
quote(self.password)))
self.input_ = ""
self.switch_mode('play')
- elif self.mode == self.mode_teleport and key == '\n':
- if self.input_ == 'YES!':
- self.host = self.teleport_target_host
- self.reconnect()
- else:
- self.log_msg('@ teleport aborted')
- self.switch_mode('play')
- self.input_ = ''
elif self.mode == self.mode_study:
if key == self.keys['switch_to_chat']:
self.switch_mode('chat')
self.send('TASK:PICK_UP')
elif key == self.keys['drop_thing'] and 'DROP' in self.game.tasks:
self.send('TASK:DROP')
+ elif key == self.keys['teleport']:
+ player = self.game.get_thing(self.game.player_id)
+ if player.position in self.game.portals:
+ self.host = self.game.portals[player.position]
+ self.reconnect()
+ else:
+ self.flash()
+ self.log_msg('? not standing on portal')
elif key in self.movement_keys and 'MOVE' in self.game.tasks:
self.send('TASK:MOVE ' + self.movement_keys[key])
elif self.mode == self.mode_edit:
<button id="take_thing">take thing</button>
<button id="drop_thing">drop thing</button>
<button id="flatten">flatten surroundings</button>
+<button id="teleport">teleport</button>
<button id="switch_to_edit">change tile</button><br />
<button id="switch_to_password">change tile editing password</button>
<button id="switch_to_annotate">annotate tile</button>
<li>move left (hex grid): <input id="key_hex_move_left" type="text" value="a" />
<li>help: <input id="key_help" type="text" value="h" />
<li>flatten surroundings: <input id="key_flatten" type="text" value="F" />
+<li>teleport: <input id="key_teleport" type="text" value="p" />
<li>take thing under player: <input id="key_take_thing" type="text" value="z" />
<li>drop carried thing: <input id="key_drop_thing" type="text" value="u" />
<li>switch to chat mode: <input id="key_switch_to_chat" type="text" value="t" />
} else if (tui.mode == mode_study) {
explorer.query_info();
}
- let t = game.get_thing(game.player_id);
- if (t.position in game.portals) {
- tui.teleport_target = game.portals[t.position];
- tui.switch_mode(mode_teleport);
- return;
- }
tui.full_refresh();
} else if (tokens[0] === 'CHAT') {
tui.log_msg('# ' + tokens[1], 1);
let mode_play = new Mode('play', 'This mode allows you to interact with the map.', false, false);
let mode_study = new Mode('study', 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it.', false, true);
let mode_edit = new Mode('edit', 'This mode allows you to change the map tile you currently stand on (if your map editing password authorizes you so). Just enter any printable ASCII character to imprint it on the ground below you.', false, false);
-let mode_teleport = new Mode('teleport', 'Follow the instructions to re-connect and log-in to another server, or enter anything else to abort.', true);
let mode_portal = new Mode('portal', 'This mode allows you to imprint/edit/remove a teleportation target on the ground you are currently standing on (provided your map editing password authorizes you so). Enter or edit a URL to imprint a teleportation target; enter emptiness to remove a pre-existing teleportation target. Hit Return to leave.', true, true);
let mode_password = new Mode('password', 'This mode allows you to change the password that you send to authorize yourself for editing password-protected map tiles. Hit return to confirm and leave.', true, false, false);
document.getElementById("take_thing").disabled = true;
document.getElementById("drop_thing").disabled = true;
document.getElementById("flatten").disabled = true;
+ document.getElementById("teleport").disabled = true;
document.getElementById("toggle_map_mode").disabled = true;
document.getElementById("switch_to_chat").disabled = true;
document.getElementById("switch_to_play").disabled = true;
}
if (game.tasks.includes('MOVE')) {
}
+ document.getElementById("teleport").disabled = false;
document.getElementById("switch_to_annotate").disabled = false;
document.getElementById("switch_to_edit").disabled = false;
document.getElementById("switch_to_portal").disabled = false;
document.getElementById("toggle_map_mode").disabled = false;
} else if (mode == mode_edit) {
this.show_help = true;
- } else if (mode == mode_teleport) {
- tui.log_msg("@ May teleport to: " + tui.teleport_target);
- tui.log_msg("@ Enter 'YES!' to entusiastically affirm.");
}
this.full_refresh();
},
if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
content += "[" + tui.keys.flatten + "] – flatten player's surroundings\n";
}
+ content += "[" + tui.keys.teleport + "] – teleport to other space\n";
content += '\nOther modes available from here:\n';
content += '[' + this.keys.switch_to_chat + '] – chat mode\n';
content += '[' + this.keys.switch_to_study + '] – study mode\n';
return null;
};
return target;
+ },
+ teleport: function() {
+ let player = this.get_thing(game.player_id);
+ if (player.position in this.portals) {
+ server.reconnect_to(this.portals[player.position]);
+ } else {
+ terminal.blink_screen();
+ tui.log_msg('? not standing on portal')
+ }
}
}
}
tui.password = tui.inputEl.value
tui.switch_mode(mode_play);
- } else if (tui.mode == mode_teleport && event.key == 'Enter') {
- if (tui.inputEl.value == 'YES!') {
- server.reconnect_to(tui.teleport_target);
- } else {
- tui.log_msg('@ teleport aborted');
- tui.switch_mode(mode_play);
- };
} else if (tui.mode == mode_chat && event.key == 'Enter') {
let [tokens, token_starts] = parser.tokenize(tui.inputEl.value);
if (tokens.length > 0 && tokens[0].length > 0) {
} else if (event.key in tui.movement_keys
&& game.tasks.includes('MOVE')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
+ } else if (event.key === tui.keys.teleport) {
+ game.teleport();
} else if (event.key === tui.keys.switch_to_portal) {
event.preventDefault();
tui.switch_mode(mode_portal);
document.getElementById("flatten").onclick = function() {
server.send(['TASK:FLATTEN_SURROUNDINGS', tui.password]);
};
+document.getElementById("teleport").onclick = function() {
+ game.teleport();
+};
document.getElementById("move_upleft").onclick = function() {
if (tui.mode == mode_play) {
server.send(['TASK:MOVE', 'UPLEFT']);