awacke1 commited on
Commit
7741083
ยท
1 Parent(s): a11f0c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -15,12 +15,10 @@ def roll_dice(num_rolls, dice_type):
15
 
16
  def plot_tokens(health_tokens, coin_tokens):
17
  fig = go.Figure()
18
- if len(health_tokens) > 0:
19
- health_foods = [FOOD_LIST[i] for i in health_tokens]
20
- fig.add_trace(go.Scatter(x=list(range(1, len(health_foods) + 1)), y=health_foods, name="๐Ÿ’– Health"))
21
- if len(coin_tokens) > 0:
22
- coin_foods = [FOOD_LIST[i] for i in coin_tokens]
23
- fig.add_trace(go.Scatter(x=list(range(1, len(coin_foods) + 1)), y=coin_foods, name="๐Ÿ’ฐ Coins"))
24
  fig.update_layout(title="Token Accumulation", xaxis_title="Rolls", yaxis_title="Tokens")
25
  st.plotly_chart(fig)
26
 
@@ -50,14 +48,7 @@ for dice_type in DICE_TYPES:
50
  st.write("๐Ÿ’ฐ๐Ÿ’– Token Accumulation:")
51
  plot_tokens(history["health_tokens"], history["coin_tokens"])
52
  df = pd.concat([pd.DataFrame(history["roll_history"]), pd.DataFrame(history["health_tokens"], columns=["Health Tokens"]), pd.DataFrame(history["coin_tokens"], columns=["Coin Tokens"])], axis=1)
53
-
54
- if username:
55
- username_str = username
56
- else:
57
- username_str = "Anonymous"
58
- timestamp_str = datetime.now().strftime("%m-%d-%Y-%I-%M-%S-%p")
59
- filename = f"{username_str}_{timestamp_str}.csv"
60
-
61
  df.to_csv(filename, index=False)
62
- st.markdown(f'<a href="data:file/csv;base64,{b64encode(open(filename, "rb").read()).decode()}" download="{filename}">Download CSV File</a>', unsafe_allow_html=True)
63
-
 
15
 
16
  def plot_tokens(health_tokens, coin_tokens):
17
  fig = go.Figure()
18
+ health_foods = [FOOD_LIST[i] for i in health_tokens]
19
+ coin_foods = [FOOD_LIST[i] for i in coin_tokens]
20
+ fig.add_trace(go.Scatter(x=list(range(1, len(health_foods) + 1)), y=health_foods, name="๐Ÿ’– Health"))
21
+ fig.add_trace(go.Scatter(x=list(range(1, len(coin_foods) + 1)), y=coin_foods, name="๐Ÿ’ฐ Coins"))
 
 
22
  fig.update_layout(title="Token Accumulation", xaxis_title="Rolls", yaxis_title="Tokens")
23
  st.plotly_chart(fig)
24
 
 
48
  st.write("๐Ÿ’ฐ๐Ÿ’– Token Accumulation:")
49
  plot_tokens(history["health_tokens"], history["coin_tokens"])
50
  df = pd.concat([pd.DataFrame(history["roll_history"]), pd.DataFrame(history["health_tokens"], columns=["Health Tokens"]), pd.DataFrame(history["coin_tokens"], columns=["Coin Tokens"])], axis=1)
51
+ timestamp = datetime.now().strftime("%m-%d-%Y-%H-%M-%S")
52
+ filename = f"{username}_{timestamp}.csv"
 
 
 
 
 
 
53
  df.to_csv(filename, index=False)
54
+ st.markdown(f'<a href="data:file/csv;base64,{b64encode(open(filename, "rb").read()).decode()}" download="{filename}">Download CSV File</a>', unsafe_allow_html=True)