self.img_bulisaright = pygame.image.load (os.path.join ("sprite", "bulisa-right.png")).convert ()
self.img_bulisaright.set_colorkey (pygame.Color (0, 255, 0))
+ self.img_mayorfront = pygame.image.load (os.path.join ("sprite", "mayor-front.png")).convert ()
+ self.img_mayorfront.set_colorkey (pygame.Color (0, 255, 0))
+
+ self.img_mayorback = pygame.image.load (os.path.join ("sprite", "mayor-back.png")).convert ()
+ self.img_mayorback.set_colorkey (pygame.Color (0, 255, 0))
+
+ self.img_mayorleft = pygame.image.load (os.path.join ("sprite", "mayor-left.png")).convert ()
+ self.img_mayorleft.set_colorkey (pygame.Color (0, 255, 0))
+
+ self.img_mayorright = pygame.image.load (os.path.join ("sprite", "mayor-right.png")).convert ()
+ self.img_mayorright.set_colorkey (pygame.Color (0, 255, 0))
+
# initialize portraits
self.img_butaba_portrait = pygame.image.load (os.path.join ("portraits", "butaba.png")).convert ()
self.img_bulisa_portrait = pygame.image.load (os.path.join ("portraits", "bulisa.png")).convert ()
+ self.img_mayor_portrait = pygame.image.load (os.path.join ("portraits", "mayor.png")).convert ()
# set level data
self.setup_levels ()
os.path.join ("dialogues", "bulisa2.dlg"),
os.path.join ("dialogues", "bulisa3.dlg"),
os.path.join ("dialogues", "bulisa4.dlg"),
- os.path.join ("dialogues", "bulisa5.dlg") ] )
+ os.path.join ("dialogues", "bulisa5.dlg"),
+ os.path.join ("dialogues", "bulisa6.dlg") ] )
+
+ npc_mayor = npcs.Mayor (5, 4, self.img_mayorleft, self.img_mayorright,
+ self.img_mayorfront, self.img_mayorback,
+ self.img_mayor_portrait, constants.FRONT,
+ (2, 2, 2, 2))
chest1.objects = [ gold50, gold25, key2, gold10 ]
self.level1n = level.Level (cPickle.load (file (os.path.join ("levels", "level1n.dat"))),
objects = [ bucket ])
- # set up the interaction between levels
+ self.level1nw = level.Level (cPickle.load (file (os.path.join ("levels", "level1nw.dat"))))
+
+ self.level1ne = level.Level (cPickle.load (file (os.path.join ("levels", "level1ne.dat"))))
+
+ self.level1nee = level.Level (cPickle.load (file (os.path.join ("levels", "level1nee.dat"))))
+
+ self.level1sw = level.Level (cPickle.load (file (os.path.join ("levels", "level1sw.dat"))))
+
+ self.level1sww = level.Level (cPickle.load (file (os.path.join ("levels", "level1sww.dat"))))
+
+ self.level1ww = level.Level (cPickle.load (file (os.path.join ("levels", "level1ww.dat"))),
+ npcs = [ npc_mayor ])
+
+ # set up the interaction between levels (level exits)
self.level1.levelright = self.level1e
self.level1.levelleft = self.level1w
self.level1e.levelleft = self.level1
self.level1w.levelright = self.level1
self.level1.leveltop = self.level1n
self.level1n.levelbottom = self.level1
+ self.level1n.levelleft = self.level1nw
+ self.level1w.leveltop = self.level1nw
+ self.level1nw.levelright = self.level1n
+ self.level1nw.levelbottom = self.level1w
+ self.level1n.levelright = self.level1ne
+ self.level1e.leveltop = self.level1ne
+ self.level1ne.levelleft = self.level1n
+ self.level1ne.levelbottom = self.level1e
+ self.level1ne.levelright = self.level1nee
+ self.level1ee.leveltop = self.level1nee
+ self.level1nee.levelleft = self.level1ne
+ self.level1nee.levelbottom = self.level1ee
+ self.level1sw.leveltop = self.level1w
+ self.level1w.levelbottom = self.level1sw
+ self.level1sww.levelright = self.level1sw
+ self.level1sw.levelleft = self.level1sww
+ self.level1ww.levelright = self.level1w
+ self.level1ww.levelbottom = self.level1sww
+ self.level1sww.leveltop = self.level1ww
+ self.level1w.levelleft = self.level1ww
def main_loop (self):
# main game loop
return
if isinstance (npc, npcs.Bulisa):
- # interact
+ # interact with Bulisa
self.interact_npc_bulisa (npc)
# interact with NPC Bulisa
def interact_npc_bulisa (self, npc):
# set initial response ID to none
resp_id = None
- # not yet started mission drawing water from well and not refused it
- if (gamestate.flag["mission_bulisa_water_from_well"] is False
- and gamestate.flag["mission_bulisa_water_from_well_refused"] is False):
- # set the current dialogue
- npc.currentdialog = 0
- # get the response ID
+
+ # check for global game states (starting from later flags to earlier ones
+
+ # whether the drawing water from well mission completed
+ if 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)
- if (gamestate.flag["mission_bulisa_water_from_well_refused"] is True and
- gamestate.flag["mission_bulisa_water_from_well"] is False):
- # set the current dialog
+ 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)
- # mission accepted but not completed - check if completed and set value
- # accordingly
- elif (gamestate.flag["mission_bulisa_water_from_well"] is True
- and gamestate.flag["mission_bulisa_water_from_well_complete"] is False):
+ # 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 = 3
# get the response ID
resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.butaba.portrait, 0, 90)
- # water from well mission is completed
- elif (gamestate.flag["mission_bulisa_water_from_well_complete"]) is True:
- npc.currentdialog = 4
+ # 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)
- # if response ID is 12, then drawing water from well mission is refused
- if resp_id == "12" or resp_id == "18":
+ # 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
- # if response ID is 13: that is accepted the drawing water from well mission begins
- if resp_id == "13" or resp_id == "17":
+ # 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 response ID is none
elif resp_id is None:
self.status_message = "You cannot initiate a conversation with %s" % npc.charname