comparison demos/rpg/scripts/actors/questgiver.py @ 551:3b933753cba8

QuestManager now loads all quests. Added some more comments.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 15 Jun 2010 21:13:01 +0000
parents d0282579668c
children 69d50e751c9a
comparison
equal deleted inserted replaced
550:d0282579668c 551:3b933753cba8
34 class QuestGiver(Actor): 34 class QuestGiver(Actor):
35 def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): 35 def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False):
36 super(QuestGiver, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance) 36 super(QuestGiver, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance)
37 self._type = GameObjectTypes["QUESTGIVER"] 37 self._type = GameObjectTypes["QUESTGIVER"]
38 38
39 def addQuest(self, quest):
40 pass
41
42 def offerNextQuest(self): 39 def offerNextQuest(self):
40 """
41 Brings up the quest dialog of there is a quest to be offered to the player.
42 """
43 if self._gamecontroller.questmanager.getNextQuest(self.id): 43 if self._gamecontroller.questmanager.getNextQuest(self.id):
44 self._gamecontroller.guicontroller.showQuestDialog(self) 44 self._gamecontroller.guicontroller.showQuestDialog(self)
45 45
46 def getNextQuest(self): 46 def getNextQuest(self):
47 """
48 Returns the next quest that will be offered by this QuestGiver.
49 """
47 return self._gamecontroller.questmanager.getNextQuest(self.id) 50 return self._gamecontroller.questmanager.getNextQuest(self.id)
48 51
49 def activateQuest(self, quest): 52 def activateQuest(self, quest):
53 """
54 This is called after the player accepts a quest. It marks it as active or "in progress".
55 """
50 self._gamecontroller.questmanager.activateQuest(quest) 56 self._gamecontroller.questmanager.activateQuest(quest)
51 57
52 def completeQuest(self): 58 def completeQuest(self):
59 """
60 Checks to see if the active quest owned by this QuestGiver is complete and
61 removes the required items or gold from the players inventory.
62 """
53 for activequest in self._gamecontroller.questmanager.activequests: 63 for activequest in self._gamecontroller.questmanager.activequests:
54 if activequest.ownerid == self.id: 64 if activequest.ownerid == self.id:
55 if activequest.checkQuestCompleted(self._gamecontroller.scene.player): 65 if activequest.checkQuestCompleted(self._gamecontroller.scene.player):
56 self.say("That everything I need. Thank you!") 66 self.say("That everything I need. Thank you!")
57 67
63 self._gamecontroller.questmanager.completeQuest(activequest) 73 self._gamecontroller.questmanager.completeQuest(activequest)
64 else: 74 else:
65 self.say("Come back when you have all the items I requested!") 75 self.say("Come back when you have all the items I requested!")
66 76
67 def haveQuest(self): 77 def haveQuest(self):
78 """
79 Returns True if there is either an active quest or the QuestGiver has a new quest to give
80 the player. Returns False otherwise.
81 """
68 return bool(self._gamecontroller.questmanager.getNextQuest(self.id)) or bool(self._getActiveQuest()) 82 return bool(self._gamecontroller.questmanager.getNextQuest(self.id)) or bool(self._getActiveQuest())
69 83
70 def _getActiveQuest(self): 84 def _getActiveQuest(self):
71 """ 85 """
72 Returns the first active quest in the list. There should only be one 86 Returns the first active quest in the list. There should only be one