From eb70e4a438288424b65c65ab0eb03ebfdb568a53 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 21 Feb 2021 17:07:14 -0500 Subject: [PATCH] Organize where the player() is initalized --- Adventure Game/adventure_game/MainMenu.py | 6 ++++++ Adventure Game/adventure_game/main.py | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Adventure Game/adventure_game/MainMenu.py b/Adventure Game/adventure_game/MainMenu.py index 7afc67d..3943b0c 100644 --- a/Adventure Game/adventure_game/MainMenu.py +++ b/Adventure Game/adventure_game/MainMenu.py @@ -1,5 +1,9 @@ import npyscreen + +from Player import Player + + class MainMenu(npyscreen.Form): def afterEditing(self): # TODO: the game needs to happen after this inital main menu @@ -8,4 +12,6 @@ class MainMenu(npyscreen.Form): def create(self): self.add(npyscreen.FixedText, value='You cannot select a file yet! Just hit OK', editable=False) self.playerSaveLocation = self.add(npyscreen.TitleFilenameCombo, name="Your save file:") + + self.parentApp.player = Player('playerdata/defaults/default_player.yaml') self.add(npyscreen.MultiLineEdit, value=self.parentApp.gamelib['menu']['graphics']['logo'], editable=False) \ No newline at end of file diff --git a/Adventure Game/adventure_game/main.py b/Adventure Game/adventure_game/main.py index 092fedb..ff04146 100644 --- a/Adventure Game/adventure_game/main.py +++ b/Adventure Game/adventure_game/main.py @@ -5,7 +5,6 @@ from os import system from yaml_parser import parse_datafile as parse from GameNavigator import GameNavigator from MainMenu import MainMenu -from Player import Player class AlphaWarning(npyscreen.Popup): @@ -24,9 +23,8 @@ class AdventureGame(npyscreen.NPSAppManaged): # Setup some important 'global' values we'll need later self.gamelib = parse( 'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu - self.playerSaveLocation = 'playerdata/defaults/default_player.yaml' #TODO: Actually load the player data - self.player = Player(self.playerSaveLocation) + self.player = None # Intalize the player as none, the player will be created in the main menu. # Set screen size before drawing windows dimensions = self.gamelib['menu']['graphics']['dimensions']