Alejandro Cremades commited on
Commit
fd1f4c2
โ€ข
1 Parent(s): d95ea05

Filter cards by power and toughness ranges

Browse files
Middle_School_Card_Search.py CHANGED
@@ -79,7 +79,7 @@ if colorcol5.checkbox(_["basic"]["color_g"][l]):
79
  if colorcol6.checkbox(_["basic"]["color_c"][l]):
80
  results_df = results_df[results_df["c"] == True]
81
 
82
- # Filter by mana value
83
  min_mv = mslist_df["mv"].min()
84
  max_mv = mslist_df["mv"].max()
85
  mv_options = [mv for mv in range(min_mv, max_mv + 1)]
@@ -118,6 +118,38 @@ input_text = st.text_input(
118
  ).strip()
119
  results_df = results_df[results_df["text"].str.contains(input_text, case=False)]
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  if results_df.shape[0] < mslist_df.shape[0]:
122
  if exact_match[0]:
123
  cardname = exact_match[1]
 
79
  if colorcol6.checkbox(_["basic"]["color_c"][l]):
80
  results_df = results_df[results_df["c"] == True]
81
 
82
+ # Filter by mana value range
83
  min_mv = mslist_df["mv"].min()
84
  max_mv = mslist_df["mv"].max()
85
  mv_options = [mv for mv in range(min_mv, max_mv + 1)]
 
118
  ).strip()
119
  results_df = results_df[results_df["text"].str.contains(input_text, case=False)]
120
 
121
+ # Filter by power and toughness ranges
122
+
123
+ powtou_df = mslist_df[mslist_df["power"].isin(range(0, 100))]
124
+
125
+ min_pow = int(powtou_df["power"].min(skipna=True))
126
+ max_pow = int(powtou_df["power"].max(skipna=True))
127
+ pow_range = range(min_pow, max_pow + 1)
128
+ pow_options = [pow for pow in pow_range]
129
+ start_pow, end_pow = st.select_slider(
130
+ f'**{_["search"]["search_by_pow"][l]}**',
131
+ options=pow_options,
132
+ value=(min_pow, max_pow),
133
+ )
134
+ if start_pow > min_pow or end_pow < max_pow:
135
+ results_df = results_df[results_df["power"].isin(pow_range)]
136
+ results_df = results_df[results_df["power"] >= start_pow]
137
+ results_df = results_df[results_df["power"] <= end_pow]
138
+
139
+ min_tou = int(powtou_df["toughness"].min(skipna=True))
140
+ max_tou = int(powtou_df["toughness"].max(skipna=True))
141
+ tou_range = range(min_tou, max_tou + 1)
142
+ tou_options = [tou for tou in tou_range]
143
+ start_tou, end_tou = st.select_slider(
144
+ f'**{_["search"]["search_by_tou"][l]}**',
145
+ options=tou_options,
146
+ value=(min_tou, max_tou),
147
+ )
148
+ if start_tou > min_tou or end_tou < max_tou:
149
+ results_df = results_df[results_df["toughness"].isin(tou_range)]
150
+ results_df = results_df[results_df["toughness"] >= start_tou]
151
+ results_df = results_df[results_df["toughness"] <= end_tou]
152
+
153
  if results_df.shape[0] < mslist_df.shape[0]:
154
  if exact_match[0]:
155
  cardname = exact_match[1]
streamlit_common/locale.py CHANGED
@@ -54,6 +54,14 @@ def get_locale():
54
  "en": "Mana value:",
55
  "ja": "ใƒžใƒŠ็ท้‡๏ผš",
56
  },
 
 
 
 
 
 
 
 
57
  "cards_found": {
58
  "en": " cards were found.",
59
  "ja": "ๆžš ใฎใ‚ซใƒผใƒ‰ใŒ่ฆ‹ใคใ‹ใ‚Šใพใ—ใŸใ€‚",
 
54
  "en": "Mana value:",
55
  "ja": "ใƒžใƒŠ็ท้‡๏ผš",
56
  },
57
+ "search_by_pow": {
58
+ "en": "Power:",
59
+ "ja": "ใƒ‘ใƒฏใƒผ๏ผš",
60
+ },
61
+ "search_by_tou": {
62
+ "en": "Toughness:",
63
+ "ja": "ใ‚ฟใƒ•ใƒใ‚น๏ผš",
64
+ },
65
  "cards_found": {
66
  "en": " cards were found.",
67
  "ja": "ๆžš ใฎใ‚ซใƒผใƒ‰ใŒ่ฆ‹ใคใ‹ใ‚Šใพใ—ใŸใ€‚",