diff nagslang/enemies.py @ 235:831e4f6b3d18

Add hints for the level editor
author Neil Muller <drnlmuller@gmail.com>
date Wed, 04 Sep 2013 21:16:09 +0200
parents 329b3044ddef
children 083053422a84
line wrap: on
line diff
--- a/nagslang/enemies.py	Wed Sep 04 19:11:00 2013 +0200
+++ b/nagslang/enemies.py	Wed Sep 04 21:16:09 2013 +0200
@@ -10,6 +10,15 @@
 from nagslang.resources import resources
 
 
+def get_editable_enemies():
+    classes = []
+    for cls_name, cls in globals().iteritems():
+        if isinstance(cls, type) and issubclass(cls, Enemy):
+            if hasattr(cls, 'requires'):
+                classes.append((cls_name, cls))
+    return classes
+
+
 class Enemy(GameObject):
     """A base class for mobile enemies"""
 
@@ -33,6 +42,10 @@
     def attack(self):
         raise NotImplementedError
 
+    @classmethod
+    def requires(cls):
+        return [("name", "string"), ("position", "coordinates")]
+
 
 class PatrollingAlien(Enemy):
     is_moving = True  # Always walking.
@@ -112,3 +125,8 @@
             self._switch_direction()
         self.set_direction(x_step, y_step)
         super(PatrollingAlien, self).animate()
+
+    @classmethod
+    def requires(cls):
+        return [("name", "string"), ("position", "coordinates"),
+                ("end_position", "coordinates")]