diff --git a/constants.py b/constants.py index 9ca60ee..80f7c41 100644 --- a/constants.py +++ b/constants.py @@ -4,9 +4,9 @@ class SimColor: -""" -Tuples corresponding to RGB colors -""" + """ + Tuples corresponding to RGB colors + """ LIGHT_GREY = (240, 240, 240) DARK_GREY = (30, 30, 50) BLACK = (0, 0, 0) @@ -17,9 +17,9 @@ class SimColor: class Disease: -""" -Constants for disease -""" + """ + Constants for disease + """ INFECTED = 0 RECOVERED = 1 UNEXPOSED = 2 @@ -34,9 +34,9 @@ class Disease: class Screen: -""" -Constants for Screen -""" + """ + Constants for Screen + """ WIDTH = 680 HEIGHT = 480 FONT_SIZE = 18 diff --git a/universe.py b/universe.py index 09a0501..d9aabe3 100644 --- a/universe.py +++ b/universe.py @@ -145,6 +145,9 @@ def run(self): pygame.display.update() while self.is_epidemic_over: + for e in pygame.event.get(): + if e.type == pygame.QUIT: + self.quit() pygame.display.update() def progress_healing(self): @@ -162,7 +165,8 @@ def progress_healing(self): if host.condition is Disease.INFECTED: host.remaining_recovery -= 1 - + if host.remaining_recovery <= 0: + host.condition = Disease.RECOVERED host.color = Disease.COLOR_MAP[host.condition] @staticmethod @@ -192,7 +196,7 @@ def is_epidemic_over(self): Returns true if there are no infected hosts :return: Boolean """ - return self.get_population_count(Disease.INFECTED) is 0 + return self.get_population_count(Disease.INFECTED) == 0 if __name__ == "__main__":