Advertisement
Trippy-Chords

actions.py (v1.0)

Dec 7th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.47 KB | None | 0 0
  1. # Visit https://www.youtube.com/user/thegrowers420 to see the tutorials maybe even subscribe! :D
  2. # Sorry for the last part, I made the account when I was 15 and forgot about that. If I get 100 subs, I can change it.
  3.  
  4. import character # Import character to get the functions we need
  5.  
  6. # Make a parent class called 'Action'
  7. class Action:
  8.     def __init__(self, method, name, keyword, **kwargs):
  9.         # Assign all parameters
  10.         self.method = method
  11.         self.keyword = keyword
  12.         self.name = name
  13.         self.kwargs = kwargs
  14.    
  15.     # Make a string representation that consists of the keyword variable
  16.     def __str__(self):
  17.         return f"{self.keyword}"
  18.  
  19. # Make movement classes that subclass Action
  20. class MoveNorth(Action):
  21.     # Note: We use super().__init__() to gain access to the parent classes __init__ so we can assign the methods and such
  22.     # Repeat for each direction
  23.     def __init__(self):
  24.         super().__init__(method=character.Character.move_north, name="move_north", keyword="go north")
  25.  
  26. class MoveSouth(Action):
  27.     def __init__(self):
  28.         super().__init__(method=character.Character.move_south, name="move_south", keyword="Go South")
  29.  
  30. class MoveEast(Action):
  31.     def __init__(self):
  32.         super().__init__(method=character.Character.move_east, name="move_east", keyword="Go East")
  33.  
  34. class MoveWest(Action):
  35.     def __init__(self):
  36.         super().__init__(method=character.Character.move_west, name="move_west", keyword="Go West")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement