iisadia commited on
Commit
f2bf2f7
·
verified ·
1 Parent(s): 99f0042

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -33
app.py CHANGED
@@ -123,7 +123,7 @@ def inject_custom_css():
123
  transition: width 0.5s ease; }
124
  .question-count { color: #6C63FF; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; }
125
 
126
-
127
  /* Add these new styles for the info modal */
128
  .info-modal {
129
  position: fixed;
@@ -300,28 +300,13 @@ def show_techniques_modal():
300
 
301
  def main():
302
  inject_custom_css()
 
 
 
 
 
303
 
304
- # ===== NEW NICKNAME CODE =====
305
- if "player_name" not in st.session_state:
306
- st.markdown('<div class="title">KASOTI</div>', unsafe_allow_html=True)
307
- st.markdown('<div class="subtitle">AI-Powered Guessing Game Challenge</div>', unsafe_allow_html=True)
308
 
309
- with st.container():
310
- st.markdown("---")
311
- st.session_state.player_name = st.text_input(
312
- "🎮 Enter your nickname:",
313
- max_chars=15,
314
- placeholder="e.g. GameMaster"
315
- )
316
- if st.button("Start Game"):
317
- if st.session_state.player_name.strip():
318
- st.rerun()
319
- else:
320
- st.warning("Please enter a nickname!")
321
- st.markdown("---")
322
- return # Stops here until nickname is entered
323
- # ===== END NEW CODE =====
324
-
325
  if 'game_state' not in st.session_state:
326
  st.session_state.game_state = "start"
327
  st.session_state.questions = []
@@ -388,21 +373,25 @@ def main():
388
  elif st.session_state.game_state == "gameplay":
389
  with st.container():
390
  progress = (st.session_state.current_q + 1) / 20
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  st.markdown(f"""
392
  <div class="question-count">QUESTION {st.session_state.current_q + 1} OF 20</div>
393
  <div class="progress-bar">
394
  <div class="progress-fill" style="width: {progress * 100}%"></div>
395
  </div>
396
  """, unsafe_allow_html=True)
397
-
398
- # ===== NEW: Show player nickname =====
399
- st.sidebar.markdown(f"""
400
- ### Player Profile
401
- 👤 **{st.session_state.player_name}**
402
- 🎯 Category: {st.session_state.category.capitalize()}
403
- """)
404
- # ===== END NEW CODE =====
405
-
406
  current_question = st.session_state.questions[st.session_state.current_q]
407
  st.markdown(f'''
408
  <div class="question-box">
@@ -523,16 +512,14 @@ def main():
523
  )
524
  st.session_state.final_guess = final_guess.split("Final Guess:")[-1].strip()
525
  show_confetti()
526
- st.markdown(f'<div class="final-reveal">🎉 {st.session_state.player_name}, it\'s...</div>', unsafe_allow_html=True)
527
  time.sleep(1)
528
  st.markdown(f'<div class="final-reveal" style="font-size:3.5rem;color:#6C63FF;">{st.session_state.final_guess}</div>',
529
  unsafe_allow_html=True)
530
  st.markdown(f"<p style='text-align:center; color:#64748B;'>Guessed in {len(st.session_state.questions)} questions</p>",
531
  unsafe_allow_html=True)
532
  if st.button("Play Again", key="play_again"):
533
- player_name = st.session_state.player_name # Save name
534
  st.session_state.clear()
535
- st.session_state.player_name = player_name # Restore name
536
  st.experimental_rerun()
537
 
538
  if __name__ == "__main__":
 
123
  transition: width 0.5s ease; }
124
  .question-count { color: #6C63FF; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; }
125
 
126
+
127
  /* Add these new styles for the info modal */
128
  .info-modal {
129
  position: fixed;
 
300
 
301
  def main():
302
  inject_custom_css()
303
+ st.markdown('<div class="title">KASOTI</div>', unsafe_allow_html=True)
304
+ st.markdown('<div class="subtitle">AI-Powered Guessing Game Challenge</div>', unsafe_allow_html=True)
305
+
306
+ if st.button("ℹ️ Project Techniques & Limitations", key="info_btn"):
307
+ show_techniques_modal()
308
 
 
 
 
 
309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  if 'game_state' not in st.session_state:
311
  st.session_state.game_state = "start"
312
  st.session_state.questions = []
 
373
  elif st.session_state.game_state == "gameplay":
374
  with st.container():
375
  progress = (st.session_state.current_q + 1) / 20
376
+ questions_left = 20 - (st.session_state.current_q + 1) # Add this line
377
+
378
+ # ===== DYNAMIC BACKGROUND =====
379
+ bg_color = "#FFEBEE" if questions_left < 5 else "#E8F5E9"
380
+ st.markdown(f"""
381
+ <style>
382
+ .stApp {{
383
+ background: {bg_color};
384
+ transition: background 0.5s ease;
385
+ }}
386
+ </style>
387
+ """, unsafe_allow_html=True)
388
+ # ===== END BACKGROUND =====
389
  st.markdown(f"""
390
  <div class="question-count">QUESTION {st.session_state.current_q + 1} OF 20</div>
391
  <div class="progress-bar">
392
  <div class="progress-fill" style="width: {progress * 100}%"></div>
393
  </div>
394
  """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
395
  current_question = st.session_state.questions[st.session_state.current_q]
396
  st.markdown(f'''
397
  <div class="question-box">
 
512
  )
513
  st.session_state.final_guess = final_guess.split("Final Guess:")[-1].strip()
514
  show_confetti()
515
+ st.markdown(f'<div class="final-reveal">🎉 It\'s...</div>', unsafe_allow_html=True)
516
  time.sleep(1)
517
  st.markdown(f'<div class="final-reveal" style="font-size:3.5rem;color:#6C63FF;">{st.session_state.final_guess}</div>',
518
  unsafe_allow_html=True)
519
  st.markdown(f"<p style='text-align:center; color:#64748B;'>Guessed in {len(st.session_state.questions)} questions</p>",
520
  unsafe_allow_html=True)
521
  if st.button("Play Again", key="play_again"):
 
522
  st.session_state.clear()
 
523
  st.experimental_rerun()
524
 
525
  if __name__ == "__main__":