diff --git a/erynrl/engine.py b/erynrl/engine.py index 4a9de14..aa628d4 100644 --- a/erynrl/engine.py +++ b/erynrl/engine.py @@ -86,7 +86,7 @@ class Engine: self.update_field_of_view() # Interface elements - self.hit_points_bar = Bar(position=Point(4, 45), width=20) + self.hit_points_bar = Bar(position=Point(4, 45), width=20, colors=list(color.HealthBar.bar_colors())) self.message_log.add_message('Greetings adventurer!', fg=(127, 127, 255), stack=False) diff --git a/erynrl/interface/color.py b/erynrl/interface/color.py index 3dfd44f..3e87d46 100644 --- a/erynrl/interface/color.py +++ b/erynrl/interface/color.py @@ -1,10 +1,45 @@ # Eryn Wells +# pylint: disable=too-few-public-methods ''' A bunch of colors. ''' -BLACK = (0, 0, 0) -WHITE = (255, 255, 255) -GREY10 = (26, 26, 26) -GREY50 = (128, 128, 128) \ No newline at end of file +from typing import Iterator, Tuple + +Color = Tuple[int, int, int] + +# Grayscale +BLACK = (0x00, 0x00, 0x00) +GREY12 = (0x20, 0x20, 0x20) +GREY25 = (0x40, 0x40, 0x40) +GREY50 = (0x80, 0x80, 0x80) +GREY75 = (0xC0, 0xC0, 0xC0) +WHITE = (0xFF, 0xFF, 0xFF) + +# Primaries +BLUE = (0x00, 0x00, 0xFF) +CYAN = (0x00, 0xFF, 0xFF) +GREEN = (0x00, 0xFF, 0x00) +MAGENTA = (0xFF, 0x00, 0xFF) +RED = (0xFF, 0x00, 0x00) +YELLOW = (0xFF, 0xFF, 0x00) +ORANGE = (0xFF, 0x77, 0x00) + +# Semantic +class HealthBar: + '''Semantic colors for the health bar''' + FULL = GREEN + GOOD = GREEN + OKAY = YELLOW + LOW = ORANGE + CRITICAL = RED + + @staticmethod + def bar_colors() -> Iterator[Tuple[float, Color]]: + '''Return an iterator of colors that a Bar class can use''' + yield (0.1, HealthBar.CRITICAL) + yield (0.25, HealthBar.LOW) + yield (0.75, HealthBar.OKAY) + yield (0.9, HealthBar.GOOD) + yield (1.0, HealthBar.FULL) \ No newline at end of file