awacke1 commited on
Commit
6eec04b
Β·
1 Parent(s): 0ff0bce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import pandas as pd
3
  import plotly.express as px
4
  import plotly.graph_objects as go
 
5
 
6
  PLAYERS = {
7
  "Player 1": {"Sketch": "🎨", "Character": "πŸ§™β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 5, "Defense": 3},
@@ -54,7 +55,7 @@ def battle_player_card():
54
  st.error("The monster defeated you.")
55
  save_data()
56
 
57
- def load_and_display_player_data():
58
  player_data = pd.read_csv("player_data.csv")
59
  st.write("## Player Data")
60
  st.write(player_data)
@@ -70,6 +71,24 @@ def load_and_display_player_data():
70
  fig.update_layout(margin=dict(t=50, b=0, l=0, r=0), height=400)
71
  st.plotly_chart(fig)
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  def main():
74
  st.set_page_config(page_title="Player Cards and Monsters")
75
  st.title("Player Cards and Monsters")
 
2
  import pandas as pd
3
  import plotly.express as px
4
  import plotly.graph_objects as go
5
+ import os
6
 
7
  PLAYERS = {
8
  "Player 1": {"Sketch": "🎨", "Character": "πŸ§™β€β™€οΈ", "Player Board": "πŸ“œ", "Action Dice": "🎲", "Health Tokens": "❀️", "Coin Tokens": "πŸ’°", "Battle Tokens": "βš”οΈ", "Attack": 5, "Defense": 3},
 
55
  st.error("The monster defeated you.")
56
  save_data()
57
 
58
+ def load_and_display_player_data_old():
59
  player_data = pd.read_csv("player_data.csv")
60
  st.write("## Player Data")
61
  st.write(player_data)
 
71
  fig.update_layout(margin=dict(t=50, b=0, l=0, r=0), height=400)
72
  st.plotly_chart(fig)
73
 
74
+ def load_and_display_player_data():
75
+ if os.path.exists("player_data.csv"):
76
+ player_data = pd.read_csv("player_data.csv")
77
+ st.write("## Player Data")
78
+ st.write(player_data)
79
+
80
+ fig = px.treemap(player_data,
81
+ path=['Player'],
82
+ values='Health Tokens',
83
+ color='Attack',
84
+ color_continuous_scale='Blues',
85
+ title='Player Attack Power and Health Tokens')
86
+ fig.update_traces(textinfo='label+value+percent entry',
87
+ hovertemplate='<b>%{label}</b><br>Attack: %{color}<br>Health: %{value}<br>Percent: %{percentEntry:.2f}%<extra></extra>')
88
+ fig.update_layout(margin=dict(t=50, b=0, l=0, r=0), height=400)
89
+ st.plotly_chart(fig)
90
+ else:
91
+ st.write("Player data file not found.")
92
  def main():
93
  st.set_page_config(page_title="Player Cards and Monsters")
94
  st.title("Player Cards and Monsters")