Spaces:
Configuration error
Configuration error
Upload stratego\web\components\status_panel.py with huggingface_hub
Browse files
stratego//web//components//status_panel.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Game status panel component - Beautiful stats display"""
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import time
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def render_status_panel(game_controller):
|
| 7 |
+
"""Display game status info with beautiful styling"""
|
| 8 |
+
if not game_controller:
|
| 9 |
+
return
|
| 10 |
+
|
| 11 |
+
st.markdown("""
|
| 12 |
+
<style>
|
| 13 |
+
.status-card {
|
| 14 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 15 |
+
padding: 20px;
|
| 16 |
+
border-radius: 10px;
|
| 17 |
+
color: white;
|
| 18 |
+
margin: 10px 0;
|
| 19 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
| 20 |
+
}
|
| 21 |
+
.status-title {
|
| 22 |
+
font-size: 18px;
|
| 23 |
+
font-weight: bold;
|
| 24 |
+
margin-bottom: 10px;
|
| 25 |
+
}
|
| 26 |
+
.turn-info {
|
| 27 |
+
background: rgba(255,255,255,0.1);
|
| 28 |
+
padding: 10px;
|
| 29 |
+
border-radius: 5px;
|
| 30 |
+
margin: 10px 0;
|
| 31 |
+
}
|
| 32 |
+
.turn-number {
|
| 33 |
+
font-size: 24px;
|
| 34 |
+
font-weight: bold;
|
| 35 |
+
}
|
| 36 |
+
</style>
|
| 37 |
+
""", unsafe_allow_html=True)
|
| 38 |
+
|
| 39 |
+
with st.container(border=True):
|
| 40 |
+
# Turn indicator with emoji
|
| 41 |
+
if game_controller.is_human_turn():
|
| 42 |
+
st.success("π― YOUR TURN - Make a Move!")
|
| 43 |
+
emoji = "π€"
|
| 44 |
+
player_text = "You"
|
| 45 |
+
elif game_controller.is_ai_turn():
|
| 46 |
+
st.info("π€ AI IS THINKING...")
|
| 47 |
+
emoji = "π€"
|
| 48 |
+
player_text = "AI"
|
| 49 |
+
else:
|
| 50 |
+
st.warning("β οΈ Game state unclear")
|
| 51 |
+
emoji = "β"
|
| 52 |
+
player_text = "Unknown"
|
| 53 |
+
|
| 54 |
+
# Game statistics
|
| 55 |
+
col1, col2, col3 = st.columns(3)
|
| 56 |
+
|
| 57 |
+
with col1:
|
| 58 |
+
st.metric(
|
| 59 |
+
"βοΈ Total Moves",
|
| 60 |
+
game_controller.get_turn_count(),
|
| 61 |
+
help="Total number of moves played by both players"
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
with col2:
|
| 65 |
+
st.metric(
|
| 66 |
+
"π€ Your Moves",
|
| 67 |
+
len(game_controller.move_history[0]),
|
| 68 |
+
help="Number of moves you have made"
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
with col3:
|
| 72 |
+
st.metric(
|
| 73 |
+
"π€ AI Moves",
|
| 74 |
+
len(game_controller.move_history[1]),
|
| 75 |
+
help="Number of moves AI has made"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
# Game status
|
| 79 |
+
st.divider()
|
| 80 |
+
|
| 81 |
+
if game_controller.game_done:
|
| 82 |
+
st.error(f"π GAME ENDED")
|
| 83 |
+
st.write(f"**Result:** {game_controller.game_info.get('result', 'Unknown')}")
|
| 84 |
+
else:
|
| 85 |
+
st.success("β
Game Active")
|
| 86 |
+
st.caption(f"Current Player: {emoji} {player_text}")
|