Refactor cat.
[koperkapel.git] / koperkapel / roaches.py
index c844b5277c404c41c4448239d58daa564fecb570..da362a306361b6b28006b641ffb5ac3ff4401523 100644 (file)
@@ -5,6 +5,32 @@ from pygame.constants import BLEND_RGBA_MULT
 from .actors.animsurf import AnimatedSurfActor
 from .serums import roach_serum_color
 
+NAMES = [
+    "roupert",
+    "roachel",
+    "roeginald",
+    "roichard",
+    "rory",
+    "roalph",
+    "roabia",
+    "roafi",
+    "roaman",
+    "roemus",
+    "roadley",
+    "roanaell",
+    "roashwan",
+    "roashid",
+    "roaphael",
+    "roenfield",
+    "roani",
+    "roaya",
+    "roaza",
+    "robekka",
+    "rogan",
+    "roiana",
+    "roberta",
+]
+
 
 def roach_by_name(world, roach_name):
     roaches = [r for r in world.roaches if r.name == roach_name]
@@ -13,6 +39,26 @@ def roach_by_name(world, roach_name):
     return roaches[0]
 
 
+def next_roach_name(world):
+    roach_names = [x['name'] for x in world.roaches]
+    for cand in NAMES:
+        if cand not in roach_names:
+            return cand
+
+
+def build_roach(world, name=None, health=5, **kw):
+    if name is None:
+        name = next_roach_name(world)
+    if name is None:
+        return
+    roach = {
+        "name": name,
+        "health": health,
+    }
+    roach.update(kw)
+    return roach
+
+
 class WorldRoach(object):
     """A roach proxy with no properties for display on the game level."""