Mercurial > parpg-core
annotate src/parpg/entities/__init__.py @ 146:6e1eb964a6e5
Fixed dropping items on the map.
author | KarstenBock@gmx.net |
---|---|
date | Mon, 03 Oct 2011 18:25:31 +0200 |
parents | 9b5498e3bda0 |
children |
rev | line source |
---|---|
116
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
1 # This file is part of PARPG. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
2 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
3 # PARPG is free software: you can redistribute it and/or modify |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
4 # it under the terms of the GNU General Public License as published by |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
5 # the Free Software Foundation, either version 3 of the License, or |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
6 # (at your option) any later version. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
7 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
8 # PARPG is distributed in the hope that it will be useful, |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
11 # GNU General Public License for more details. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
12 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
13 # You should have received a copy of the GNU General Public License |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
15 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
16 import sys |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
17 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
18 from general import General |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
19 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
20 def createEntity(info, identifier, world, extra = None): |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
21 """Called when we need to get an actual object. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
22 @type info: dict |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
23 @param info: stores information about the object we want to create |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
24 @type extra: dict |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
25 @param extra: stores additionally required attributes |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
26 @return: the object""" |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
27 # First, we try to get the world, which every game_obj needs. |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
28 extra = extra or {} |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
29 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
30 # add the extra info |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
31 for key, val in extra.items(): |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
32 info[key].update(val) |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
33 |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
34 # this is for testing purposes |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
35 new_ent = General(world, identifier) |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
36 for component, data in info.items(): |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
37 comp_obj = getattr(new_ent, component) |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
38 for key, value in data.items(): |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
39 setattr(comp_obj, key, value) |
9b5498e3bda0
Move the identifier field from the FifeAgent component to the new General component.
KarstenBock@gmx.net
parents:
88
diff
changeset
|
40 return new_ent |