comparison entities/action.py @ 165:95461b06bac1

Added "Say" action.
author KarstenBock@gmx.net
date Thu, 15 Dec 2011 21:14:13 +0100
parents ed24962cdf5e
children f4994e080d87
comparison
equal deleted inserted replaced
164:ed24962cdf5e 165:95461b06bac1
579 In the inventory: 579 In the inventory:
580 Wood 580 Wood
581 Empty bottle""")) 581 Empty bottle"""))
582 super(BrewBeerAction, self).execute() 582 super(BrewBeerAction, self).execute()
583 583
584 class SayAction(Action):
585 """Action that will display a short text over the entity and in the action
586 box."""
587
588 def __init__(self, controller, entity, text, commands = None):
589 """Basic action constructor
590 @param controller: A reference to the GameSceneController.
591 @type controller: parpg.GameSceneController
592 @param entity: The entity that says the text
593 @type script: parpg.entities.General
594 @param text: The text to be displayed
595 @type text: string
596 @param commands: Special commands that are executed
597 @type commands: Dictionary
598 """
599 Action.__init__(self, controller, commands)
600 self.entity = entity
601 self.text = text
602
603 def execute(self):
604 if self.entity.fifeagent:
605 self.entity.fifeagent.behaviour.agent.say(self.text);
606 if self.entity.description:
607 self.controller.view.hud.actions_box.addDialog(
608 self.entity.description.view_name,
609 self.text)
610 Action.execute(self)
611
584 ACTIONS = {"ChangeMap":ChangeMapAction, 612 ACTIONS = {"ChangeMap":ChangeMapAction,
585 "Open":OpenAction, 613 "Open":OpenAction,
586 "Close":CloseAction, 614 "Close":CloseAction,
587 "Unlock":UnlockAction, 615 "Unlock":UnlockAction,
588 "Lock":LockAction, 616 "Lock":LockAction,
595 "PickUp":PickUpAction, 623 "PickUp":PickUpAction,
596 "DropFromInventory":DropItemFromContainerAction, 624 "DropFromInventory":DropItemFromContainerAction,
597 "BrewBeer":BrewBeerAction, 625 "BrewBeer":BrewBeerAction,
598 "ExamineContents": ExamineContentsAction, 626 "ExamineContents": ExamineContentsAction,
599 "RunScript": RunScriptAction, 627 "RunScript": RunScriptAction,
628 "Say" : SayAction,
600 "None": Action, 629 "None": Action,
601 } 630 }