Mercurial > skaapsteker
diff skaapsteker/dialogue.py @ 217:fcc5eca8eaca
Add explicit starting state to avoid it magically appearing later.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Thu, 07 Apr 2011 00:59:08 +0200 |
parents | 023eea4ad4a5 |
children | 8ea658969f47 |
line wrap: on
line diff
--- a/skaapsteker/dialogue.py Thu Apr 07 00:47:02 2011 +0200 +++ b/skaapsteker/dialogue.py Thu Apr 07 00:59:08 2011 +0200 @@ -15,17 +15,15 @@ Something to allow states to introspect the game state with. """ - def __init__(self, name, world, json_filename): - me = getattr(world.npcs, name) - self.state = getattr(me, 'state', 'start') - me.state = self.state + def __init__(self, name, world, json_filename, state): + self.state = state self.world = world self.states = AttrDict() src = json.loads(data.load(json_filename).read()) for state, state_src in src.iteritems(): pseudo_path = [json_filename, state] self.states[state] = DsmState(state, state_src, pseudo_path) - assert self.state in self.states, "DSM must have start state" + assert self.state in self.states, "DSM must have start state %r" % (self.state,) def get_state(self): return self.states[self.state] @@ -42,6 +40,7 @@ if next_state.name in self.states: self.states[self.state].leave(my_locals) self.state = next_state.name + # TODO: update self.world to reflect new state? self.states[self.state].enter(my_locals) def choice(self, i):