Merge pull request #2 from ethanrusz/calculations

Basic Functionality
This commit is contained in:
Em (Ethan) Ruszanowski 2024-02-14 16:25:05 -06:00 committed by GitHub
commit b54765f369
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 240 additions and 85 deletions

154
app.py
View file

@ -1,4 +1,5 @@
import streamlit as st import streamlit as st
from itertools import chain
class Moon: class Moon:
@ -21,80 +22,147 @@ class Creature:
class Run: class Run:
def __init__(self, moon): def __init__(self, moon):
self.moon = moon self.moon = moon
self.inside_power = moon.inside_max_power
self.outside_power = moon.outside_max_power
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, 10, 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, 10, 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!', "Moon",
help='Pick your current 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))
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 outside_creature in outside_creatures: with st.form("outside"):
st.slider(outside_creature.name, 0, outside_creature.max_spawns, help=outside_creature.nickname) for creature in outside_creatures:
moon_max = min(
creature.max_spawns, run.moon.outside_max_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 = 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 inside_creature in inside_creatures: with st.form("inside"):
st.slider(inside_creature.name, 0, inside_creature.max_spawns, help=inside_creature.nickname) for creature in inside_creatures:
moon_max = min(
creature.max_spawns, run.moon.inside_max_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 = 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,45 +1,132 @@
altair==5.2.0 aiodns==3.0.0
attrs==23.2.0 aiohttp==3.9.3
blinker==1.7.0 aiosignal==1.3.1
cachetools==5.3.2 apsw==3.42.0.1
certifi==2024.2.2 argcomplete==2.0.0
charset-normalizer==3.3.2 attrs==23.1.0
click==8.1.7 Beaker==1.12.1
gitdb==4.0.11 beautifulsoup4==4.12.3
GitPython==3.1.41 black==24.1.1
idna==3.6 blivet==3.8.2
importlib-metadata==7.0.1 blivet-gui==2.4.2
Jinja2==3.1.3 Brlapi==0.8.5
jsonschema==4.21.1 Brotli==1.1.0
jsonschema-specifications==2023.12.1 cffi==1.15.1
markdown-it-py==3.0.0 chardet==5.2.0
MarkupSafe==2.1.5 charset-normalizer==3.2.0
mdurl==0.1.2 click==8.1.3
numpy==1.26.4 cryptography==41.0.3
packaging==23.2 css-parser==1.0.7
pandas==2.2.0 cupshelpers==1.0
dasbus==1.7
dbus-python==1.3.2
defusedxml==0.7.1
distro==1.8.0
dnf==4.18.2
dnspython==2.4.2
docstring-to-markdown==0.13
fb-re2==1.0.7
fedora-third-party==0.10
feedparser==6.0.10
file-magic==0.4.0
fros==1.1
frozenlist==1.4.0
FVS==0.3.4
gpg==1.20.0
html2text==2020.1.16
html5-parser==0.4.10
html5lib==1.1
humanize==3.13.1
icoextract==0.1.4
idna==3.4
ifaddr==0.1.7
jedi==0.19.0
jeepney==0.8.0
langtable==0.0.64
libcomps==0.1.20
libdnf==0.72.0
lxml==4.9.3
Mako==1.2.3
Markdown==3.5.1
MarkupSafe==2.1.3
mechanize==0.4.8
mercurial==6.5.3
msgpack==1.0.5
multidict==6.0.4
mypy-extensions==1.0.0
netifaces==0.11.0
odfpy==1.4.1
olefile==0.46
orjson==3.9.10
packaging==23.1
parso==0.8.3
Paste==3.5.3
pathspec==0.12.1
pathvalidate==2.5.2
patool==1.12
pefile==2023.2.7
pexpect==4.8.0
pid==2.2.3
pillow==10.2.0 pillow==10.2.0
protobuf==4.25.2 platformdirs==3.9.1
pyarrow==15.0.0 pluggy==1.2.0
pydeck==0.8.1b0 ply==3.11
Pygments==2.17.2 productmd==1.38
psutil==5.9.5
ptyprocess==0.7.0
pwquality==1.4.5
pycairo==1.25.1
pycares==4.3.0
pychm==0.8.6
pycparser==2.20
pycrypto==2.6.1
pycups==2.0.1
pycurl==7.45.2
pyenchant==3.2.2
Pygments==2.15.1
PyGObject==3.46.0
pykickstart==3.48
pyOpenSSL==23.2.0
pyparted==3.13.0
PyQt6==6.6.1
PyQt6-sip==13.6.0
PyQt6-WebEngine==6.6.0
PySocks==1.7.1
python-augeas==1.1.0
python-dateutil==2.8.2 python-dateutil==2.8.2
pytz==2024.1 python-lsp-black==2.0.0
referencing==0.33.0 python-lsp-jsonrpc==1.1.2
requests==2.31.0 python-lsp-server==1.10.0
rich==13.7.0 python-meh==0.51
rpds-py==0.17.1 pyudev==0.24.1
pyxdg==0.27
PyYAML==6.0.1
ranger-fm==1.9.3
regex==2023.12.25
requests==2.28.2
requests-file==1.5.1
requests-ftp==0.3.1
rpm==4.19.1
selinux @ file:///builddir/build/BUILD/libselinux-3.5/src
sepolicy @ file:///builddir/build/BUILD/selinux-3.5/python/sepolicy
setools==4.4.3
setuptools==67.7.2
sgmllib3k==1.0.0
simpleaudio==1.0.4
simpleline==1.9.0
six==1.16.0 six==1.16.0
smmap==5.0.1 sos==4.6.0
streamlit==1.31.0 soupsieve==2.5
tenacity==8.2.3 speedtest-cli==2.1.3
toml==0.10.2 systemd-python==235
toolz==0.12.1 Tempita==0.5.2
tornado==6.4 tomli==2.0.1
typing_extensions==4.9.0 ufw==0.35
tzdata==2023.4 ujson==5.8.0
tzlocal==5.2 urllib3==1.26.18
urllib3==2.2.0 vkbasalt-cli==3.1.1.post1
validators==0.22.0 webencodings==0.5.1
watchdog==4.0.0 xxhash==3.4.1
zipp==3.17.0 yarl==1.9.2
zeroconf==0.118.0
zombie-imp==0.0.2