diff skaapsteker/dialogue.py @ 193:897eec397cbb

Fix state checks for hattori, ichiro, kaneda and kumiko. In the process provide easier access to other npcs.
author Simon Cross <hodgestar@gmail.com>
date Wed, 06 Apr 2011 21:44:54 +0200
parents e4b466368b89
children a4c4e2f34162
line wrap: on
line diff
--- a/skaapsteker/dialogue.py	Wed Apr 06 21:39:30 2011 +0200
+++ b/skaapsteker/dialogue.py	Wed Apr 06 21:44:54 2011 +0200
@@ -15,9 +15,11 @@
            Something to allow states to introspect the game state with.
        """
 
-    def __init__(self, json_filename, world):
+    def __init__(self, name, world, json_filename):
+        me = getattr(world.npcs, name)
+        self.state = getattr(me, 'state', 'start')
+        me.state = self.state
         self.world = world
-        self.state = "start"
         self.states = AttrDict()
         src = json.loads(data.load(json_filename).read())
         for state, state_src in src.iteritems():
@@ -31,7 +33,8 @@
     def event(self, ev):
         my_locals = {
             "state": self.states,
-            "world" : self.world,
+            "world": self.world,
+            "npcs": self.world.npcs,
         }
         my_locals.update(ev.items)
         state = self.states[self.state]