def toReloadGame(self, checked):
        fname = self.openFileNameDialog()
        try:
            with open(fname, "r") as f:
                saved_data = json.load(f)
                print("File loaded succesfully!")
        except Exception as inst:
            print(f"Problem loading save file - {inst}")
            sys.exit(1)

        try:
            config.progress.data = pd.DataFrame.from_dict(
                saved_data["progress"])
            config.progress.notes = saved_data["notes"]
            config.nancy.inventory = saved_data["inventory"]
        except Exception as inst:
            print(f"Problem loading in data - {inst}")
            sys.exit(1)

        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

        self.close()
class LoadGame(StartMenu):
    def __init__(self):
        super().__init__()
        self.title = 'Load Game'

    def setButtons(self):

        self.startButton = QPushButton('Choose File', self)
        self.startButton.setGeometry((self.width - self.button_width) / 2, 170,
                                     self.button_width, self.button_height)
        self.startButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.startButton.clicked.connect(self.toReloadGame)

        self.leaderButton = QPushButton('Back to Menu', self)
        self.leaderButton.setGeometry((self.width - self.button_width) / 2,
                                      390, self.button_width,
                                      self.button_height)
        self.leaderButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.leaderButton.clicked.connect(self.toMenu)

    def toReloadGame(self, checked):
        fname = self.openFileNameDialog()
        try:
            with open(fname, "r") as f:
                saved_data = json.load(f)
                print("File loaded succesfully!")
        except Exception as inst:
            print(f"Problem loading save file - {inst}")
            sys.exit(1)

        try:
            config.progress.data = pd.DataFrame.from_dict(
                saved_data["progress"])
            config.progress.notes = saved_data["notes"]
            config.nancy.inventory = saved_data["inventory"]
        except Exception as inst:
            print(f"Problem loading in data - {inst}")
            sys.exit(1)

        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

        self.close()

    def openFileNameDialog(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fname, _ = QFileDialog.getOpenFileName(self, "Choose File",
                                               "../data/save_files",
                                               "JSON Files (*.json)")
        return fname
    def toGame(self, checked):
        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

        self.close()
    def toOldGame(self, checked):
        # play start video
        # Create a VideoCapture object and read from input file
        cap = cv2.VideoCapture('../videos/test.mp4')
        cap.set(3, 1080)
        cap.set(4, 860)

        # Check if camera opened successfully
        if (cap.isOpened() == False):
            print("Error opening video file")

        # Read until video is completed
        while (cap.isOpened()):

            # Resize frame
            ret, frame = cap.read()
            width = int(frame.shape[1] * 2.25)
            height = int(frame.shape[0] * 3.17)
            dim = (width, height)
            frame = cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
            # Capture frame-by-frame
            if ret == True:

                # Display the resulting frame
                cv2.imshow('Frame', frame)

                # Press Q on keyboard to  exit
                if cv2.waitKey(25) & 0xFF == ord('q'):
                    break

            # Break the loop
            else:
                break

        # When everything done, release
        # the video capture object
        cap.release()

        # Closes all the frames
        cv2.destroyAllWindows()
        # creates first window
        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None
Ejemplo n.º 5
0
    def toReloadGame(self, checked):
        fname = self.openFileNameDialog()
        print("here")
        #try:
        saved_data = json.load(fname)
        # loading data into correct files
        config.progress.data = pd.DataFrame.from_dict(saved_data["progress"])
        config.progress.notes = saved_data["notes"]
        config.nancy.inventory = saved_data["inventory"]

        print(saved_data)
        #except Exception as inst:
        #    print(inst)

        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None
Ejemplo n.º 6
0
class Map(object):
    
    scenes = {
		'Introduction': Introduction(),
        'Kitchen': Kitchen(),
        'LivingRoom': LivingRoom(),
        'Toilet': Toilet(),
        'Bacement': Bacement(),
		'GameRoom': GameRoom(),
        'Attick': Attick(),
        'Out': Out()
    }
     
    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        return Map.scenes.get(scene_name)

    def opening_scene(self):
        return self.next_scene(self.start_scene)
Ejemplo n.º 7
0
class LoadGame(StartMenu):
    def __init__(self):
        super().__init__()
        self.title = 'Load Game'

        self.menu = None

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.setBackground()

        self.nancy_title = QLabel("Nancy Drew", self)
        self.nancy_title.setStyleSheet(
            "color: gold; background-color: black; qproperty-alignment: 'AlignHCenter | AlignVCenter'; border-width: 2px; border-color: black; font: bold 28px;"
        )
        self.nancy_title.setGeometry(50, 50, 380, 50)
        self.game_title = QLabel("Forced Quarantine", self)
        self.game_title.setStyleSheet(
            "color: gold; background-color: black; qproperty-alignment: 'AlignHCenter | AlignVCenter'; border-width: 2px; border-color: black; font: bold 44px;"
        )
        self.game_title.setGeometry(50, 90, 380, 50)

        self.startButton = QPushButton('Choose File', self)
        self.startButton.setGeometry(50, 170, 380, 100)
        self.startButton.setStyleSheet(
            "color: black; background-color: white; border-width: 2px; border-color: black; font: bold 32px;"
        )
        self.startButton.clicked.connect(self.toReloadGame)

        self.leaderButton = QPushButton('Back to Menu', self)
        self.leaderButton.setGeometry(50, 390, 380, 100)
        self.leaderButton.setStyleSheet(
            "color: black; background-color: white; border-width: 2px; border-color: black; font: bold 32px;"
        )
        self.leaderButton.clicked.connect(self.toMenu)

        self.exitButton = QPushButton('Exit', self)
        self.exitButton.setGeometry(50, 500, 380, 100)
        self.exitButton.setStyleSheet(
            "color: black; background-color: white; border-width: 2px; border-color: black; font: bold 32px;"
        )
        self.exitButton.clicked.connect(self.toExit)

    def toReloadGame(self, checked):
        fname = self.openFileNameDialog()
        print("here")
        #try:
        saved_data = json.load(fname)
        # loading data into correct files
        config.progress.data = pd.DataFrame.from_dict(saved_data["progress"])
        config.progress.notes = saved_data["notes"]
        config.nancy.inventory = saved_data["inventory"]

        print(saved_data)
        #except Exception as inst:
        #    print(inst)

        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

    def openFileNameDialog(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        fname, _ = QFileDialog.getOpenFileName(self, "Choose File",
                                               "../data/save_files",
                                               "JSON Files (*.json)")
        return fname

    def toMenu(self, checked):
        if self.menu is None:
            self.menu = StartMenu()
            self.menu.show()
            self.close()
        else:
            self.menu.close()
            self.menu = None
Ejemplo n.º 8
0
from SecondFloor import SecondFloor
from Basement import Basement
from Player import Player
from Parser import parser_rooms
import time
import os


def clear_screen():
	os.system('cls' if os.name == 'nt' else 'clear')


john = Player()
kitchen = Kitchen()
dining_room = DiningRoom()
living_room = LivingRoom()
office = OfficeRoom()
second_floor = SecondFloor()
basement = Basement()

class FirstFloor:
	rooms = ["kitchen", "dining", "living", "office", "second", "basement"]
	john.set_floor("first")

	def welcome(self):
		print(
			"You are at the First Floor here you have: {}, {}, {}, "
			"{}, {} and {}. "
				.format(kitchen.get_name(), dining_room.get_name(), living_room.get_name(), office.get_name(),
			            "Staircase to Second Floor", "Staircase to Basement"))
		time.sleep(1)
class StartMenu(QDialog):
    def __init__(self):
        super().__init__()
        self.title = 'Menu'
        self.left = 0
        self.top = 0
        self.width = 480
        self.height = 650

        self.game = None
        self.menu = None
        self.load_game = None
        self.leader_board_window = None

        self.f_size = 28
        self.button_width = 340
        self.button_height = 80

        self.setBackground()
        self.setButtons()
        self.initUI()

    def initUI(self):

        self.nancy_title = QLabel("Nancy Drew", self)
        self.nancy_title.setStyleSheet(
            "color: gold; background-color: black; qproperty-alignment: 'AlignHCenter | AlignVCenter'; border-width: 2px; border-color: black; font: bold 28px;"
        )
        self.nancy_title.setGeometry(50, 50, 380, 50)
        self.game_title = QLabel("Forced Quarantine", self)
        self.game_title.setStyleSheet(
            "color: gold; background-color: black; qproperty-alignment: 'AlignHCenter | AlignVCenter'; border-width: 2px; border-color: black; font: bold 44px;"
        )
        self.game_title.setGeometry(50, 90, 380, 50)

        self.exitButton = QPushButton('Exit', self)
        self.exitButton.setGeometry((self.width - self.button_width) / 2, 500,
                                    self.button_width, self.button_height)
        self.exitButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.exitButton.clicked.connect(self.toExit)

    def setButtons(self):

        self.startButton = QPushButton('Start New Game', self)
        self.startButton.setGeometry((self.width - self.button_width) / 2, 170,
                                     self.button_width, self.button_height)
        self.startButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.startButton.clicked.connect(self.toGame)

        self.loadButton = QPushButton('Load Game', self)
        self.loadButton.setGeometry((self.width - self.button_width) / 2, 280,
                                    self.button_width, self.button_height)
        self.loadButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.loadButton.clicked.connect(self.toLoad)

        self.leaderButton = QPushButton('Leaderboard', self)
        self.leaderButton.setGeometry((self.width - self.button_width) / 2,
                                      390, self.button_width,
                                      self.button_height)
        self.leaderButton.setStyleSheet(
            f"color: black; background-color: white; border-width: 2px; border-color: black; font: bold {self.f_size}px;"
        )
        self.leaderButton.clicked.connect(self.toLeader)

    def toGame(self, checked):
        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

        self.close()

    def toOldGame(self, checked):
        # play start video
        # Create a VideoCapture object and read from input file
        cap = cv2.VideoCapture('../videos/test.mp4')
        cap.set(3, 1080)
        cap.set(4, 860)

        # Check if camera opened successfully
        if (cap.isOpened() == False):
            print("Error opening video file")

        # Read until video is completed
        while (cap.isOpened()):

            # Resize frame
            ret, frame = cap.read()
            width = int(frame.shape[1] * 2.25)
            height = int(frame.shape[0] * 3.17)
            dim = (width, height)
            frame = cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
            # Capture frame-by-frame
            if ret == True:

                # Display the resulting frame
                cv2.imshow('Frame', frame)

                # Press Q on keyboard to  exit
                if cv2.waitKey(25) & 0xFF == ord('q'):
                    break

            # Break the loop
            else:
                break

        # When everything done, release
        # the video capture object
        cap.release()

        # Closes all the frames
        cv2.destroyAllWindows()
        # creates first window
        if self.game is None:
            self.game = LivingRoom()
            self.game.show()
            self.close()
        else:
            self.game.close()
            self.game = None

    def toLoad(self, checked):
        if self.load_game is None:
            self.load_game = LoadGame()
            self.load_game.show()
            self.close
        else:
            self.load_game.close()
            self.load_game = None

    def toLeader(self, checked):
        if self.leader_board_window is None:
            self.leader_board_window = Leaderboard()
            self.leader_board_window.show()
            self.close
        else:
            self.leader_board_window.close()
            self.leader_board_window = None

    def toMenu(self, checked):
        if self.menu is None:
            self.menu = StartMenu()
            self.menu.show()
            self.close()
        else:
            self.menu.close()
            self.menu = None

    def toExit(self, checked):
        QCoreApplication.exit(0)

    def setBackground(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        # Add paint widget and paint
        self.m = PaintWidget(self)
        self.m.move(0, 0)
        self.m.resize(self.width, self.height)