File size: 2,128 Bytes
402fd67
 
455480a
 
402fd67
455480a
c646f73
 
 
 
 
 
 
455480a
 
4ea296a
 
 
455480a
402fd67
 
 
455480a
 
402fd67
455480a
4ea296a
 
455480a
4ea296a
3f4338d
 
 
 
4ea296a
3f4338d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ea296a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import streamlit as st
import plotly.express as px
import pandas as pd
import numpy as np

# Define the list of game mechanics
game_mechanics = ["Action Queue โฑ๏ธ", "Action Retrieval ๐Ÿ”", "Campaign / Battle Card Driven ๐Ÿ—ƒ๏ธ",
"Card Play Conflict Resolution ๐Ÿ’ณ๐Ÿค", "Communication Limits ๐Ÿ™Š",
"Cooperative Game ๐Ÿค๐Ÿ‘ฅ", "Critical Hits and Failures ๐Ÿ’ฅ๐Ÿ’”", "Deck Construction ๐ŸŽด๐Ÿ› ๏ธ",
"Grid Movement ๐Ÿ—บ๏ธ", "Hand Management ๐Ÿ–๏ธ๐Ÿ“Š", "Hexagon Grid ๐Ÿ”ณ", "Legacy Game ๐ŸŽ“๐ŸŽฎ",
"Line of Sight ๐Ÿ‘€", "Modular Board ๐Ÿงฉ", "Once-Per-Game Abilities ๐ŸŒŸ", "Role Playing ๐ŸŽญ",
"Scenario / Mission / Campaign Game ๐ŸŽฏ", "Simultaneous Action Selection ๐Ÿคœ๐Ÿค›",
"Solo / Solitaire Game ๐Ÿ•บ", "Storytelling ๐Ÿ“–", "Variable Player Powers ๐Ÿฆธโ€โ™‚๏ธ๐Ÿฆนโ€โ™€๏ธ"]

# Define a function to generate random values for each game mechanic
def generate_values(n):
    health_points = np.random.randint(50, 100, size=n)
    coins = np.random.randint(10, 50, size=n)
    return {"HealthPoints": health_points, "Coins": coins}

# Define the Streamlit app
def app():
    st.title("Game Mechanics Treemap Chart")
    st.write("This app displays a Treemap chart of game mechanics.")

    # Generate the data for the chart
    n = len(game_mechanics)
    values = generate_values(n)
    data = pd.DataFrame({
        "category": ["Category 1"] * n,
        "mechanic": game_mechanics,
        "value": list(values.values()),
        "HealthPoints": values["HealthPoints"],
        "Coins": values["Coins"],
        "description": ["Description"] * n
    })
    data["value"] = data["value"].apply(lambda x: sum(x))

    # Draw the chart
    fig = px.treemap(data, path=["category", "mechanic"], values="value",
                     color="HealthPoints", hover_data=["Coins"])
    st.plotly_chart(fig)

    # Display a download link for the data
    csv = data.to_csv(index=False)
    b64 = base64.b64encode(csv.encode()).decode()
    href = f'<a href="data:file/csv;base64,{b64}" download="game_mechanics.csv">Download CSV</a>'
    st.markdown(href, unsafe_allow_html=True)

if __name__ == '__main__':
    app()