+# class for well
+class Well (GameObject):
+ def __init__ (self, row, col, image=None, liquid = "water"):
+ self.liquid = liquid
+ text = "Well"
+ GameObject.__init__ (self, row, col, text, image, False, "Draw %s" % liquid)
+
+ def interact (self):
+ return False
+
+ def use (self, otherobject):
+ # if the object is a bucket, fill it
+ if isinstance (otherobject, Bucket) is True:
+ # but only if it is empty
+ if otherobject.liquid is None:
+ otherobject.liquid = self.liquid
+
+
+# class for buckets
+class Bucket (GameObject):
+ def __init__ (self, row, col, image=None, liquid = None):
+ self.liquid = liquid
+ text = "Bucket"
+ if liquid is not None:
+ text = text + " containing %s" % liquid
+ GameObject.__init__ (self, row, col, text, image, True, "Empty it")
+
+ def interact (self):
+ return True
+
+ def use (self, otherobject):
+ # if the other object is a bucket, transfer its
+ # contents to the other bucket
+ if isinstance (otherobject, Bucket):
+ otherobject.liquid = self.liquid
+ # empty the bucket of its contents
+ self.liquid = None
+ self.text = "Bucket"
+