annotate src/parpg/entities/action.py @ 201:c0915e63a557

Added "Say" action.
author KarstenBock@gmx.net
date Thu, 15 Dec 2011 21:14:13 +0100
parents cf6345ec8988
children
rev   line source
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 # This file is part of PARPG.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 # (at your option) any later version.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 # GNU General Public License for more details.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
15
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
16 #exceptions
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18 import logging
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
19
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
20 logger = logging.getLogger('action')
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22 from parpg.gui import drag_drop_data as data_drag
12
d60f1dab8469 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
23 from parpg.dialoguecontroller import DialogueController
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
24 from parpg.components import container, lockable
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
25
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
26
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
27 class NoSuchQuestException(Exception):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28 """NoQuestException is used when there is no active quest with the id"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 pass
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 #classes
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 class Action(object):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 """Base Action class, to define the structure"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37 def __init__(self, controller, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 """Basic action constructor
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 self.commands = commands or ()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 self.controller = controller
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 self.model = controller.model
189
61d158ce6bc3 Implemented simple script system.
KarstenBock@gmx.net
parents: 178
diff changeset
47 self.executed = False
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
49 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50 """To be overwritten"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 #Check if there are special commands and execute them
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 for command_data in self.commands:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 command = command_data["Command"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 if command == "SetQuestVariable":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55 quest_id = command_data["ID"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56 variable = command_data["Variable"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 value = command_data["Value"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 quest_engine = self.model.game_state.quest_engine
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 if quest_engine.hasQuest(quest_id):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 quest_engine[quest_id].setValue(variable, value)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 else:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62 raise NoSuchQuestException
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63 elif command == "ResetMouseCursor":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 self.controller.resetMouseCursor()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 elif command == "StopDragging":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66 data_drag.dragging = False
189
61d158ce6bc3 Implemented simple script system.
KarstenBock@gmx.net
parents: 178
diff changeset
67 self.executed = True
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
68
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
69 class ChangeMapAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
70 """A change map scheduled"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
71 def __init__(self, controller, target_map_name, target_pos, commands=None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
72 """Initiates a change of the position of the character
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
73 possibly flagging a new map to be loaded.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
74 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
75 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
76 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
77 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
78 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
79 @param view: The view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
80 @type target_map_name: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
81 @param target_map_name: Target map id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
82 @type target_pos: Tuple
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
83 @param target_pos: (X, Y) coordinates on the target map.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
84 @return: None"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
85 super(ChangeMapAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
86 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
87 self.target_pos = target_pos
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
88 self.target_map_name = target_map_name
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
89
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
91 """Executes the map change."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
92 self.model.changeMap(self.target_map_name,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
93 self.target_pos)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
94 super(ChangeMapAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
95
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
96 class OpenAction(Action):
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
97 """Open an lockable"""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
98 def __init__(self, controller, lockable, commands=None):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 @param view: The view
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
106 @param lockable: A reference to the lockable
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107 """
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
108 Action.__init__(self, controller, commands)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
109 self.view = controller.view
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
110 self.lockable = lockable
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
111
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
112 def execute(self):
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
113 """Open the lockable."""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
114 try:
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
115 lockable.open(self.lockable.lockable)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
116 self.lockable.fifeagent.behaviour.animate("open")
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
117 self.lockable.fifeagent.behaviour.queue_animation("opened",
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
118 repeating=True)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
119 except lockable.LockedError:
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
120 self.view.hud.createExamineBox(self.lockable.description.view_name,
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
121 "Locked")
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
122 Action.execute(self)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
123
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
124 class CloseAction(Action):
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
125 """Close an lockable"""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
126 def __init__(self, controller, lockable, commands=None):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
127 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
128 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
129 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
130 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
131 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
132 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
133 @param view: The view
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
134 @param lockable: A reference to the lockable
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
135 """
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
136 Action.__init__(self, controller, commands)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
137 self.lockable = lockable
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
138
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
139 def execute(self):
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
140 """Close the lockable."""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
141 lockable.close(self.lockable.lockable)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
142 self.lockable.fifeagent.behaviour.animate("close")
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
143 self.lockable.fifeagent.behaviour.queue_animation("closed",
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
144 repeating=True)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
145 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
146
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
147 class UnlockAction(Action):
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
148 """Unlocks a lockable."""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
149 def __init__(self, controller, lockable, commands = None):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
150 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
151 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
152 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
153 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
154 @type commands: Dictionary
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
155 @param lockable: A reference to the lockable
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
156 """
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
157 Action.__init__(self, controller, commands)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
158 self.lockable = lockable
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
159
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
160 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
161 """Open the box."""
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
162 lockable.unlock(self.lockable.lockable)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
163 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
165 class LockAction(Action):
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
166 """Locks a lockable."""
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
167 def __init__(self, controller, lockable, commands = None):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
168 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
169 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
170 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
171 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
172 @type commands: Dictionary
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
173 @param lockable: A reference to the lockable
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
174 """
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
175 Action.__init__(self, controller, commands)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
176 self.lockable = lockable
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
177 self.view = controller.view
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
178
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
179 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
180 """Lock the box."""
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
181 try:
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
182 lockable.lock(self.lockable.lockable)
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
183 except lockable.OpenError:
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
184 self.view.hud.createExamineBox(self.lockable.description.view_name,
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
185 "Is open")
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
186
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
187 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
188
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
189
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
190 class ExamineAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
191 """Examine an object."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
192 def __init__(self, controller, examine_id, examine_name, examine_desc=None, commands=None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
193 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
194 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
195 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
196 @param examine_id: An object id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
197 @type examine_id: integer
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
198 @param examine_name: An object name
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
199 @type examine_name: string
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
200 @param examine_desc: A description of the object that will be displayed.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
201 @type examine_desc: string
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
202 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
203 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
204 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
205 super(ExamineAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
206 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
207 self.examine_id = examine_id
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
208 self.examine_name = examine_name
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
209 if examine_desc is not None:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
210 self.examine_desc = examine_desc
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
211 else:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
212 self.examine_desc = "No Description"
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
213
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
214 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
215 """Display the text."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
216 action_text = self.examine_desc
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
217 self.view.hud.addAction(unicode(action_text))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
218 logger.debug(action_text)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
219 #this code will cut the line up into smaller lines that will be displayed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
220 place = 25
81
5508000aceaf Fixed bug in the text splitting code of ExamineAction.
KarstenBock@gmx.net
parents: 78
diff changeset
221 while place < len(action_text):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
222 if action_text[place] == ' ':
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
223 action_text = action_text[:place] +'\n'+action_text[place:]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
224 place += 26 #plus 1 character to offset the new line
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
225 else: place += 1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
226 self.view.displayObjectText(self.examine_id, unicode(action_text), time=3000)
137
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
227 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
228
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
229 class ExamineItemAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
230 """Examine an item."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
231 def __init__(self, controller, examine_name, examine_desc, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
232 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
233 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
234 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
235 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
236 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
237 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
238 @param view: The view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
239 @type examine_name: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
240 @param examine_name: Name of the object to be examined.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
241 @type examine_name: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
242 @param examine_name: Description of the object to be examined.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
243 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
244 super(ExamineItemAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
245 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
246 self.examine_name = examine_name
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
247 self.examine_desc = examine_desc
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
248
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
249 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
250 """Display the text."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
251 action_text = unicode(self.examine_desc)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
252 self.view.hud.addAction(action_text)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
253 logger.debug(action_text)
137
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
254 Action.execute(self)
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
255
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
256 class ExamineContentsAction(Action):
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
257 """Examine the contens of an container"""
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
258 def __init__(self, controller, container, commands=None):
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
259 """
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
260 @param controller: A reference to the GameSceneController.
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
261 @type controller: parpg.GameSceneController
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
262 @param container: The container
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
263 @type container: parpg.entities.General
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
264 @param commands: Special commands that are executed
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
265 @type commands: Dictionary
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
266 """
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
267 Action.__init__(self, controller, commands)
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
268 self.view = controller.view
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
269 self.container = container
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
270
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
271 def execute(self):
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
272 """Examine the contents"""
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
273 self.view.hud.createBoxGUI(self.container.description.view_name,
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
274 self.container.container)
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
275 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
276
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
277 class ReadAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
278 """Read a text."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
279 def __init__(self, controller, text_name, text, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
280 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
281 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
282 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
283 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
284 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
285 @param view: The view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
286 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
287 @param text_name: Name of the object containing the text
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
288 @type text_name: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
289 @param text: Text to be displayied
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
290 @type text: String
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
291 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
292 super(ReadAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
293 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
294 self.text_name = text_name
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
295 self.text = text
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
296
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
297 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
298 """Examine the box."""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
299 action_text = unicode('\n'.join(["You read " + self.text_name + ".",
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
300 self.text]))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
301 self.view.hud.addAction(action_text)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
302 logger.debug(action_text)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
303 super(ReadAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
304
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
305 class TalkAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
306 """An action to represent starting a dialogue"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
307 def __init__(self, controller, npc, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
308 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
309 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
310 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
311 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
312 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
313 @type view: class derived from parpg.ViewBase
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
314 @param view: The view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
315 @type npc: NonPlayerCharacter
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
316 @param npc: NPC to interact with.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
317 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
318 super(TalkAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
319 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
320 self.npc = npc
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
321
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
322 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
323 """Talk with the NPC when close enough, otherwise move closer.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
324 @return: None"""
78
c25c734bd2a7 Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 69
diff changeset
325 player_char = self.model.game_state.\
c25c734bd2a7 Modifications to make talking with npcs possible again. Special actions won't work yet though.
KarstenBock@gmx.net
parents: 69
diff changeset
326 getObjectById("PlayerCharacter").fifeagent
190
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
327 player_char.behaviour.animate(
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
328 'stand',
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
329 self.npc.fifeagent.behaviour.getLocation()
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
330 )
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
331
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
332 if self.npc.dialogue.dialogue is not None:
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
333 dialogue_controller = DialogueController(
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
334 self.controller.engine,
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
335 self.view,
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
336 self.model,
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
337 self.controller.application
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
338 )
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
339 self.controller.application.manager.push_mode(
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
340 dialogue_controller
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
341 )
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
342 dialogue_controller.startTalk(self.npc)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
343 else:
190
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
344 self.npc.fifeagent.behaviour.agent.say("Leave me alone!", 1000)
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
345
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
346 self.model.game_state.getObjectById("PlayerCharacter").\
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
347 fifeagent.behaviour.idle()
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
348 self.model.game_state.getObjectById("PlayerCharacter").\
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
349 fifeagent.behaviour.nextAction = None
a22e92090018 The approach method of MovingAgentBehaviour now accepts a locatior or another instance, and uses the follow method to move to the instance position.
KarstenBock@gmx.net
parents: 189
diff changeset
350 super(TalkAction, self).execute()
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
351
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
352 class UseAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
353 """Action for carryable items. It executes special commands that can be only
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
354 used on carryable utens"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
355
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
356
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
357 def __init__(self, controller, item, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
358 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
359 @param controller: A reference to the GameSceneController.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
360 @type controller: parpg.GameSceneController
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
361 @param item: Item on which the action is called
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
362 @type item: CarryableItem
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
363 @param commands: Special commands that are executed
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
364 @type commands: Dictionary
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
365 """
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
366 super(UseAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
367 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
368 self.item = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
369
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
370 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
371 #Check if there are special commands and execute them
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
372 for command_data in self.commands:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
373 command = command_data["Command"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
374 if command == "ReplaceItem":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
375 object_id = command_data["ID"]
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
376 object_type = command_data["ObjectType"]
166
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
377 containable = self.item.containable
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
378 new_item = self.model.createItemByType(object_type,
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
379 object_id,
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
380 self.item.world)
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
381 container.put_item(containable.container,
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
382 new_item.containable,
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
383 containable.slot)
171
7f03365c098d ReplaceItem in UseAction will now delete the old object from the database and the world.
KarstenBock@gmx.net
parents: 166
diff changeset
384 self.model.deleteObject(self.item.general.identifier)
7f03365c098d ReplaceItem in UseAction will now delete the old object from the database and the world.
KarstenBock@gmx.net
parents: 166
diff changeset
385 self.item.delete()
166
7f044776de60 Fixed UseAction.
KarstenBock@gmx.net
parents: 164
diff changeset
386 self.view.hud.inventory.updateImages()
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
387 super(UseAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
388
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
389 class PickUpAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
390 """Action for picking up items from a map"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
391
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
392 def __init__(self, controller, item, commands = None):
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
393 super(PickUpAction, self).__init__(controller, commands)
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
394 self.item = item
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
395 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
396
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
397 def execute(self):
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
398 real_item = self.item.containable
131
0ffebdca7ba3 Fixed Saving and Loading.
KarstenBock@gmx.net
parents: 116
diff changeset
399 self.item.fifeagent = None
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
400 player = self.model.game_state.getObjectById("PlayerCharacter")
116
9b5498e3bda0 Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents: 115
diff changeset
401 self.model.moveObject(self.item.general.identifier, None)
158
9ba129380af8 PickUpAction now calls updateObjectDB of the GameModel class.
KarstenBock@gmx.net
parents: 157
diff changeset
402 self.model.updateObjectDB(self.item.world)
115
a85d58fcd253 Fixed PickUpAction. Items can be picked up again.
KarstenBock@gmx.net
parents: 81
diff changeset
403 container.put_item(player.container, real_item)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
404 super(PickUpAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
405
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
406 class DropItemAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
407 """Action for dropping an items on a map"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
408 def __init__(self, controller, item, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
409 super(DropItemAction, self).__init__(controller, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
410 self.item = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
411
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
412 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
413 map_name = self.model.game_state.current_map_name
146
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
414 identifier = self.item.entity.general.identifier
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
415 agent_values = self.model.items[identifier]
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
416 coords = (self.model.game_state.getObjectById("PlayerCharacter").
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
417 fifeagent.behaviour.getLocation().getExactLayerCoordinates()
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
418 )
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
419 agent_values["Position"] = (coords.x, coords.y)
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
420 agent_values["Rotation"] = 0
157
db6403c1a7a1 Fixed that dropped items cannot be picked up.
KarstenBock@gmx.net
parents: 155
diff changeset
421 agent_values["Map"] = map_name
146
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
422 self.model.deleteObject(identifier)
157
db6403c1a7a1 Fixed that dropped items cannot be picked up.
KarstenBock@gmx.net
parents: 155
diff changeset
423 self.model.addAgent(self.model.ALL_AGENTS_KEY,
db6403c1a7a1 Fixed that dropped items cannot be picked up.
KarstenBock@gmx.net
parents: 155
diff changeset
424 {identifier: agent_values})
146
6e1eb964a6e5 Fixed dropping items on the map.
KarstenBock@gmx.net
parents: 137
diff changeset
425 self.model.placeAgents(self.item.entity.world)
155
7214224b8d83 Fixed that items in the player characters inventory could not be dropped.
KarstenBock@gmx.net
parents: 146
diff changeset
426 self.model.updateObjectDB(self.item.entity.world)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
427 super(DropItemAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
428
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
429 class DropItemFromContainerAction(DropItemAction):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
430 """Action for dropping an items from the Inventory to a map"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
431
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
432 def __init__(self, controller, item, container_gui, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
433 super(DropItemFromContainerAction, self).__init__(controller, item, commands)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
434 self.container_gui = container_gui
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
435
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
436 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
437 super(DropItemFromContainerAction, self).execute()
175
c50a7adeae85 Changed DropItemFromContainerAction to work with components.
KarstenBock@gmx.net
parents: 171
diff changeset
438 container.remove_item(self.item.container, self.item.slot)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
439 self.container_gui.updateImages()
195
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
440
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
441 class RunScriptAction(Action):
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
442 """Action that runs a specific script"""
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
443
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
444 def __init__(self, controller, script, commands = None):
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
445 """Basic action constructor
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
446 @param controller: A reference to the GameSceneController.
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
447 @type controller: parpg.GameSceneController
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
448 @param script: The name of the script to run.
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
449 @type script: string
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
450 @param commands: Special commands that are executed
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
451 @type commands: Dictionary
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
452 """
197
cf6345ec8988 Small fixes.
KarstenBock@gmx.net
parents: 196
diff changeset
453 Action.__init__(self, controller, commands)
195
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
454 self.script = script
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
455
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
456 def execute(self):
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
457 self.controller.systems.scripting.runScript(self.script)
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
458 Action.execute(self)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
459
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
460 class BrewBeerAction(Action):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
461 """Action for brewing beer in a pot"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
462 def __init__(self, controller, pot, commands = None):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
463 super(BrewBeerAction, self).__init__(controller, commands)
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
464 self.pot = pot.container
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
465 self.view = controller.view
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
466
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
467 def execute(self):
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
468 """Brew the beer"""
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
469 has_water = False
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
470 has_yeast = False
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
471 has_fruit = False
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
472 has_wood = False
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
473 has_bottle = False
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
474 player_character = (self.model.game_state.
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
475 getObjectById("PlayerCharacter").container)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
476 for item in self.pot.children:
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
477 if not item:
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
478 continue
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
479 if item.item_type == "Questionable water":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
480 if has_water:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
481 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
482 "Please put only 1 water in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
483 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
484 has_water = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
485 water_type = 1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
486 water = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
487 elif item.item_type == "Pure water":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
488 if has_water:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
489 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
490 "Please put only 1 water in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
491 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
492 has_water = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
493 water_type = 2
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
494 water = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
495 elif item.item_type == "Grain":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
496 if has_fruit:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
497 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
498 "Please put only 1 fruit in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
499 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
500 has_fruit = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
501 fruit_type = 3
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
502 fruit = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
503 elif item.item_type == "Wild potato":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
504 if has_fruit:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
505 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
506 "Please put only 1 fruit in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
507 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
508 has_fruit = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
509 fruit_type = 2
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
510 fruit = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
511 elif item.item_type == "Rotten yam":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
512 if has_fruit:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
513 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
514 "Please put only 1 fruit in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
515 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
516 has_fruit = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
517 fruit_type = 1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
518 fruit = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
519 elif item.item_type == "Yeast":
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
520 if has_yeast:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
521 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
522 "Please put only 1 yeast in the pot"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
523 return
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
524 has_yeast = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
525 yeast = item
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
526 else:
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
527 self.view.hud.addAction(unicode(
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
528 "Item " + (item.entity.description.view_name) +
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
529 " is not needed for brewing beer"))
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
530 self.view.hud.addAction(unicode(\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
531 "Please put only ingredients for the beer in the pot.\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
532 Things like bottles and wood have to be in your inventory"))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
533 return
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
534 wood = container.get_item(player_character, "Wood")
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
535 if wood:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
536 has_wood = True
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
537 bottle = container.get_item(player_character, "Empty beer bottle")
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
538 if bottle:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
539 has_bottle = True
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
540 if has_water and has_fruit and has_wood and has_bottle:
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
541 container.remove_item(self.pot, water.slot)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
542 container.remove_item(self.pot, fruit.slot)
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
543 if has_yeast:
164
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
544 container.remove_item(self.pot, yeast.slot)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
545 container.remove_item(player_character, wood.slot)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
546 new_item = (self.model.createItemByType("Beer", "Beer",
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
547 self.pot.entity.world)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
548 )
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
549 container.put_item(player_character, new_item.containable)
ede6f6b31bf8 Changed BrewBeerAction to work with components.
KarstenBock@gmx.net
parents: 158
diff changeset
550 self.view.hud.inventory.updateImages()
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
551 beer_quality = 0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
552 if water_type == 1:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
553 if fruit_type == 1:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
554 beer_quality = -1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
555 elif fruit_type == 2:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
556 beer_quality = 2
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
557 elif fruit_type == 3:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
558 beer_quality = 3
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
559 if water_type == 2:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
560 if fruit_type == 1:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
561 beer_quality = 1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
562 elif fruit_type == 2:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
563 beer_quality = 3
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
564 elif fruit_type == 3:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
565 beer_quality = 4
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
566 if beer_quality > 0 and has_yeast:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
567 beer_quality += 1
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
568 self.model.game_state.quest_engine.quests["beer"].\
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
569 setValue("beer_quality", beer_quality)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
570 else:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
571 self.view.hud.addAction(unicode(
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
572 """For brewing beer you need at least:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
573 In the pot:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
574 Fruit (like grain, potato, yam)
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
575 Water
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
576 Optionally:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
577 Good quality yeast.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
578 Wild yeast will be used if none present.
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
579 In the inventory:
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
580 Wood
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
581 Empty bottle"""))
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
582 super(BrewBeerAction, self).execute()
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
583
201
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
584 class SayAction(Action):
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
585 """Action that will display a short text over the entity and in the action
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
586 box."""
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
587
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
588 def __init__(self, controller, entity, text, commands = None):
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
589 """Basic action constructor
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
590 @param controller: A reference to the GameSceneController.
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
591 @type controller: parpg.GameSceneController
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
592 @param entity: The entity that says the text
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
593 @type script: parpg.entities.General
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
594 @param text: The text to be displayed
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
595 @type text: string
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
596 @param commands: Special commands that are executed
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
597 @type commands: Dictionary
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
598 """
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
599 Action.__init__(self, controller, commands)
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
600 self.entity = entity
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
601 self.text = text
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
602
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
603 def execute(self):
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
604 if self.entity.fifeagent:
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
605 self.entity.fifeagent.behaviour.agent.say(self.text);
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
606 if self.entity.description:
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
607 self.controller.view.hud.actions_box.addDialog(
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
608 self.entity.description.view_name,
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
609 self.text)
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
610 Action.execute(self)
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
611
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
612 ACTIONS = {"ChangeMap":ChangeMapAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
613 "Open":OpenAction,
134
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
614 "Close":CloseAction,
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
615 "Unlock":UnlockAction,
c938a828a38a Added actions for lockable components (Open, Close, Lock and Unlock).
KarstenBock@gmx.net
parents: 131
diff changeset
616 "Lock":LockAction,
0
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
617 "ExamineItem":ExamineItemAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
618 "Examine":ExamineAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
619 "Look":ExamineItemAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
620 "Read":ReadAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
621 "Talk":TalkAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
622 "Use":UseAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
623 "PickUp":PickUpAction,
1fd2201f5c36 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
624 "DropFromInventory":DropItemFromContainerAction,
137
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
625 "BrewBeer":BrewBeerAction,
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
626 "ExamineContents": ExamineContentsAction,
195
fabe303ab74f Added RunScriptAction class.
KarstenBock@gmx.net
parents: 190
diff changeset
627 "RunScript": RunScriptAction,
201
c0915e63a557 Added "Say" action.
KarstenBock@gmx.net
parents: 197
diff changeset
628 "Say" : SayAction,
196
7e51bae477f7 Added "None" to the action dict which calls an "no-op" action.
KarstenBock@gmx.net
parents: 195
diff changeset
629 "None": Action,
137
140e5e93f026 Added ExamineContentsAction.
KarstenBock@gmx.net
parents: 134
diff changeset
630 }