Mercurial > fife-parpg
annotate demos/rpg/scripts/quests/basequest.py @ 540:2e739ae9a8bc
Some misc code cleanup.
Added the EnterPortalAction action.
You can now move between town and level1.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 01 Jun 2010 19:17:30 +0000 |
parents | 65a92a2449d5 |
children | 67f6f3538e88 |
rev | line source |
---|---|
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 # This is the rio de hola client for FIFE. |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 import sys, os, re, math, random, shutil, time |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 from datetime import datetime |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 from fife import fife |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 class Quest(object): |
540
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
33 """ |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
34 @todo: do a little refactoring here to split out the type of quests. |
2e739ae9a8bc
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
35 """ |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 def __init__(self, owner, questname, questtext): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 self._owner = owner |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 self._name = questname |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 self._text = questtext |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 self._requireditems = [] |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 self._requiredgold = 0 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 def addRequiredItem(self, itemid): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 self._requireditems.append(itemid) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 def addRequiredGold(self, goldcount): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self._requiredgold += goldcount |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 def checkQuestCompleted(self, actor): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 completed = False |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 if self._requiredgold > 0: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 if actor.gold >= self._requiredgold: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 completed = True |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 for item in self._requireditems: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 if item in actor.inventory: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 completed = True |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 return completed |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 def _getOwner(self): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 return self._owner |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 def _getName(self): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 return self._name |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 def _setName(self, questname): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 self._name = questname |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 def _getText(self): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 return self._text |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 def _setText(self, questtext): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 self._text = questtext |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 def _getRequiredGold(self): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 return self._requiredgold |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 def _getRequiredItems(self): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 return self._requireditems |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 owner = property(_getOwner) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 name = property(_getName, _setName) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 text = property(_getText, _setText) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 requiredgold = property(_getRequiredGold) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 requireditems = property(_getRequiredItems) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 |