Skip to content

Instantly share code, notes, and snippets.

@AntLouiz
Created August 11, 2020 11:28
Show Gist options
  • Save AntLouiz/8d6d58acdfd67fbcbe9d0d2875cb3c4e to your computer and use it in GitHub Desktop.
Save AntLouiz/8d6d58acdfd67fbcbe9d0d2875cb3c4e to your computer and use it in GitHub Desktop.
from events import Events
class Player(Events):
itens = []
__events__ = ('add_item_event',)
def add_item(self, item):
self.itens.append(item)
self.add_item_event(item)
def something_to_happen_when_the_event_is_fired(item):
print("A {} was added to the bag.".format(item))
if __name__ == '__main__':
player = Player()
player.add_item_event += something_to_happen_when_the_event_is_fired
player.add_item("Knife")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment