Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -186,7 +186,8 @@ def main():
|
|
186 |
st.markdown("## Choose Your Cat Rider:")
|
187 |
cols = st.columns(len(CAT_RIDERS))
|
188 |
for i, rider in enumerate(CAT_RIDERS):
|
189 |
-
|
|
|
190 |
st.session_state.game_state['cat_rider'] = rider
|
191 |
st.session_state.game_state['rider_skill'] = rider['skill']
|
192 |
|
@@ -195,7 +196,8 @@ def main():
|
|
195 |
st.markdown("## Select Your Riding Gear:")
|
196 |
cols = st.columns(len(RIDING_GEAR))
|
197 |
for i, gear in enumerate(RIDING_GEAR):
|
198 |
-
|
|
|
199 |
st.session_state.game_state['riding_gear'] = gear
|
200 |
st.session_state.game_state['gear_strength'] = gear['strength']
|
201 |
|
@@ -210,7 +212,8 @@ def main():
|
|
210 |
|
211 |
cols = st.columns(3)
|
212 |
for i, action in enumerate(actions):
|
213 |
-
|
|
|
214 |
outcome, success_chance = evaluate_action(situation, action, st.session_state.game_state['gear_strength'], st.session_state.game_state['rider_skill'], st.session_state.game_state['history'])
|
215 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
216 |
|
@@ -269,444 +272,3 @@ def main():
|
|
269 |
if __name__ == "__main__":
|
270 |
main()
|
271 |
|
272 |
-
|
273 |
-
|
274 |
-
import streamlit as st
|
275 |
-
import pandas as pd
|
276 |
-
import plotly.express as px
|
277 |
-
import random
|
278 |
-
import uuid
|
279 |
-
from datetime import datetime
|
280 |
-
from streamlit_flow import streamlit_flow
|
281 |
-
from streamlit_flow.elements import StreamlitFlowNode, StreamlitFlowEdge
|
282 |
-
from streamlit_flow.layouts import TreeLayout
|
283 |
-
|
284 |
-
# 🐱 Cat Rider and Gear Data
|
285 |
-
CAT_RIDERS = [
|
286 |
-
{"name": "Whiskers", "type": "Speed", "emoji": "🐾", "strength": 3, "skill": 7},
|
287 |
-
{"name": "Fluffy", "type": "Bravery", "emoji": "🦁", "strength": 5, "skill": 5},
|
288 |
-
{"name": "Midnight", "type": "Stealth", "emoji": "🌑", "strength": 4, "skill": 6},
|
289 |
-
{"name": "Bella", "type": "Charm", "emoji": "😺", "strength": 2, "skill": 8}
|
290 |
-
]
|
291 |
-
|
292 |
-
RIDING_GEAR = [
|
293 |
-
{"name": "Feathered Boots", "type": "Agility", "strength": 2},
|
294 |
-
{"name": "Golden Armor", "type": "Defense", "strength": 4},
|
295 |
-
{"name": "Magic Whisker Wand", "type": "Magic", "strength": 3},
|
296 |
-
{"name": "Sleek Shadow Cape", "type": "Stealth", "strength": 1}
|
297 |
-
]
|
298 |
-
|
299 |
-
# 🌍 Game World Data - SITUATIONS and ACTIONS expanded with humorous elements
|
300 |
-
SITUATIONS = [
|
301 |
-
{
|
302 |
-
"id": "feline_escape",
|
303 |
-
"name": "The Great Feline Escape",
|
304 |
-
"description": "Your cat rider is trapped in an old mansion, which is about to be demolished. Using agility, wit, and bravery, orchestrate the perfect escape before the walls crumble! 🏚️",
|
305 |
-
"emoji": "🚪",
|
306 |
-
"type": "escape"
|
307 |
-
},
|
308 |
-
{
|
309 |
-
"id": "lost_temple",
|
310 |
-
"name": "The Treasure of the Lost Temple",
|
311 |
-
"description": "On a quest to retrieve an ancient artifact, your cat rider must navigate through a labyrinth filled with traps and guardian spirits. Don't let the spooky ghosts get you! 👻",
|
312 |
-
"emoji": "🏛️",
|
313 |
-
"type": "exploration"
|
314 |
-
},
|
315 |
-
{
|
316 |
-
"id": "royal_tournament",
|
317 |
-
"name": "The Royal Tournament",
|
318 |
-
"description": "Compete in a grand tournament where the finest cat riders showcase their skills and bravery to earn the title of the Royal Rider. Be prepared to face noble feline adversaries! 🐱",
|
319 |
-
"emoji": "👑",
|
320 |
-
"type": "competition"
|
321 |
-
},
|
322 |
-
{
|
323 |
-
"id": "cheese_heist",
|
324 |
-
"name": "The Great Cheese Heist",
|
325 |
-
"description": "Your cat rider must sneak into the royal pantry to steal the legendary Cheese of Destiny. But beware – the palace mice are guarding it! 🧀",
|
326 |
-
"emoji": "🧀",
|
327 |
-
"type": "heist"
|
328 |
-
},
|
329 |
-
{
|
330 |
-
"id": "sky_race",
|
331 |
-
"name": "The Sky Race",
|
332 |
-
"description": "Compete in the annual Sky Race where your cat rider flies across the skies on a magical broomstick! Watch out for lightning storms and mischievous crows! 🌩️",
|
333 |
-
"emoji": "☁️",
|
334 |
-
"type": "competition"
|
335 |
-
},
|
336 |
-
{
|
337 |
-
"id": "purr_summit",
|
338 |
-
"name": "The Purr Summit",
|
339 |
-
"description": "Join a secret gathering of the most intellectual cats in the world. Engage in a battle of wits and wisdom to become the Grand Purr! 🧠",
|
340 |
-
"emoji": "📜",
|
341 |
-
"type": "debate"
|
342 |
-
},
|
343 |
-
{
|
344 |
-
"id": "cat_nap",
|
345 |
-
"name": "The Eternal Catnap",
|
346 |
-
"description": "You've entered a sacred temple where cats nap for centuries. Can you navigate the dream world and escape before you too are lulled into eternal slumber? 🛏️",
|
347 |
-
"emoji": "💤",
|
348 |
-
"type": "exploration"
|
349 |
-
},
|
350 |
-
{
|
351 |
-
"id": "feline_moon_mission",
|
352 |
-
"name": "The Feline Moon Mission",
|
353 |
-
"description": "Blast off into space! Your mission is to plant the flag of Catopia on the moon. But first, you must pilot your rocket through an asteroid field. 🚀",
|
354 |
-
"emoji": "🌕",
|
355 |
-
"type": "exploration"
|
356 |
-
},
|
357 |
-
{
|
358 |
-
"id": "pirate_cove",
|
359 |
-
"name": "The Pirate Cove",
|
360 |
-
"description": "Sail the high seas with your trusty crew of cats and uncover the secrets of the Pirate Cove. But beware of the treacherous Sea Dogs! 🏴☠️",
|
361 |
-
"emoji": "🏴☠️",
|
362 |
-
"type": "exploration"
|
363 |
-
},
|
364 |
-
{
|
365 |
-
"id": "cat_casino",
|
366 |
-
"name": "The Cat Casino",
|
367 |
-
"description": "Test your luck in the glamorous Cat Casino! Bet your whiskers on the tables and try not to lose it all. Meow is the time! 🎲",
|
368 |
-
"emoji": "🎰",
|
369 |
-
"type": "competition"
|
370 |
-
}
|
371 |
-
]
|
372 |
-
|
373 |
-
ACTIONS = [
|
374 |
-
{
|
375 |
-
"id": "stealth",
|
376 |
-
"name": "Use Stealth",
|
377 |
-
"description": "Sneak past obstacles or enemies without being detected. You're like a ninja in the shadows! 🐾",
|
378 |
-
"emoji": "🤫",
|
379 |
-
"type": "skill"
|
380 |
-
},
|
381 |
-
{
|
382 |
-
"id": "agility",
|
383 |
-
"name": "Showcase Agility",
|
384 |
-
"description": "Perform impressive acrobatic maneuvers to overcome challenges. Cats always land on their feet, right? 🏃",
|
385 |
-
"emoji": "🏃",
|
386 |
-
"type": "physical"
|
387 |
-
},
|
388 |
-
{
|
389 |
-
"id": "charm",
|
390 |
-
"name": "Charm Others",
|
391 |
-
"description": "Use your cat's natural charisma to win over allies or distract foes. Who could resist those cute eyes? 😻",
|
392 |
-
"emoji": "😻",
|
393 |
-
"type": "social"
|
394 |
-
},
|
395 |
-
{
|
396 |
-
"id": "resourcefulness",
|
397 |
-
"name": "Be Resourceful",
|
398 |
-
"description": "Utilize the environment or items in creative ways to solve problems. Think on your paws! 🧠",
|
399 |
-
"emoji": "🧠",
|
400 |
-
"type": "mental"
|
401 |
-
},
|
402 |
-
{
|
403 |
-
"id": "bravery",
|
404 |
-
"name": "Show Bravery",
|
405 |
-
"description": "Face dangers head-on with your feline courage. Not all heroes wear capes – some wear fur! 🦸♀️",
|
406 |
-
"emoji": "🦸♀️",
|
407 |
-
"type": "physical"
|
408 |
-
},
|
409 |
-
{
|
410 |
-
"id": "negotiation",
|
411 |
-
"name": "Negotiate",
|
412 |
-
"description": "Use diplomacy and clever negotiation to get out of a tight spot. Every cat has their price! 💼",
|
413 |
-
"emoji": "💼",
|
414 |
-
"type": "social"
|
415 |
-
},
|
416 |
-
{
|
417 |
-
"id": "precision",
|
418 |
-
"name": "Precision Attack",
|
419 |
-
"description": "Execute a perfectly timed attack to disable traps or defeat enemies. Purrfection in motion! 🎯",
|
420 |
-
"emoji": "🎯",
|
421 |
-
"type": "skill"
|
422 |
-
},
|
423 |
-
{
|
424 |
-
"id": "distraction",
|
425 |
-
"name": "Create a Distraction",
|
426 |
-
"description": "Use cunning tricks and diversions to draw attention away from your real goal. Look over there! 🪄",
|
427 |
-
"emoji": "🪄",
|
428 |
-
"type": "mental"
|
429 |
-
},
|
430 |
-
{
|
431 |
-
"id": "speed",
|
432 |
-
"name": "Sprint Away",
|
433 |
-
"description": "Run faster than you've ever run before to escape danger. Just like a cat fleeing a vacuum cleaner! 🏃♀️",
|
434 |
-
"emoji": "🏃♀️",
|
435 |
-
"type": "physical"
|
436 |
-
},
|
437 |
-
{
|
438 |
-
"id": "insight",
|
439 |
-
"name": "Use Insight",
|
440 |
-
"description": "Tap into ancient feline wisdom to solve puzzles and mysteries. A cat always knows! 🔮",
|
441 |
-
"emoji": "🔮",
|
442 |
-
"type": "mental"
|
443 |
-
}
|
444 |
-
]
|
445 |
-
|
446 |
-
# Expanded conclusions for outcomes - 10 items each for success and failure
|
447 |
-
SUCCESS_CONCLUSIONS = [
|
448 |
-
"Your swift paws led you to victory! 🎉",
|
449 |
-
"You pounced at the perfect moment! 🏆",
|
450 |
-
"The stars aligned for your cat rider! 🌟",
|
451 |
-
"You navigated the challenge like a true feline champion! 🐱",
|
452 |
-
"Victory is sweet, just like a bowl of fresh milk! 🥛",
|
453 |
-
"Your opponents are left in awe of your skills! 😺",
|
454 |
-
"You’ve earned the title of Cat Commander! 🏅",
|
455 |
-
"All the other cats are jealous of your agility! 🏃♂️",
|
456 |
-
"Your strategy was flawless, and the victory is yours! 🎖️",
|
457 |
-
"Your cat rider is now a legend in the feline world! 👑"
|
458 |
-
]
|
459 |
-
|
460 |
-
FAILURE_CONCLUSIONS = [
|
461 |
-
"You tried your best, but it just wasn’t enough. 😿",
|
462 |
-
"Maybe next time, kitty. Keep your tail up! 🐾",
|
463 |
-
"That didn’t go as planned. Time for a catnap to recover! 💤",
|
464 |
-
"Even the best cats have their off days. 😔",
|
465 |
-
"The challenge was too great this time. Better luck next time! 🍀",
|
466 |
-
"You might need more than nine lives to get through this. 🐈",
|
467 |
-
"The enemy was too clever for your plan. 🧠",
|
468 |
-
"You tripped over your own paws! 🐾",
|
469 |
-
"The cat gods were not in your favor today. 🙀",
|
470 |
-
"It’s okay, every cat has a learning curve. 📚"
|
471 |
-
]
|
472 |
-
|
473 |
-
# 🧠 Game Mechanics
|
474 |
-
def generate_situation():
|
475 |
-
return random.choice(SITUATIONS)
|
476 |
-
|
477 |
-
def generate_actions():
|
478 |
-
return random.sample(ACTIONS, min(3, len(ACTIONS)))
|
479 |
-
|
480 |
-
def evaluate_action(action, gear_strength, rider_skill, history):
|
481 |
-
base_success_chance = (gear_strength + rider_skill) / 2
|
482 |
-
if action['id'] in history:
|
483 |
-
success_chance = base_success_chance + (history[action['id']] * 2)
|
484 |
-
else:
|
485 |
-
success_chance = base_success_chance
|
486 |
-
outcome = random.randint(1, 100) <= success_chance
|
487 |
-
return outcome, success_chance
|
488 |
-
|
489 |
-
def generate_encounter_conclusion(situation, action, outcome):
|
490 |
-
if outcome:
|
491 |
-
return random.choice(SUCCESS_CONCLUSIONS)
|
492 |
-
else:
|
493 |
-
return random.choice(FAILURE_CONCLUSIONS)
|
494 |
-
|
495 |
-
# 🌳 Journey Visualization with Heterogeneous Graph Structure
|
496 |
-
def create_heterogeneous_graph(history_df):
|
497 |
-
nodes = []
|
498 |
-
edges = []
|
499 |
-
|
500 |
-
# Define node shapes based on situation and action types
|
501 |
-
situation_shapes = {
|
502 |
-
"escape": "diamond",
|
503 |
-
"exploration": "triangle",
|
504 |
-
"competition": "star"
|
505 |
-
}
|
506 |
-
action_shapes = {
|
507 |
-
"skill": "square",
|
508 |
-
"physical": "circle",
|
509 |
-
"social": "hexagon",
|
510 |
-
"mental": "octagon"
|
511 |
-
}
|
512 |
-
|
513 |
-
for index, row in history_df.iterrows():
|
514 |
-
situation_id = f"situation-{index}"
|
515 |
-
action_id = f"action-{index}"
|
516 |
-
conclusion_id = f"conclusion-{index}"
|
517 |
-
|
518 |
-
# Create situation node
|
519 |
-
situation_content = f"{row['situation_emoji']} {row['situation_name']}\n🕒 {row['timestamp']}"
|
520 |
-
situation_node = StreamlitFlowNode(situation_id, (0, 0), {'content': situation_content}, 'output', 'bottom', 'top', shape=situation_shapes.get(row['situation_type'], 'ellipse'))
|
521 |
-
nodes.append(situation_node)
|
522 |
-
|
523 |
-
# Create action node
|
524 |
-
action_content = f"{row['action_emoji']} {row['action_name']}\nOutcome: {'✅ Success' if row['outcome'] else '❌ Failure'}"
|
525 |
-
action_node = StreamlitFlowNode(action_id, (0, 0), {'content': action_content}, 'output', 'bottom', 'top', shape=action_shapes.get(row['action_type'], 'ellipse'))
|
526 |
-
nodes.append(action_node)
|
527 |
-
|
528 |
-
# Create conclusion node
|
529 |
-
conclusion_content = f"📜 {row['conclusion']}\n💪 Gear: {row['gear_strength']:.2f} | 🏋️ Skill: {row['rider_skill']:.2f}"
|
530 |
-
conclusion_node = StreamlitFlowNode(conclusion_id, (0, 0), {'content': conclusion_content}, 'output', 'bottom', 'top', shape='parallelogram')
|
531 |
-
nodes.append(conclusion_node)
|
532 |
-
|
533 |
-
# Create edges
|
534 |
-
edges.append(StreamlitFlowEdge(f"{situation_id}-{action_id}", situation_id, action_id, animated=True, dashed=False))
|
535 |
-
edges.append(StreamlitFlowEdge(f"{action_id}-{conclusion_id}", action_id, conclusion_id, animated=True, dashed=False))
|
536 |
-
|
537 |
-
# Create edge to previous conclusion if not the first node
|
538 |
-
if index > 0:
|
539 |
-
prev_conclusion_id = f"conclusion-{index-1}"
|
540 |
-
edges.append(StreamlitFlowEdge(f"{prev_conclusion_id}-{situation_id}", prev_conclusion_id, situation_id, animated=True, dashed=True))
|
541 |
-
|
542 |
-
return nodes, edges
|
543 |
-
|
544 |
-
# 📝 Markdown Preview
|
545 |
-
def create_markdown_preview(history_df):
|
546 |
-
markdown = "## 🌳 Journey Preview\n\n"
|
547 |
-
for index, row in history_df.iterrows():
|
548 |
-
indent = " " * (index * 3)
|
549 |
-
markdown += f"{indent}🌟 **{row['situation_name']}** ({row['situation_type']})\n"
|
550 |
-
markdown += f"{indent} ↪ {row['action_emoji']} {row['action_name']} ({row['action_type']}): "
|
551 |
-
markdown += "✅ Success\n" if row['outcome'] else "❌ Failure\n"
|
552 |
-
markdown += f"{indent} 📜 {row['conclusion']}\n"
|
553 |
-
markdown += f"{indent} 💪 Gear: {row['gear_strength']:.2f} | 🏋️ Skill: {row['rider_skill']:.2f}\n\n"
|
554 |
-
return markdown
|
555 |
-
|
556 |
-
# 🔄 Game State Management
|
557 |
-
def update_game_state(game_state, situation, action, outcome, timestamp):
|
558 |
-
conclusion = generate_encounter_conclusion(situation, action, outcome)
|
559 |
-
game_state = update_character_stats(game_state, outcome)
|
560 |
-
|
561 |
-
new_record = pd.DataFrame({
|
562 |
-
'user_id': [game_state['user_id']],
|
563 |
-
'timestamp': [timestamp],
|
564 |
-
'situation_id': [situation['id']],
|
565 |
-
'situation_name': [situation['name']],
|
566 |
-
'situation_emoji': [situation['emoji']],
|
567 |
-
'situation_type': [situation['type']],
|
568 |
-
'action_id': [action['id']],
|
569 |
-
'action_name': [action['name']],
|
570 |
-
'action_emoji': [action['emoji']],
|
571 |
-
'action_type': [action['type']],
|
572 |
-
'outcome': [outcome],
|
573 |
-
'conclusion': [conclusion],
|
574 |
-
'gear_strength': [game_state['gear_strength']],
|
575 |
-
'rider_skill': [game_state['rider_skill']],
|
576 |
-
'score': [game_state['score']]
|
577 |
-
})
|
578 |
-
game_state['history_df'] = pd.concat([game_state['history_df'], new_record], ignore_index=True)
|
579 |
-
|
580 |
-
if action['id'] in game_state['history']:
|
581 |
-
game_state['history'][action['id']] += 1 if outcome else -1
|
582 |
-
else:
|
583 |
-
game_state['history'][action['id']] = 1 if outcome else -1
|
584 |
-
|
585 |
-
return game_state
|
586 |
-
|
587 |
-
# 🔄 Update character stats based on the outcome
|
588 |
-
def update_character_stats(game_state, outcome):
|
589 |
-
if outcome:
|
590 |
-
game_state['gear_strength'] = min(10, game_state['gear_strength'] + random.uniform(0.1, 0.5))
|
591 |
-
game_state['rider_skill'] = min(10, game_state['rider_skill'] + random.uniform(0.1, 0.5))
|
592 |
-
return game_state
|
593 |
-
|
594 |
-
# 🎮 Main Game Application
|
595 |
-
def main():
|
596 |
-
st.title("🐱 Cat Rider 🏇")
|
597 |
-
|
598 |
-
# 📜 Game Rules
|
599 |
-
st.markdown("""
|
600 |
-
### 📜 Game Rules
|
601 |
-
| Step | Description |
|
602 |
-
|------|-------------|
|
603 |
-
| 1️⃣ | Choose your Cat Rider |
|
604 |
-
| 2️⃣ | Select your Riding Gear |
|
605 |
-
| 3️⃣ | Set off on an Adventure |
|
606 |
-
| 4️⃣ | Encounter Challenges and Make Decisions |
|
607 |
-
| 5️⃣ | Complete the Quest and Grow Stronger |
|
608 |
-
""")
|
609 |
-
|
610 |
-
# 🏁 Initialize game state
|
611 |
-
if 'game_state' not in st.session_state:
|
612 |
-
st.session_state.game_state = {
|
613 |
-
'user_id': str(uuid.uuid4()),
|
614 |
-
'score': 0,
|
615 |
-
'history': {},
|
616 |
-
'gear_strength': 0,
|
617 |
-
'rider_skill': 0,
|
618 |
-
'cat_rider': None,
|
619 |
-
'riding_gear': None,
|
620 |
-
'history_df': pd.DataFrame(columns=['user_id', 'timestamp', 'situation_id', 'situation_name', 'situation_emoji', 'situation_type', 'action_id', 'action_name', 'action_emoji', 'action_type', 'outcome', 'conclusion', 'gear_strength', 'rider_skill', 'score'])
|
621 |
-
}
|
622 |
-
|
623 |
-
# 🐱 Cat Rider Selection
|
624 |
-
if st.session_state.game_state['cat_rider'] is None:
|
625 |
-
st.markdown("## Choose Your Cat Rider:")
|
626 |
-
cols = st.columns(len(CAT_RIDERS))
|
627 |
-
for i, rider in enumerate(CAT_RIDERS):
|
628 |
-
if cols[i].button(f"{rider['emoji']} {rider['name']} ({rider['type']})"):
|
629 |
-
st.session_state.game_state['cat_rider'] = rider
|
630 |
-
st.session_state.game_state['rider_skill'] = rider['skill']
|
631 |
-
|
632 |
-
# 🏇 Riding Gear Selection
|
633 |
-
if st.session_state.game_state['riding_gear'] is None and st.session_state.game_state['cat_rider'] is not None:
|
634 |
-
st.markdown("## Select Your Riding Gear:")
|
635 |
-
cols = st.columns(len(RIDING_GEAR))
|
636 |
-
for i, gear in enumerate(RIDING_GEAR):
|
637 |
-
if cols[i].button(f"{gear['name']} ({gear['type']})"):
|
638 |
-
st.session_state.game_state['riding_gear'] = gear
|
639 |
-
st.session_state.game_state['gear_strength'] = gear['strength']
|
640 |
-
|
641 |
-
# 🎭 Game Loop
|
642 |
-
if st.session_state.game_state['cat_rider'] is not None and st.session_state.game_state['riding_gear'] is not None:
|
643 |
-
situation = generate_situation()
|
644 |
-
actions = generate_actions()
|
645 |
-
|
646 |
-
st.markdown(f"## {situation['emoji']} Current Situation: {situation['name']} ({situation['type']})")
|
647 |
-
st.markdown(situation['description'])
|
648 |
-
st.markdown("### 🎭 Choose your action:")
|
649 |
-
|
650 |
-
cols = st.columns(3)
|
651 |
-
for i, action in enumerate(actions):
|
652 |
-
if cols[i].button(f"{action['emoji']} {action['name']} ({action['type']})"):
|
653 |
-
outcome, success_chance = evaluate_action(action, st.session_state.game_state['gear_strength'], st.session_state.game_state['rider_skill'], st.session_state.game_state['history'])
|
654 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
655 |
-
|
656 |
-
st.markdown(f"You decided to: **{action['name']}** ({action['type']})")
|
657 |
-
st.markdown(action['description'])
|
658 |
-
st.markdown(f"**Outcome:** {'✅ Success!' if outcome else '❌ Failure.'}")
|
659 |
-
st.markdown(f"**Success Chance:** {success_chance:.2f}%")
|
660 |
-
|
661 |
-
if outcome:
|
662 |
-
st.session_state.game_state['score'] += 1
|
663 |
-
|
664 |
-
# 🔄 Update game state
|
665 |
-
st.session_state.game_state = update_game_state(
|
666 |
-
st.session_state.game_state,
|
667 |
-
situation,
|
668 |
-
action,
|
669 |
-
outcome,
|
670 |
-
timestamp
|
671 |
-
)
|
672 |
-
|
673 |
-
# Display conclusion
|
674 |
-
conclusion = st.session_state.game_state['history_df'].iloc[-1]['conclusion']
|
675 |
-
st.markdown(f"**Encounter Conclusion:** {conclusion}")
|
676 |
-
|
677 |
-
# Display updated stats
|
678 |
-
st.markdown(f"**Updated Stats:**")
|
679 |
-
st.markdown(f"💪 Gear Strength: {st.session_state.game_state['gear_strength']:.2f}")
|
680 |
-
st.markdown(f"🏋️ Rider Skill: {st.session_state.game_state['rider_skill']:.2f}")
|
681 |
-
|
682 |
-
# 📝 Display Markdown Preview
|
683 |
-
if not st.session_state.game_state['history_df'].empty:
|
684 |
-
st.markdown(create_markdown_preview(st.session_state.game_state['history_df']))
|
685 |
-
|
686 |
-
# 🌳 Display Heterogeneous Journey Graph
|
687 |
-
if not st.session_state.game_state['history_df'].empty:
|
688 |
-
st.markdown("## 🌳 Your Journey (Heterogeneous Graph)")
|
689 |
-
nodes, edges = create_heterogeneous_graph(st.session_state.game_state['history_df'])
|
690 |
-
try:
|
691 |
-
streamlit_flow('cat_rider_flow',
|
692 |
-
nodes,
|
693 |
-
edges,
|
694 |
-
layout=TreeLayout(direction='down'),
|
695 |
-
fit_view=True,
|
696 |
-
height=600)
|
697 |
-
except Exception as e:
|
698 |
-
st.error(f"An error occurred while rendering the journey graph: {str(e)}")
|
699 |
-
st.markdown("Please try refreshing the page if the graph doesn't appear.")
|
700 |
-
|
701 |
-
# 📊 Character Stats Visualization
|
702 |
-
data = {"Stat": ["Gear Strength 🛡️", "Rider Skill 🏇"],
|
703 |
-
"Value": [st.session_state.game_state['gear_strength'], st.session_state.game_state['rider_skill']]}
|
704 |
-
df = pd.DataFrame(data)
|
705 |
-
fig = px.bar(df, x='Stat', y='Value', title="Cat Rider Stats 📊")
|
706 |
-
st.plotly_chart(fig)
|
707 |
-
|
708 |
-
if __name__ == "__main__":
|
709 |
-
main()
|
710 |
-
|
711 |
-
|
712 |
-
|
|
|
186 |
st.markdown("## Choose Your Cat Rider:")
|
187 |
cols = st.columns(len(CAT_RIDERS))
|
188 |
for i, rider in enumerate(CAT_RIDERS):
|
189 |
+
# Adding unique key for each button
|
190 |
+
if cols[i].button(f"{rider['emoji']} {rider['name']} ({rider['type']})", key=f"rider_{i}"):
|
191 |
st.session_state.game_state['cat_rider'] = rider
|
192 |
st.session_state.game_state['rider_skill'] = rider['skill']
|
193 |
|
|
|
196 |
st.markdown("## Select Your Riding Gear:")
|
197 |
cols = st.columns(len(RIDING_GEAR))
|
198 |
for i, gear in enumerate(RIDING_GEAR):
|
199 |
+
# Adding unique key for each button
|
200 |
+
if cols[i].button(f"{gear['name']} ({gear['type']})", key=f"gear_{i}"):
|
201 |
st.session_state.game_state['riding_gear'] = gear
|
202 |
st.session_state.game_state['gear_strength'] = gear['strength']
|
203 |
|
|
|
212 |
|
213 |
cols = st.columns(3)
|
214 |
for i, action in enumerate(actions):
|
215 |
+
# Adding unique key for each button
|
216 |
+
if cols[i].button(f"{action['emoji']} {action['name']} ({action['type']})", key=f"action_{i}"):
|
217 |
outcome, success_chance = evaluate_action(situation, action, st.session_state.game_state['gear_strength'], st.session_state.game_state['rider_skill'], st.session_state.game_state['history'])
|
218 |
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
219 |
|
|
|
272 |
if __name__ == "__main__":
|
273 |
main()
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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