Compare commits

..

2 commits

Author SHA1 Message Date
a3c25f1c71
Correct imports and requirements 2024-02-14 17:39:21 -05:00
7945d1be8c
Add power level outputs 2024-02-14 17:23:02 -05:00
2 changed files with 109 additions and 57 deletions

162
app.py
View file

@ -1,5 +1,4 @@
import streamlit as st import streamlit as st
from itertools import chain
class Moon: class Moon:
@ -27,93 +26,142 @@ class Run:
def main(): def main():
st.set_page_config('Lethal Company Scouter', '🛰️') st.set_page_config("Lethal Company Scouter", "🛰️")
moons = [ moons = [
# Tier 1 # Tier 1
Moon('Experimentation', 1, 4, 8), Moon("Experimentation", 1, 4, 8),
Moon('Assurance', 1, 6, 8), Moon("Assurance", 1, 6, 8),
Moon('Vow', 1, 7, 6), Moon("Vow", 1, 7, 6),
# Tier 2 # Tier 2
Moon('Offense', 2, 12, 12), Moon("Offense", 2, 12, 12),
Moon('March', 2, 14, 12), Moon("March", 2, 14, 12),
# Tier 3 # Tier 3
Moon('Rend', 3, 10, 6), Moon("Rend", 3, 10, 6),
Moon('Dine', 3, 15, 6), Moon("Dine", 3, 15, 6),
Moon('Titan', 3, 18, 7), Moon("Titan", 3, 18, 7),
] ]
outside_creatures = [ outside_creatures = [
Creature('Baboon Hawk', None, 1, 15, 6), Creature("Baboon Hawk", None, 1, 15, 6),
Creature('Circuit Bees', None, 1, 6, None), Creature("Circuit Bees", None, 1, 6, None),
Creature('Eyeless Dog', None, 2, 8, 12), Creature("Eyeless Dog", None, 2, 8, 12),
Creature('Forest Keeper', 'Giant', 3, 3, None), Creature("Forest Keeper", "Giant", 3, 3, None),
Creature('Earth Leviathan', 'Worm', 2, 3, None), Creature("Earth Leviathan", "Worm", 2, 3, None),
# Hybrid # Hybrid
Creature('Outside Ghost Girl ', None, 2, 1, None), Creature("Outside Ghost Girl ", None, 2, 1, None),
Creature('Outside Masked', None, 1, 10, 4), Creature("Outside Masked", None, 1, 10, 4),
] ]
inside_creatures = [ inside_creatures = [
Creature('Bracken', 'Freddy Fazbear', 3, 1, 6), Creature("Bracken", "Freddy Fazbear", 3, 1, 6),
Creature('Bunker Spider', None, 3, 1, 6), Creature("Bunker Spider", None, 3, 1, 6),
Creature('Coil Head', None, 1, 5, None), Creature("Coil Head", None, 1, 5, None),
Creature('Hoarding Bug', 'Yippee Bug', 1, 8, 3), Creature("Hoarding Bug", "Yippee Bug", 1, 8, 3),
Creature('Hygrodere', 'Goo', 1, 2, None), Creature("Hygrodere", "Goo", 1, 2, None),
Creature('Jester', None, 3, 1, None), Creature("Jester", None, 3, 1, None),
Creature('Nutcracker', None, 1, 10, 5), Creature("Nutcracker", None, 1, 10, 5),
Creature('Snare Flea', "Head. Bug.", 1, 4, 3), Creature("Snare Flea", "Head. Bug.", 1, 4, 3),
Creature('Spore Lizard', None, 1, 2, None), Creature("Spore Lizard", None, 1, 2, None),
Creature('Thumper', None, 2, 4, 4), Creature("Thumper", None, 2, 4, 4),
# Hybrid
Creature('Inside Ghost Girl', None, 2, 1, None),
Creature('Inside Masked', None, 1, 10, 4),
] ]
st.markdown('# :red[Lethal Company] Scouter') hybrid_creatures = [
Creature("Ghost Girl", None, 2, 1, None),
Creature("Masked", None, 1, 10, 4),
]
st.markdown("# :red[Lethal Company] Scouter")
st.markdown(":rainbow[What does the scouter say about this moon's power level?]") st.markdown(":rainbow[What does the scouter say about this moon's power level?]")
moon = st.selectbox('Moon', sorted(m.name for m in moons), moon = st.selectbox(
placeholder='Moon! Pick a moon!', help='Pick your current moon.') "Moon",
sorted(m.name for m in moons),
placeholder="Moon! Pick a moon!",
help="Pick your current moon.",
)
run = Run(next(m for m in moons if m.name is moon)) run = Run(next(m for m in moons if m.name is moon))
if not st.session_state:
for creature in chain(outside_creatures, inside_creatures):
st.session_state[creature.name] = 0
st.markdown(f"## {run.moon.name} (Tier {run.moon.tier})") st.markdown(f"## {run.moon.name} (Tier {run.moon.tier})")
column_1, column_2 = st.columns(2) column_1, column_2 = st.columns(2)
with column_1: with column_1:
st.markdown('### Outside') st.markdown("### Outside")
st.info(f"Maximum power: {run.moon.outside_max_power}") st.info(f"Maximum power: {run.moon.outside_max_power}")
for creature in outside_creatures: with st.form("outside"):
hold = st.session_state[creature.name] for creature in outside_creatures:
moon_max = min(creature.max_spawns, run.outside_power // creature.power) moon_max = min(
if moon_max > 0: creature.max_spawns, run.moon.outside_max_power // creature.power
st.slider(creature.name, 0, moon_max, key=creature.name, help=creature.nickname) )
else: if moon_max > 0:
st.slider(creature.name, 0, 1, key=creature.name, help=creature.nickname, disabled=True) 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 = run.outside_power - st.session_state[creature.name] run.outside_power = run.outside_power - st.session_state[creature.name]
outside_submit = st.form_submit_button("Calculate")
if outside_submit:
if run.outside_power >= 0:
st.toast(f"🌳 Outside power remaining: {run.outside_power}")
else:
st.error(
f"Power level exceedes maximum possible for {run.moon.name}."
)
with column_2: with column_2:
st.markdown('### Inside') st.markdown("### Inside")
st.info(f"Maximum power: {run.moon.inside_max_power}") st.info(f"Maximum power: {run.moon.inside_max_power}")
for creature in inside_creatures: with st.form("inside"):
moon_max = min(creature.max_spawns, run.inside_power // creature.power) for creature in inside_creatures:
if moon_max > 0: moon_max = min(
st.slider(creature.name, 0, moon_max, key=creature.name, help=creature.nickname) creature.max_spawns, run.moon.inside_max_power // creature.power
else: )
st.slider(creature.name, 0, 1, key=creature.name, help=creature.nickname, disabled=True) 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 = run.inside_power - st.session_state[creature.name] run.inside_power = run.inside_power - st.session_state[creature.name]
inside_submit = st.form_submit_button("Calculate")
if inside_submit:
if run.inside_power >= 0:
st.toast(f"🏭 Inside power remaining: {run.inside_power}")
else:
st.error(
f"Power level exceedes maximum possible for {run.moon.name}."
)
# https://docs.streamlit.io/library/api-reference/session-state if __name__ == "__main__":
if __name__ == '__main__':
main() main()

View file

@ -1,5 +1,6 @@
altair==5.2.0 altair==5.2.0
attrs==23.2.0 attrs==23.2.0
black==24.2.0
blinker==1.7.0 blinker==1.7.0
cachetools==5.3.2 cachetools==5.3.2
certifi==2024.2.2 certifi==2024.2.2
@ -15,10 +16,13 @@ jsonschema-specifications==2023.12.1
markdown-it-py==3.0.0 markdown-it-py==3.0.0
MarkupSafe==2.1.5 MarkupSafe==2.1.5
mdurl==0.1.2 mdurl==0.1.2
mypy-extensions==1.0.0
numpy==1.26.4 numpy==1.26.4
packaging==23.2 packaging==23.2
pandas==2.2.0 pandas==2.2.0
pathspec==0.12.1
pillow==10.2.0 pillow==10.2.0
platformdirs==4.2.0
protobuf==4.25.2 protobuf==4.25.2
pyarrow==15.0.0 pyarrow==15.0.0
pydeck==0.8.1b0 pydeck==0.8.1b0