Mercurial > skaapsteker
changeset 286:0dbb50d07764
Poke the current state before checking to see if there is text in case the world has changed and it is time for the state machine to move on.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Fri, 08 Apr 2011 20:58:12 +0200 |
parents | 71f15f6e9274 |
children | f512e874b2e7 |
files | skaapsteker/dialogue.py |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/skaapsteker/dialogue.py Fri Apr 08 20:52:47 2011 +0200 +++ b/skaapsteker/dialogue.py Fri Apr 08 20:58:12 2011 +0200 @@ -29,6 +29,7 @@ return self.states[self.state] def has_text(self): + self.poke() return bool(self.states[self.state].text) def event(self, ev): @@ -52,6 +53,11 @@ def auto_next(self): self.event(DsmEvent(auto_next=True)) + def poke(self): + # poke the current state to see if it feels like making + # a transition. + self.event(DsmEvent(poke=True)) + class AttrDict(dict): @@ -63,10 +69,11 @@ class DsmEvent(object): - def __init__(self, choice=None, auto_next=False): + def __init__(self, choice=None, auto_next=False, poke=False): self.items = { "choice": choice, "auto_next": auto_next, + "poke": poke, }