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

Revision 212, 2.7 KB checked in by tZee_parpg, 11 years ago (diff)

#70 Merged the approach functions and added a tiny action queue for the PC.

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, targetmap, targetpos):
27        """@type engine: Engine reference
28           @param engine: A reference to the engine.
29           @type targetmap: String
30           @param targetmap: Target mapname.
31           @type targetpos: Tuple
32           @param targetpos: (X, Y) coordinates on the target map.
33           @return: None"""
34        self.engine = engine
35        self.targetpos = targetpos
36        self.targetmap = targetmap
37       
38    def execute(self):
39        """Executes the mapchange."""
40        self.engine.changeMap(self.targetmap, self.targetpos)
41       
42class OpenBoxAction(Action):
43    """Open a box. Needs to be more generic, but will do for now."""
44    def __init__(self, engine, boxTitle):
45        """@type engine: Engine reference
46           @param engine: A reference to the engine.
47           @type boxTitle: String
48           @param boxTitle: Box title.
49           """
50        self.engine = engine
51        self.boxTitle = boxTitle
52   
53    def execute(self):
54        """Open the box."""
55        self.engine.view.createBoxGUI(self.boxTitle)
56       
57class ExamineBoxAction(Action):
58    """Examine a box. Needs to be more generic, but will do for now."""
59    def __init__(self, engine, examineName, examineDesc):
60        """@type engine: Engine reference
61           @param engine: A reference to the engine.
62           @type examineName: String
63           @param examineName: Name of the object to be examined.
64           @type examineName: String
65           @param examineName: Description of the object to be examined.
66           """
67        self.engine = engine
68        self.examineName = examineName
69        self.examineDesc = examineDesc
70       
71    def execute(self):
72        """Examine the box."""
73        self.engine.view.createExamineBox(self.examineName, self.examineDesc)
Note: See TracBrowser for help on using the repository browser.