changeset 12:9c7a96c6fe41

Refactored components and began defining basic Entities and Systems. * Moved the components from parpg.objects.components into their own top-level package, components, and separated them into individual modules. * Added a few new components, including Behavior, Container and Containable. * Created the systems top-level package for defining Grease Systems and added stub classes for the ScriptingSystem and GameRulesSystem. * Created the entities top-level package for defining Grease Entities and added an incomplete definition of the Character entity type.
author M. George Hansen <technopolitica@gmail.com>
date Wed, 27 Jul 2011 12:16:30 -1000
parents fa8bb78832e6
children bf165b30254f
files components/Behavior.py components/CharacterStatistics.py components/__init__.py components/containable.py components/container.py components/description.py components/dialog.py components/fifeagent.py components/lockable.py entities/__init__.py entities/character.py objects/components.py systems/__init__.py systems/gamerulessystem.py systems/scriptingsystem.py
diffstat 12 files changed, 241 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/Behavior.py	Wed Jul 27 12:16:30 2011 -1000
@@ -0,0 +1,24 @@
+#   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.grease.component import Component
+
+class Behavior(Component):
+    """
+    Component that defines how an entity interacts with the world though
+    scripting.
+    """
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(scripts=list)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/CharacterStatistics.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class CharacterStatistics(Component):
+    """Component that defines character statistics."""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(statistics=dict)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/containable.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class Containable(Component):
+    """Component that allows an entity to be contained by Container entity."""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(bulk=int, weight=int, image=str, container=object)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/container.py	Wed Jul 27 12:16:30 2011 -1000
@@ -0,0 +1,22 @@
+#   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.grease.component import Component
+
+class Container(Component):
+    """
+    Component that allows an entity to contain one or more child entities.
+    """
+    
+    def __init__(self):
+        Component.__init__(children=list, max_bulk=int)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/description.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class Description(Component):
+    """Component that stores the description of an object"""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(view_name=str, real_name=str, desc=str)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/dialog.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class Dialog(Component):
+    """Component that stores the dialogue"""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(dialogue=object)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/fifeagent.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class FifeAgent(Component):
+    """Component that stores the values for a fife agent"""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(identifier=int, layer=object, behaviour=object, gfx=str)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/lockable.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease.component import Component
+
+class Lockable(Component):
+    """Component that stores the data of a lock"""
+    
+    def __init__(self):
+        """Constructor"""
+        Component.__init__(locked=bool)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/entities/character.py	Wed Jul 27 12:16:30 2011 -1000
@@ -0,0 +1,26 @@
+#   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.grease import Entity
+
+class Character(Entity):
+    def __init__(self, world, view_name, real_name, desc, statistics, max_bulk,
+            items=None):
+        self.characterstats.statistics = statistics
+        
+        self.description.view_name = view_name
+        self.description.real_name = real_name
+        self.description.desc = desc
+        
+        self.container.children = items or []
+        self.container.max_bulk = max_bulk
--- a/objects/components.py	Mon Jul 25 13:39:01 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#   This file is part of PARPG.
-
-#   PARPG 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.
-
-#   PARPG 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 PARPG.  If not, see <http://www.gnu.org/licenses/>.
-
-from parpg.grease.component import Component
-from parpg.grease.geometry import Vec2d
-
-""" Contains the components for PARPG
-"""
-
-class FifeAgent(Component):
-    """Component that stores the values for a fife agent"""
-    
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(identifier=int, layer=object, behaviour=object, gfx=str)
-
-class Description(Component):
-    """Component that stores the description of an object"""
-    
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(view_name=str, real_name=str, desc=str)     
-        
-class Statistics(Component):
-    """Component that stores statistics"""
-    
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(statistics=object)
-        
-class Dialogue(Component):
-    """Component that stores the dialogue"""
-
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(dialogue=object)
-        
-class Inventory(Component):
-    """Component that stores the inventory"""
-
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(inventory=object, hidden=bool)
-        
-class Lock(Component):
-    """Component that stores the data of a lock"""
-
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(open=bool, locked=bool)
-        
-class Item(Component):
-    """Component that stores the data of an item"""
-
-    def __init__(self):
-        """Constructor"""
-        Component.__init__(bulk=int, weight=int, image=str, container=object)     
-    
-    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/systems/gamerulessystem.py	Wed Jul 27 12:16:30 2011 -1000
@@ -0,0 +1,22 @@
+#   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.grease import System
+
+class GameRulesSystem(System):
+    """
+    System responsible for defining the game rules and mechanics by which
+    characters interact with the world.
+    """
+    
+    pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/systems/scriptingsystem.py	Wed Jul 27 12:16:30 2011 -1000
@@ -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.grease import System
+
+class ScriptingSystem(System):
+    """
+    System responsible for managing scripts attached to entities to define 
+    their behavior.
+    """
+    pass
\ No newline at end of file