Esempio n. 1
0
def stairs(x, y, direction="down"):
    """Stairs components."""
    return [
        c.Render("stairs-" + str(direction)),
        c.TilePosition(x, y),
        c.Stairs(direction=direction),
    ]
Esempio n. 2
0
def exit_stairs(x, y):
    """Exit stairs components."""
    return [
        c.Render("stairs-down"),
        c.TilePosition(x, y),
        c.ExitStairs(),
    ]
Esempio n. 3
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
Esempio n. 4
0
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"]),
    ]
Esempio n. 5
0
 def wall(self, x, y):
     return self.world.create_entity(
         components.Position(x, y),
         components.Render("#", libtcod.dark_gray),
         components.Tangible(True),
         components.Optics(transparent=False),
         components.Terrain(),
         components.Text("wall", "a", description="A smooth stone wall."),
         components.Essence(0),
     )
Esempio n. 6
0
 def troll(self, x, y):
     self.log.debug("Adding troll at (" + str(x) + ", " + str(y) + ")")
     return self.world.create_entity(
         components.Actor(), components.Position(x, y),
         components.Render("T", libtcod.darker_green),
         components.Tangible(True), components.Optics(transparent=True),
         components.Creature(),
         components.Text("troll", description="A slimy green troll"),
         components.Health(20), components.Fighter(5, 1),
         components.Essence(40), components.Time(), components.Inventory())
Esempio n. 7
0
 def orc(self, x, y):
     self.log.debug("Adding orc at (" + str(x) + ", " + str(y) + ")")
     return self.world.create_entity(
         components.Actor(), components.Position(x, y),
         components.Render("o", libtcod.desaturated_green),
         components.Tangible(True), components.Optics(transparent=True),
         components.Creature(),
         components.Text("orc", description="A massive snarling orc"),
         components.Health(10), components.Fighter(3, 0),
         components.Essence(20), components.Time(), components.Inventory())
Esempio n. 8
0
    def player(self, x, y):
        player = self.world.create_entity(
            components.Actor(initial=0), components.Position(x, y),
            components.Render("@", libtcod.turquoise),
            components.Tangible(False), components.Optics(transparent=True),
            components.Player(),
            components.Text("ghost", "a", "A creepy old ghost..."),
            components.Possessor(2.0), components.Essence(100),
            components.EssenceAbsorber(1, 10),
            components.EssenceDrain(0.1, 1000), components.Time())

        return player
Esempio n. 9
0
def wall(x, y):
    """Wall components."""
    return [
        c.Render(choice(("wall1", "wall2"))),
        c.TilePosition(x, y),
        c.Blocker(),
        c.Destructible(),
        # For alive walls
        #c.Health(15),
        #c.Initiative(4),
        #c.AI(),
        #c.Movement(False),
        #   c.Attack(5),
    ]
Esempio n. 10
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
Esempio n. 11
0
def creature(**args):
    """Creature components."""
    if "image" not in args:
        args["image"] = None

    components = [
        c.Render(args["image"]),
        c.TilePosition(args["x"], args["y"]),
        c.Movement(diagonal=args["diagonal"]),
        c.Blocker(),
        c.Health(args["health"]),
        c.Attack(args["attack"]),
    ]
    if "anim_idle" in args:
        components.append(
            c.Animation(idle=args["anim_idle"], ready=args["anim_ready"]))
    if "speed" in args:
        components.append(c.Initiative(args["speed"]))

    return components
Esempio n. 12
0
 def target(self, x, y):
     return self.world.create_entity(
         components.Position(x, y),
         components.Render("", color=libtcod.yellow), components.Target())