changeset 201:c0915e63a557

Added "Say" action.
author KarstenBock@gmx.net
date Thu, 15 Dec 2011 21:14:13 +0100
parents 13433b3e55ce
children 7747b0f73694
files .hgsubstate src/parpg/entities/action.py
diffstat 2 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Mon Dec 12 22:09:20 2011 +0100
+++ b/.hgsubstate	Thu Dec 15 21:14:13 2011 +0100
@@ -1,2 +1,2 @@
-22 data
+23 data
 833aac39c9bd43873554f19ab3d6c27ddba317ff tools
--- a/src/parpg/entities/action.py	Mon Dec 12 22:09:20 2011 +0100
+++ b/src/parpg/entities/action.py	Thu Dec 15 21:14:13 2011 +0100
@@ -581,6 +581,34 @@
                 Empty bottle"""))
         super(BrewBeerAction, self).execute()
 
+class SayAction(Action):
+    """Action that will display a short text over the entity and in the action
+    box."""
+
+    def __init__(self, controller, entity, text, commands = None):
+        """Basic action constructor
+        @param controller: A reference to the GameSceneController.
+        @type controller: parpg.GameSceneController
+        @param entity: The entity that says the text
+        @type script: parpg.entities.General
+        @param text: The text to be displayed
+        @type text: string
+        @param commands: Special commands that are executed
+        @type commands: Dictionary 
+        """
+        Action.__init__(self, controller, commands)
+        self.entity = entity
+        self.text = text
+    
+    def execute(self):
+        if self.entity.fifeagent:
+            self.entity.fifeagent.behaviour.agent.say(self.text);
+        if self.entity.description:
+            self.controller.view.hud.actions_box.addDialog(
+                self.entity.description.view_name,
+                self.text)
+        Action.execute(self)
+
 ACTIONS = {"ChangeMap":ChangeMapAction, 
            "Open":OpenAction,
            "Close":CloseAction,
@@ -597,5 +625,6 @@
            "BrewBeer":BrewBeerAction,
            "ExamineContents": ExamineContentsAction,
            "RunScript": RunScriptAction,
+           "Say" : SayAction,
            "None": Action,
            }