From 2dd8b15a9d7f82ce5406abe525ca257a0057cced Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 21 Feb 2021 20:20:05 -0500 Subject: [PATCH] fix this bit --- Adventure Game/adventure_game/GameNavigator.py | 12 +++--------- Adventure Game/adventure_game/handler.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 Adventure Game/adventure_game/handler.py diff --git a/Adventure Game/adventure_game/GameNavigator.py b/Adventure Game/adventure_game/GameNavigator.py index 620d33c..44ba48e 100644 --- a/Adventure Game/adventure_game/GameNavigator.py +++ b/Adventure Game/adventure_game/GameNavigator.py @@ -1,19 +1,14 @@ import npyscreen import sys +from Handler import Handler + class QuitButton(npyscreen.ButtonPress): def whenPressed(self): sys.exit(0) -class Render(npyscreen.ButtonPress): - def whenPressed(self): - self.parent.artContent.value = 'Undraw!' - self.parent.artContent.display() - self.parent.parentApp.switchForm('GAME') - - class GameNavigator(npyscreen.FormBaseNew): # def afterEditing(self): # it self.parentApp.setNextForm('GAME') @@ -55,7 +50,6 @@ class GameNavigator(npyscreen.FormBaseNew): editable=False) self.logBox = self.add(npyscreen.Textfield, - name='Type Here', max_width=inventory_width + art_width - 7, max_height=7, relx=2, @@ -76,7 +70,7 @@ class GameNavigator(npyscreen.FormBaseNew): relx=2, rely=top_division_height + 3 + 9) - self.sendButton = self.add(Render, + self.sendButton = self.add(Handler, name="Send", relx=inventory_width + art_width - 7, rely=top_division_height + 3 + 9) diff --git a/Adventure Game/adventure_game/handler.py b/Adventure Game/adventure_game/handler.py new file mode 100644 index 0000000..874cb99 --- /dev/null +++ b/Adventure Game/adventure_game/handler.py @@ -0,0 +1,15 @@ +import npyscreen + + +class Handler(npyscreen.ButtonPress): + """ + Very important, called when the player hits send, there are several things we need to do here: + 1: handle the player's input, and run logic, this is done in handler.py + 2: prepare new items to display on the screen + 3: re-render the screen + """ + def whenPressed(self): + self.parent.logBox.value = self.parent.dialogueBox.value + self.parent.dialogueBox.value = '' + self.parent.artContent.display() + self.parent.parentApp.switchForm('GAME') \ No newline at end of file