diff gamelib/state.py @ 117:139864ce8bdb

removed items can't be the current tool
author Neil Muller <neil@dip.sun.ac.za>
date Tue, 24 Aug 2010 15:30:51 +0200
parents 5213b45fcc7e
children d5f7cccfdb6c
line wrap: on
line diff
--- a/gamelib/state.py	Tue Aug 24 14:56:39 2010 +0200
+++ b/gamelib/state.py	Tue Aug 24 15:30:51 2010 +0200
@@ -80,6 +80,9 @@
 
     def remove_inventory_item(self, name):
         self.inventory.remove(self.items[name])
+        # Unselect tool if it's removed
+        if self.tool == self.items[name]:
+            self.set_tool(None)
 
     def set_tool(self, item):
         self.tool = item