Example #1
0
    def potion_healing(self, x, y):
        self.log.debug("Adding healing potion at (" + str(x) + ", " + str(y) +
                       ")")

        item = self.world.create_entity(
            components.Position(x, y),
            components.Render("!", libtcod.light_red),
            components.Optics(transparent=True, lit=True), components.Item(),
            components.Text(
                noun="healing potion",
                pronoun=pronoun_from_name("healing potion"),
                description=
                "A bubbling red potion with miraculous healing powers."),
            components.HealingEffect(hit_points=5,
                                     duration=3000,
                                     interval=1000))

        drop_action = components.DropAction(item)
        self.world.add_component(item, drop_action)

        drink_action = components.DrinkAction(item)
        self.world.add_component(item, drink_action)

        throw_action = components.ThrowAction(item, distance=4)
        self.world.add_component(item, throw_action)

        return item
def item(**args):
    """Item components."""
    return [
        c.Describable(args["name"], args["desc"]),
        c.Render(args["image"]),
        c.TilePosition(args["x"], args["y"]),
        c.Item(consumable=args["consumable"]),
    ]
Example #3
0
    def __init__(self,
                 position: Point,
                 char: str,
                 color: Colors,
                 name: str,
                 blocks: bool = False,
                 render_order: RenderLayer = RenderLayer.CORPSE,
                 fighter: Optional[components.Fighter] = None,
                 ai: Optional[EntityComponent] = None,
                 item: Optional[components.Item] = None,
                 inventory: Optional[components.Inventory] = None,
                 stairs: Optional[components.Stairs] = None,
                 level: Optional[components.Level] = None,
                 equipment: Optional[components.Equipment] = None,
                 equippable: Optional[components.Equippable] = None):
        self.position: Point = position
        self.char: str = char
        self.color: Colors = color
        self.name: str = name
        self.blocks: bool = blocks
        self.render_order: RenderLayer = render_order
        self.fighter: Optional[components.Fighter] = fighter
        self.ai: Optional[EntityComponent] = ai
        self.item: Optional[components.Item] = item
        self.inventory: Optional[components.Inventory] = inventory
        self.stairs: Optional[components.Stairs] = stairs
        self.level: Optional[components.Level] = level
        self.equipment: Optional[components.Equipment] = equipment
        self.equippable: Optional[components.Equippable] = equippable

        if self.fighter:
            self.fighter.owner = self

        if self.ai:
            self.ai.owner = self

        if self.item:
            self.item.owner = self

        if self.inventory:
            self.inventory.owner = self

        if self.stairs:
            self.stairs.owner = self

        if self.level:
            self.level.owner = self

        if self.equipment:
            self.equipment.owner = self

        if self.equippable:
            self.equippable.owner = self

            if not self.item:
                item = components.Item()
                self.item = item
                self.item.owner = self
Example #4
0
 def add_item(self, name, location=None):
     g = components.Item(self, name)
     if name in self.area.nodes:
         self.area.nodes[name].do_hide()
     self.area.nodes[name] = g
     if location is not None:
         g.setLocation(*location)
     self.area.add(g)
     self.area.repaint()
     return g
Example #5
0
def healing_potion(x, y):
    item_component = components.Item('A healing potion',
                                     use_function=spells.cast_heal)
    return components.Entity(x,
                             y,
                             'healing potion',
                             config.TILE_HEALING_POTION,
                             libtcodpy.violet,
                             is_walkable=True,
                             item=item_component)
Example #6
0
def scroll_fireball(x, y):
    item_component = components.Item('A fireball scroll',
                                     use_function=spells.cast_fireball)
    return components.Entity(x,
                             y,
                             'fireball scroll',
                             config.TILE_SCROLL,
                             libtcodpy.orange,
                             is_walkable=True,
                             item=item_component)
Example #7
0
def scroll_lightning(x, y):
    item_component = components.Item('A lightning scroll',
                                     use_function=spells.cast_lightning)
    return components.Entity(x,
                             y,
                             'lightning scroll',
                             config.TILE_SCROLL,
                             libtcodpy.light_yellow,
                             is_walkable=True,
                             item=item_component)
Example #8
0
    def decode_item(self, file, x, y):
        item_dict = Decoder.decode(self, file)

        color = vars(libtcod)[item_dict['color']]
        item_component = Components.Item(
            use_function=vars(Components)[item_dict['use_function']])
        item = object.Object(x,
                             y,
                             item_dict['char'],
                             item_dict['name'],
                             color=color,
                             always_visible=True,
                             item=item_component)
        return item
Example #9
0
    def corpse(self, x, y, creature_type):
        self.log.debug("Adding corpse at (" + str(x) + ", " + str(y) + ")")

        item = self.world.create_entity(
            components.Position(x, y),
            components.Render("%", libtcod.darker_red),
            components.Optics(transparent=True, lit=True), components.Item(),
            components.Text(noun=creature_type.lower() + " corpse",
                            pronoun=pronoun_from_name(creature_type),
                            description="A mutilated " + creature_type +
                            " corpse."))

        drop_action = components.DropAction(item)
        self.world.add_component(item, drop_action)

        return item
Example #10
0
    def __init__(self,
                 x,
                 y,
                 char,
                 name,
                 color,
                 blocks=False,
                 always_visible=False,
                 fighter=None,
                 ai=None,
                 item=None,
                 equipment=None):
        self.x = x
        self.y = y
        self.char = char
        self.name = name
        self.color = color
        self.blocks = blocks
        self.always_visible = always_visible

        self.fighter = fighter
        if self.fighter:
            self.fighter.owner = self

        self.ai = ai
        if self.ai:
            self.ai.owner = self

        self.item = item
        if self.item:
            self.item.owner = self

        self.equipment = equipment
        if self.equipment:
            self.equipment.owner = self
            self.item = Components.Item()
            self.item.owner = self