comparison demos/rpg/scripts/quests/basequest.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 67f6f3538e88
children 69d50e751c9a
comparison
equal deleted inserted replaced
549:c9113e23b004 550:d0282579668c
31 31
32 QuestTypes = {'DEFAULT':0, 32 QuestTypes = {'DEFAULT':0,
33 'RETURN_ITEM':1} 33 'RETURN_ITEM':1}
34 34
35 class Quest(object): 35 class Quest(object):
36 def __init__(self, owner, questname, questtext): 36 def __init__(self, ownerid, questid, questtitle, questtext):
37 self._owner = owner 37 self._ownerid = ownerid
38 self._name = questname 38 self._questid = questid
39 self._name = questtitle
39 self._text = questtext 40 self._text = questtext
41
42 def __eq__(self, other):
43 return self._questid == other.id
40 44
41 def checkQuestCompleted(self, actor): 45 def checkQuestCompleted(self, actor):
42 pass 46 pass
43 47
44 def _getOwner(self): 48 def _getOwnerID(self):
45 return self._owner 49 return self._ownerid
46 50
47 def _getName(self): 51 def _getName(self):
48 return self._name 52 return self._name
49 53
50 def _setName(self, questname): 54 def _setName(self, questtitle):
51 self._name = questname 55 self._name = questtitle
52 56
53 def _getText(self): 57 def _getText(self):
54 return self._text 58 return self._text
55 59
56 def _setText(self, questtext): 60 def _setText(self, questtext):
57 self._text = questtext 61 self._text = questtext
58 62
59 owner = property(_getOwner) 63 def _getID(self):
64 return self._questid
65
66 ownerid = property(_getOwnerID)
60 name = property(_getName, _setName) 67 name = property(_getName, _setName)
61 text = property(_getText, _setText) 68 text = property(_getText, _setText)
69 id = property(_getID)
62 70
63 class ReturnItemQuest(Quest): 71 class ReturnItemQuest(Quest):
64 def __init__(self, owner, questname, questtext): 72 def __init__(self, ownerid, questid, questtitle, questtext):
65 super(ReturnItemQuest, self).__init__(owner, questname, questtext) 73 super(ReturnItemQuest, self).__init__(ownerid, questid, questtitle, questtext)
66 74
67 self._requireditems = [] 75 self._requireditems = []
68 self._requiredgold = 0 76 self._requiredgold = 0
69 77
70 def addRequiredItem(self, itemid): 78 def addRequiredItem(self, itemid):