From cda4116741c03cb69ee972a4285251126fa4de2e Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Fri, 4 Mar 2016 23:59:46 +0200 Subject: [PATCH] Start describing serums. --- koperkapel/roaches.py | 19 ++----------------- koperkapel/serums.py | 18 ++++++++++++++++++ koperkapel/world.py | 3 +++ 3 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 koperkapel/serums.py diff --git a/koperkapel/roaches.py b/koperkapel/roaches.py index 20220c4..08440cc 100644 --- a/koperkapel/roaches.py +++ b/koperkapel/roaches.py @@ -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 index 0000000..951d002 --- /dev/null +++ b/koperkapel/serums.py @@ -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"] diff --git a/koperkapel/world.py b/koperkapel/world.py index f03bffa..b0e3deb 100644 --- a/koperkapel/world.py +++ b/koperkapel/world.py @@ -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"], -- 2.34.1