Package pajammin :: Module game :: Class Game
[show private | hide private]
[frames | no frames]

Class Game


The entire state of a single Pajammin' game. The Game object records the state of the player's avatar and of every level that the player has explored. In order to reduce memory usage, it maintains some of this state on disk: a single file is used for each level that the player visits, and only a few levels are kept in memory at a given time.
Method Summary
  __init__(self, playdir, current_level)
  level(self, levelname, update_current_level)
Return the level with the given name.
  load(savename, playdir)
Load a game from the subdirectory of 'data/saves' with the given name. (Static method)
  save(self, savename)
Save this game to a subdirectory of the 'data/saves' directory with the given name.

Instance Variable Summary
  current_level: The name of the current level.

Class Variable Summary
int CACHE_SIZE = 3                                                                     

Instance Method Details

__init__(self, playdir='play', current_level=None)
(Constructor)

level(self, levelname=None, update_current_level=True)

Return the level with the given name. If the level is present in memory or on disk, then it will be returned from there; otherwise, it is returned from the 'data/levels' directory.
Parameters:
levelname - The name of the level to return (or None to return the current level).
update_current_level - If true, then the current_level variable will be set to levelname.

save(self, savename)

Save this game to a subdirectory of the 'data/saves' directory with the given name. Each level will be saved in a separate file, and an additional file will be created that contains the name of the current level.

Static Method Details

load(savename, playdir='play')

Load a game from the subdirectory of 'data/saves' with the given name.

Instance Variable Details

current_level

The name of the current level.

Class Variable Details

CACHE_SIZE

Type:
int
Value:
3