diff --git a/problems/py101/make_a_game/lib/player.py b/problems/py101/make_a_game/lib/player.py index 620f0da..116ad55 100644 --- a/problems/py101/make_a_game/lib/player.py +++ b/problems/py101/make_a_game/lib/player.py @@ -1,7 +1,11 @@ +from .pythonmon import Pythonmon +import random + class Player: def __init__(self): self._in_game = True self.name = None + self.pymon = None def say_hello(self): return "Hello!" @@ -16,8 +20,30 @@ def repeat(self, message): def in_game(self): return self._in_game + def catch_pymon(self): + self.has_pymon = True + list_of_pymon = ["Pykachu", "Pymander", "Pytle", "Pybasaur"] + seed = random.randint(0,len(list_of_pymon) - 1) + name = list_of_pymon[seed] + self.pymon = Pythonmon(name) + pass + + def check_pymon(self): + if self.pymon is not None: + print(f'Your pymon is called :{self.pymon.name} and has {self.pymon.hp} hp') + else: + print("Go catch a Pymon") + + def fight_baddie(self): + if self.pymon is None: + print("No Pymon") + else: + self.pymon.get_attacked() + @in_game.setter def in_game(self, game_state): if not isinstance(game_state, bool): raise Exception("Must set game state to True or False") self._in_game = game_state + + \ No newline at end of file diff --git a/problems/py101/make_a_game/run.py b/problems/py101/make_a_game/run.py index c5374ba..075b364 100644 --- a/problems/py101/make_a_game/run.py +++ b/problems/py101/make_a_game/run.py @@ -2,11 +2,11 @@ if __name__ == "__main__": player = Player() - player_name = input("Hello! What is your name? ") + player_name = input("Yo! What is your name? ") player.set_name(player_name) - print(f"Welcome {player.name} to this new game!") - print("Right now, all we can do is repeat what you say.") - print("Edit this program to add in more functionality!") + print(f"Welcome {player.name} to Pymon!") + print("Type 'catch' to catch a Pymon!") + print("Type 'Fight' to fight!") print("To stop playing, type quit") while player.in_game: @@ -14,5 +14,12 @@ if message == "quit": print("Roger that, thanks for playing!") player.in_game = False + elif message == "catch": + player.catch_pymon() + print("You just caught a Pymon!") + elif message == "fight": + player.fight_baddie() + elif message == "check": + player.check_pymon() else: print(player.repeat(message))