comparison gamestate.py @ 174:230d316cc43b

Moved the getEnvironment method from the ScriptingSystem to the GameState and renamed it to getGameEnvironment.
author Beliar
date Fri, 02 Mar 2012 19:42:26 +0100
parents 75c0b728ccf3
children 0d0422243490
comparison
equal deleted inserted replaced
173:3abd31885f0f 174:230d316cc43b
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 12
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. 14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
15
16 import math
15 17
16 from parpg.quest_engine import QuestEngine 18 from parpg.quest_engine import QuestEngine
17 19
18 class GameState(object): 20 class GameState(object):
19 """This class holds the current state of the game.""" 21 """This class holds the current state of the game."""
26 self.current_map_name = None 28 self.current_map_name = None
27 self.maps = {} 29 self.maps = {}
28 self.npcs_met = set() 30 self.npcs_met = set()
29 self.funcs = { 31 self.funcs = {
30 "meet":self.meet, 32 "meet":self.meet,
31 "met":self.met 33 "met":self.met,
32 } 34 "sqrt":math.sqrt,
35 "log":math.log,
36 }
33 37
34 38
35 def addObject(self, object_id, map_id, game_object): 39 def addObject(self, object_id, map_id, game_object):
36 """Adds an object to the objects and object_ids 40 """Adds an object to the objects and object_ids
37 dictionaries. 41 dictionaries.
163 """Indicate whether the PC has met this npc before 167 """Indicate whether the PC has met this npc before
164 @type npc: str 168 @type npc: str
165 @param npc: The NPC's name or id 169 @param npc: The NPC's name or id
166 @return: None""" 170 @return: None"""
167 return npc in self.npcs_met 171 return npc in self.npcs_met
172
173 def getGameEnvironment(self):
174 """Returns a 2 item list containing the entities and functions that
175 can work with it. This can be used in functions like eval or exec"""
176 vals = {}
177 vals.update(self.getObjectDictOfMap(self.current_map_name))
178 return vals, self.funcs