Compare commits

...

3 commits

Author SHA1 Message Date
11b003bca4
Update app.py 2024-02-16 17:20:05 -05:00
8c992591a8
Merge pull request #8 from ethanrusz/use-none
Return None instead of empty list
2024-02-16 16:11:47 -06:00
1a95687e59
Return None instead of empty list 2024-02-16 17:07:28 -05:00

11
app.py
View file

@ -25,16 +25,23 @@ class Run:
self.outside_power = moon.outside_max_power self.outside_power = moon.outside_max_power
def find_spawnlist(remaining_power: int, creatures: list[Creature]) -> list[str]: def find_spawnlist(remaining_power: int, creatures: list[Creature]) -> list[str] | None:
""" """
Given a run, return all possible spwns for location. Given a run, return all possible spwns for location.
:param remaining_power: The remaining power in the current location. :param remaining_power: The remaining power in the current location.
:return: A list of all creatures that may still spawn. :return: A list of all creatures that may still spawn.
""" """
return sorted( if remaining_power == 0:
return None
spawnable = sorted(
[creature.name for creature in creatures if creature.power <= remaining_power] [creature.name for creature in creatures if creature.power <= remaining_power]
) )
if spawnable != []:
return spawnable
else:
return None
def main(): def main():