mirror of
https://github.com/ethanrusz/scouter.git
synced 2024-11-21 10:57:45 -05:00
Refactor Run class
This commit is contained in:
parent
31730b8406
commit
4a5b994ef0
1 changed files with 6 additions and 10 deletions
16
app.py
16
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
|
||||
|
|
Loading…
Reference in a new issue