Hack keyboard behaviour to be different. Also incidently allow rotating in place
[koperkapel.git] / koperkapel / serums.py
1 """ Tools for creating serum actors. """
2
3 from pgzero.loaders import images
4 from pygame.constants import BLEND_RGBA_MULT
5 from .actors.surf import SurfActor
6
7 SERUMS = ["smart", "fast", "strong"]
8
9 SERUM_TILENAME_MAP = {
10     "smart": "intelligence",
11     "fast": "speed",
12     "strong": "strength",
13 }
14
15 SERUM_OVERLAY_COLORS = {
16     "smart": (0, 0, 255, 255),  # blue
17     "fast": (0, 255, 0, 255),  # green
18     "strong": (255, 0, 255, 255),  # purple
19     "none": (170, 68, 0, 255),  # brown
20 }
21
22
23 def roach_serum_color(roach):
24     for serum_name in SERUMS:
25         if getattr(roach, serum_name):
26             return SERUM_OVERLAY_COLORS[serum_name]
27     return SERUM_OVERLAY_COLORS["none"]
28
29
30 def roach_is_serumless(roach):
31     for serum_name in SERUMS:
32         if getattr(roach, serum_name):
33             return False
34     return True
35
36
37 class SerumFactory:
38     def __init__(self, suffix):
39         self.suffix = suffix
40
41     def assemble(self, name):
42         assert name in SERUMS
43         puddle = images.load("serum%s/serum" % (self.suffix,))
44         serum_icon = images.load("serum%s/%s" % (
45             self.suffix, SERUM_TILENAME_MAP[name],))
46         frame = puddle.copy()
47         frame.fill(SERUM_OVERLAY_COLORS[name], None, BLEND_RGBA_MULT)
48         frame.blit(serum_icon, (0, 0))
49         return SurfActor(frame)
50
51
52 default_serums = SerumFactory("")
53 big_serums = SerumFactory("_big")