X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=rogue_chat_curses.py;h=34db7c9a1debff3163a3ade429556f9c9b379600;hb=b5440b01de1253e7741d2d48f56557f269943263;hp=9519a95609a82ba0f9a0fd4f7d7bca95999f756e;hpb=0ae5c165fbce33fcdc60f92cceb18109124aabde;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 9519a95..34db7c9 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -59,7 +59,7 @@ mode_helps = { 'enter_hat': { 'short': 'enter your hat', 'intro': '@ enter hat line (enter nothing to abort):', - 'long': 'Draw your hat as ASCII art. The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom..' + 'long': 'Draw your face as ASCII art. The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom. Eat cookies to extend the ASCII characters available for drawing.' }, 'write': { 'short': 'change terrain', @@ -582,6 +582,8 @@ class TUI: 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) @@ -652,6 +654,13 @@ class TUI: elif self.mode.name == 'admin_thing_protect': if hasattr(self.thing_selected, 'protection'): self.input_ = self.thing_selected.protection + 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' % @@ -1087,6 +1096,22 @@ class TUI: 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', @@ -1188,19 +1213,9 @@ class TUI: 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':