From: Simon Cross Date: Sat, 5 Mar 2016 13:28:45 +0000 (+0200) Subject: Add roach_by_name helper. X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=9ab469b266d1c4446b2b84af4522f68d0074d940;p=koperkapel.git Add roach_by_name helper. --- 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