annotate demos/rpg/scripts/actors/baseactor.py @ 560:69d50e751c9a

Lots of changes. - Added the Serializer class - Made exceptions a little more usable - Added actor attributes (not used yet but will be with the combat engine) - Made the quest dialogs more customizable - Many other small changes
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 23 Jun 2010 19:20:24 +0000
parents e59ece21ab3e
children f85762e634c5
rev   line source
513
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 #!/usr/bin/env python
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # -*- coding: utf-8 -*-
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # ####################################################################
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # Copyright (C) 2005-2010 by the FIFE team
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 # http://www.fifengine.net
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # This file is part of FIFE.
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 #
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # FIFE is free software; you can redistribute it and/or
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # modify it under the terms of the GNU Lesser General Public
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 # License as published by the Free Software Foundation; either
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # version 2.1 of the License, or (at your option) any later version.
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 #
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # This library is distributed in the hope that it will be useful,
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # Lesser General Public License for more details.
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 #
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # You should have received a copy of the GNU Lesser General Public
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # License along with this library; if not, write to the
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # Free Software Foundation, Inc.,
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 # ####################################################################
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import sys, os, re, math, random, shutil
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 from fife import fife
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from fife.extensions.loaders import loadMapFile
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 519
diff changeset
31 from scripts.objects.baseobject import ObjectActionListener, BaseGameObject, GameObjectTypes
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
32 from scripts.objects.items import GoldStack
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
33 from scripts.misc.serializer import Serializer
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
34
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
35 Actions = {'NONE':0,
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
36 'PICKUP':1,
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
37 'TALK':2,
535
9fbe3dce925a Added custom exceptions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 534
diff changeset
38 'ATTACK':3,
520
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 519
diff changeset
39 'OPEN':4,
b6bd314df28a Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 519
diff changeset
40 'ENTER':5}
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
41
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
42 class BaseAction(object):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
43 def __init__(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
44 self._actiontype = Actions['NONE']
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
45
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
46 def execute(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
47 pass
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
48
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
49 class TalkAction(BaseAction):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
50 def __init__(self, sourceobj, destobj):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
51 self._actiontype = Actions['TALK']
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
52 self._source = sourceobj
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
53 self._dest = destobj
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
54
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
55 def execute(self):
524
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
56 if self._dest.type == GameObjectTypes["QUESTGIVER"]:
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
57 if self._dest.haveQuest():
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
58 if not self._dest.activequest:
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
59 self._dest.offerNextQuest()
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
60 else:
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
61 self._dest.completeQuest()
521
494c60cf61cf Player can now receive a quest, accept it, and complete it. Quests do not have any requirements (i.e. bring me back an item.. etc etc) to be completed at this time.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 520
diff changeset
62 else:
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
63 self._dest.showNoQuestDialog()
523
d01eb65b2726 Enabling the FloatingTextRenderer for the RPG demo. The NPC now complains at you if he doesn't have a quest to give you.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 521
diff changeset
64 else:
524
6037f79b0dcf Multiple quests now work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 523
diff changeset
65 self._dest.instance.say("Hello there!")
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
66
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
67 class PickUpItemAction(BaseAction):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
68 def __init__(self, actor, item):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
69 self._actiontype = Actions['PICKUP']
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
70 self._actor = actor
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
71 self._item = item
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
72
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
73 def execute(self):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
74 self._actor.pickUpItem(self._item)
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
75
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
76 class EnterPortalAction(BaseAction):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
77 def __init__(self, actor, portal):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
78 self._actiontype = Actions["ENTER"]
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
79 self._actor = actor
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
80 self._portal = portal
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
81
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
82 def execute(self):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
83 self._actor.enterPortal(self._portal)
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
84
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
85 ActorStates = {'STAND':0,
516
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
86 'WALK':1,
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
87 'ATTACK':2}
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
88
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
89 class ActorActionListener(ObjectActionListener):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
90 def __init__(self, gamecontroller, obj):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
91 super(ActorActionListener, self).__init__(gamecontroller, obj)
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
92
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
93 def onInstanceActionFinished(self, instance, action):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
94 if action.getId() == 'walk':
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
95 self._object.stand()
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
96 self._object.performNextAction()
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
97
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
98 class ActorAttributes(Serializer):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
99 def __init__(self, strength=0, dexterity=0, intelligence=0, health=0):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
100 self._str = strength
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
101 self._dex = dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
102 self._int = intelligence
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
103 self._hp = health
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
104
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
105 def serialize(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
106 lvars['str'] = self._str
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
107 lvars['dex'] = self._dex
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
108 lvars['int'] = self._int
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
109 lvars['hp'] = self._hp
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
110
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
111 return lvars
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
112
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
113 def deserialize(self, valuedict):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
114 if valuedict.has_key("str"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
115 self._str = int(valuedict['str'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
116 if valuedict.has_key("dex"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
117 self._dex = int(valuedict['dex'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
118 if valuedict.has_key("int"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
119 self._int = int(valuedict['int'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
120 if valuedict.has_key("hp"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
121 self._hp = int(valuedict['hp'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
122
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
123 def _getStrength(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
124 return self._str
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
125
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
126 def _setStrength(self, strength):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
127 self._str = strength
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
128
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
129 def _getDexterity(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
130 return self._dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
131
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
132 def _setDexterity(self, dexterity):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
133 self._dexterity = dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
134
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
135 def _getIntelligence(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
136 return self._int
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
137
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
138 def _setIntelligence(self, intelligence):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
139 self._int = intelligence
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
140
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
141 def _getHealth(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
142 return self._hp
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
143
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
144 def _setHealth(self, health):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
145 self._hp = health
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
146
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
147
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
148 strength = property(_getStrength, _setStrength)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
149 dexterity = property(_getDexterity, _setDexterity)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
150 intelligence = property(_getIntelligence, _setIntelligence)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
151 health = property(_getHealth, _setHealth)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
152
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
153
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
154 class Actor(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
155 def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False):
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
156 super(Actor, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance)
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
157
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
158 self._type = GameObjectTypes["DEFAULT"]
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
159
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
160 self._nextaction = None
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
161 self._inventory = []
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
162 self._maxinventoryitems = 20
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
163
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
164 self._walkspeed = self._gamecontroller.settings.get("RPG", "DefaultActorWalkSpeed", 4.0)
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
165
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
166 self._gold = 0
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
167 self._attributes = ActorAttributes()
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
168
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
169 self.stand()
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
170
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
171 def stand(self):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
172 self._state = ActorStates["STAND"]
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
173 self._instance.act('stand', self._instance.getFacingLocation())
513
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174
516
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
175 def walk(self, location):
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
176 self._state = ActorStates["WALK"]
d70fc46c8aa5 Added some placeholder graphics for the warrior. The player can now walk around the map.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 513
diff changeset
177 self._instance.move('walk', location, self._walkspeed)
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
178
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
179 def say(self, text):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
180 self._instance.say(text, 2500)
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
181
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
182 def performNextAction(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
183 if self._nextaction:
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
184 self._nextaction.execute()
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
185 self._nextaction = None
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
186
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
187 def pickUpItem(self, item):
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
188 if self.addItemToInventory(item):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
189 item.onPickUp()
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
190 else:
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
191 #could do something cool like throw the item back on the ground
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
192 pass
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
193
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
194 def enterPortal(self, portal):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
195 if self._id == "player":
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
196 self._gamecontroller.switchMap(portal.dest)
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
197 else:
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
198 self._gamecontroller.scene.removeObjectFromScene(self._id)
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
199
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
200 def addItemToInventory(self, item):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
201 if len(self._inventory) >= self._maxinventoryitems:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
202 return False
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
203 else:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
204 if type(item) == GoldStack:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
205 self._gold += item.value
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
206 else:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
207 self._inventory.append(item)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
208
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
209 return True
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
210
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
211 def removeItemFromInventory(self, itemid):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
212 itemtoremove = None
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
213 for item in self._inventory:
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
214 if item.id == itemid:
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
215 itemtoremove = item
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
216
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
217 if itemtoremove:
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
218 self._inventory.remove(itemtoremove)
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
219
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
220 def serialize(self):
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
221 lvars = super(Actor, self).serialize()
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
222
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
223 lvars['gold'] = self._gold
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
224
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
225 return lvars
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
226
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
227 def deserialize(self, valuedict):
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
228 super(Actor, self).deserialize(valuedict)
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
229
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
230 if valuedict.has_key("gold"):
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
231 self._gold = int(valuedict['gold'])
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
232 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
233 self._gold = 0
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
234
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
235 if valuedict.has_key("walk_speed"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
236 self._walkspeed = float(valuedict['walk_speed'])
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
237
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
238 def _getState(self):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
239 return self._state
513
edf5c0cf52f3 Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
241 def _setState(self, state):
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
242 self._state = state
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
243
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
244 def _getNextAction(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
245 return self._nextaction
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
246
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
247 def _setNextAction(self, action):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
248 self._nextaction = action
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
249
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
250 def _getGold(self):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
251 return self._gold
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
252
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
253 def _setGold(self, gold):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
254 self._gold = gold
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
255
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
256 def _getInventory(self):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
257 return self._inventory
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
258
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
259 def _getAttributes(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
260 return self._attributes
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
261
517
c3a026cdd91b Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 516
diff changeset
262 state = property(_getState, _setState)
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
263 nextaction = property(_getNextAction, _setNextAction)
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
264 gold = property(_getGold, _setGold)
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
265 inventory = property(_getInventory)
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
266 attributes = property(_getAttributes)