Mercurial > fife-parpg
diff demos/rpg/scripts/quests/questmanager.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 |
line wrap: on
line diff
--- a/demos/rpg/scripts/quests/questmanager.py Tue Jun 15 17:53:20 2010 +0000 +++ b/demos/rpg/scripts/quests/questmanager.py Tue Jun 15 21:13:01 2010 +0000 @@ -26,14 +26,46 @@ from fife import fife +from fife.extensions.fife_settings import Setting +from scripts.quests.basequest import Quest, ReturnItemQuest, QuestTypes + class QuestManager(object): def __init__(self, gamecontroller): self._gamecontroller = gamecontroller + + self._questsettings = None self._quests = {} self._activequests = [] self._completedquests = [] + def initializeQuests(self): + questfile = self._gamecontroller.settings.get("RPG", "QuestFile", "maps/quests.xml") + + self._questsettings = Setting(settings_file=questfile) + + for identifier in self._questsettings.get("QuestGivers", "list", []): + for quest in self._questsettings.get(identifier, "questlist", []): + questdict = self._questsettings.get(identifier, quest, {}) + + if questdict['type'] == "RETURN_ITEM": + questobj = ReturnItemQuest(identifier, quest, questdict['name'], questdict['desc']) + for ritem in self._questsettings.get(quest+"_items", "itemlist", []): + itemdict = self._questsettings.get(quest+"_items", ritem, {}) + if itemdict["name"] == "GOLD_COINS": + questobj.addRequiredGold(int(itemdict['value'])) + else: + questobj.addRequiredItem(ritem) + else: + questobj = Quest(identifier, quest, questdict['name'], questdict['desc']) + + self._gamecontroller.questmanager.addQuest(questobj) + + def destroy(self): + self._quests = {} + self._activequests = [] + self._completedquests = [] + def addQuest(self, quest): if self._quests.has_key(quest.ownerid): if not quest in self._quests[quest.ownerid]: