Package adventure :: Module adventure_GUI :: Class Adventure_GUI
[hide private]
[frames] | no frames]

Class Adventure_GUI

object --+
         |
        Adventure_GUI

This class contains a GUI for the Adventure text game project. The GUI reads its input from a text field and displays data about the game in uneditable text areas.


See Also: adventure.ui.adventure_text_UI

Instance Methods [hide private]
 
__init__(self)
Creates a new adventure game frame and starts a new adventure from the beginning.
 
text_entered(self, event)
Event handler method: reacts (assuming the game is not over) to the user giving a new command in the command input field.
 
play_turn(self, command)
Lets the player play a turn by executing the given command.
 
update_info(self, turn_report)
Updates the GUI with the current game status data.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

Creates a new adventure game frame and starts a new adventure from the beginning. Immediately makes the frame visible.

Overrides: object.__init__

text_entered(self, event)

 

Event handler method: reacts (assuming the game is not over) to the user giving a new command in the command input field. Clears the input field and proceeds to execute the given command.

Parameters:
  • event (event object) - the field that that received the input

play_turn(self, command)

 

Lets the player play a turn by executing the given command. If the player wants to quit, exits the application. Otherwise, updates the GUI with the game's new status after the player's turn.

Parameters:
  • command (string) - a command to execute, e.g. "go north", "quit"

update_info(self, turn_report)

 

Updates the GUI with the current game status data.

Parameters:
  • turn_report (string) - a report of the player's latest turn