Mercurial > pyntnclick
diff gamelib/scenes/machine.py @ 759:386475464202 pyntnclick
Inspect game state for Thing.set_interact() instead of setting it manually everywhere.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 26 Jan 2013 13:00:31 +0200 |
parents | c910c8b51d55 |
children | a8510f4e2ea1 43b49f1de828 |
line wrap: on
line diff
--- a/gamelib/scenes/machine.py Sat Jan 26 12:56:21 2013 +0200 +++ b/gamelib/scenes/machine.py Sat Jan 26 13:00:31 2013 +0200 @@ -100,18 +100,17 @@ 'contents': set(), } - def update_contents(self): - """Update the interact after a contents change.""" + def select_interact(self): contents = self.get_data('contents') if not contents: - self.set_interact("empty") + return "empty" elif len(contents) == 1: if "can" in contents: - self.set_interact("can") + return "can" elif "tube" in contents: - self.set_interact("tube") + return "tube" else: - self.set_interact("can_and_tube") + return "can_and_tube" def interact_without(self): return Result("You really don't want to put your hand in there.") @@ -122,7 +121,7 @@ return Result("There is already a can in the welder.") self.game.remove_inventory_item(item.name) contents.add("can") - self.update_contents() + self.set_interact() return Result("You carefully place the can in the laser welder.") def interact_with_tube_fragment(self, item): @@ -131,7 +130,7 @@ return Result("There is already a tube fragment in the welder.") self.game.remove_inventory_item(item.name) contents.add("tube") - self.update_contents() + self.set_interact() return Result("You carefully place the tube fragments in the" " laser welder.") @@ -179,7 +178,7 @@ " tube fragments to.") else: welder_slot.set_data("contents", set()) - welder_slot.update_contents() + welder_slot.set_interact() if self.game.is_in_inventory("cryo_pipes_one"): self.game.replace_inventory_item("cryo_pipes_one", "cryo_pipes_two")