diff 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
line wrap: on
line diff
--- a/gamestate.py	Thu Mar 01 14:49:09 2012 +0100
+++ b/gamestate.py	Fri Mar 02 19:42:26 2012 +0100
@@ -13,6 +13,8 @@
 #   You should have received a copy of the GNU General Public License
 #   along with PARPG.  If not, see <http://www.gnu.org/licenses/>.
 
+import math
+
 from parpg.quest_engine import QuestEngine
 
 class GameState(object):
@@ -28,8 +30,10 @@
         self.npcs_met = set()
         self.funcs = {
             "meet":self.meet,
-            "met":self.met
-        }
+            "met":self.met,
+            "sqrt":math.sqrt,
+            "log":math.log,          
+            }
         
         
     def addObject(self, object_id, map_id, game_object):
@@ -164,4 +168,11 @@
            @type npc: str
            @param npc: The NPC's name or id
            @return: None"""
-        return npc in self.npcs_met
\ No newline at end of file
+        return npc in self.npcs_met
+    
+    def getGameEnvironment(self):
+        """Returns a 2 item list containing the entities and functions that 
+        can work with it. This can be used in functions like eval or exec"""
+        vals = {}
+        vals.update(self.getObjectDictOfMap(self.current_map_name))
+        return vals, self.funcs
\ No newline at end of file