# HG changeset patch # User KarstenBock@gmx.net # Date 1317128283 -7200 # Node ID 3564a46544bc74617c642493656e1a49232cf773 # Parent 29869273f9e15904867bcc1402aeaba1d5f104f6 Added Base component, which has a saveable_fields property. It is supposed to be derived from, thus it is not in the components list. diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/CharacterStatistics.py --- a/src/parpg/components/CharacterStatistics.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/CharacterStatistics.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,11 +11,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class CharacterStatistics(Component): +class CharacterStatistics(Base): """Component that defines character statistics.""" def __init__(self): """Constructor""" - Component.__init__(self, statistics=dict) \ No newline at end of file + Base.__init__(self, statistics=dict) \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/base.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/parpg/components/base.py Tue Sep 27 14:58:03 2011 +0200 @@ -0,0 +1,21 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from parpg.bGrease.component import Component + +class Base(Component): + """Base component for PARPG.""" + + @property + def saveable_fields(self): + return self.fields \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/change_map.py --- a/src/parpg/components/change_map.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/change_map.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,12 +11,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base from parpg.bGrease.geometry import Vec2d -class ChangeMap(Component): +class ChangeMap(Base): """Component that allows an entity to be contained by Container entity.""" def __init__(self): """Constructor""" - Component.__init__(self, target_map=str, target_position=list) \ No newline at end of file + Base.__init__(self, target_map=str, target_position=list) \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/containable.py --- a/src/parpg/components/containable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/containable.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,11 +11,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Containable(Component): +class Containable(Base): """Component that allows an entity to be contained by Container entity.""" def __init__(self): """Constructor""" - Component.__init__(self, bulk=int, weight=int, item_type=str, image=str, container=object, slot=int) + Base.__init__(self, bulk=int, weight=int, item_type=str, image=str, container=object, slot=int) diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/container.py --- a/src/parpg/components/container.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/container.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,15 +11,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Container(Component): +class Container(Base): """ Component that allows an entity to contain one or more child entities. """ def __init__(self): - Component.__init__(self, children=list, max_bulk=int) + Base.__init__(self, children=list, max_bulk=int) class BulkLimitError(Exception): diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/description.py --- a/src/parpg/components/description.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/description.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,11 +11,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Description(Component): +class Description(Base): """Component that stores the description of an object""" def __init__(self): """Constructor""" - Component.__init__(self, view_name=str, real_name=str, desc=str) + Base.__init__(self, view_name=str, real_name=str, desc=str) diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/dialogue.py --- a/src/parpg/components/dialogue.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/dialogue.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,11 +11,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Dialogue(Component): +class Dialogue(Base): """Component that stores the dialogue""" def __init__(self): """Constructor""" - Component.__init__(self, dialogue=object) + Base.__init__(self, dialogue=object) diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/equip.py --- a/src/parpg/components/equip.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/equip.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,15 +11,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Equip(Component): +class Equip(Base): """ Component that stores the equipment (what is being worn/wieled). """ def __init__(self): - Component.__init__(self, head=object, body=object, leg=object, feet=object, l_arm=object, r_arm=object) + Base.__init__(self, head=object, body=object, leg=object, feet=object, l_arm=object, r_arm=object) class SlotInvalidError(Exception): """Error that gets raised when the slot is invalid.""" diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/equipable.py --- a/src/parpg/components/equipable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/equipable.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,12 +11,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Equipable(Component): +class Equipable(Base): """ Component that stores the data for an entity that can be equipped. """ def __init__(self): - Component.__init__(self, possible_slots=list, wearer=object, in_slot=str) \ No newline at end of file + Base.__init__(self, possible_slots=list, wearer=object, in_slot=str) \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/fifeagent.py --- a/src/parpg/components/fifeagent.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/fifeagent.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,14 +11,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class FifeAgent(Component): +class FifeAgent(Base): """Component that stores the values for a fife agent""" def __init__(self): """Constructor""" - Component.__init__(self, layer=object, behaviour=object, gfx=str) + Base.__init__(self, layer=object, behaviour=object, gfx=str) def setup_behaviour(agent): diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/general.py --- a/src/parpg/components/general.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/general.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,11 +11,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class General(Component): +class General(Base): """Component that stores the general values of an parpg entity""" def __init__(self): """Constructor""" - Component.__init__(self, identifier=str) \ No newline at end of file + Base.__init__(self, identifier=str) \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/lockable.py --- a/src/parpg/components/lockable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/lockable.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,14 +11,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Lockable(Component): +class Lockable(Base): """Component that stores the data of a lock""" def __init__(self): """Constructor""" - Component.__init__(self, closed=bool, locked=bool) + Base.__init__(self, closed=bool, locked=bool) class LockedError(Exception): diff -r 29869273f9e1 -r 3564a46544bc src/parpg/components/usable.py --- a/src/parpg/components/usable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/components/usable.py Tue Sep 27 14:58:03 2011 +0200 @@ -11,12 +11,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from parpg.bGrease.component import Component +from base import Base -class Usable(Component): +class Usable(Base): """ Component that stores data about the actions that an object can do. """ def __init__(self): - Component.__init__(self, actions=dict) \ No newline at end of file + Base.__init__(self, actions=dict) \ No newline at end of file diff -r 29869273f9e1 -r 3564a46544bc src/parpg/gamemodel.py --- a/src/parpg/gamemodel.py Mon Sep 26 15:44:42 2011 +0200 +++ b/src/parpg/gamemodel.py Tue Sep 27 14:58:03 2011 +0200 @@ -694,7 +694,7 @@ pass else: comp_vals = getattr(entity, name) - for field in component.fields: + for field in component.saveable_fields: try: comp_data[field] = getattr(comp_vals, field) except AttributeError: