Jung commited on
Commit
e6af0f7
·
1 Parent(s): 8458525

team simulation draft

Browse files
Files changed (1) hide show
  1. app.py +36 -9
app.py CHANGED
@@ -66,11 +66,12 @@ def display_image(url, scale=0.5):
66
  image = Image.open(urlopen(url))
67
  st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
68
 
69
- def display_heroes_from_df(df,display_cols=display_cols):
70
  vtob = "is" if len(df)<=1 else "are"
71
  st.write(f'There {vtob} {len(df)} heroes in the filtered list')
72
-
73
- st.dataframe(df[display_cols],
 
74
  column_config={
75
  "image": st.column_config.ImageColumn("Avatar", help="")},
76
  use_container_width=True,
@@ -159,6 +160,9 @@ st.write('Powered by Heroplan.io : Thanks E&P community for continually update h
159
  df = pd.read_csv('heroes_ep.csv')
160
  st.write(f'### Updated: Oct 23, 2023 -- Total heroes in HeroPlan database = {len(df)}')
161
 
 
 
 
162
  #########################################
163
 
164
  class_values = ['None'] + list(df['class'].unique())
@@ -173,7 +177,7 @@ source_values = ['None'] + list(df['source'].unique()) # Contain lot of typo bug
173
  with st.sidebar:
174
  genre = st.radio(
175
  "Choose how to explore heroes",
176
- [":rainbow[Heroes Explorer]", "***LB/CB Hero Stat*** :movie_camera:"],
177
  captions = ["Filter only heroes with certain properties", "Co-powered by Elioty33's DataVault"])
178
 
179
  #########################################
@@ -266,9 +270,32 @@ if genre == ':rainbow[Heroes Explorer]':
266
 
267
  display_heroes_from_df(df2.sort_values(sort_option, ascending=False))
268
  #########################################
269
- ## Program 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  else:
271
- df_extra = pd.read_csv("heroes_ep_extra.csv")
272
 
273
  st.header("Analyze Hero LB/CB Stat (without Emblem)")
274
  st.write("HeroPlan and DataVault are combined here. Thanks ***@Elioty33*** for his DataVault contribution")
@@ -281,11 +308,11 @@ else:
281
  name_values = sorted(list(df_extra['name'].values))
282
  name_choice = st.selectbox(label='Hero Name:', options=name_values, index=0)
283
 
284
- lb_list = ['None', 'LB1', 'LB2']
285
  costume_list = return_costume_list(df_extra, name_choice)
286
-
287
- lb_choice = st.selectbox(label='Limit Break:', options=lb_list, index=0)
288
  costume_choice = st.selectbox(label='Costume:', options=costume_list, index=0)
 
 
 
289
 
290
  df_ret = return_hero_stat(df_extra, name_choice, lb_choice=lb_choice, costume_choice=costume_choice)
291
  display_heroes_from_df(df_ret,display_cols=df_ret.columns[:-2]) # display all except special-skill text
 
66
  image = Image.open(urlopen(url))
67
  st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
68
 
69
+ def display_heroes_from_df(df,display_cols=display_cols, show_df=True):
70
  vtob = "is" if len(df)<=1 else "are"
71
  st.write(f'There {vtob} {len(df)} heroes in the filtered list')
72
+
73
+ if show_df:
74
+ st.dataframe(df[display_cols],
75
  column_config={
76
  "image": st.column_config.ImageColumn("Avatar", help="")},
77
  use_container_width=True,
 
160
  df = pd.read_csv('heroes_ep.csv')
161
  st.write(f'### Updated: Oct 23, 2023 -- Total heroes in HeroPlan database = {len(df)}')
162
 
163
+ df_extra = pd.read_csv("heroes_ep_extra.csv")
164
+ all_name_extra = sorted(list(df_extra['name'].values))
165
+
166
  #########################################
167
 
168
  class_values = ['None'] + list(df['class'].unique())
 
177
  with st.sidebar:
178
  genre = st.radio(
179
  "Choose how to explore heroes",
180
+ [":rainbow[Heroes Explorer]", "Team Simulation","***LB/CB Hero Stat*** :movie_camera:"],
181
  captions = ["Filter only heroes with certain properties", "Co-powered by Elioty33's DataVault"])
182
 
183
  #########################################
 
270
 
271
  display_heroes_from_df(df2.sort_values(sort_option, ascending=False))
272
  #########################################
273
+ ## Program 2 "Team Simulation"
274
+ elif genre == "Team Simulation":
275
+
276
+ def choose_hero():
277
+ name_choice = st.selectbox(label='Hero Name:', options=all_name_extra, index=0)
278
+ costume_list = return_costume_list(df_extra, name_choice)
279
+ costume_choice = st.selectbox(label='Costume:', options=costume_list, index=0)
280
+ lb_list = ['None', 'LB1', 'LB2']
281
+ lb_choice = st.selectbox(label='Limit Break:', options=lb_list, index=0)
282
+
283
+ df_ret = return_hero_stat(df_extra, name_choice, lb_choice=lb_choice, costume_choice=costume_choice)
284
+ return df_ret
285
+
286
+ col1, col2, col3, col4, col5 = st.columns(5)
287
+ with col1:
288
+ df_hero1 = choose_hero()
289
+ with col2:
290
+ df_hero2 = choose_hero()
291
+
292
+ df_hero_all5 = pd.concat([df_hero1, df_hero2])
293
+ display_heroes_from_df(df_hero_all5, display_cols=df_ret.columns[:-2], show_df=False) # display all except special-skill text
294
+
295
+ #########################################
296
+ ## Program 3 "Individual Stat"
297
  else:
298
+
299
 
300
  st.header("Analyze Hero LB/CB Stat (without Emblem)")
301
  st.write("HeroPlan and DataVault are combined here. Thanks ***@Elioty33*** for his DataVault contribution")
 
308
  name_values = sorted(list(df_extra['name'].values))
309
  name_choice = st.selectbox(label='Hero Name:', options=name_values, index=0)
310
 
 
311
  costume_list = return_costume_list(df_extra, name_choice)
 
 
312
  costume_choice = st.selectbox(label='Costume:', options=costume_list, index=0)
313
+
314
+ lb_list = ['None', 'LB1', 'LB2']
315
+ lb_choice = st.selectbox(label='Limit Break:', options=lb_list, index=0)
316
 
317
  df_ret = return_hero_stat(df_extra, name_choice, lb_choice=lb_choice, costume_choice=costume_choice)
318
  display_heroes_from_df(df_ret,display_cols=df_ret.columns[:-2]) # display all except special-skill text