},
offset: [0,0],
map_lines: [],
+ ascii_draw_stage: 0,
+ full_ascii_draw: '',
selectables: [],
draw_face: false,
init: function() {
for (let [i, direction] of this.selectables.entries()) {
this.log_msg(i + ': ' + direction);
};
+ } else if (this.mode.name == 'enter_hat') {
+ this.log_msg('legal characters: ' + game.players_hat_chars);
} else if (this.mode.name == 'command_thing') {
server.send(['TASK:COMMAND', 'HELP']);
} else if (this.mode.name == 'control_pw_pw') {
if (t && t.protection) {
this.inputEl.value = t.protection;
}
- } else if (this.mode.name == 'enter_face' && game.player.face) {
- this.inputEl.value = game.player.face;
- } else if (this.mode.name == 'enter_hat' && game.player.hat) {
- this.inputEl.value = game.player.hat;
+ } else if (['enter_face', 'enter_hat'].includes(this.mode.name)) {
+ const start = this.ascii_draw_stage * 6;
+ const end = (this.ascii_draw_stage + 1) * 6;
+ if (this.mode.name == 'enter_face') {
+ this.inputEl.value = game.player.face.slice(start, end);
+ } else if (this.mode.name == 'enter_hat') {
+ this.inputEl.value = game.player.hat.slice(start, end);
+ }
}
},
recalc_input_lines: function() {
this.inputEl.value = "";
this.switch_mode('play');
},
+ enter_ascii_art: function(command) {
+ if (this.inputEl.value.length != 6) {
+ this.log_msg('? wrong input length, try again');
+ return;
+ }
+ this.log_msg(' ' + this.inputEl.value);
+ this.full_ascii_draw += this.inputEl.value;
+ this.ascii_draw_stage += 1;
+ if (this.ascii_draw_stage < 3) {
+ this.restore_input_values();
+ } else {
+ server.send([command, this.full_ascii_draw]);
+ this.full_ascii_draw = '';
+ this.ascii_draw_stage = 0;
+ this.inputEl.value = '';
+ this.switch_mode('edit');
+ }
+ },
draw_map: function() {
if (!game.turn_complete && this.map_lines.length == 0) {
return;
server.send(['LOGIN', tui.inputEl.value]);
tui.inputEl.value = "";
} else if (tui.mode.name == 'enter_face' && event.key == 'Enter') {
- if (tui.inputEl.value.length != 18) {
- tui.log_msg('? wrong input length, aborting');
- } else {
- server.send(['PLAYER_FACE', tui.inputEl.value]);
- }
- tui.inputEl.value = "";
- tui.switch_mode('edit');
+ tui.enter_ascii_art('PLAYER_FACE');
} else if (tui.mode.name == 'enter_hat' && event.key == 'Enter') {
- if (tui.inputEl.value.length != 18) {
- tui.log_msg('? wrong input length, aborting');
- } else {
- server.send(['PLAYER_HAT', tui.inputEl.value]);
- }
- tui.inputEl.value = "";
- tui.switch_mode('edit');
+ tui.enter_ascii_art('PLAYER_HAT');
} else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
server.send(['TASK:COMMAND', tui.inputEl.value]);
tui.inputEl.value = "";
self.fov = ''
self.flash = False
self.map_lines = []
+ self.ascii_draw_stage = 0
+ self.full_ascii_draw = ''
self.offset = YX(0,0)
curses.wrapper(self.loop)
elif self.mode.name == 'admin_thing_protect':
if hasattr(self.thing_selected, 'protection'):
self.input_ = self.thing_selected.protection
- elif self.mode.name == 'enter_face':
- self.input_ = self.game.player.face
- elif self.mode.name == 'enter_hat':
- self.input_ = self.game.player.hat
+ elif self.mode.name in {'enter_face', 'enter_hat'}:
+ start = self.ascii_draw_stage * 6
+ end = (self.ascii_draw_stage + 1) * 6
+ if self.mode.name == 'enter_face':
+ self.input_ = self.game.player.face[start:end]
+ elif self.mode.name == 'enter_hat':
+ self.input_ = self.game.player.hat[start:end]
def send_tile_control_command(self):
self.send('SET_TILE_CONTROL %s %s' %
self.input_ = ''
self.switch_mode('play')
+ def enter_ascii_art(command):
+ if len(self.input_) != 6:
+ self.log_msg('? wrong input length, try again')
+ return
+ self.log_msg(' ' + self.input_)
+ self.full_ascii_draw += self.input_
+ self.ascii_draw_stage += 1
+ if self.ascii_draw_stage < 3:
+ self.restore_input_values()
+ else:
+ self.send('%s %s' % (command, quote(self.full_ascii_draw)))
+ self.full_ascii_draw = ""
+ self.ascii_draw_stage = 0
+ self.input_ = ""
+ self.switch_mode('edit')
+
action_descriptions = {
'move': 'move',
'flatten': 'flatten surroundings',
self.send('LOGIN ' + quote(self.input_))
self.input_ = ""
elif self.mode.name == 'enter_face' and key == '\n':
- if len(self.input_) != 18:
- self.log_msg('? wrong input length, aborting')
- else:
- self.send('PLAYER_FACE %s' % quote(self.input_))
- self.input_ = ""
- self.switch_mode('edit')
+ enter_ascii_art('PLAYER_FACE')
elif self.mode.name == 'enter_hat' and key == '\n':
- if len(self.input_) != 18:
- self.log_msg('? wrong input length, aborting')
- else:
- self.send('PLAYER_HAT %s' % quote(self.input_))
- self.input_ = ""
- self.switch_mode('edit')
+ enter_ascii_art('PLAYER_HAT')
elif self.mode.name == 'take_thing' and key == '\n':
pick_selectable('PICK_UP')
elif self.mode.name == 'drop_thing' and key == '\n':