Mercurial > pyntnclick
changeset 808:d99400fcd624 pyntnclick
Avoid setting Thing state twice and empty state at all.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 27 Jan 2013 16:24:22 +0200 |
parents | 642564a3bedf |
children | 9968778115ce |
files | pyntnclick/state.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pyntnclick/state.py Sun Jan 27 16:19:19 2013 +0200 +++ b/pyntnclick/state.py Sun Jan 27 16:24:22 2013 +0200 @@ -262,7 +262,11 @@ def set_state(self, state): """Set the state object and initialize if needed""" self.state = state - self.state.initialize_state(self.state_key, self.INITIAL_DATA) + if self.state_key is None: + assert self.INITIAL_DATA is None, ( + "Can't provide self.INITIAL_DATA without self.state_key.") + if self.INITIAL_DATA is not None: + self.state.initialize_state(self.state_key, self.INITIAL_DATA) def set_data(self, key, value): if self.state: @@ -486,7 +490,6 @@ if self.folder is None: self.folder = scene.FOLDER self.game = scene.game - self.set_state(self.game.data) for interact in self.interacts.itervalues(): interact.set_thing(self) self.set_interact()