Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
550:d0282579668c | 551:3b933753cba8 |
---|---|
24 # #################################################################### | 24 # #################################################################### |
25 # This is the rio de hola client for FIFE. | 25 # This is the rio de hola client for FIFE. |
26 | 26 |
27 from fife import fife | 27 from fife import fife |
28 | 28 |
29 from fife.extensions.fife_settings import Setting | |
30 from scripts.quests.basequest import Quest, ReturnItemQuest, QuestTypes | |
31 | |
29 class QuestManager(object): | 32 class QuestManager(object): |
30 def __init__(self, gamecontroller): | 33 def __init__(self, gamecontroller): |
31 self._gamecontroller = gamecontroller | 34 self._gamecontroller = gamecontroller |
35 | |
36 self._questsettings = None | |
32 | 37 |
38 self._quests = {} | |
39 self._activequests = [] | |
40 self._completedquests = [] | |
41 | |
42 def initializeQuests(self): | |
43 questfile = self._gamecontroller.settings.get("RPG", "QuestFile", "maps/quests.xml") | |
44 | |
45 self._questsettings = Setting(settings_file=questfile) | |
46 | |
47 for identifier in self._questsettings.get("QuestGivers", "list", []): | |
48 for quest in self._questsettings.get(identifier, "questlist", []): | |
49 questdict = self._questsettings.get(identifier, quest, {}) | |
50 | |
51 if questdict['type'] == "RETURN_ITEM": | |
52 questobj = ReturnItemQuest(identifier, quest, questdict['name'], questdict['desc']) | |
53 for ritem in self._questsettings.get(quest+"_items", "itemlist", []): | |
54 itemdict = self._questsettings.get(quest+"_items", ritem, {}) | |
55 if itemdict["name"] == "GOLD_COINS": | |
56 questobj.addRequiredGold(int(itemdict['value'])) | |
57 else: | |
58 questobj.addRequiredItem(ritem) | |
59 else: | |
60 questobj = Quest(identifier, quest, questdict['name'], questdict['desc']) | |
61 | |
62 self._gamecontroller.questmanager.addQuest(questobj) | |
63 | |
64 def destroy(self): | |
33 self._quests = {} | 65 self._quests = {} |
34 self._activequests = [] | 66 self._activequests = [] |
35 self._completedquests = [] | 67 self._completedquests = [] |
36 | 68 |
37 def addQuest(self, quest): | 69 def addQuest(self, quest): |