Spaces:
Runtime error
Runtime error
Update backupapp.py
Browse files- backupapp.py +67 -52
backupapp.py
CHANGED
@@ -1,19 +1,33 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
|
|
|
|
17 |
icons = ['πͺ', 'π', 'π€', 'π', 'π§ββοΈ', 'πΊοΈ', 'βοΈ', 'π€', 'π¦ ', 'π']
|
18 |
|
19 |
# Main code
|
@@ -24,48 +38,49 @@ for i, (game, icon) in enumerate(zip(games, icons)):
|
|
24 |
|
25 |
# Expanders for each game to outline map rules or strategies
|
26 |
with st.expander(f"See Map Building & Gamification Strategy for {game}"):
|
|
|
|
|
27 |
|
28 |
if game == 'Terraforming Mars':
|
29 |
-
|
30 |
-
|
31 |
-
1. π± Opt for plant-heavy areas
|
32 |
-
2. π§ Prioritize water tiles
|
33 |
-
3. π Position factories near energy resources
|
34 |
-
4. π Leverage volcanic areas
|
35 |
-
5. π Control key global parameters
|
36 |
-
6. π‘ Plan your energy grid
|
37 |
-
7. π€οΈ Connect your colonies
|
38 |
-
8. π‘οΈ Master temperature control
|
39 |
-
9. π― Aim for synergies
|
40 |
-
10. π Upgrade spaceports for max mobility
|
41 |
-
""")
|
42 |
|
43 |
elif game == 'Twilight Imperium (Fourth Edition)':
|
44 |
-
|
45 |
-
|
46 |
-
1. π Position fleets in strategic nebulas
|
47 |
-
2. π° Fortify chokepoints
|
48 |
-
3. βοΈ Balance resources among systems
|
49 |
-
4. π Establish effective trade routes
|
50 |
-
5. π‘οΈ Use PDS systems wisely
|
51 |
-
6. π Be cautious around wormholes
|
52 |
-
7. π Prioritize Mecatol Rex
|
53 |
-
8. π Use moons for surprise attacks
|
54 |
-
9. π οΈ Optimize unit upgrades
|
55 |
-
10. π€ Forge strategic alliances
|
56 |
-
""")
|
57 |
|
58 |
elif game == 'Scythe':
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Function to generate HTML with textarea
|
4 |
+
def generate_html_with_textarea(text_to_speak):
|
5 |
+
return f'''
|
6 |
+
<!DOCTYPE html>
|
7 |
+
<html>
|
8 |
+
<head>
|
9 |
+
<title>Read It Aloud</title>
|
10 |
+
<script type="text/javascript">
|
11 |
+
function readAloud() {{
|
12 |
+
const text = document.getElementById("textArea").value;
|
13 |
+
const speech = new SpeechSynthesisUtterance(text);
|
14 |
+
window.speechSynthesis.speak(speech);
|
15 |
+
}}
|
16 |
+
</script>
|
17 |
+
</head>
|
18 |
+
<body>
|
19 |
+
<h1>π Read It Aloud</h1>
|
20 |
+
<textarea id="textArea" rows="10" cols="80">
|
21 |
+
{text_to_speak}
|
22 |
+
</textarea>
|
23 |
+
<br>
|
24 |
+
<button onclick="readAloud()">π Read Aloud</button>
|
25 |
+
</body>
|
26 |
+
</html>
|
27 |
+
'''
|
28 |
|
29 |
+
# Game list and associated icons
|
30 |
+
games = ['Terraforming Mars', 'Twilight Imperium (Fourth Edition)', 'Scythe', 'Eclipse', 'Small World', 'Risk Legacy', 'Axis & Allies', 'Diplomacy', 'Pandemic Legacy: Season 1', 'Brass: Birmingham']
|
31 |
icons = ['πͺ', 'π', 'π€', 'π', 'π§ββοΈ', 'πΊοΈ', 'βοΈ', 'π€', 'π¦ ', 'π']
|
32 |
|
33 |
# Main code
|
|
|
38 |
|
39 |
# Expanders for each game to outline map rules or strategies
|
40 |
with st.expander(f"See Map Building & Gamification Strategy for {game}"):
|
41 |
+
# Defining text for each game's map strategy to use as a variable
|
42 |
+
text_to_speak = ""
|
43 |
|
44 |
if game == 'Terraforming Mars':
|
45 |
+
text_to_speak = "πͺπ‘ **Terraforming Mars** \n1οΈβ£ π±π§ Opt for plant-heavy and water tiles \n2οΈβ£ ππ Position factories near volcanic areas \n3οΈβ£ ππ‘ Control key parameters and energy grid \n4οΈβ£ π€οΈπ‘οΈ Connect colonies and temperature control \n5οΈβ£ ππ― Upgrade spaceports and aim for synergies."
|
46 |
+
st.markdown(text_to_speak)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
elif game == 'Twilight Imperium (Fourth Edition)':
|
49 |
+
text_to_speak = "ππ **Twilight Imperium** \n1οΈβ£ πβοΈ Position fleets in strategic nebulas and balance resources \n2οΈβ£ π°π‘οΈ Fortify chokepoints and use PDS systems \n3οΈβ£ ππ Effective trade routes and wormhole caution \n4οΈβ£ ππ Prioritize Mecatol Rex and moon attacks \n5οΈβ£ π οΈπ€ Optimize unit upgrades and forge alliances."
|
50 |
+
st.markdown(text_to_speak)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
elif game == 'Scythe':
|
53 |
+
text_to_speak = "π€ποΈ **Scythe** \n1οΈβ£ ποΈπ οΈ Choose starting positions and factory cards \n2οΈβ£ πΊοΈπ Be aware of neighbors and control rivers \n3οΈβ£ ππ‘οΈ Maximize resource buildings and backdoor defense \n4οΈβ£ π―πΎ Focus objectives and manage food \n5οΈβ£ π²π Play probabilities and hunt treasures."
|
54 |
+
st.markdown(text_to_speak)
|
55 |
+
|
56 |
+
elif game == 'Eclipse':
|
57 |
+
text_to_speak = "ππ **Eclipse** \n1οΈβ£ ππ Control sectors and central hexes \n2οΈβ£ πΈπ‘οΈ Build formidable fleets and defenses \n3οΈβ£ ππ Prioritize production and research \n4οΈβ£ π€π Trade and diplomacy \n5οΈβ£ ππ Wormhole travel and expansion speed."
|
58 |
+
st.markdown(text_to_speak)
|
59 |
+
|
60 |
+
elif game == 'Small World':
|
61 |
+
text_to_speak = "π§ββοΈπ **Small World** \n1οΈβ£ πΊοΈπ Choose realms and races wisely \n2οΈβ£ ππ‘οΈ Exploit powers and defend territories \n3οΈβ£ ππ Collect victory coins and treasures \n4οΈβ£ π€π Forge short alliances and occupy mountains \n5οΈβ£ ππ° Know when to decline and occupy forts."
|
62 |
+
st.markdown(text_to_speak)
|
63 |
+
|
64 |
+
elif game == 'Risk Legacy':
|
65 |
+
text_to_speak = "πΊοΈβοΈ **Risk Legacy** \n1οΈβ£ πΊοΈβοΈ Control continents and aggressive expansion \n2οΈβ£ π‘οΈπ Fortify borders and use fortresses \n3οΈβ£ ππ Complete missions and airfields \n4οΈβ£ ππ₯ Collect victory points and scorched earth \n5οΈβ£ π€π Alliances and betrayal."
|
66 |
+
st.markdown(text_to_speak)
|
67 |
+
|
68 |
+
elif game == 'Axis & Allies':
|
69 |
+
text_to_speak = "βοΈπ **Axis & Allies** \n1οΈβ£ βοΈπ Strategic frontlines and global dominance \n2οΈβ£ ππ Resource management and economy \n3οΈβ£ π‘οΈπ’ Naval blockades and fortress defenses \n4οΈβ£ ποΈπ― Focused objectives and key battles \n5οΈβ£ π€π₯ Alliances and surprise attacks."
|
70 |
+
st.markdown(text_to_speak)
|
71 |
+
|
72 |
+
elif game == 'Diplomacy':
|
73 |
+
text_to_speak = "π€π **Diplomacy** \n1οΈβ£ π€π Negotiation and written orders \n2οΈβ£ πΊοΈπ‘οΈ Strategic positioning and defenses \n3οΈβ£ π’β Naval forces and chokepoints \n4οΈβ£ π°π Territory control and key regions \n5οΈβ£ ππ Timing and deception."
|
74 |
+
st.markdown(text_to_speak)
|
75 |
+
|
76 |
+
elif game == 'Pandemic Legacy: Season 1':
|
77 |
+
text_to_speak = "π¦ π **Pandemic Legacy** \n1οΈβ£ π¦ π¬ Cure research and outbreak control \n2οΈβ£ ππ Global movement and airlifts \n3οΈβ£ π₯π‘οΈ Build research stations and quarantine \n4οΈβ£ ππ― Complete objectives and bonus cards \n5οΈβ£ π€π Teamwork and role synergy."
|
78 |
+
st.markdown(text_to_speak)
|
79 |
+
|
80 |
+
elif game == 'Brass: Birmingham':
|
81 |
+
text_to_speak = "ππ€οΈ **Brass Birmingham** \n1οΈβ£ ππ€οΈ Industry and canal routes \n2οΈβ£ ππΊ Economic management and beer supply \n3οΈβ£ π οΈπΊοΈ Optimize developments and map control \n4οΈβ£ π€π‘ Partnerships and market strategy \n5οΈβ£ ππ Railroads and victory points."
|
82 |
+
st.markdown(text_to_speak)
|
83 |
+
|
84 |
+
# Button to read the strategies aloud
|
85 |
+
if st.button(f"π Read {game}'s Strategies Aloud"):
|
86 |
+
st.markdown(generate_html_with_textarea(text_to_speak), unsafe_allow_html=True)
|