# HG changeset patch # User KarstenBock@gmx.net # Date 1317128283 -7200 # Node ID 939984cff702e501f5909896dd877f878b2a7cac # Parent 0411a4bcceeebc0461f139a3db651268a51d4587 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 0411a4bcceee -r 939984cff702 components/CharacterStatistics.py --- a/components/CharacterStatistics.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/base.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/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 0411a4bcceee -r 939984cff702 components/change_map.py --- a/components/change_map.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/containable.py --- a/components/containable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/container.py --- a/components/container.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/description.py --- a/components/description.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/dialogue.py --- a/components/dialogue.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/equip.py --- a/components/equip.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/equipable.py --- a/components/equipable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/fifeagent.py --- a/components/fifeagent.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/general.py --- a/components/general.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/lockable.py --- a/components/lockable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 components/usable.py --- a/components/usable.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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 0411a4bcceee -r 939984cff702 gamemodel.py --- a/gamemodel.py Mon Sep 26 15:44:42 2011 +0200 +++ b/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: