Mercurial > fife-parpg
diff demos/rpg/scripts/actors/questgiver.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 | 3b933753cba8 |
children |
line wrap: on
line diff
--- a/demos/rpg/scripts/actors/questgiver.py Tue Jun 22 15:41:36 2010 +0000 +++ b/demos/rpg/scripts/actors/questgiver.py Wed Jun 23 19:20:24 2010 +0000 @@ -35,6 +35,8 @@ def __init__(self, gamecontroller, layer, typename, baseobjectname, instancename, instanceid=None, createInstance=False): super(QuestGiver, self).__init__(gamecontroller, layer, typename, baseobjectname, instancename, instanceid, createInstance) self._type = GameObjectTypes["QUESTGIVER"] + + self._noquest_dialog = "I've got nothing for you... leave me alone." def offerNextQuest(self): """ @@ -54,7 +56,10 @@ This is called after the player accepts a quest. It marks it as active or "in progress". """ self._gamecontroller.questmanager.activateQuest(quest) - + + def showNoQuestDialog(self): + self.say(self._noquest_dialog) + def completeQuest(self): """ Checks to see if the active quest owned by this QuestGiver is complete and @@ -63,7 +68,7 @@ for activequest in self._gamecontroller.questmanager.activequests: if activequest.ownerid == self.id: if activequest.checkQuestCompleted(self._gamecontroller.scene.player): - self.say("That everything I need. Thank you!") + self.say(activequest._complete_dialog) self._gamecontroller.scene.player.gold = self._gamecontroller.scene.player.gold - activequest.requiredgold @@ -72,7 +77,7 @@ self._gamecontroller.questmanager.completeQuest(activequest) else: - self.say("Come back when you have all the items I requested!") + self.say(activequest._incomplete_dialog) def haveQuest(self): """ @@ -80,6 +85,19 @@ the player. Returns False otherwise. """ return bool(self._gamecontroller.questmanager.getNextQuest(self.id)) or bool(self._getActiveQuest()) + + def serialize(self): + lvars = super(QuestGiver, self).serialize() + + lvars['noquest_dialog'] = self._noquest_dialog + + return lvars + + def deserialize(self, valuedict): + super(QuestGiver, self).deserialize(valuedict) + + self._noquest_dialog = valuedict['noquest_dialog'] + def _getActiveQuest(self): """