コード例 #1
0
 def on_boarding():
     """ creates a player object with user input ,writes to save and starts the location"""
     print(f"hello and welcome to my game!\n What is your name?")
     name = UI.ask("(abc)")
     print(f"Oh your name is {name} and what is your gender?")
     gender = UI.ask("(abc)")
     Player = main_player(name, gender)
     print(f'here is your stats:\n {Player.stats()}')
     print("""Sorry for i was only interseted, it's hard to see.
     Welcome to this wonderful land.""")
     save_info.write(Player,Player.name)
     main.move_to_location(Player)
コード例 #2
0
    def run():
        """main function to run"""
        print("Have you ever played before? \n 1: Yes, 2: No")
        c = UI.options("(1-2)",1,2)
        if c == 1:
            main.reload()

        if c == 2:
            main.on_boarding()
コード例 #3
0
    def spawn(self):
        """spawn point for player will move to different paths"""

        print(f"You are now in {self.location.name}\n You see two doors in front which do you choose 1 or 2?")
        c = UI.options("(1-2)",1,2)
        if c == 1:
            self.do_action(self.location.pathone)
            print('you move on to path two')
            self.do_action(self.location.pathtwo)
            print('you win!, you find a hole and escape')
        elif c == 2:
            self.do_action(self.location.pathtwo)
            print('you move on to path one')
            self.do_action(self.location.pathone)
            print('you win!, time to escape')
コード例 #4
0
    def move_to_location(Player):
        """Will call a class depending on user input

        Locations:
            dead.spawn(),
            holy.spawn()

        Args:
            player (obj): the main_player
        
        """
        print("would you like to travel toh 1:hell or heaven?")
        location = UI.options("(1-2)", 1, 2)

        if location == 1:
            hell = play_location(Player,save_info.location("hell"))
            hell.spawn()

        if location == 2:
            heven = play_location(Player,save_info.location("heven"))
            heven.spawn()
コード例 #5
0
 def test_inject_A_or_D(self):
     with patch('builtins.input', return_value='A'):
         r = UI.fight_options()
         self.assertEqual(r, 'a')
コード例 #6
0
 def test_inject_ask(self):
     with patch('builtins.input', return_value='hello'):
         r = UI.ask("test")
         self.assertEqual(r, "hello")
コード例 #7
0
 def test_inject_vaild_options(self):
     with patch('builtins.input', return_value='1'):
         r = UI.options("1-3", 1, 3)
         print(r)
         self.assertEqual(r, 1)