Compare commits

..

3 Commits

Author SHA1 Message Date
Joe S e58af07b5e Create AdventureGame.log 2021-02-22 23:30:53 -05:00
Joe S e32e9895e5 Prepare logging! 2021-02-22 23:30:49 -05:00
Joe S 9fc4ed130c Add error handling to handler 2021-02-22 23:30:38 -05:00
3 changed files with 23 additions and 2 deletions

View File

@ -9,7 +9,20 @@ class Handler(npyscreen.ButtonPress):
3: re-render the screen
"""
def whenPressed(self):
self.parent.update_log(self.parent.dialogueBox.value)
# This is the raw command from the user
raw_command = self.parent.dialogueBox.value
# This is the raw command from the user
parsed_command = raw_command.split()
try:
command = parsed_command.pop(0)
except IndexError:
pass
arguments = parsed_command
self.parent.update_log('command: ' + command)
self.parent.update_log('args: {0}'.format(arguments))
self.parent.dialogueBox.value = ''
self.parent.artContent.display()
self.parent.parentApp.switchForm('GAME')

View File

@ -1,5 +1,6 @@
import pathlib
import npyscreen
import logging
from npyscreen import NotEnoughSpaceForWidget
from os import system
@ -19,12 +20,19 @@ class AlphaWarning(npyscreen.Popup):
class AdventureGame(npyscreen.NPSAppManaged):
"""
This is the 'root' of the entire game!
"""
# Do on creation
def onStart(self):
# Setup some important 'global' values we'll need later
# Set the path all other files will follow
self.mainPath = pathlib.Path(__file__).parent
# Setup logging
self.log = logging
self.log.basicConfig(filename=self.mainPath / 'logs/AdventureGame.log', filemode='w', level=logging.DEBUG)
# Parse world
self.gamelib = parse(
self.mainPath / 'gamedata/gamelib.yaml') # parse this data first (since it includes graphics for the main menu