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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -12
app.py CHANGED
@@ -123,12 +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
- body {
127
- background: #000 !important;
128
- color: #0f0 !important;
129
- font-family: "Courier New" !important;
130
- text-shadow: 0 0 5px lime;
131
- }
132
  /* Add these new styles for the info modal */
133
  .info-modal {
134
  position: fixed;
@@ -305,13 +300,28 @@ def show_techniques_modal():
305
 
306
  def main():
307
  inject_custom_css()
308
- st.markdown('<div class="title">KASOTI</div>', unsafe_allow_html=True)
309
- st.markdown('<div class="subtitle">AI-Powered Guessing Game Challenge</div>', unsafe_allow_html=True)
310
-
311
- if st.button("ℹ️ Project Techniques & Limitations", key="info_btn"):
312
- show_techniques_modal()
313
 
 
 
 
 
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  if 'game_state' not in st.session_state:
316
  st.session_state.game_state = "start"
317
  st.session_state.questions = []
@@ -384,6 +394,15 @@ def main():
384
  <div class="progress-fill" style="width: {progress * 100}%"></div>
385
  </div>
386
  """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
387
  current_question = st.session_state.questions[st.session_state.current_q]
388
  st.markdown(f'''
389
  <div class="question-box">
@@ -504,14 +523,16 @@ def main():
504
  )
505
  st.session_state.final_guess = final_guess.split("Final Guess:")[-1].strip()
506
  show_confetti()
507
- st.markdown(f'<div class="final-reveal">🎉 It\'s...</div>', unsafe_allow_html=True)
508
  time.sleep(1)
509
  st.markdown(f'<div class="final-reveal" style="font-size:3.5rem;color:#6C63FF;">{st.session_state.final_guess}</div>',
510
  unsafe_allow_html=True)
511
  st.markdown(f"<p style='text-align:center; color:#64748B;'>Guessed in {len(st.session_state.questions)} questions</p>",
512
  unsafe_allow_html=True)
513
  if st.button("Play Again", key="play_again"):
 
514
  st.session_state.clear()
 
515
  st.experimental_rerun()
516
 
517
  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
 
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 = []
 
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
  )
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__":