From 9ab469b266d1c4446b2b84af4522f68d0074d940 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sat, 5 Mar 2016 15:28:45 +0200 Subject: [PATCH] Add roach_by_name helper. --- koperkapel/roaches.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/koperkapel/roaches.py b/koperkapel/roaches.py index 0d24482..6dedf30 100644 --- a/koperkapel/roaches.py +++ b/koperkapel/roaches.py @@ -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 -- 2.34.1