SpaceNLasers
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lib.MenuGod.MenuGod Class Reference

Abstraction of a display for scores and stuff. More...

Inheritance diagram for lib.MenuGod.MenuGod:
Inheritance graph
[legend]
Collaboration diagram for lib.MenuGod.MenuGod:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, targetHostname)
 Initialises state and sends player information to display. More...
 
def CheckNewGameStart (self)
 Check if new game start is available. More...
 
def SendNewGameStart (self, msg)
 Send gamestart. More...
 
def SendGameInfo (self, info)
 Send game info (scores). More...
 
def SendError (self, error)
 Send error message to menu god. More...
 
def GameOver (self)
 Send game over message. More...
 

Public Attributes

 state
 
 buffer
 
 server
 
 connection
 
 targetHostname
 

Static Public Attributes

float CONNECTION_TIMEOUT = 0.1
 Time to try to establish a new connection. More...
 

Detailed Description

Abstraction of a display for scores and stuff.

Usage

1 m=MenuGod("")
2 # in lobby mode now
3 while(True):
4  gamestart=m.CheckNewGameStart()
5  if gamestart is not None:
6  # use gamestart info to initialize game
7  break

During game

1 try:
2  while(True):
3  # game loop
4  m.SendGameInfo(info)
5  m.GameOver()
6 except AbortGameException:
7  # cleanup game
8  return

Constructor & Destructor Documentation

def lib.MenuGod.MenuGod.__init__ (   self,
  targetHostname 
)

Initialises state and sends player information to display.

Parameters
targetHostnameIP of server to connect to. Use empty string to use server-mode

Member Function Documentation

def lib.MenuGod.MenuGod.CheckNewGameStart (   self)

Check if new game start is available.

If yes, MenuGod goes to game mode

Returns
game info if present, else None
def lib.MenuGod.MenuGod.GameOver (   self)

Send game over message.

After this, no more messages should be sent!

def lib.MenuGod.MenuGod.SendError (   self,
  error 
)

Send error message to menu god.

def lib.MenuGod.MenuGod.SendGameInfo (   self,
  info 
)

Send game info (scores).

Raises AbortGameException if data received

def lib.MenuGod.MenuGod.SendNewGameStart (   self,
  msg 
)

Send gamestart.

Only used for beamer

Member Data Documentation

lib.MenuGod.MenuGod.buffer
lib.MenuGod.MenuGod.connection
float lib.MenuGod.MenuGod.CONNECTION_TIMEOUT = 0.1
static

Time to try to establish a new connection.

lib.MenuGod.MenuGod.server
lib.MenuGod.MenuGod.state
lib.MenuGod.MenuGod.targetHostname

The documentation for this class was generated from the following file: