Exemplo n.º 1
0
    def pick_up(self,inventory):
        #add to the player's inventory and remove from the map
        self.owner.x = None
        self.owner.y = None
        if not self.owner.misc:
            for item in inventory:
                if item.item:
                    if item.item.check_stackable() and item.name == self.owner.name:
                        item.item.stack(self.qty)
                        if self.owner.objects:
                            if self.owner in self.owner.objects:
                                self.owner.objects.remove(self.owner)
                        if self.owner.message:
                            msg = menu.color_text('You picked up a ', libtcod.yellow)
                            msg+= menu.color_text(self.owner.name, self.owner.color)
                            msg+= menu.color_text('!', libtcod.yellow)
                            self.owner.message.message(msg, 0)
                        return

            if len(inventory) >= 26:
                if self.owner.message:
                    msg = menu.color_text('Your inventory is full, cannot pick up ',libtcod.yellow)
                    msg+= menu.color_text(self.owner.name,self.owner.color)
                    msg+= menu.color_text('.',libtcod.yellow)
                    self.owner.message.message(msg,0)
            else:
                inventory.append(self.owner)
                if self.owner.objects:
                    if self.owner in self.owner.objects:
                        self.owner.objects.remove(self.owner)
                if self.owner.message:
                    msg = menu.color_text('You picked up a ',libtcod.yellow)
                    msg+= menu.color_text(self.owner.name,self.owner.color)
                    msg+= menu.color_text('!',libtcod.yellow)
                    self.owner.message.message(msg,0)
Exemplo n.º 2
0
 def drop(self,inventory, owner, mes=True):
     #add to the map and remove from the owners inventory. 
     #also, place it at the owners coordinates
     self.owner.objects.append(self.owner)
     inventory.remove(self.owner)
     self.owner.x = owner.x
     self.owner.y = owner.y
     #only display a message if the player dropped it, or if its special
     if mes:
         msg = menu.color_text('%s dropped a '%owner.name.capitalize(),libtcod.yellow)
         msg+= menu.color_text(self.owner.name,self.owner.color)
         msg+= menu.color_text('.',libtcod.yellow)
         self.owner.message.message(msg,0)
Exemplo n.º 3
0
 def drop(self, inventory, owner, mes=True):
     #add to the map and remove from the owners inventory.
     #also, place it at the owners coordinates
     self.owner.objects.append(self.owner)
     inventory.remove(self.owner)
     self.owner.x = owner.x
     self.owner.y = owner.y
     #only display a message if the player dropped it, or if its special
     if mes:
         msg = menu.color_text('%s dropped a ' % owner.name.capitalize(),
                               libtcod.yellow)
         msg += menu.color_text(self.owner.name, self.owner.color)
         msg += menu.color_text('.', libtcod.yellow)
         self.owner.message.message(msg, 0)
Exemplo n.º 4
0
    def pick_up(self, inventory):
        #add to the player's inventory and remove from the map
        self.owner.x = None
        self.owner.y = None
        if not self.owner.misc:
            for item in inventory:
                if item.item:
                    if item.item.check_stackable(
                    ) and item.name == self.owner.name:
                        item.item.stack(self.qty)
                        if self.owner.objects:
                            if self.owner in self.owner.objects:
                                self.owner.objects.remove(self.owner)
                        if self.owner.message:
                            msg = menu.color_text('You picked up a ',
                                                  libtcod.yellow)
                            msg += menu.color_text(self.owner.name,
                                                   self.owner.color)
                            msg += menu.color_text('!', libtcod.yellow)
                            self.owner.message.message(msg, 0)
                        return

            if len(inventory) >= 26:
                if self.owner.message:
                    msg = menu.color_text(
                        'Your inventory is full, cannot pick up ',
                        libtcod.yellow)
                    msg += menu.color_text(self.owner.name, self.owner.color)
                    msg += menu.color_text('.', libtcod.yellow)
                    self.owner.message.message(msg, 0)
            else:
                inventory.append(self.owner)
                if self.owner.objects:
                    if self.owner in self.owner.objects:
                        self.owner.objects.remove(self.owner)
                if self.owner.message:
                    msg = menu.color_text('You picked up a ', libtcod.yellow)
                    msg += menu.color_text(self.owner.name, self.owner.color)
                    msg += menu.color_text('!', libtcod.yellow)
                    self.owner.message.message(msg, 0)