Ejemplo n.º 1
0
 def examine(self):
     self.__write_message('Move cursor to view squares.  ESC to end.', True)
     _pl = self.cc.get_player_loc()
     _row = _pl[0]
     _col = _pl[1]
     _max_r = self.display_rows-1
     _max_c = self.display_cols-1
     
     while True:
         _dir = self.get_direction(False)
         if _dir in ('>', '<'):
             continue
         if _dir == '': 
             break
         _dt = get_direction_tuple(_dir)
         
         _sr = _row - self.map_r
         _sc = _col - self.map_c
         if _sr + _dt[0] >= 0 and _sr + _dt[0] < _max_r and _sc + _dt[1] >= 0 and _sc + _dt[1] <= _max_c:
             self.update_view(self.cc.get_sqr_info(_row, _col))
         
             _row += _dt[0]
             _col += _dt[1]
         
             _sqr = self.cc.get_tile_info(_row, _col)
             if _sqr.remembered:
                 self.write_cursor(_row, _col, _sqr.get_ch())
                 self.display_message('You see ' + _sqr.name)
             else:
                 self.write_cursor(_row, _col, ' ')
                 self.display_message('You see nothing.')
     
     self.update_view(self.cc.get_sqr_info(_row, _col))
     self.clear_msg_line()
Ejemplo n.º 2
0
 def do_action(self):
     _p = self.dm.player
     _lvl = self.dm.curr_lvl
     
     _sqr = self.find_actionable_sqrs(_p.row, _p.col)
     if _sqr == None:
         _dir = self.dui.get_direction()
         if _dir == '':
             self.dui.display_message("Nevermind.")
             return
         
         _dt = get_direction_tuple(_dir)
         _sr = _p.row+_dt[0]
         _sc = _p.col+_dt[1]
         
         if _dir == '>':
             _boxes = self.get_boxes(_lvl, _sr, _sc)
             
             # This is obviously dumb.  Need to fix it for sqrs with more
             # than one box, but it'll do for now.
             if len(_boxes) > 0:
                 _sqr = _boxes[0][0]
             
         if _sqr == None:
             _sqr = _lvl.map[_sr][_sc]
     else:
         _sr = _sqr[1][0]
         _sc = _sqr[1][1]
         _sqr = _sqr[0]
     
     if isinstance(_sqr, Terrain.Door):
         self.door_action(_sqr, _sr, _sc, _lvl)
     elif isinstance(_sqr, Terminal) and _sr == _p.row and _sc == _p.col:
         _sqr.jack_in(self.dm)
         self.dm.player.energy -= STD_ENERGY_COST
     elif isinstance(_sqr, Items.Box) and _sr == _p.row and _sc == _p.col:
         self.open_box(_sqr, _sr, _sc)
     else:
         self.dui.display_message("Hmm?")