コード例 #1
0
ファイル: game.py プロジェクト: miceslim/cis215final
    def Play_Game(self):
        """
        Plays current game!
        original by Philip Johnson, modifications by Chadwick.
        """
        player = Player(world) # instantiate new player by giving it the loaded world model so it has all the map information.
        player.name = self.name

        if self.player_coordinates != (-1, -1): # if player has loaded from a save file
            print(" COORDINATES: %s, %s " % self.player_coordinates)

        while player.is_alive() and self.game_active:
            room = world.tile_at(player.x, player.y) # Get current tile / room
            room.modify_player(player)

            if player.is_alive() and self.game_active:
                if room != world.tile_at(player.x, player.y): # On NL, room was not being updated to fix this, we check to see if there are any updates.
                    room = world.tile_at(player.x, player.y)

                room_strip = str(world.tile_at(player.x, player.y)).split()[0].strip('<')  # checks current tile player is on, strips away unnecessary information.
                if room_strip == "classes.world.StartTile":
                    print("Level Name: %s " % room.level_name)

                print(room.intro_text())
                print(" ")

                self.choose_action(room, player)

            elif not player.is_alive():
                print("%s has died! Game Over." % self.name)
コード例 #2
0
def play():
    world.load_tiles()
    player = Player()

    room = world.tile_exists(player.location_x, player.location_y)
    print(room.intro_text())

    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        room.modify_player(player)

        if room.id == CONST.EXIT_TILE_ID:
            player.victory = True

        if player.is_alive() and not player.victory:
            print("Choose an action:\n")
            available_actions = room.available_actions()
            for action in available_actions:
                print(action)

            action_input = input('Action: ')
            for action in available_actions:
                if action_input == action.hotkey:
                    player.do_action(action, **action.kwargs)
                    break
コード例 #3
0
 def Play_Game(self):
     player = Player(
         world
     )  # instantiate new player by giving it the loaded world model so it has all the map information.
     while player.is_alive() and self.game_active:
         room = world.Tile_At(player.x, player.y)
         print(room.intro_text())
         room.modify_player(player)
         if player.is_alive() and self.game_active:
             self.choose_action(room, player)
         elif not player.is_alive():
             print("%s has died! Game Over." % self.name)
コード例 #4
0
ファイル: game.py プロジェクト: tcollum/cis215final
    def Play_Game(self):
        player = Player(world) # instantiate new player by giving it the loaded world model so it has all the map information.

        while player.is_alive() and self.game_active:
            room = world.tile_at(player.x, player.y) # Get current tile / room
            print(room.intro_text())
            room.modify_player(player)

            if player.is_alive() and self.game_active:
                if room != world.tile_at(player.x, player.y): # On NL, room was not being updated to fix this, we check to see if there are any updates.
                    room = world.tile_at(player.x, player.y)

                self.choose_action(room, player)

            elif not player.is_alive():
                print("%s has died! Game Over." % self.name)