Package parpg :: Module gamestate :: Class GameState
[hide private]
[frames] | no frames]

Class GameState

source code

object --+
         |
        GameState

This class holds the current state of the game.

Instance Methods [hide private]
 
__init__(self, quests_dir=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
addObject(self, map_id, game_object)
Adds an object to the objects and object_ids dictionaries.
source code
 
deleteObject(self, object_id)
Removes an object from the dictionaries
source code
 
getObjectsFromMap(self, map_id)
Gets all objects that are currently on the given map.
source code
 
hasObject(self, object_id)
Check if an object with the given id is present
source code
 
getMapOfObject(self, object_id)
Returns the map the object is on.
source code
 
getObjectById(self, obj_id, map_id=None)
Gets an object by its object id and map id
source code
 
clearObjects(self)
Delete all objects from the state
source code
 
getStateForSaving(self)
Prepares state for saving
source code
 
restoreFromState(self, state)
Restores the state
source code

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, quests_dir=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

addObject(self, map_id, game_object)

source code 

Adds an object to the objects and object_ids dictionaries.

Parameters:
  • map_id (str or None) - ID of the map the object is on. If the object is in a container this has to be None
  • object (GameObject) - object to be added

deleteObject(self, object_id)

source code 

Removes an object from the dictionaries

Parameters:
  • object_id (str) - ID of the object

getObjectsFromMap(self, map_id)

source code 

Gets all objects that are currently on the given map.

Parameters:
  • map (String) - The map name.
Returns:
The list of objects on this map. Or an empty list

hasObject(self, object_id)

source code 

Check if an object with the given id is present

Parameters:
  • object_id (str) - ID of the object
Returns:
True if there is an object False if not

getMapOfObject(self, object_id)

source code 

Returns the map the object is on.

Parameters:
  • object_id (str) - ID of the object
Returns:
Name of the map the object is on. If there is no such object or the object is in a container None is returned

getObjectById(self, obj_id, map_id=None)

source code 

Gets an object by its object id and map id

Parameters:
  • obj_id (String) - The id of the object.
  • map_id (String) - It id of the map containing the object.
Returns:
The object or None.

getStateForSaving(self)

source code 

Prepares state for saving

Parameters:
  • state (dictionary) - State of the object