How to use the flax.component.Equipment function in flax

To help you get started, we’ve selected a few flax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eevee / flax / flax / entity.py View on Github external
# TODO not quite sure where this goes.  should it be able to react to events
# too?
class Modifier:
    def __init__(self, stat, add):
        self.stat = stat
        self.add = add

    def modify(self, attr, value):
        if attr is not self.stat:
            return value

        return value + self.add


Armor = Item(
    Equipment(modifiers=[Modifier(ICombatant['strength'], add=3)]),
    Render(sprite=Sprite.armor, color='default'),
    name='armor',
)
github eevee / flax / flax / component.py View on Github external
@Equip.perform(Equipment)
def put_on_equipment(event, equipment):
    equipment.worn_by.add(event.actor)
github eevee / flax / flax / component.py View on Github external
@Equip.check(Equipment)
def equipper_must_have_body_part(event, equipment):
    # TODO need to implement slots
    if IBodied not in event.actor:
        log.info("you can't wear that")
        event.cancel()
github eevee / flax / flax / component.py View on Github external
@Unequip.announce(Equipment)
def unequip_success(event, equipment):
    log.info("you take off the armor")
github eevee / flax / flax / component.py View on Github external
@Unequip.perform(Equipment)
def take_off_equipment(event, equipment):
    self.worn_by.remove(event.actor)
github eevee / flax / flax / component.py View on Github external
@Unequip.check(Equipment)
def can_only_equip_whats_equipped(event, equipment):
    if event.actor not in equipment.worn_by:
        log.info("you're not wearing the armor!")
        event.cancel()
github eevee / flax / flax / component.py View on Github external
@Equip.announce(Equipment)
def equipment_success(event, equipment):
    log.info("you put on the armor")