Add roach_by_name helper.
authorSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 13:28:45 +0000 (15:28 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sat, 5 Mar 2016 13:28:45 +0000 (15:28 +0200)
koperkapel/roaches.py

index 0d2448216c16a00900759736ed66e32fe975dbcb..6dedf305fd3b50b96e3da5c2e748b9f32551964e 100644 (file)
@@ -8,6 +8,13 @@ from .actors.orientatedsurf import OrientatedSurfActor
 from .serums import roach_serum_color
 
 
+def roach_by_name(world, roach_name):
+    roaches = [r for r in world.roaches if r.name == roach_name]
+    if not roaches:
+        return None
+    return roaches[0]
+
+
 class RoachActor(OrientatedSurfActor):
     def __init__(self, frames):
         self._frames = frames