Mercurial > fife-parpg
diff demos/rpg/scripts/actors/baseactor.py @ 534:65a92a2449d5
Doing some re-factoring.
Minor change to the way the console commands are parsed.
Added the spawn command to the help file.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 31 May 2010 17:45:04 +0000 |
parents | d0bce896a526 |
children | 9fbe3dce925a |
line wrap: on
line diff
--- a/demos/rpg/scripts/actors/baseactor.py Sat May 29 17:52:07 2010 +0000 +++ b/demos/rpg/scripts/actors/baseactor.py Mon May 31 17:45:04 2010 +0000 @@ -169,110 +169,3 @@ nextaction = property(_getNextAction, _setNextAction) gold = property(_getGold, _setGold) inventory = property(_getInventory) - -class Quest(object): - def __init__(self, owner, questname, questtext): - self._owner = owner - self._name = questname - self._text = questtext - self._requireditems = [] - self._requiredgold = 0 - - def addRequiredItem(self, itemid): - self._requireditems.append(itemid) - - def addRequiredGold(self, goldcount): - self._requiredgold += goldcount - - def checkQuestCompleted(self, actor): - completed = False - - if self._requiredgold > 0: - if actor.gold >= self._requiredgold: - completed = True - - for item in self._requireditems: - if item in actor.inventory: - completed = True - - return completed - - def _getOwner(self): - return self._owner - - def _getName(self): - return self._name - - def _setName(self, questname): - self._name = questname - - def _getText(self): - return self._text - - def _setText(self, questtext): - self._text = questtext - - def _getRequiredGold(self): - return self._requiredgold - - def _getRequiredItems(self): - return self._requireditems - - owner = property(_getOwner) - name = property(_getName, _setName) - text = property(_getText, _setText) - requiredgold = property(_getRequiredGold) - requireditems = property(_getRequiredItems) - -class QuestGiver(Actor): - def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): - self._type = GameObjectTypes["QUESTGIVER"] - super(QuestGiver, self).__init__(gamecontroller, instancename, instanceid, createInstance) - - self._quests = [] - - self._activequest = None - - def addQuest(self, quest): - self._quests.append(quest) - - def offerNextQuest(self): - if self._activequest: - return - - if len(self._quests) > 0: - self._gamecontroller.guicontroller.showQuestDialog(self) - - def getNextQuest(self): - if len(self._quests) > 0: - return self._quests[0] - - return None - - def activateQuest(self, quest): - self._activequest = quest - - def completeQuest(self): - if self._activequest in self._quests: - if self._activequest.checkQuestCompleted(self._gamecontroller.scene.player): - self.say("That everything I need. Thank you!") - self._gamecontroller.scene.player.gold = self._gamecontroller.scene.player.gold - self._activequest.requiredgold - - for itemid in self._activequest.requireditems: - self._gamecontroller.scene.player.removeItemFromInventory(itemid) - - self._quests.remove(self._activequest) - self._activequest = None - else: - self.say("Come back when you have all the items I requested!") - else: - #something went wrong - self._activequest = None - - def haveQuest(self): - return len(self._quests) > 0 - - def _getActiveQuest(self): - return self._activequest - - activequest = property(_getActiveQuest)