tmnam20's picture
Upload app.py
5304f4d verified
from PIL import Image
import streamlit as st
import math
import time
import datetime
st.set_page_config(
page_title="IdleMMO - Moonlit Festival Campaign Calculator",
page_icon="https://cdn.idle-mmo.com/uploaded/icons/01J305JYQ75MXXV2C3Z4D19SAV.png",
layout="wide",
)
# st.logo(
# "https://cdn.idle-mmo.com/cdn-cgi/image/height=250,width=250/global/helmet-solo.png"
# )
tier_point = [
55,
75,
90,
110,
135,
150,
180,
230,
260,
300,
315,
330,
345,
360,
410,
450,
550,
]
TARGET_POINT = 26_070
st.title("IdleMMO - Moonlit Festival Campaign Calculator")
st.write("Author: cloux")
with st.form("Player Statistics", border=False):
with st.container(border=True):
st.header("Base Information")
col1, _, col2, _, col3 = st.columns([8, 1, 8, 1, 8])
with col1:
has_membership = st.checkbox("Membership")
with col2:
current_point = st.number_input("Current Point", min_value=0)
with col3:
col31, mid3, col32 = st.columns([1, 1, 16])
col31.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30HD3FTAN0WGHEKRAPPRS4C.png",
width=64,
)
lunar_ticket = col32.number_input("Lunar Ticket", min_value=0)
col1, _, col2 = st.columns([8, 1, 8])
with col1:
playtime_per_day = st.slider(
"Play Hour(s) per Day", min_value=1, max_value=24, value=16
)
with col2:
current_tier = st.slider("Current Tier", min_value=1, max_value=17, value=1)
# subtract the current tier to convert to 0-based index
consumed_point = 0
for i in range(0, current_tier - 1):
consumed_point += tier_point[i]
with st.container(border=True):
st.subheader("Collected Resources")
st.write("Skill Resources")
col1, _, col2, _, col3 = st.columns([8, 1, 8, 1, 8])
with col1:
col11, mid1, col12 = st.columns([1, 1, 16])
# with col11:
col11.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30CDE8XEVDVB91FHT7HQR7Z.png",
width=64,
)
starlight_gem = col12.number_input("Starlight Gem", min_value=0)
with col2:
col21, mid2, col22 = st.columns([1, 1, 16])
col21.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30CCHESG0XADBJ1PB7VPN3B.png",
width=64,
)
moonlit_chalice = col22.number_input("Moonlit Chalice", min_value=0)
with col3:
col31, mid3, col32 = st.columns([1, 1, 16])
col31.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=200,height=200/uploaded/skins/01J30CC0VYJB7E0BKVB06A2R6V.png",
width=64,
)
moonlight_essence = col32.number_input("Moonlight Essence", min_value=0)
st.divider()
st.write("Battle Resources")
col1, _, col2, _, col3 = st.columns([8, 1, 8, 1, 8])
# ancient_parchment,ethereal_gem,lunar_stone
with col1:
col11, mid1, col12 = st.columns([1, 1, 16])
col11.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30CA49KTAY88AKKFKAVTPP3.png",
width=64,
)
ancient_parchment = col12.number_input("Ancient Parchment", min_value=0)
with col2:
col21, mid2, col22 = st.columns([1, 1, 16])
col21.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30CB0A8GSCTNN57DBQQ0KHR.png",
width=64,
)
ethereal_gem = col22.number_input("Ethereal Gem", min_value=0)
with col3:
col31, mid3, col32 = st.columns([1, 1, 16])
col31.image(
"https://cdn.idle-mmo.com/cdn-cgi/image/width=150,height=150/uploaded/skins/01J30CBA0B2JF8Y6BEEYWCBE9S.png",
width=64,
)
lunar_stone = col32.number_input("Lunar Stone", min_value=0)
button = st.form_submit_button("Submit")
if button:
starlight_gem = min(starlight_gem, TARGET_POINT)
moonlit_chalice = min(moonlit_chalice, TARGET_POINT)
moonlight_essence = min(moonlight_essence, TARGET_POINT)
time_to_complete = (
TARGET_POINT
- current_point
- consumed_point * 6
- lunar_ticket
- ancient_parchment // 10
- ethereal_gem // 10
- lunar_stone // 10
) * (10 + 6 + 10)
time_to_complete -= starlight_gem * 10
time_to_complete -= moonlit_chalice * (6 + 10)
time_to_complete -= moonlight_essence * (10 + 6 + 10)
if has_membership:
time_to_complete = math.ceil(time_to_complete * 0.9)
if playtime_per_day > 16:
playtime_per_day = 16 + (playtime_per_day - 16) * 0.5
day = time_to_complete // 60 // 60 // playtime_per_day
hour = (time_to_complete - day * playtime_per_day * 60 * 60) // 60 // 60
minute = (
time_to_complete - day * playtime_per_day * 60 * 60 - hour * 60 * 60
) // 60
st.info(
f"Time to complete: {day:.0f} days {hour:.0f} hours {minute:.0f} minutes"
+ "\n"
)
current_time = datetime.datetime.now()
end_time = current_time + datetime.timedelta(seconds=time_to_complete)
st.info(f"Estimated End Date: {end_time.strftime('%Y-%m-%d %H:%M:%S')}")
if playtime_per_day > 16:
st.warning(
"There is a 4-hour 50% performance penalty for playing more than 16 hours a day."
)