Spaces:
Sleeping
Sleeping
elfsong commited on
Commit ·
7812de0
1
Parent(s): 2fcc1f1
Enhance game state management and output formatting in app.py and dixit.py
Browse files- Updated the storytelling stage to correctly set the selected card ID for the storyteller.
- Improved output formatting for guessed and voted cards in the scoring stage for better readability.
- Minor adjustment in scoring logic for the storyteller to maintain consistency.
app.py
CHANGED
|
@@ -55,8 +55,6 @@ class OnlinePlayer(Player):
|
|
| 55 |
|
| 56 |
st.title("Dixit :blue[Bench]")
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
if "stage" not in st.session_state:
|
| 61 |
token = st.text_input("OpenAI Token", type="password")
|
| 62 |
if token:
|
|
@@ -101,6 +99,7 @@ if st.session_state.stage == "storytelling":
|
|
| 101 |
|
| 102 |
if st.session_state.story != "":
|
| 103 |
st.success(f"Story: {st.session_state.story}")
|
|
|
|
| 104 |
st.session_state.stage = "guessing"
|
| 105 |
st.rerun()
|
| 106 |
|
|
@@ -157,10 +156,10 @@ if st.session_state.stage == "scoring":
|
|
| 157 |
|
| 158 |
# Guess Details
|
| 159 |
for card in st.session_state.game.table_cards.values():
|
| 160 |
-
st.write(f"Guessed Card {card.card_id} <- {card.guessed_by}")
|
| 161 |
|
| 162 |
# Voted Details
|
| 163 |
for card in st.session_state.game.table_cards.values():
|
| 164 |
-
st.write(f"Voted Card {card.card_id} <- {card.voted_by}")
|
| 165 |
|
| 166 |
st.write(f"Score: {st.session_state.game.score_dict}")
|
|
|
|
| 55 |
|
| 56 |
st.title("Dixit :blue[Bench]")
|
| 57 |
|
|
|
|
|
|
|
| 58 |
if "stage" not in st.session_state:
|
| 59 |
token = st.text_input("OpenAI Token", type="password")
|
| 60 |
if token:
|
|
|
|
| 99 |
|
| 100 |
if st.session_state.story != "":
|
| 101 |
st.success(f"Story: {st.session_state.story}")
|
| 102 |
+
st.session_state.game.storyteller.selected_card_id = st.session_state.storyteller_card.card_id
|
| 103 |
st.session_state.stage = "guessing"
|
| 104 |
st.rerun()
|
| 105 |
|
|
|
|
| 156 |
|
| 157 |
# Guess Details
|
| 158 |
for card in st.session_state.game.table_cards.values():
|
| 159 |
+
st.write(f"- Guessed Card {card.card_id} <- {card.guessed_by}")
|
| 160 |
|
| 161 |
# Voted Details
|
| 162 |
for card in st.session_state.game.table_cards.values():
|
| 163 |
+
st.write(f"- Voted Card {card.card_id} <- {card.voted_by}")
|
| 164 |
|
| 165 |
st.write(f"Score: {st.session_state.game.score_dict}")
|
dixit.py
CHANGED
|
@@ -410,7 +410,7 @@ class Game:
|
|
| 410 |
self.score_dict[guessed_card.guessed_by] += 1
|
| 411 |
elif self.num_players == 6:
|
| 412 |
# Storyteller
|
| 413 |
-
self.score_dict[self.storyteller.player_id] += 3 if len(correct_voted_list) in [1, 2, 3,4] else 0
|
| 414 |
|
| 415 |
# Guesser (Find the Storyteller's card)
|
| 416 |
if len(correct_voted_list) == 0:
|
|
|
|
| 410 |
self.score_dict[guessed_card.guessed_by] += 1
|
| 411 |
elif self.num_players == 6:
|
| 412 |
# Storyteller
|
| 413 |
+
self.score_dict[self.storyteller.player_id] += 3 if len(correct_voted_list) in [1, 2, 3, 4] else 0
|
| 414 |
|
| 415 |
# Guesser (Find the Storyteller's card)
|
| 416 |
if len(correct_voted_list) == 0:
|