adventure-game #3

Open
Kenwood wants to merge 80 commits from adventure-game into master
2 changed files with 18 additions and 9 deletions
Showing only changes of commit 2dd8b15a9d - Show all commits

View File

@ -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)

View File

@ -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')