X-Git-Url: https://harishankar.org/repos/?p=butaba-adventures.git;a=blobdiff_plain;f=maingame.py;h=66f28b89d6a270ce4a4453dc3386e20cd674d352;hp=431d44dd4d6fb6b1b9d14b3900fb67e04e5680b0;hb=63f74206e69c1147ed006ccadb359fc6e21fefbb;hpb=4d50728c1454554fef2ad4841345d0c28101702d diff --git a/maingame.py b/maingame.py index 431d44d..66f28b8 100644 --- a/maingame.py +++ b/maingame.py @@ -10,6 +10,7 @@ import utility import gameobjects import constants import npcs +import gamestate class MainGame: @@ -28,6 +29,9 @@ class MainGame: self.img_chestbg = pygame.image.load (os.path.join ("background", "chestcontent.png")).convert () + self.img_dialogue = pygame.image.load (os.path.join ("background", "dialog_screen.png")).convert () + self.img_dialogue.set_colorkey (pygame.Color (0, 255, 0)) + # initialize object graphics self.img_redpotion = pygame.image.load (os.path.join ("objects", "red-potion.png")).convert () @@ -61,6 +65,10 @@ class MainGame: self.img_bulisa = pygame.image.load (os.path.join ("sprite", "bulisa.png")).convert () self.img_bulisa.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 () + # set level data self.setup_levels () # set current level and position of our character @@ -85,7 +93,10 @@ class MainGame: potion2 = gameobjects.HealthPotion (5, 2, self.img_redpotion) potion3 = gameobjects.HealthPotion (5, 2, self.img_redpotion) - npc_bulisa = npcs.Bulisa (4, 3, self.img_bulisa, None) + npc_bulisa = npcs.Bulisa (4, 3, self.img_bulisa, self.img_bulisa_portrait, + [ os.path.join ("dialogues", "bulisa1.dlg"), + os.path.join ("dialogues", "bulisa2.dlg"), + os.path.join ("dialogues", "bulisa3.dlg") ] ) chest1.objects = [ gold50, gold25, potion2, potion3, key2, gold10 ] @@ -247,7 +258,45 @@ class MainGame: # interaction with npcs def interact_npc (self, npc): - pass + # interact with NPC and get the response ID + # if the NPC is Bulisa + if isinstance (npc, npcs.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 + print (gamestate.mission_bulisa_water_from_well, gamestate.mission_bulisa_water_from_well_complete) + # not yet started mission drawing water from well and not refused it + if (gamestate.mission_bulisa_water_from_well is False + and gamestate.mission_bulisa_water_from_well_refused is False): + # set the current dialogue + npc.currentdialog = 0 + # get the response ID + resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.img_butaba_portrait, 0, 90) + if (gamestate.mission_bulisa_water_from_well_refused is True and + gamestate.mission_bulisa_water_from_well is False): + # set the current dialog + npc.currentdialog = 2 + resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.img_butaba_portrait, 0, 90) + # mission accepted but not completed + elif (gamestate.mission_bulisa_water_from_well is True + and gamestate.mission_bulisa_water_from_well_complete is False): + npc.currentdialog = 1 + # get the response ID + resp_id = utility.dialogue_play (self.screen, self.img_dialogue, npc, self.img_butaba_portrait, 0, 90) + + print resp_id + # if response ID is 12, then drawing water from well mission is refused + if resp_id == "12" or resp_id == "18": + gamestate.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": + gamestate.mission_bulisa_water_from_well = 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):