Beispiel #1
0
    def check_next_case(self, x_position, command_position, show_map,
                        map_array):
        if map_array[command_position] == self.barrier:
            print("There is a barrier")

        elif map_array[command_position] == self.way_out:
            print("That's the way_out")
            print("")
            print("You win !!!")
            print("")
            Carte.delete_game()
            Carte.leave_game()

        elif map_array[command_position] == self.door:
            print("There is a door")
            print("")
            map_array[command_position] = "X"
            map_array[x_position[0], x_position[1]] = " "

        elif map_array[command_position] == " ":
            print("Movement of X")
            print("")
            map_array[command_position] = "X"
            map_array[x_position[0], x_position[1]] = " "

        else:
            print("There is an issue")
            print("")
Beispiel #2
0
def check_if_game_session_open():
    if os.path.exists(name_file_histo):  # If the file exist we collect it
        file_histo = open(name_file_histo, "rb")
        # mon_depickler = pickle.Unpickler(file_histo)
        if os.stat(name_file_histo).st_size == 0:
            print("No game running.")
            choose_map_game()

        else:
            valide_selection = True
            while valide_selection:
                try:
                    print(" ")
                    print("A party is saved, do you want to continue? "
                          "(Y/N)")
                    selection = input()
                    if selection.lower() == 'y':
                        print("we'll continue the party")
                        map_game = Carte.load_game(file_histo)
                        map_game = str('\n'.join(''.join(
                            str(cell) for cell in row) for row in map_game))
                        print(map_game)
                        line_tab.extend(map_game[:].split('\n'))
                        valide_selection = False

                    elif selection.lower() == 'n':
                        print("New game")
                        Carte.delete_game()
                        print("Old party deleted.")
                        choose_map_game()
                        valide_selection = False
                    else:
                        print("You wrote a wrong command. Please retry.")
                except ValueError:
                    print("problem")

    else:  # The file doesn't exist
        histo = {}