Start describing serums.
authorSimon Cross <hodgestar@gmail.com>
Fri, 4 Mar 2016 21:59:46 +0000 (23:59 +0200)
committerSimon Cross <hodgestar@gmail.com>
Fri, 4 Mar 2016 21:59:46 +0000 (23:59 +0200)
koperkapel/roaches.py
koperkapel/serums.py [new file with mode: 0644]
koperkapel/world.py

index 20220c4c6da52165651910e691ad354d62c83dde..08440ccda8333e1b3e7369585682038a12991100 100644 (file)
@@ -5,13 +5,7 @@ from pgzero.clock import each_tick
 from pgzero.loaders import images
 from pygame.constants import BLEND_RGBA_MULT
 from .actors.surf import SurfActor
-
-ROACH_COLORS = {
-    "blue": (0, 0, 255, 255),
-    "green": (0, 255, 0, 255),
-    "purple": (255, 0, 255, 255),
-    "brown": (170, 68, 0, 255),
-}
+from .serums import roach_serum_color
 
 
 class RoachActor(SurfActor):
@@ -38,15 +32,6 @@ class RoachFactory:
         self.suffix = suffix
         self.frames = 4
 
-    def roach_color(self, roach):
-        if roach.smart:
-            return ROACH_COLORS["blue"]
-        elif roach.fast:
-            return ROACH_COLORS["green"]
-        elif roach.strong:
-            return ROACH_COLORS["purple"]
-        return ROACH_COLORS["brown"]
-
     def assemble_frame(self, i, color, roach_data):
         roach = images.load("roach%s/roach_%d" % (self.suffix, i + 1))
         eyes = images.load("roach%s/eyes_%d" % (self.suffix, i + 1))
@@ -56,7 +41,7 @@ class RoachFactory:
         return roach
 
     def assemble(self, roach_data):
-        color = self.roach_color(roach_data)
+        color = roach_serum_color(roach_data)
         frames = [
             self.assemble_frame(i, color, roach_data)
             for i in range(self.frames)]
diff --git a/koperkapel/serums.py b/koperkapel/serums.py
new file mode 100644 (file)
index 0000000..951d002
--- /dev/null
@@ -0,0 +1,18 @@
+""" Tools for creating serum actors. """
+
+
+SERUMS = ["smart", "fast", "strong"]
+
+SERUM_OVERLAY_COLORS = {
+    "smart": (0, 0, 255, 255),  # blue
+    "fast": (0, 255, 0, 255),  # green
+    "strong": (255, 0, 255, 255),  # purple
+    "none": (170, 68, 0, 255),  # brown
+}
+
+
+def roach_serum_color(roach):
+    for serum_name in SERUMS:
+        if getattr(roach, serum_name):
+            return SERUM_OVERLAY_COLORS[serum_name]
+    return SERUM_OVERLAY_COLORS["none"]
index f03bffa1a88e7945e429dc9319c7228096e1dc54..b0e3debfd16d830ee8d030aee2aa2eb4e5be8a3a 100644 (file)
@@ -25,6 +25,9 @@ class World:
             self._build_roach("roichard", fast=True),
             self._build_roach("roupert"),
         ]
+        state["serums"] = [
+            "smart", "strong", "fast",
+        ]
         state["vehicles"] = {
             "current": "walking",
             "available": ["walking"],