changeset 110:5feab6555bf9

Added pc_has and npc_has as functions to the dialogue engine. These replace calls to pc.has_item and ncp.has_item.
author KarstenBock@gmx.net
date Fri, 23 Sep 2011 14:11:49 +0200
parents bb0e09112a1f
children a33fdfeb4109
files src/parpg/gui/dialoguegui.py src/parpg/gui/hud.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/gui/dialoguegui.py	Fri Sep 23 13:35:44 2011 +0200
+++ b/src/parpg/gui/dialoguegui.py	Fri Sep 23 14:11:49 2011 +0200
@@ -27,7 +27,7 @@
     """Window that handles the dialogues."""
     _logger = logging.getLogger('dialoguegui.DialogueGUI')
     
-    def __init__(self, controller, npc, quest_engine, met_fnc, meet_fnc, player_character):
+    def __init__(self, controller, npc, quest_engine, met_fnc, meet_fnc, has_fnc, player_character):
         self.active = False
         self.controller = controller
         xml_file = vfs.VFS.open('gui/dialogue.xml')
@@ -40,6 +40,10 @@
         self.player_character = player_character
         self.met_fnc = met_fnc
         self.meet_fnc = meet_fnc
+        self.pc_has_fnc = lambda slot_or_type:\
+            has_fnc(player_character.container, slot_or_type)
+        self.npc_has_fnc = lambda slot_or_type:\
+            has_fnc(npc.container, slot_or_type)
     
     def initiateDialogue(self):
         """Callback for starting a quest"""
@@ -55,7 +59,10 @@
         self.setAvatarImage(self.npc.dialogue.dialogue.avatar_path)
         
         game_state = {'npc': self.npc, 'pc': self.player_character,
-                      'quest': self.quest_engine, 'met': self.met_fnc, 'meet': self.meet_fnc}
+                      'quest': self.quest_engine, 
+                      'met': self.met_fnc, 'meet': self.meet_fnc, 
+                      'pc_has': self.pc_has_fnc, 'npc_has': self.npc_has_fnc,
+                      }
         try:
             self.dialogue_processor = DialogueProcessor(self.npc.dialogue.dialogue,
                                                         game_state)
--- a/src/parpg/gui/hud.py	Fri Sep 23 13:35:44 2011 +0200
+++ b/src/parpg/gui/hud.py	Fri Sep 23 14:11:49 2011 +0200
@@ -28,7 +28,7 @@
 from parpg.gui import drag_drop_data as data_drag
 from parpg.gui.inventorygui import InventoryGUI
 from actionsbox import ActionsBox
-
+from parpg.components import container
 logger = logging.getLogger('hud')
 class Hud(object):
     """Main Hud class"""
@@ -509,5 +509,6 @@
                     npc,
                     self.model.game_state.quest_engine,
                     self.model.game_state.met, self.model.game_state.meet,
+                    container.get_item,
                     self.model.game_state.getObjectById("PlayerCharacter"))
         return dialogue