File size: 1,516 Bytes
448e881
a807ea9
 
d9b4271
448e881
a807ea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448e881
 
 
a807ea9
 
448e881
 
a807ea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9863595
 
a807ea9
 
9863595
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
import streamlit as st
import pandas as pd
import re
import streamlit_common.footer


def remove_number_of_copies(line: str) -> str:
    if len(line.strip()) < 1:
        return None
    pattern = re.compile("^([0-9]+) +")
    return pattern.sub("", line)


def is_legal(cardname: str) -> bool:
    if mslist_df[mslist_df["name"].str.lower() == cardname.lower()].shape[0] > 0:
        return True
    if mslist_df[mslist_df["name_ja"] == cardname].shape[0] > 0:
        return True
    return False


mslist_path = "output/middleschool.csv"

st.set_page_config(
    page_title="Middle School | Check Card List",
    page_icon="πŸƒ",
    layout="wide",
)
st.write(
    """
    # Middle School List Check

    Paste or type your list here to confirm that every card in it is Middle School legal.
    """
)

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

col1, col2 = st.columns(2)

input_list = col1.text_area(
    label="##### Card list", placeholder="4 Lightning Bolt\n4 γƒœγƒΌγƒ«γƒ»γƒ©γ‚€γƒˆγƒ‹γƒ³γ‚°", height=400
)

cardnames = []

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

input_cards = pd.DataFrame(cardnames, columns=["cardname"])
input_cards["legal"] = input_cards["cardname"].apply(is_legal)

col2.write("##### Middle School legality")
col2.dataframe(input_cards[["legal", "cardname"]], use_container_width=True)

streamlit_common.footer.write_footer()