Mercurial > fife-parpg
annotate demos/rpg/scripts/objects/items.py @ 697:ecaa4d98f05f tip
Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
* Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring.
* GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass.
* The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class.
* The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged.
* Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Sat, 18 Jun 2011 00:28:40 -1000 |
parents | f85762e634c5 |
children |
rev | line source |
---|---|
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 import sys, os, re, math, random, shutil |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 from fife import fife |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
563
f85762e634c5
- Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
560
diff
changeset
|
30 from scripts.objects.baseobject import BaseGameObject, GameObjectTypes |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 class BaseItem(BaseGameObject): |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
34 def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
35 super(BaseItem, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname, True) |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
36 |
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 def _getItemType(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 return self._name |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 def _getItemName(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 return self._id |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 itemtype = property(_getItemType) |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 itemname = property(_getItemName) |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
45 |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
46 class PickableItem(BaseItem): |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
47 def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
48 super(PickableItem, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
49 self._type = GameObjectTypes["ITEM"] |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
50 |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
51 def onPickUp(self): |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
52 #remove item from the scene |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
53 self._gamecontroller.scene.removeObjectFromScene(self) |
525
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
54 |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
55 def onDrop(self, dropx, dropy): |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
56 #recreate object |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
57 self._createFIFEInstance(self, self._gamecontroller.scene.itemlayer) |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
58 self.setMapPosition(dropx, dropy) |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
59 |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
60 self._gamecontroller.scene.addObjectToScene(self) |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
61 |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
62 class GoldStack(PickableItem): |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
63 def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
64 super(GoldStack, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) |
525
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
65 |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
66 self._value = 0 |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
67 |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
68 def serialize(self): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
69 lvars = super(GoldStack, self).serialize() |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
70 lvars['value'] = self._value |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
71 |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
72 return lvars |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
73 |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
74 def deserialize(self, valuedict): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
75 super(GoldStack, self).deserialize(valuedict) |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
76 |
547
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
77 if valuedict.has_key("value"): |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
78 self._value = int(valuedict['value']) |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
79 else: |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
80 self._value = 0 |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
81 |
525
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
82 def _getValue(self): |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
83 return self._value |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
84 |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
85 def _setValue(self, value): |
529
d0bce896a526
Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
525
diff
changeset
|
86 self._value = int(value) |
525
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
87 |
19db5a8619a4
Added the GoldStack item class. The scene now loads the goldstack and assigns it's value based on the maps objects file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
524
diff
changeset
|
88 value = property(_getValue, _setValue) |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
89 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
90 class Portal(BaseItem): |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
91 def __init__(self, gamecontroller, layer, typename, baseobjectname, itemtype, itemname): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
92 super(Portal, self).__init__(gamecontroller, layer, typename, baseobjectname, itemtype, itemname) |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
93 self._type = GameObjectTypes["PORTAL"] |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
94 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
95 self._dest = None |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
96 |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
97 def serialize(self): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
98 lvars = super(Portal, self).serialize() |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
99 lvars['dest'] = self._dest |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
100 |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
101 return lvars |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
102 |
546
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
103 def deserialize(self, valuedict): |
8fee2d2286e9
Rewrote the object serializing routines to use a "template" idea for loading an object from disk. This allows for multiple objects to load the same base object template but be unique on the scene AND have different values. Useful for say more than one gold stack on the ground with different gold values. TODO: fix the "spawn" console command.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
104 super(Portal, self).deserialize(valuedict) |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
105 |
547
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
106 if valuedict.has_key("dest"): |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
107 self._dest = valuedict['dest'] |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
108 else: |
e59ece21ab3e
Item serialization will now assume some default values if they are not found in the save files.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
546
diff
changeset
|
109 self._dest = "town" |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
540
diff
changeset
|
110 |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
111 def _getDest(self): |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
112 return self._dest |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
113 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
114 def _setDest(self, dest): |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
115 self._dest = dest |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
116 |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
529
diff
changeset
|
117 dest = property(_getDest, _setDest) |