# HG changeset patch # User Adrianna Pińska # Date 1302111586 -7200 # Node ID a7cdf8458eddd694634e3cea0733c03887452c6a # Parent 164c30a7b776b2cd115837758707124ac9d3bcd9 ichiro and hattori, plus stuff for querying npc state from the world diff -r 164c30a7b776 -r a7cdf8458edd data/npcs/hattori.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/npcs/hattori.json Wed Apr 06 19:39:46 2011 +0200 @@ -0,0 +1,38 @@ +{ + "start" : { + "text" : "Ichiro, there is nothing to fear. Uesugi will light the signal fire if they come close.", + "events" : [ + { "matches" : "world.npc_is('ichiro', 'prepared')", "next": "state.wait" } + ] + }, + "wait" : { + "text" : "There’s nothing more for us to do but sit and wait. Sasuke will arrive with our cannon in a while. We can’t take on the entire Hayashi clan without it.", + "events" : [ + { "matches" : "world.npc_is('ichiro', 'sitting')", "next": "state.relax" } + ] + }, + "relax" : { + "text" : "Relax! You’re with me, the most fearsome katana in the East. We’re not moving from this spot until we have to. Besides, I need to meditate.", + "events" : [ + { "matches" : "world.npc_is('ichiro', 'but')", "next": "state.omm" } + ] + }, + "omm" : { + "text" : "Ommmmm...", + "events" : [ + { "matches" : "world.npc_is('ichiro', 'wakeup')", "next": "state.letsgo" } + ] + }, + "letsgo" : { + "text" : "Ha- huh? Uesugi’s fire! Let’s go!", + "events" : [ + { "matches" : "world.npc_is('ichiro', 'cannon')", "next": "state.attack" } + ] + }, + "attack" : { + "text" : "It will have to catch up. Attack!", + "auto_next": "state.gone" + }, + "gone" : { + } +} diff -r 164c30a7b776 -r a7cdf8458edd data/npcs/ichiro.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/npcs/ichiro.json Wed Apr 06 19:39:46 2011 +0200 @@ -0,0 +1,46 @@ +{ + "start" : { + "text" : "I’m telling you, Hattori. The Hayashi clan will arrive any minute now.", + "events" : [ + { "matches" : "world.npc_is('hattori', 'start')", "next": "state.prepared" } + ] + }, + "prepared" : { + "text" : "It doesn’t hurt to be prepared.", + "events" : [ + { "matches" : "world.npc_is('hattori', 'wait')", "next": "state.sitting" } + ] + }, + "sitting" : { + "text" : "I just don’t like sitting out in the open like this.", + "events" : [ + { "matches" : "world.npc_is('hattori', 'relax')", "next": "state.but" } + ] + }, + "but" : { + "text" : "But-", + "events" : [ + { "matches" : "world.npc_is('hattori', 'omm')", "next": "state.sigh" } + ] + }, + "sigh" : { + "text" : "Sigh.", + "events" : [ + { "matches" : "world.fire_started()", "next": "state.wakeup" } + ] + }, + "wakeup" : { + "text" : "Hattori, wake up! Look! Smoke coming over the rise.", + "events" : [ + { "matches" : "world.npc_is('hattori', 'letsgo')", "next": "state.cannon" } + ] + }, + "cannon" : { + "text" : "What about the cannon?", + "events" : [ + { "matches" : "world.npc_is('hattori', 'attack')", "next": "state.gone" } + ] + }, + "gone" : { + } +} diff -r 164c30a7b776 -r a7cdf8458edd skaapsteker/dialogue.py --- a/skaapsteker/dialogue.py Wed Apr 06 19:47:12 2011 +0200 +++ b/skaapsteker/dialogue.py Wed Apr 06 19:39:46 2011 +0200 @@ -15,11 +15,12 @@ Something to allow states to introspect the game state with. """ - def __init__(self, json_filename, world): + def __init__(self, npc_name, world): self.world = world + world.npcs[npc_name] = self self.state = "start" self.states = AttrDict() - src = json.loads(data.load(json_filename).read()) + src = json.loads(data.load('npcs/' + npc_name + '.json').read()) for state, state_src in src.iteritems(): pseudo_path = [json_filename, state] self.states[state] = DsmState(state, state_src, pseudo_path) @@ -124,6 +125,10 @@ self._fox_is_shapeshifted = False self._fox_is_disguised = False + self._fire_started = False + + self.npcs = {} + def fox_has_tea(self): return self._fox_has_tea @@ -133,3 +138,8 @@ def fox_is_disguised(self): return self._fox_is_disguised + def fire_started(self): + return self._fire_started + + def npc_is(self, npc_name, state): + return self.npcs[npc_name].state == state