diff src/parpg/dialogueactions.py @ 109:bb0e09112a1f

take_stuff and give_stuff in dialogues work again.
author KarstenBock@gmx.net
date Fri, 23 Sep 2011 13:35:44 +0200
parents 2e307c4f78e3
children 371b17bc9113
line wrap: on
line diff
--- a/src/parpg/dialogueactions.py	Fri Sep 23 13:30:41 2011 +0200
+++ b/src/parpg/dialogueactions.py	Fri Sep 23 13:35:44 2011 +0200
@@ -18,6 +18,8 @@
 """
 import logging
 
+from parpg.components import container
+
 logger = logging.getLogger('dialogueaction')
 
 class DialogueAction(object):
@@ -147,14 +149,15 @@
         @type game_state: dict of objects
         """
         item_types = self.item_types
-        for item_type in item_types:
-            item = game_state['npc'].inventory.findItem(item_type=item_type)
+        for item_type in item_types:            
+            item = container.take_item(game_state['npc'].container, item_type)
             if (item):
-                game_state['npc'].give(item, game_state['pc'])
-                print("{0} gave you the {1}".format(game_state['npc'].name,
+                container.put_item(game_state['pc'].container, item)
+                print("{0} gave you the {1}".format(game_state['npc'].description.view_name,
                                                     item_type))
             else:
-                print("{0} doesn't have the {1}".format(game_state['npc'].name,
+                print("{0} doesn't have the {1}".format(game_state['npc'].
+                                                        description.view_name,
                                                         item_type))
 DialogueAction.registerAction(TakeStuffAction)
 
@@ -176,11 +179,12 @@
         """
         item_types = self.item_types
         for item_type in item_types:
-            item = game_state['npc'].inventory.findItem(item_type = item_type)
+            item = container.take_item(game_state['pc'].container, item_type)
             if (item):
-                game_state['pc'].give(item, game_state['npc'])
+                container.put_item(game_state['npc'].container, item)
                 print("You give the {0} to {1}".format(item_type,
-                                                       game_state['npc'].name))
+                                                       game_state['npc'].
+                                                       description.view_name))
             else:
                 print("You don't have the {0}".format(item_type))
 DialogueAction.registerAction(GiveStuffAction)