awacke1 commited on
Commit
85ae7ed
ยท
1 Parent(s): 8e4c37b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import plotly.express as px
3
+ import pandas as pd
4
+ import numpy as np
5
+ import base64
6
+
7
+ def generate_values(n):
8
+ return {"HealthPoints": np.random.randint(50, 100, size=n),
9
+ "Coins": np.random.randint(10, 50, size=n)}
10
+
11
+ def app():
12
+ st.title("Game Mechanics Treemap Chart")
13
+ st.write("This app displays a Treemap chart of game mechanics.")
14
+
15
+ n = len(game_mechanics := ["Action Queue โฑ๏ธ", "Action Retrieval ๐Ÿ”",
16
+ "Campaign / Battle Card Driven ๐Ÿ—ƒ๏ธ", "Card Play Conflict Resolution ๐Ÿ’ณ๐Ÿค",
17
+ "Communication Limits ๐Ÿ™Š", "Cooperative Game ๐Ÿค๐Ÿ‘ฅ", "Critical Hits and Failures ๐Ÿ’ฅ๐Ÿ’”",
18
+ "Deck Construction ๐ŸŽด๐Ÿ› ๏ธ", "Grid Movement ๐Ÿ—บ๏ธ", "Hand Management ๐Ÿ–๏ธ๐Ÿ“Š",
19
+ "Hexagon Grid ๐Ÿ”ณ", "Legacy Game ๐ŸŽ“๐ŸŽฎ", "Line of Sight ๐Ÿ‘€", "Modular Board ๐Ÿงฉ",
20
+ "Once-Per-Game Abilities ๐ŸŒŸ", "Role Playing ๐ŸŽญ", "Scenario / Mission / Campaign Game ๐ŸŽฏ",
21
+ "Simultaneous Action Selection ๐Ÿคœ๐Ÿค›", "Solo / Solitaire Game ๐Ÿ•บ", "Storytelling ๐Ÿ“–",
22
+ "Variable Player Powers ๐Ÿฆธโ€โ™‚๏ธ๐Ÿฆนโ€โ™€๏ธ"])
23
+
24
+ values = generate_values(n)
25
+ data = pd.DataFrame({"category": ["Category 1"] * n, "mechanic": game_mechanics,
26
+ "value": list(values.values()), "HealthPoints": values["HealthPoints"],
27
+ "Coins": values["Coins"], "description": ["Description"] * n})
28
+ data["value"] = data["value"].apply(lambda x: sum(x))
29
+
30
+ fig = px.treemap(data, path=["category", "mechanic"], values="value",
31
+ color="HealthPoints", hover_data=["Coins"])
32
+ st.plotly_chart(fig)
33
+
34
+ csv = data.to_csv(index=False)
35
+ b64 = base64.b64encode(csv.encode()).decode()
36
+ href = f'<a href="data:file/csv;base64,{b64}" download="game_mechanics.csv">Download CSV</a>'
37
+ st.markdown(href, unsafe_allow_html=True)
38
+
39
+ if __name__ == '__main__':
40
+ app()