Mercurial > sypikslang
diff gamelib/game_base.py @ 94:245ef50de84d
Sanity-check research, schematic and mission classes. (Ironic, no?)
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Wed, 09 May 2012 21:22:10 +0200 |
parents | 74ce25ec2073 |
children | 53277724645b |
line wrap: on
line diff
--- a/gamelib/game_base.py Wed May 09 21:16:53 2012 +0200 +++ b/gamelib/game_base.py Wed May 09 21:22:10 2012 +0200 @@ -8,6 +8,8 @@ if leaf_only and cls.__subclasses__(): # Not a leaf class, and only want leaves continue + if hasattr(cls, 'sanity_check'): + cls.sanity_check() subclasses.append(cls) return subclasses @@ -60,3 +62,9 @@ def save_data(self): return (self.save_name(), self.points) + + @classmethod + def sanity_check(cls): + for science, points in cls.PREREQUISITES: + assert issubclass(science, Science) + assert isinstance(points, int)