# HG changeset patch # User KarstenBock@gmx.net # Date 1316779909 -7200 # Node ID 5feab6555bf9efb5c7abf42e634932e82dc284d7 # Parent bb0e09112a1f15bd4c90c2cc7899f78e89231cf2 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 bb0e09112a1f -r 5feab6555bf9 src/parpg/gui/dialoguegui.py --- 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) diff -r bb0e09112a1f -r 5feab6555bf9 src/parpg/gui/hud.py --- 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