annotate demos/rpg/scripts/actors/baseactor.py @ 563:f85762e634c5

- Added the AttackAction along with a test enemy on level 1. - Removed the getModuleByType() helper function.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 24 Jun 2010 21:27:11 +0000
parents 69d50e751c9a
children 872a7a94563e
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:
563
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
65 self._dest.say("Hello there!")
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
66
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
67 class AttackAction(BaseAction):
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
68 def __init__(self, attacker, defender):
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
69 self._actiontype = Actions['ATTACK']
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
70 self._attacker = attacker
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
71 self._defender = defender
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
72
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
73 def execute(self):
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
74 if self._defender.type == GameObjectTypes["ENEMY"]:
f85762e634c5 - Added the AttackAction along with a test enemy on level 1.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 560
diff changeset
75 self._defender.say("Ouch")
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
76
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
77 class PickUpItemAction(BaseAction):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
78 def __init__(self, actor, item):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
79 self._actiontype = Actions['PICKUP']
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
80 self._actor = actor
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
81 self._item = item
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
82
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
83 def execute(self):
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
84 self._actor.pickUpItem(self._item)
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
85
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
86 class EnterPortalAction(BaseAction):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
87 def __init__(self, actor, portal):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
88 self._actiontype = Actions["ENTER"]
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
89 self._actor = actor
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
90 self._portal = portal
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
91
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
92 def execute(self):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
93 self._actor.enterPortal(self._portal)
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
94
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
95 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
96 '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
97 '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
98
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
99 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
100 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
101 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
102
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
103 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
104 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
105 self._object.stand()
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
106 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
107
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
108 class ActorAttributes(Serializer):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
109 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
110 self._str = strength
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
111 self._dex = dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
112 self._int = intelligence
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
113 self._hp = health
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
114
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
115 def serialize(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
116 lvars['str'] = self._str
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
117 lvars['dex'] = self._dex
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
118 lvars['int'] = self._int
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
119 lvars['hp'] = self._hp
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
120
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
121 return lvars
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 deserialize(self, valuedict):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
124 if valuedict.has_key("str"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
125 self._str = int(valuedict['str'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
126 if valuedict.has_key("dex"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
127 self._dex = int(valuedict['dex'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
128 if valuedict.has_key("int"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
129 self._int = int(valuedict['int'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
130 if valuedict.has_key("hp"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
131 self._hp = int(valuedict['hp'])
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
132
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
133 def _getStrength(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
134 return self._str
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
135
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
136 def _setStrength(self, strength):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
137 self._str = strength
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
138
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
139 def _getDexterity(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
140 return self._dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
141
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
142 def _setDexterity(self, dexterity):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
143 self._dexterity = dexterity
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
144
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
145 def _getIntelligence(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
146 return self._int
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 def _setIntelligence(self, intelligence):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
149 self._int = intelligence
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
150
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
151 def _getHealth(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
152 return self._hp
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
153
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
154 def _setHealth(self, health):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
155 self._hp = health
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
156
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
157
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
158 strength = property(_getStrength, _setStrength)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
159 dexterity = property(_getDexterity, _setDexterity)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
160 intelligence = property(_getIntelligence, _setIntelligence)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
161 health = property(_getHealth, _setHealth)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
162
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
163
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
164 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
165 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
166 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
167
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
168 self._nextaction = None
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
169 self._inventory = []
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
170 self._maxinventoryitems = 20
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
171
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
172 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
173
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
174 self._gold = 0
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
175 self._attributes = ActorAttributes()
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
176
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
177 self.stand()
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
178
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
179 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
180 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
181 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
182
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
183 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
184 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
185 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
186
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
187 def say(self, text):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
188 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
189
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
190 def performNextAction(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
191 if self._nextaction:
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
192 self._nextaction.execute()
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
193 self._nextaction = None
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
194
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
195 def pickUpItem(self, item):
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
196 if self.addItemToInventory(item):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
197 item.onPickUp()
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
198 else:
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
199 #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
200 pass
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
201
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
202 def enterPortal(self, portal):
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
203 if self._id == "player":
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
204 self._gamecontroller.switchMap(portal.dest)
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
205 else:
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
206 self._gamecontroller.scene.removeObjectFromScene(self._id)
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
207
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
208 def addItemToInventory(self, item):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
209 if len(self._inventory) >= self._maxinventoryitems:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
210 return False
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
211 else:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
212 if type(item) == GoldStack:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
213 self._gold += item.value
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
214 else:
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
215 self._inventory.append(item)
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
216
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
217 return True
540
2e739ae9a8bc Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 536
diff changeset
218
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
219 def removeItemFromInventory(self, itemid):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
220 itemtoremove = None
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
221 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
222 if item.id == itemid:
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
223 itemtoremove = item
528
796d49ab9380 Cleaned up the createScene function.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 524
diff changeset
224
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
225 if itemtoremove:
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
226 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
227
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 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
229 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
230
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 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
232
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
233 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
234
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
235 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
236 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
237
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
238 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
239 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
240 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
241 self._gold = 0
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
242
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
243 if valuedict.has_key("walk_speed"):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
244 self._walkspeed = float(valuedict['walk_speed'])
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
245
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
246 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
247 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
248
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 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
250 self._state = state
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
251
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
252 def _getNextAction(self):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
253 return self._nextaction
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
254
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
255 def _setNextAction(self, action):
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
256 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
257
529
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
258 def _getGold(self):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
259 return self._gold
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
260
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
261 def _setGold(self, gold):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
262 self._gold = gold
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
263
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
264 def _getInventory(self):
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
265 return self._inventory
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
266
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
267 def _getAttributes(self):
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
268 return self._attributes
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
269
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
270 state = property(_getState, _setState)
519
14f777be6b94 Added a rudimentary Action class.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 517
diff changeset
271 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
272 gold = property(_getGold, _setGold)
d0bce896a526 Changed the quest format in the object xml file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 528
diff changeset
273 inventory = property(_getInventory)
560
69d50e751c9a Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 547
diff changeset
274 attributes = property(_getAttributes)