Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,6 +44,7 @@ def store_message(name: str, message: str):
|
|
| 44 |
commit_url = repo.push_to_hub()
|
| 45 |
return generate_html()
|
| 46 |
|
|
|
|
| 47 |
# Initialize player, dealer, deck and game play. Cache these variables
|
| 48 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True)
|
| 49 |
def start_game():
|
|
@@ -103,32 +104,39 @@ result = st.empty()
|
|
| 103 |
pro_tip = st.empty()
|
| 104 |
betting_strategy = st.empty()
|
| 105 |
|
| 106 |
-
|
| 107 |
-
if
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
player_hit_option.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
if
|
| 113 |
-
|
| 114 |
-
player.double_down(game_deck, game_play)
|
| 115 |
-
player_double_down_option.empty()
|
| 116 |
-
player_hit_option.empty()
|
| 117 |
-
player_stand_option.empty()
|
| 118 |
-
|
| 119 |
-
if 'Stand' in player.possible_actions:
|
| 120 |
-
if player_stand_option.button('Stand'):
|
| 121 |
-
player.stand(game_play)
|
| 122 |
-
player_hit_option.empty()
|
| 123 |
-
player_double_down_option.empty()
|
| 124 |
-
player_stand_option.empty()
|
| 125 |
-
|
| 126 |
-
game_play.update()
|
| 127 |
-
player_stats.write(player)
|
| 128 |
-
player_images.image([Image.open(card.image_location) for card in player.cards], width=100)
|
| 129 |
-
dealer_stats.write(dealer)
|
| 130 |
-
dealer_images.image([Image.open(card.image_location) for card in dealer.cards], width=100)
|
| 131 |
-
result.write(game_play)
|
| 132 |
-
|
| 133 |
-
pro_tip.write(display_pro_tip(player, dealer))
|
| 134 |
-
betting_strategy.write(display_betting_strategy(player, dealer))
|
|
|
|
| 44 |
commit_url = repo.push_to_hub()
|
| 45 |
return generate_html()
|
| 46 |
|
| 47 |
+
|
| 48 |
# Initialize player, dealer, deck and game play. Cache these variables
|
| 49 |
@st.cache(allow_output_mutation=True, suppress_st_warning=True)
|
| 50 |
def start_game():
|
|
|
|
| 104 |
pro_tip = st.empty()
|
| 105 |
betting_strategy = st.empty()
|
| 106 |
|
| 107 |
+
while True:
|
| 108 |
+
if 'Hit' in player.possible_actions:
|
| 109 |
+
if player_hit_option.button('Hit'):
|
| 110 |
+
player.player_hit(game_deck, game_play)
|
| 111 |
+
if 'Hit' not in player.possible_actions:
|
| 112 |
+
player_hit_option.empty()
|
| 113 |
+
|
| 114 |
+
if 'Double Down' in player.possible_actions:
|
| 115 |
+
if player_double_down_option.button('Double Down'):
|
| 116 |
+
player.double_down(game_deck, game_play)
|
| 117 |
+
player_double_down_option.empty()
|
| 118 |
+
player_hit_option.empty()
|
| 119 |
+
player_stand_option.empty()
|
| 120 |
+
|
| 121 |
+
if 'Stand' in player.possible_actions:
|
| 122 |
+
if player_stand_option.button('Stand'):
|
| 123 |
+
player.stand(game_play)
|
| 124 |
player_hit_option.empty()
|
| 125 |
+
player_double_down_option.empty()
|
| 126 |
+
player_stand_option.empty()
|
| 127 |
+
|
| 128 |
+
game_play.update()
|
| 129 |
+
player_stats.write(player)
|
| 130 |
+
player_images.image([Image.open(card.image_location) for card in player.cards], width=100)
|
| 131 |
+
dealer_stats.write(dealer)
|
| 132 |
+
dealer_images.image([Image.open(card.image_location) for card in dealer.cards], width=100)
|
| 133 |
+
result.write(game_play)
|
| 134 |
+
|
| 135 |
+
pro_tip.write(display_pro_tip(player, dealer))
|
| 136 |
+
betting_strategy.write(display_betting_strategy(player, dealer))
|
| 137 |
+
|
| 138 |
+
if game_play.game_over:
|
| 139 |
+
break
|
| 140 |
|
| 141 |
+
if not player.possible_actions:
|
| 142 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|