File size: 2,134 Bytes
448e881
a807ea9
d9b4271
14f90e3
5dbcf27
a807ea9
 
5dbcf27
a807ea9
 
c751fd4
 
a807ea9
 
6085806
 
 
448e881
6085806
c751fd4
 
 
 
5dbcf27
a807ea9
 
 
 
 
 
 
5dbcf27
 
 
a807ea9
 
 
 
 
14f90e3
a807ea9
14f90e3
a807ea9
9863595
642bcd2
 
 
d3537a9
82116f7
e9812fa
 
a807ea9
e9812fa
 
 
 
5dbcf27
 
 
82116f7
 
 
 
 
 
d9b4271
df9758b
 
 
d9b4271
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import streamlit as st
import pandas as pd
import streamlit_common.footer
import streamlit_common.lib as lib
import streamlit_common.locale

mslist_path = "output/middleschool.csv"
_ = streamlit_common.locale.get_locale()

st.set_page_config(
    page_title="Middle School Tutor | Check Card List",
    page_icon="favicon.ico",
    layout="wide",
)
lang = st.sidebar.radio(
    label="Language / 言θͺž",
    options=["English", "ζ—₯本θͺž"],
)
l = "ja" if lang == "ζ—₯本θͺž" else "en"
headcol1, headcol2 = st.columns([1, 7])
headcol1.image("favicon.ico", width=80)
headcol2.write(f"# Middle School Tutor")
st.write(f'## {_["check"]["title"][l]}')
st.write(_["check"]["instructions"][l])

mslist_df = pd.read_csv(mslist_path)
mslist_df.fillna("", inplace=True)

col1, col2 = st.columns(2)

input_list = col1.text_area(
    label=f'##### {_["check"]["card_list"][l]}',
    placeholder="4 Lightning Bolt\n4 γƒœγƒΌγƒ«γƒ»γƒ©γ‚€γƒˆγƒ‹γƒ³γ‚°",
    height=400,
)

cardnames = []

for line in input_list.split("\n"):
    cardname = lib.remove_number_of_copies(line)
    if cardname is not None:
        cardnames.append(lib.remove_number_of_copies(cardname))

input_cards = pd.DataFrame(cardnames, columns=["cardname"])
input_cards["legalnames"] = input_cards["cardname"].apply(
    lib.get_legal_cardnames, args=[mslist_df]
)
input_cards = input_cards.apply(lib.split_names_list, axis=1)
input_cards = input_cards.apply(lib.legal_to_checkmark, axis=1)
if input_cards.shape[0] > 0:
    input_cards = input_cards.sort_values(by="Legal", ascending=False)

illegal_cards = 0
if input_cards.shape[0] > 0:
    illegal_cards = input_cards[input_cards["Legal"] != "βœ…"].shape[0]

col2.write(
    f'##### {_["check"]["illegal_cards_1"][l]}{illegal_cards}{_["check"]["illegal_cards_2"][l]}'
)
if "English" in input_cards and "ζ—₯本θͺž" in input_cards:
    col2.dataframe(
        input_cards[["Legal", "English", "ζ—₯本θͺž"]],
        use_container_width=True,
        hide_index=True,
    )

if input_cards.shape[0] > 0:
    input_cards[input_cards["Legal"] == "βœ…"].apply(lib.row_to_button_link, axis=1)

streamlit_common.footer.write_footer()