Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
PlayerIntelligence,
Render(sprite=Sprite.player, color='player'),
name='you',
)
Salamango = Creature(
Combatant(strength=1, health=5),
GenericAI,
Render(sprite=Sprite.lizard, color='salamango'),
name='salamango',
)
# -----------------------------------------------------------------------------
# Items
Item = partial(EntityType, Portable, layer=Layer.item)
Key = Item(Render(sprite=Sprite.key, color='default'), name='key')
Gem = Item(Render(sprite=Sprite.gem, color='default'), name='gemstone')
Crown = Item(Render(sprite=Sprite.crown, color='gold'), name='crown')
# TODO implement a potion!
# Potion = Item(UsablePotion, name='potion', tmp_rendering=('รฐ', 'default'))
Potion = Item(
Render(sprite=Sprite.flask, color='default'),
name='potion',
)
Crate = Item(
Container,
Render(sprite=Sprite.crate, color='wood'),
def do_pick_up(event, portable):
from flax.entity import Layer
assert portable.entity.type.layer is Layer.item
event.world.current_map.remove(portable.entity)
IContainer(event.actor).inventory.append(portable.entity)
# โญ gravestone
# โถ ammo
# โค cabin? uggh too wide barely
class Material(Enum):
pass
###############################################################################
# From here on it's all just definitions of specific types.
# -----------------------------------------------------------------------------
# Architecture
Architecture = partial(EntityType, layer=Layer.architecture)
StairsDown = Architecture(
Empty,
PortalDownstairs,
Render(sprite=Sprite.stairs_down, color='stairs'),
name='stairs',
)
StairsUp = Architecture(
Empty,
PortalUpstairs,
Render(sprite=Sprite.stairs_up, color='stairs'),
name='stairs',
)
Ladder = Architecture(
Empty,
PortalUpstairs,
def attach(self, entity):
"""Add the given entity from this tile. Its position is not affected.
This method is only intended to be called by the map object.
"""
if entity.layer is Layer.architecture:
assert self.architecture is None
self.architecture = entity
elif entity.layer is Layer.item:
self.items.append(entity)
elif entity.layer is Layer.creature:
assert self.creature is None
self.creature = entity
else:
raise TypeError(
"Unknown layer {!r} for entity {!r}"
.format(entity.layer, entity))
def detach(self, entity):
"""Remove the given entity from this tile. Its position is not
affected. This method is only intended to be called by the map object.
"""
if entity.layer is Layer.architecture:
assert self.architecture is entity
self.architecture = None
elif entity.layer is Layer.item:
self.items.remove(entity)
elif entity.layer is Layer.creature:
assert self.creature is entity
self.creature = None
else:
raise TypeError(
"Unknown layer {!r} for entity {!r}"
.format(entity.layer, entity))
(1, Sprite.ruin4b, 'decay3'),
(1, Sprite.ruin4c, 'decay3'),
(1, Sprite.ruin4d, 'decay3'),
(5, Sprite.ruin3a, 'decay2'),
(5, Sprite.ruin3b, 'decay2'),
(3, Sprite.ruin2, 'decay1'),
(10, Sprite.ruin1e, 'decay0'),
),
name='ruin',
)
# -----------------------------------------------------------------------------
# Creatures
Creature = partial(EntityType, Solid, Container, Bodied, layer=Layer.creature)
Player = Creature(
Combatant(strength=3, health=20),
PlayerIntelligence,
Render(sprite=Sprite.player, color='player'),
name='you',
)
Salamango = Creature(
Combatant(strength=1, health=5),
GenericAI,
Render(sprite=Sprite.lizard, color='salamango'),
name='salamango',
)
# -----------------------------------------------------------------------------
# Items