changeset 119:3564a46544bc

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 29869273f9e1
children 1703dbb4fefb
files src/parpg/components/CharacterStatistics.py src/parpg/components/base.py src/parpg/components/change_map.py src/parpg/components/containable.py src/parpg/components/container.py src/parpg/components/description.py src/parpg/components/dialogue.py src/parpg/components/equip.py src/parpg/components/equipable.py src/parpg/components/fifeagent.py src/parpg/components/general.py src/parpg/components/lockable.py src/parpg/components/usable.py src/parpg/gamemodel.py
diffstat 14 files changed, 58 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- 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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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 <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/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: