+ notblock = self.interact_objects (level, objs)
+
+ # get npc at current location
+ current_npc = None
+ for npc in level.npcs:
+ if npc.row == row and npc.col == col:
+ current_npc = npc
+ break
+
+ # npcs always block the tile. So return false if there is an NPC
+ # at the location
+ if current_npc is not None:
+ self.interact_npc (current_npc)
+ return False
+
+ return notblock
+
+ # interaction with npcs
+ def interact_npc (self, npc):
+ # interact with NPC and get the response ID
+ # if the NPC is Bulisa
+
+ # if the NPC is dead cannot talk with the NPC
+ if npc.is_dead is True:
+ self.status_message = "%s is dead! RIP..." % npc.charname
+ return
+
+ if isinstance (npc, npcs.Bulisa):
+ # interact with Bulisa
+ self.interact_npc_bulisa (npc)
+ elif isinstance (npc, npcs.Mayor):
+ # interact with the Mayor
+ self.interact_npc_mayor (npc)
+
+ # interact with the mayor
+ def interact_npc_mayor (self, npc):
+ resp_id = None
+
+ if gamestate.flag["mission_charity_money"] is True:
+ npc.currentdialog = 2
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ elif gamestate.flag["mission_charity_informed_mayor"] is True:
+ npc.currentdialog = 1
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ else:
+ npc.currentdialog = 0
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+
+
+ # deal with the respnses
+ if resp_id == "missioncharityaccepted":
+ gamestate.flag["mission_charity_money"] = True
+ # response ID is none
+ elif resp_id is None:
+ self.status_message = "You cannot initiate a conversation with %s" % npc.charname
+
+ # interact with NPC Bulisa
+ def interact_npc_bulisa (self, npc):
+ # set initial response ID to none
+ resp_id = None
+
+ # check for global game states (starting from later flags to earlier ones
+
+ # whether butaba is doing the mayor charity mission
+ if gamestate.flag["mission_charity_money"] is True:
+ npc.currentdialog = 6
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ # whether the drawing water from well mission completed
+ elif gamestate.flag["mission_charity_informed"] is True:
+ npc.currentdialog = 5
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ elif gamestate.flag['mission_bulisa_water_from_well_complete'] is True:
+ npc.currentdialog = 4
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ # whether the drawing water from well mission refused
+ elif gamestate.flag['mission_bulisa_water_from_well_refused'] is True:
+ npc.currentdialog = 2
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ # whether the drawing water from well mission is accepted
+ elif gamestate.flag ['mission_bulisa_water_from_well'] is True:
+ # check if butaba has a bucket full of water
+ for invobj in self.butaba.objects:
+ if isinstance (invobj, gameobjects.Bucket) is True:
+ # if yes, then mission is completed accordingly
+ if invobj.liquid == "water":
+ gamestate.flag["mission_bulisa_water_from_well_complete"] = True
+ self.butaba.objects.remove (invobj)
+ key1 = gameobjects.Key (5, 3, "a chest key", self.img_key2, constants.KEY_CHEST1)
+ self.butaba.objects.append (key1)
+ break
+ # water mission is not completed yet
+ if gamestate.flag["mission_bulisa_water_from_well_complete"] is False:
+ npc.currentdialog = 1
+ else:
+ npc.currentdialog = 3
+ # get the response ID
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+ # Butaba hasn't been told about the initial mission yet, so tell him now
+ else:
+ npc.currentdialog = 0
+ # get the response ID
+ resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
+
+ # NPC RESPONSES:
+ # Check each response
+
+ # Drawing water from well mission is refused
+ if resp_id == "refusedwatermission":
+ gamestate.flag["mission_bulisa_water_from_well_refused"] = True
+ # Drawing water from well mission begins
+ elif resp_id == "acceptedwatermission":
+ gamestate.flag["mission_bulisa_water_from_well"] = True
+ gamestate.flag["mission_bulisa_water_from_well_refused"] = False
+ # Butaba is informed about the mayor's charity
+ elif resp_id == "informedcharitymission":
+ gamestate.flag["mission_charity_informed"] = True
+ # if mayor has been told about Butaba
+ elif resp_id == "mayortoldaboutbutaba":
+ gamestate.flag["mission_charity_informed_mayor"] = True
+ # if response ID is none
+ elif resp_id is None:
+ self.status_message = "You cannot initiate a conversation with %s" % npc.charname
+
+ # interaction with objects
+ def interact_objects (self, container, objs):