Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Visit https://www.youtube.com/user/thegrowers420 to see the tutorials maybe even subscribe! :D
- # 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.
- import character # Import character to get the functions we need
- # Make a parent class called 'Action'
- class Action:
- def __init__(self, method, name, keyword, **kwargs):
- # Assign all parameters
- self.method = method
- self.keyword = keyword
- self.name = name
- self.kwargs = kwargs
- # Make a string representation that consists of the keyword variable
- def __str__(self):
- return f"{self.keyword}"
- # Make movement classes that subclass Action
- class MoveNorth(Action):
- # Note: We use super().__init__() to gain access to the parent classes __init__ so we can assign the methods and such
- # Repeat for each direction
- def __init__(self):
- super().__init__(method=character.Character.move_north, name="move_north", keyword="go north")
- class MoveSouth(Action):
- def __init__(self):
- super().__init__(method=character.Character.move_south, name="move_south", keyword="Go South")
- class MoveEast(Action):
- def __init__(self):
- super().__init__(method=character.Character.move_east, name="move_east", keyword="Go East")
- class MoveWest(Action):
- def __init__(self):
- super().__init__(method=character.Character.move_west, name="move_west", keyword="Go West")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement