Mercurial > fife-parpg
comparison demos/rpg/scripts/actors/questgiver.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 | |
children | 2e739ae9a8bc |
comparison
equal
deleted
inserted
replaced
533:082e919cc348 | 534:65a92a2449d5 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 # -*- coding: utf-8 -*- | |
4 | |
5 # #################################################################### | |
6 # Copyright (C) 2005-2010 by the FIFE team | |
7 # http://www.fifengine.net | |
8 # This file is part of FIFE. | |
9 # | |
10 # FIFE is free software; you can redistribute it and/or | |
11 # modify it under the terms of the GNU Lesser General Public | |
12 # License as published by the Free Software Foundation; either | |
13 # version 2.1 of the License, or (at your option) any later version. | |
14 # | |
15 # This library is distributed in the hope that it will be useful, | |
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 # Lesser General Public License for more details. | |
19 # | |
20 # You should have received a copy of the GNU Lesser General Public | |
21 # License along with this library; if not, write to the | |
22 # Free Software Foundation, Inc., | |
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
24 # #################################################################### | |
25 # This is the rio de hola client for FIFE. | |
26 | |
27 import sys, os, re, math, random, shutil | |
28 | |
29 from fife import fife | |
30 | |
31 from scripts.objects.baseobject import BaseGameObject, GameObjectTypes | |
32 from scripts.actors.baseactor import Actor | |
33 | |
34 class QuestGiver(Actor): | |
35 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): | |
36 self._type = GameObjectTypes["QUESTGIVER"] | |
37 super(QuestGiver, self).__init__(gamecontroller, instancename, instanceid, createInstance) | |
38 | |
39 self._quests = [] | |
40 | |
41 self._activequest = None | |
42 | |
43 def addQuest(self, quest): | |
44 self._quests.append(quest) | |
45 | |
46 def offerNextQuest(self): | |
47 if self._activequest: | |
48 return | |
49 | |
50 if len(self._quests) > 0: | |
51 self._gamecontroller.guicontroller.showQuestDialog(self) | |
52 | |
53 def getNextQuest(self): | |
54 if len(self._quests) > 0: | |
55 return self._quests[0] | |
56 | |
57 return None | |
58 | |
59 def activateQuest(self, quest): | |
60 self._activequest = quest | |
61 | |
62 def completeQuest(self): | |
63 if self._activequest in self._quests: | |
64 if self._activequest.checkQuestCompleted(self._gamecontroller.scene.player): | |
65 self.say("That everything I need. Thank you!") | |
66 self._gamecontroller.scene.player.gold = self._gamecontroller.scene.player.gold - self._activequest.requiredgold | |
67 | |
68 for itemid in self._activequest.requireditems: | |
69 self._gamecontroller.scene.player.removeItemFromInventory(itemid) | |
70 | |
71 self._quests.remove(self._activequest) | |
72 self._activequest = None | |
73 else: | |
74 self.say("Come back when you have all the items I requested!") | |
75 else: | |
76 #something went wrong | |
77 self._activequest = None | |
78 | |
79 def haveQuest(self): | |
80 return len(self._quests) > 0 | |
81 | |
82 def _getActiveQuest(self): | |
83 return self._activequest | |
84 | |
85 activequest = property(_getActiveQuest) |