source: trunk/game/scripts/objects/action.py @ 310

Revision 310, 3.7 KB checked in by eliedebrauwer, 10 years ago (diff)

Ticket #66: Patch by saritor (& eliedebrauwer), implements saritors rework of teleporting, at this point it implements the within-a-map teleport successfully, but cross map teleport still has in issue which probably has to do with the setup of the PC. comment[s:trac, t:66]

  • Property svn:eol-style set to native
Line 
1#!/usr/bin/python
2
3#   This file is part of PARPG.
4
5#   PARPG is free software: you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation, either version 3 of the License, or
8#   (at your option) any later version.
9
10#   PARPG is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY; without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#   GNU General Public License for more details.
14
15#   You should have received a copy of the GNU General Public License
16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>.
17
18class Action(object):
19    """Base Action class, to define the structure"""
20    def execute(self):
21        """To be overwritten"""
22        pass
23
24class ChangeMapAction(Action):
25    """A change map scheduled"""
26    def __init__(self, engine, targetmapname, targetmapfile , targetpos):
27        """Initiates a change of the position of the character
28           possibly flagging a new map to be loaded.
29           @type engine: Engine reference
30           @param engine: A reference to the engine.
31           @type targetmapname: String
32           @param targetmapname: Target map id
33           @type targetmapfile: String
34           @param targetmapfile: Target map filename
35           @type targetpos: Tuple
36           @param targetpos: (X, Y) coordinates on the target map.
37           @return: None"""
38        self.engine = engine
39        self.targetpos = targetpos
40        self.targetmapname = targetmapname
41        self.targetmapfile = targetmapfile
42
43    def execute(self):
44        """Executes the mapchange."""
45        self.engine.changeMap(self.targetmapname, self.targetmapfile, self.targetpos)
46       
47class OpenBoxAction(Action):
48    """Open a box. Needs to be more generic, but will do for now."""
49    def __init__(self, engine, boxTitle):
50        """@type engine: Engine reference
51           @param engine: A reference to the engine.
52           @type boxTitle: String
53           @param boxTitle: Box title.
54           """
55        self.engine = engine
56        self.boxTitle = boxTitle
57   
58    def execute(self):
59        """Open the box."""
60        self.engine.view.hud.createBoxGUI(self.boxTitle)
61       
62class ExamineBoxAction(Action):
63    """Examine a box. Needs to be more generic, but will do for now."""
64    def __init__(self, engine, examineName, examineDesc):
65        """@type engine: Engine reference
66           @param engine: A reference to the engine.
67           @type examineName: String
68           @param examineName: Name of the object to be examined.
69           @type examineName: String
70           @param examineName: Description of the object to be examined.
71           """
72        self.engine = engine
73        self.examineName = examineName
74        self.examineDesc = examineDesc
75       
76    def execute(self):
77        """Examine the box."""
78        self.engine.view.hud.createExamineBox(self.examineName, self.examineDesc)
79
80class TalkAction(Action):
81    """An action to represent starting a dialogue"""
82    def __init__(self, engine, npc):
83        """@type engine: Engine reference
84           @param engine: A reference to the engine.
85           @type examineName: String
86           @param examineName: Name of the object to be examined.
87           @type examineName: String
88           @param examineName: Description of the object to be examined.
89           """
90        self.engine = engine
91        self.npc = npc
92       
93    def execute(self):
94        """Examine the box."""
95        pc = self.engine.gameState.PC
96        pc.behaviour.agent.act('stand', self.npc.getLocation())
97        self.npc.talk(pc)
98        self.engine.view.hud.showDialogue(self.npc)
Note: See TracBrowser for help on using the repository browser.