- 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':
+ for t in self.game.world.things:
+ if t == self.game.world.player or \
+ t.id_ in self.game.world.player_inventory:
+ continue
+ if t.position == self.game.world.player.position:
+ self.socket.send('TASK:PICKUP %s' % t.id_)
+ break
+ elif key == 'i':
+ self.view = 'inventory'
+ self.game.to_update['map'] = True
+ elif self.view == 'inventory':
+ if key == 'i':
+ self.view = 'map'
+ elif key == 'j' and \
+ len(self.game.world.player_inventory) > \
+ self.inventory_pointer + 1:
+ self.inventory_pointer += 1
+ elif key == 'k' and self.inventory_pointer > 0:
+ self.inventory_pointer -= 1
+ elif key == 'd' and \
+ len(self.game.world.player_inventory) > 0:
+ id_ = self.game.world.player_inventory[self.inventory_pointer]
+ self.socket.send('TASK:DROP %s' % id_)
+ if self.inventory_pointer > 0:
+ self.inventory_pointer -= 1
+ else:
+ continue
+ self.game.to_update['map'] = True