source: trunk/PARPG/scripts/gamedata.py @ 181

Revision 151, 6.4 KB checked in by maximinus_parpg, 10 years ago (diff)

Merged gamestate and engine.
Fixed a few typos.

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 BaseObjectData(object):
19    """Basis for game object data.
20    """
21    def __init__(self, ident, posx, posy, text, cmap, gfx=None, display=True):
22        """Set the basic values that are shared by all game objects.
23        @type ident: String
24        @param ident: Unique identifier for this object.
25        @type posx: Integer
26        @param posx: Position X
27        @type posy: Integer
28        @param posy: Position Y
29        @type text: String
30        @param text: The caption of this object
31        @type cmap: String
32        @param cmap: Map where this object is currently located
33        @type display: Bool
34        @param display: Display this object?
35        @type gfx: String
36        @param gfx: ???
37        @returns: None"""
38        self.id = ident
39        self.posx = posx
40        self.posy = posy
41        self.display = display
42        self.text = text
43        self.map = cmap
44        self.gfx = gfx
45   
46    def __cmp__(self, other):
47        """Compares this instance to another.
48        @type other: BaseObjectData
49        @param other: The other object to compare
50        @returns: True if the ids are equal, false otherwise."""
51        return self.id == other.id
52   
53class DoorData(BaseObjectData):
54    """Represents a door.
55    """
56    def __init__(self, ident, posx, posy, text, cmap, gfx, display,
57                 owner, destx, desty, destmap):
58        """Set initial values
59        @type ident: String
60        @param ident: Unique identifier for this object.
61        @type posx: Integer
62        @param posx: Position X
63        @type posy: Integer
64        @param posy: Position Y
65        @type text: String
66        @param text: The caption of this object
67        @type cmap: String
68        @param cmap: Map where this NPC is currently located
69        @type display: Bool
70        @param display: Display this object?
71        @type gfx: String
72        @param gfx: ???
73        @type owner: ???
74        @param owner: The owner of this object
75        @type destx: Integer
76        @param destx: Target X
77        @type desty: Integer
78        @param desty: Target Y
79        @type destmap: String
80        @param destmap: Target map
81        @returns: None"""
82        super(DoorData, self).__init__(ident, posx, posy, text,
83                                       cmap, gfx, display)
84        self.destx = destx
85        self.desty = desty
86        self.owner = owner
87        self.destmap = destmap
88
89class NpcData(BaseObjectData):
90    """Non Player Character
91    """
92    def __init__(self, ident, posx, posy, text, cmap, gfx=None, display=True):
93        """Set initial NPC values.
94        @type ident: String
95        @param ident: Unique identifier for this object.
96        @type posx: Integer
97        @param posx: Position X
98        @type posy: Integer
99        @param posy: Position Y
100        @type text: String
101        @param text: The caption of this object
102        @type cmap: String
103        @param cmap: Map where this NPC is currently located
104        @type display: Bool
105        @param display: Display this object?
106        @type gfx: String
107        @param gfx: ???
108        @returns: None"""
109        super(NpcData, self).__init__(ident, posx, posy, text,
110                                      cmap, gfx, display)
111
112class HeroData(NpcData):
113    """Hero character, for now equal to a NPC"""
114    def __init__(self, ident, posx, posy, text, cmap, gfx=None, display=True):
115        """Set initial NPC values.
116        @type ident: String
117        @param ident: Unique identifier for this object.
118        @type posx: Integer
119        @param posx: Position X
120        @type posy: Integer
121        @param posy: Position Y
122        @type text: String
123        @param text: The caption of this object
124        @type cmap: String
125        @param cmap: Map where this NPC is currently located
126        @type display: Bool
127        @param display: Display this object?
128        @type gfx: String
129        @param gfx: ???
130        @returns: None"""
131        super(HeroData, self).__init__(ident, posx, posy, text,
132                                       cmap, gfx, display)
133
134class NonLivingObjectData(BaseObjectData):
135    def __init__(self, ident, posx, posy, text, cmap, gfx=None, display=True, 
136                 owner=None, container=False, carryable=False):
137        """Set initial object values.
138        @type ident: String
139        @param ident: Unique identifier for this object.
140        @type posx: Integer
141        @param posx: Position X
142        @type posy: Integer
143        @param posy: Position Y
144        @type text: String
145        @param text: The caption of this object
146        @type cmap: String
147        @param cmap: Map where this NPC is currently located
148        @type owner: ???
149        @param owner: The owner of this object
150        @type container: Bool
151        @param container: Can this a container?
152        @type carryable: Bool
153        @param carryable: Can this object be carried?
154        @type display: Bool
155        @param display: Display this object?
156        @type gfx: String
157        @param gfx: ???
158        @returns: None"""
159        super(NonLivingObjectData, self).__init__(ident, posx, posy, text, 
160                                                  cmap, gfx, display)
161        self.container = container
162        self.carryable = carryable
163        self.owner = owner
164
165class MapDoor:
166    """A MapDoor is an item that when clicked transports the player to
167       another map"""
168    def __init__(self, name, new_map, location):
169        """@type name: string
170           @param name: name of fife object
171           @type new_map: string
172           @param new_map: name of new map
173           @type location: tuple
174           @param location: where to put the PC when map is loaded
175           @return: None"""
176        self.id = name
177        self.map = new_map
178        # location is an (int, int) which stores the intended location
179        # of the PC on the new map
180        self.targ_coords = location
181
Note: See TracBrowser for help on using the repository browser.