elkay frontend game xp
Browse files- phase/Student_view/game.py +8 -22
phase/Student_view/game.py
CHANGED
|
@@ -270,24 +270,13 @@ def show_games():
|
|
| 270 |
st.session_state.xp = total_xp
|
| 271 |
st.session_state.streak = int(stats.get("streak", 0))
|
| 272 |
|
| 273 |
-
#
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
level = max(1, total_xp // base + 1)
|
| 281 |
-
start = (level - 1) * base
|
| 282 |
-
into = total_xp - start
|
| 283 |
-
need = base
|
| 284 |
-
if into == need:
|
| 285 |
-
level += 1
|
| 286 |
-
into = 0
|
| 287 |
-
|
| 288 |
-
into = int(max(0, into))
|
| 289 |
-
need = int(max(1, need))
|
| 290 |
-
progress_pct = min(100, int(round((into / need) * 100)))
|
| 291 |
|
| 292 |
st.write(f"Level {level} Experience Points")
|
| 293 |
st.markdown(f"""
|
|
@@ -297,15 +286,12 @@ def show_games():
|
|
| 297 |
background:linear-gradient(135deg,#22c55e,#059669);
|
| 298 |
height:24px;border-radius:10px;text-align:right;
|
| 299 |
color:white;font-weight:bold;padding-right:8px;line-height:24px;">
|
| 300 |
-
{
|
| 301 |
</div>
|
| 302 |
</div>
|
| 303 |
<div style="font-size:12px;color:#6b7280;margin-top:6px;">Total XP: {total_xp:,}</div>
|
| 304 |
""", unsafe_allow_html=True)
|
| 305 |
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
st.markdown("---")
|
| 310 |
|
| 311 |
# Game list
|
|
|
|
| 270 |
st.session_state.xp = total_xp
|
| 271 |
st.session_state.streak = int(stats.get("streak", 0))
|
| 272 |
|
| 273 |
+
# Show progress as TOTAL XP toward the NEXT threshold
|
| 274 |
+
base = 500
|
| 275 |
+
# keep the server's level if it is sane, otherwise recompute
|
| 276 |
+
level = level if level >= 1 else max(1, total_xp // base + 1)
|
| 277 |
+
|
| 278 |
+
cap = level * base # Level 1 -> 500, Level 2 -> 1000, etc.
|
| 279 |
+
progress_pct = min(100, int(round((total_xp / cap) * 100)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
st.write(f"Level {level} Experience Points")
|
| 282 |
st.markdown(f"""
|
|
|
|
| 286 |
background:linear-gradient(135deg,#22c55e,#059669);
|
| 287 |
height:24px;border-radius:10px;text-align:right;
|
| 288 |
color:white;font-weight:bold;padding-right:8px;line-height:24px;">
|
| 289 |
+
{total_xp:,} / {cap:,} XP
|
| 290 |
</div>
|
| 291 |
</div>
|
| 292 |
<div style="font-size:12px;color:#6b7280;margin-top:6px;">Total XP: {total_xp:,}</div>
|
| 293 |
""", unsafe_allow_html=True)
|
| 294 |
|
|
|
|
|
|
|
|
|
|
| 295 |
st.markdown("---")
|
| 296 |
|
| 297 |
# Game list
|