Mercurial > fife-parpg
annotate demos/rpg/scripts/objects/items.py @ 520:b6bd314df28a
Added a quest dialog.
Added QuestGiver class.
Moved level specific settings to another file.
Added BaseItem class.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 27 May 2010 16:29:07 +0000 |
parents | |
children | 6037f79b0dcf |
rev | line source |
---|---|
520
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 # This is the rio de hola client for FIFE. |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 import sys, os, re, math, random, shutil |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 from fife import fife |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 from scripts.objects.baseobject import BaseGameObject, GameObjectTypes |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 class BaseItem(BaseGameObject): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 def __init__(self, gamecontroller, itemname, itemtype="unknown"): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 super(Item, self).__init__(gamecontroller, itemtype, itemname, True) |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 self._type = GameObjectTypes["ITEM"] |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 def onPickUp(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 #remove item from the map |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 self.destroy() |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 def onDrop(self, dropx, dropy): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 #recreate object |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self._createFIFEInstance(self) |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self.setMapPosition(dropx, dropy) |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 def _getItemType(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 return self._name |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 def _getItemName(self): |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 return self._id |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 itemtype = property(_getItemType) |
b6bd314df28a
Added a quest dialog.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 itemname = property(_getItemName) |