- else:
- if len(key) == 1 and key in ASCII_printable and \
- len(self.to_send) < len(self.edit):
- self.to_send += [key]
- self.to_update['edit'] = True
- elif key == 'KEY_BACKSPACE':
- self.to_send[:] = self.to_send[:-1]
- self.to_update['edit'] = True
- elif key == '\n': # Return key
- self.socket.send(''.join(self.to_send))
- self.to_send[:] = []
- self.to_update['edit'] = True
+ elif key == 'p':
+ self.socket.send('GET_PICKABLE_ITEMS')
+ self.item_pointer = 0
+ self.view = 'pickable_items'
+ elif key == 'i':
+ self.item_pointer = 0
+ self.view = 'inventory'
+ self.game.to_update['map'] = True
+ elif self.view == 'pickable_items':
+ if key == 'c':
+ self.view = 'map'
+ elif key == 'j' and \
+ len(self.game.world.pickable_items) > \
+ self.item_pointer + 1:
+ self.item_pointer += 1
+ elif key == 'k' and self.item_pointer > 0:
+ self.item_pointer -= 1
+ elif key == 'p' and \
+ len(self.game.world.pickable_items) > 0:
+ id_ = self.game.world.pickable_items[self.item_pointer]
+ self.socket.send('TASK:PICKUP %s' % id_)
+ self.view = 'map'
+ else:
+ continue
+ self.game.to_update['map'] = True
+ elif self.view == 'inventory':
+ if key == 'c':
+ self.view = 'map'
+ elif key == 'j' and \
+ len(self.game.world.player_inventory) > \
+ self.item_pointer + 1:
+ self.item_pointer += 1
+ elif key == 'k' and self.item_pointer > 0:
+ self.item_pointer -= 1
+ elif key == 'd' and \
+ len(self.game.world.player_inventory) > 0:
+ id_ = self.game.world.player_inventory[self.item_pointer]
+ self.socket.send('TASK:DROP %s' % id_)
+ if self.item_pointer > 0:
+ self.item_pointer -= 1
+ else:
+ continue
+ self.game.to_update['map'] = True