changeset 89:939984cff702

Added Base component, which has a saveable_fields property. It is supposed to be derived from, thus it is not in the components list.
author KarstenBock@gmx.net
date Tue, 27 Sep 2011 14:58:03 +0200
parents 0411a4bcceee
children 4a8a0cd7f79a
files components/CharacterStatistics.py components/base.py components/change_map.py components/containable.py components/container.py components/description.py components/dialogue.py components/equip.py components/equipable.py components/fifeagent.py components/general.py components/lockable.py components/usable.py gamemodel.py
diffstat 14 files changed, 58 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- 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 <http://www.gnu.org/licenses/>.
 
-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
--- /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 <http://www.gnu.org/licenses/>.
+
+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
--- 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 <http://www.gnu.org/licenses/>.
 
-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
--- 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 <http://www.gnu.org/licenses/>.
 
-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)
--- 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 <http://www.gnu.org/licenses/>.
 
-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):
--- 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 <http://www.gnu.org/licenses/>.
 
-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)
--- 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 <http://www.gnu.org/licenses/>.
 
-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)
--- 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 <http://www.gnu.org/licenses/>.
 
-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."""
--- 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 <http://www.gnu.org/licenses/>.
 
-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
--- 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 <http://www.gnu.org/licenses/>.
 
-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):
--- 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 <http://www.gnu.org/licenses/>.
 
-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
--- 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 <http://www.gnu.org/licenses/>.
 
-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):
 
--- 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 <http://www.gnu.org/licenses/>.
 
-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
--- 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: