Created
August 11, 2020 11:28
-
-
Save AntLouiz/8d6d58acdfd67fbcbe9d0d2875cb3c4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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