Mercurial > parpg-core
comparison src/parpg/quest_engine.py @ 12:d60f1dab8469
Fixed resource path dependencies issue that caused PARPG to crash on start.
* PARPG should now run without issue (system installation not tested).
* Utilized FIFE's VFS module to remove path dependencies from most PARPG modules.
* The new parpg.vfs module is a singleton with a single global variable, VFS, which is a reference to the global VFS instance. Although a singleton is not ideal it should be replaced once PARPG's core code is refactored.
* The parpg.vfs singleton is initialized in the parpg.applicaiton.PARPGApplication class with the absolute path to the data directory via the parpg.settings module and corresponding configuration file.
* A new DataPath entry was added to the default system configuration file template under the [parpg] section to support the new parpg.vfs module.
* Updated the parpg-assets subrepo to revision 3 to fix some dialog file format issues (for details see commit message for parpg-assets).
* Fixed a few bugs in the parpg.dialogueparsers.YAMLDialogueParser class related to exception handling.
author | M. George Hansen <technopolitica@gmail.com> |
---|---|
date | Mon, 06 Jun 2011 15:56:14 -1000 |
parents | 1fd2201f5c36 |
children |
comparison
equal
deleted
inserted
replaced
11:4706e0194af3 | 12:d60f1dab8469 |
---|---|
12 | 12 |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. | 14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 import yaml | 16 import yaml |
17 | |
17 from parpg.common.utils import locateFiles | 18 from parpg.common.utils import locateFiles |
18 import os.path | 19 from parpg import vfs |
19 | 20 |
20 class Quest(object): | 21 class Quest(object): |
21 """Class that holds the information for a quest""" | 22 """Class that holds the information for a quest""" |
22 def __init__(self, quest_id, quest_giver_id, quest_name, description, | 23 def __init__(self, quest_id, quest_giver_id, quest_name, description, |
23 variables): | 24 variables): |
140 def keys(self): | 141 def keys(self): |
141 return self.quests.keys() | 142 return self.quests.keys() |
142 | 143 |
143 def readQuests(self): | 144 def readQuests(self): |
144 """Reads in the quests in the quest directory""" | 145 """Reads in the quests in the quest directory""" |
145 files = locateFiles("*.yaml", self.quest_dir) | 146 filepaths = locateFiles("*.yaml", self.quest_dir) |
146 self.quests = {} | 147 self.quests = {} |
147 self.active_quests = [] | 148 self.active_quests = [] |
148 self.finished_quests = [] | 149 self.finished_quests = [] |
149 self.failed_quests = [] | 150 self.failed_quests = [] |
150 for quest_file in files: | 151 for filepath in filepaths: |
151 quest_file = os.path.relpath(quest_file).replace("\\", "/") | 152 quest_file = vfs.VFS.open(filepath) |
152 tree = yaml.load(open(quest_file)) | 153 tree = yaml.load(quest_file) |
153 quest_properties = tree["QUEST_PROPERTIES"] | 154 quest_properties = tree["QUEST_PROPERTIES"] |
154 variable_defines = tree["DEFINES"] | 155 variable_defines = tree["DEFINES"] |
155 | 156 |
156 self.quests[quest_properties["quest_id"]] = \ | 157 self.quests[quest_properties["quest_id"]] = \ |
157 Quest(quest_properties["quest_id"], | 158 Quest(quest_properties["quest_id"], |