Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -86,9 +86,9 @@ FAILURE_CONCLUSIONS = [
|
|
86 |
]
|
87 |
|
88 |
# Function to save history to a markdown file
|
89 |
-
def save_history_to_file(history_df, user_id
|
90 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
91 |
-
filename = f"history_{user_id}_{
|
92 |
markdown = create_markdown_preview(history_df)
|
93 |
with open(filename, 'w', encoding='utf-8') as f:
|
94 |
f.write(markdown)
|
@@ -321,7 +321,8 @@ def main():
|
|
321 |
'history_df': pd.DataFrame(columns=['user_id', 'timestamp', 'situation_id', 'situation_name', 'situation_emoji', 'situation_type', 'attempt', 'action_id', 'action_name', 'action_emoji', 'action_type', 'outcome', 'conclusion', 'gear_strength', 'rider_skill', 'score']),
|
322 |
'current_situation': None,
|
323 |
'current_attempt': 1,
|
324 |
-
'actions': []
|
|
|
325 |
}
|
326 |
|
327 |
# Sidebar functionality
|
@@ -363,6 +364,8 @@ def main():
|
|
363 |
game_state['current_situation'] = generate_situation()
|
364 |
game_state['current_attempt'] = 1
|
365 |
game_state['succeeded'] = False
|
|
|
|
|
366 |
|
367 |
situation = game_state['current_situation']
|
368 |
st.markdown(f"## {situation['emoji']} Current Situation: {situation['name']} ({situation['type']})")
|
@@ -451,10 +454,12 @@ def main():
|
|
451 |
|
452 |
# Save history to file
|
453 |
if st.button("πΎ Save Game History"):
|
454 |
-
filename = save_history_to_file(game_state['history_df'], game_state['user_id']
|
455 |
st.success(f"History saved to {filename}")
|
|
|
|
|
456 |
|
457 |
-
# Provide download
|
458 |
st.sidebar.markdown("### π₯ Download Histories")
|
459 |
for history_file in history_files:
|
460 |
with open(history_file, 'r', encoding='utf-8') as f:
|
|
|
86 |
]
|
87 |
|
88 |
# Function to save history to a markdown file
|
89 |
+
def save_history_to_file(history_df, user_id):
|
90 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
91 |
+
filename = f"history_{user_id}_{timestamp}.md"
|
92 |
markdown = create_markdown_preview(history_df)
|
93 |
with open(filename, 'w', encoding='utf-8') as f:
|
94 |
f.write(markdown)
|
|
|
321 |
'history_df': pd.DataFrame(columns=['user_id', 'timestamp', 'situation_id', 'situation_name', 'situation_emoji', 'situation_type', 'attempt', 'action_id', 'action_name', 'action_emoji', 'action_type', 'outcome', 'conclusion', 'gear_strength', 'rider_skill', 'score']),
|
322 |
'current_situation': None,
|
323 |
'current_attempt': 1,
|
324 |
+
'actions': [],
|
325 |
+
'succeeded': False
|
326 |
}
|
327 |
|
328 |
# Sidebar functionality
|
|
|
364 |
game_state['current_situation'] = generate_situation()
|
365 |
game_state['current_attempt'] = 1
|
366 |
game_state['succeeded'] = False
|
367 |
+
# Clear actions for new situation
|
368 |
+
game_state['actions'] = []
|
369 |
|
370 |
situation = game_state['current_situation']
|
371 |
st.markdown(f"## {situation['emoji']} Current Situation: {situation['name']} ({situation['type']})")
|
|
|
454 |
|
455 |
# Save history to file
|
456 |
if st.button("πΎ Save Game History"):
|
457 |
+
filename = save_history_to_file(game_state['history_df'], game_state['user_id'])
|
458 |
st.success(f"History saved to {filename}")
|
459 |
+
# Update history files list
|
460 |
+
history_files = load_saved_histories()
|
461 |
|
462 |
+
# Provide download buttons for saved histories
|
463 |
st.sidebar.markdown("### π₯ Download Histories")
|
464 |
for history_file in history_files:
|
465 |
with open(history_file, 'r', encoding='utf-8') as f:
|