# HG changeset patch # User KarstenBock@gmx.net # Date 1316779909 -7200 # Node ID d0b600d7136c610f7954b015e3048263e76b0b2e # Parent e719bf53c25a8be9eef23f06a1630df2aff0a21b Added pc_has and npc_has as functions to the dialogue engine. These replace calls to pc.has_item and ncp.has_item. diff -r e719bf53c25a -r d0b600d7136c gui/dialoguegui.py --- a/gui/dialoguegui.py Fri Sep 23 13:35:44 2011 +0200 +++ b/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) diff -r e719bf53c25a -r d0b600d7136c gui/hud.py --- a/gui/hud.py Fri Sep 23 13:35:44 2011 +0200 +++ b/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