Ejemplo n.º 1
0
 def use_item(self, item):
     """
     Use item in different ways, depending on the item
     """
     if is_potion(item) and is_drinking_legal(self.character, item):
         drink(self.character,
               item)
     elif is_weapon(item):
         if self.character.inventory.weapon is not None:
             unequip(self.character,
                     self.character.inventory.weapon)
         equip(self.character,
               item)
     elif is_armour(item):
         if self.character.inventory.armour is not None:
             unequip(self.character,
                     self.character.inventory.armour)
         equip(self.character,
               item)
     elif is_boots(item):
         if self.character.inventory.boots is not None:
             unequip(self.character,
                     self.character.inventory.boots)
         equip(self.character,
               item)
     elif is_ammunition(item):
         equip(self.character,
               item)
     elif is_trap_bag(item):
         place_trap(self.character,
                    item)
Ejemplo n.º 2
0
def impl(context, character_name, item_name):
    if item_name in context.armour_list:
        item = context.armour_list[item_name]()
    elif item_name in context.boots_list:
        item = context.boots_list[item_name]()

    context.items.append(item)

    character = get_character(context, character_name)
    character.inventory.append(item)

    if is_armour(item):
        character.inventory.armour = item
    elif is_boots(item):
        character.inventory.boots = item
Ejemplo n.º 3
0
def impl(context, character_name, item_name):
    if item_name in context.armour_list:
        item = context.armour_list[item_name]()
    elif item_name in context.boots_list:
        item = context.boots_list[item_name]()

    context.items.append(item)

    character = get_character(context, character_name)
    character.inventory.append(item)

    if is_armour(item):
        character.inventory.armour = item
    elif is_boots(item):
        character.inventory.boots = item
Ejemplo n.º 4
0
    def execute(self):
        """
        Executes this action
        """
        if is_armour(self.item):
            self.character.inventory.armour = None
            self.character.raise_event(new_unequip_event(self.character,
                                                         self.item))
        if is_weapon(self.item):
            self.character.inventory.weapon = None
            self.character.raise_event(new_unequip_event(self.character,
                                                         self.item))

        if is_boots(self.item):
            self.character.inventory.boots = None
            self.character.raise_event(new_unequip_event(self.character,
                                                         self.item))
Ejemplo n.º 5
0
    def execute(self):
        """
        Executes this action
        """
        if is_armour(self.item):
            self.character.inventory.armour = None
            self.character.raise_event(
                new_unequip_event(self.character, self.item))
        if is_weapon(self.item):
            self.character.inventory.weapon = None
            self.character.raise_event(
                new_unequip_event(self.character, self.item))

        if is_boots(self.item):
            self.character.inventory.boots = None
            self.character.raise_event(
                new_unequip_event(self.character, self.item))
Ejemplo n.º 6
0
 def execute(self):
     """
     Executes this action
     """
     if is_armour(self.item):
         self.character.inventory.armour = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     if is_weapon(self.item):
         self.character.inventory.weapon = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     if is_ammunition(self.item):
         self.character.inventory.projectiles = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     elif is_boots(self.item):
         self.character.inventory.boots = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
Ejemplo n.º 7
0
 def execute(self):
     """
     Executes this action
     """
     if is_armour(self.item):
         self.character.inventory.armour = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     if is_weapon(self.item):
         self.character.inventory.weapon = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     if is_ammunition(self.item):
         self.character.inventory.projectiles = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))
     elif is_boots(self.item):
         self.character.inventory.boots = self.item
         self.character.raise_event(new_equip_event(self.character,
                                                    self.item))