cha0smagick
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,15 @@ concepts = ["The Reluctant Hero", "The Fallen Angel", "The Seeker", "The Scholar
|
|
15 |
|
16 |
# Funci贸n para generar un personaje
|
17 |
def generate_character():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
character = {
|
19 |
"Name": f"{random.choice(first_names)} {random.choice(last_names)}",
|
20 |
"Nature": random.choice(natures),
|
@@ -104,11 +113,24 @@ def generate_character():
|
|
104 |
"Status": random.randint(1, 5),
|
105 |
},
|
106 |
"Other Traits": {
|
107 |
-
"Quirks":
|
108 |
}
|
109 |
}
|
110 |
return character
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
# Funci贸n para generar un background de personaje basado en sus atributos
|
113 |
def generate_background():
|
114 |
backgrounds = [
|
@@ -121,27 +143,6 @@ def generate_background():
|
|
121 |
]
|
122 |
return random.choice(backgrounds)
|
123 |
|
124 |
-
# Funci贸n para generar una descripci贸n basada en las caracter铆sticas del personaje
|
125 |
-
def generate_description():
|
126 |
-
return (f"{random.choice(['A', 'An'])} {random.choice(natures)} {random.choice(concepts)} who is "
|
127 |
-
f"{random.choice(demeanors)} and {random.choice(essences)}. They are affiliated with a {random.choice(affiliations)} "
|
128 |
-
f"and belong to the {random.choice(sects)} sect.")
|
129 |
-
|
130 |
-
# Funci贸n para generar quirk aleatorio
|
131 |
-
def generate_random_quirk():
|
132 |
-
quirks = [
|
133 |
-
"Always speaks in riddles.",
|
134 |
-
"Has a collection of odd trinkets.",
|
135 |
-
"Can't resist a good challenge.",
|
136 |
-
"Often loses track of time.",
|
137 |
-
"Has an unusual laugh.",
|
138 |
-
"Believes in omens and signs.",
|
139 |
-
"Tends to hum while working.",
|
140 |
-
"Is fascinated by insects.",
|
141 |
-
"Enjoys making up stories about people."
|
142 |
-
]
|
143 |
-
return random.choice(quirks)
|
144 |
-
|
145 |
# Inicializar la aplicaci贸n
|
146 |
st.title("Character Creator for MAGE")
|
147 |
|
@@ -157,7 +158,7 @@ if st.session_state.character_sheet:
|
|
157 |
st.subheader("Character Sheet")
|
158 |
st.write(character_sheet)
|
159 |
|
160 |
-
def
|
161 |
html = f"""
|
162 |
<html>
|
163 |
<head>
|
@@ -238,19 +239,15 @@ if st.session_state.character_sheet:
|
|
238 |
</table>
|
239 |
|
240 |
<h2>Other Traits</h2>
|
241 |
-
<
|
242 |
-
<tr><th>Trait</th><th>Value</th></tr>
|
243 |
-
<tr><td>Quirk</td><td>{character_sheet["Other Traits"]["Quirks"]}</td></tr>
|
244 |
-
</table>
|
245 |
</body>
|
246 |
</html>
|
247 |
"""
|
248 |
-
|
249 |
-
return pdf_bytes
|
250 |
|
251 |
-
# Bot贸n para descargar el
|
252 |
-
if st.button("Download Character Sheet as
|
253 |
-
|
254 |
-
b64 = base64.b64encode(
|
255 |
-
href = f'<a href="data:
|
256 |
st.markdown(href, unsafe_allow_html=True)
|
|
|
15 |
|
16 |
# Funci贸n para generar un personaje
|
17 |
def generate_character():
|
18 |
+
quirks = [
|
19 |
+
"Has a peculiar laugh that echoes in the quiet.",
|
20 |
+
"Collects unusual trinkets from every place visited.",
|
21 |
+
"Always wears mismatched socks as a personal statement.",
|
22 |
+
"Speaks in riddles to confuse and amuse others.",
|
23 |
+
"Has an irrational fear of ducks.",
|
24 |
+
"Is convinced they can communicate with ghosts."
|
25 |
+
]
|
26 |
+
|
27 |
character = {
|
28 |
"Name": f"{random.choice(first_names)} {random.choice(last_names)}",
|
29 |
"Nature": random.choice(natures),
|
|
|
113 |
"Status": random.randint(1, 5),
|
114 |
},
|
115 |
"Other Traits": {
|
116 |
+
"Quirks": random.choice(quirks),
|
117 |
}
|
118 |
}
|
119 |
return character
|
120 |
|
121 |
+
# Funci贸n para generar una descripci贸n del personaje
|
122 |
+
def generate_description():
|
123 |
+
character_traits = [
|
124 |
+
"They are exceptionally intelligent, often outsmarting their opponents.",
|
125 |
+
"With a heart of a protector, they stand firm against injustice.",
|
126 |
+
"Their rebellious nature leads them to challenge authority at every turn.",
|
127 |
+
"A visionary at heart, they can see possibilities where others see obstacles.",
|
128 |
+
"They can charm their way out of most situations with their charisma.",
|
129 |
+
"Often reserved, they observe more than they speak, learning the secrets around them."
|
130 |
+
]
|
131 |
+
|
132 |
+
return random.choice(character_traits)
|
133 |
+
|
134 |
# Funci贸n para generar un background de personaje basado en sus atributos
|
135 |
def generate_background():
|
136 |
backgrounds = [
|
|
|
143 |
]
|
144 |
return random.choice(backgrounds)
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
# Inicializar la aplicaci贸n
|
147 |
st.title("Character Creator for MAGE")
|
148 |
|
|
|
158 |
st.subheader("Character Sheet")
|
159 |
st.write(character_sheet)
|
160 |
|
161 |
+
def download_html(character_sheet):
|
162 |
html = f"""
|
163 |
<html>
|
164 |
<head>
|
|
|
239 |
</table>
|
240 |
|
241 |
<h2>Other Traits</h2>
|
242 |
+
<p>Quirks: {character_sheet["Other Traits"]["Quirks"]}</p>
|
|
|
|
|
|
|
243 |
</body>
|
244 |
</html>
|
245 |
"""
|
246 |
+
return html
|
|
|
247 |
|
248 |
+
# Bot贸n para descargar el HTML
|
249 |
+
if st.button("Download Character Sheet as HTML"):
|
250 |
+
html = download_html(character_sheet)
|
251 |
+
b64 = base64.b64encode(html.encode()).decode()
|
252 |
+
href = f'<a href="data:text/html;base64,{b64}" download="character_sheet.html">Download your character sheet!</a>'
|
253 |
st.markdown(href, unsafe_allow_html=True)
|