From 4a5b994ef0de6a47c4f855efa7e436d51102954a Mon Sep 17 00:00:00 2001 From: Ethan Ruszanowski Date: Fri, 9 Feb 2024 18:00:04 -0500 Subject: [PATCH] Refactor Run class --- app.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 2c7e3cc..889e76b 100644 --- a/app.py +++ b/app.py @@ -22,8 +22,8 @@ class Creature: class Run: def __init__(self, moon): self.moon = moon - self.inside_power_level = moon.inside_max_power - self.outside_power_level = moon.outside_max_power + self.inside_power = moon.inside_max_power + self.outside_power = moon.outside_max_power def main(): @@ -81,7 +81,6 @@ def main(): for creature in chain(outside_creatures, inside_creatures): st.session_state[creature.name] = 0 - st.markdown(f"## {run.moon.name} (Tier {run.moon.tier})") column_1, column_2 = st.columns(2) @@ -91,29 +90,26 @@ def main(): for creature in outside_creatures: hold = st.session_state[creature.name] - moon_max = min(creature.max_spawns, run.outside_power_level // creature.power) + moon_max = min(creature.max_spawns, run.outside_power // creature.power) if moon_max > 0: st.slider(creature.name, 0, moon_max, key=creature.name, help=creature.nickname) else: st.slider(creature.name, 0, 1, key=creature.name, help=creature.nickname, disabled=True) - run.outside_power_level = run.outside_power_level - st.session_state[creature.name] - + run.outside_power = run.outside_power - st.session_state[creature.name] with column_2: st.markdown('### Inside') st.info(f"Maximum power: {run.moon.inside_max_power}") for creature in inside_creatures: - moon_max = min(creature.max_spawns, run.inside_power_level // creature.power) + moon_max = min(creature.max_spawns, run.inside_power // creature.power) if moon_max > 0: st.slider(creature.name, 0, moon_max, key=creature.name, help=creature.nickname) else: st.slider(creature.name, 0, 1, key=creature.name, help=creature.nickname, disabled=True) - run.inside_power_level = run.inside_power_level - st.session_state[creature.name] - - + run.inside_power = run.inside_power - st.session_state[creature.name] # https://docs.streamlit.io/library/api-reference/session-state