annotate demos/rpg/scripts/objects/items.py @ 550:d0282579668c

Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code. Started adding more comments.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 15 Jun 2010 17:53:20 +0000
parents e59ece21ab3e
children 69d50e751c9a
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 # This is the rio de hola client for FIFE.
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 import sys, os, re, math, random, shutil
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from fife import fife
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
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
31 from scripts.objects.baseobject import BaseGameObject, GameObjectTypes, getModuleByType
520
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
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 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
35 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
36 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
37
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 def _getItemType(self):
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 return self._name
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 def _getItemName(self):
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 return self._id
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 itemtype = property(_getItemType)
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 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
46
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
47 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
48 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
49 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
50 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
51
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 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
53 #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
54 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
55
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
56 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
57 #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
58 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
59 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
60
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 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
62
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
63 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
64 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
65 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
66
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 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
68
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
69 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
70 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
71 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
72
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 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
74
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 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
76 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
77
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
78 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
79 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
80 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
81 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
82
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
83 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
84 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
85
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
86 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
87 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
88
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
89 value = property(_getValue, _setValue)
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
90
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
91 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
92 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
93 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
94 self._type = GameObjectTypes["PORTAL"]
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
95
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
96 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
97
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
98 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
99 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
100 lvars['dest'] = self._dest
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
101
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
102 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
103
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
104 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
105 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
106
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
107 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
108 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
109 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
110 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
111
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
112 def _getDest(self):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
113 return self._dest
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
114
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
115 def _setDest(self, dest):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
116 self._dest = dest
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
117
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 529
diff changeset
118 dest = property(_getDest, _setDest)