Index: components/blackjack/BlackjackHeader.jsx
===================================================================
--- components/blackjack/BlackjackHeader.jsx	(revision 9bd09b003e0450668a5ceb182fb4d9dfb5a2d704)
+++ components/blackjack/BlackjackHeader.jsx	(revision 55701f0270de2168597a7ca5d1a05ae6a66f516b)
@@ -30,15 +30,5 @@
         }));
 
-        dispatch(setBlackjack({
-            ...styleState.blackjack,
-            inputControls: {
-                ...styleState.blackjack.inputControls,
-                initialBet: {
-                    ...styleState.blackjack.inputControls.initialBet,
-                    chosenCredits: parseInt(playerState.player.credits/2),
-                }
-            }
-        }));
-
+        let interval = null;
         axios.get(`/api/blackjack?action=get_player_info_on_enter&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(res => {
             if (res.data?.success) {
@@ -48,185 +38,81 @@
                     session_id: res.data?.session_id,
                     credits: res.data?.credits,
-                }));
-
-                dispatch(setBlackjackGame({
-                    ...playerState.blackjackGame,
-                    status: res.data?.status,
-                    playerCards: res.data?.playerCards,
-                    dealerCards: res.data?.dealerCards,
                 }))
 
-                dispatch(setStyle({
-                    ...styleState.style,
-                    displayLoadingScreen: false,
+                dispatch(setBlackjack({
+                    ...styleState.blackjack,
+                    inputControls: {
+                        ...styleState.blackjack.inputControls,
+                        initialBet: {
+                            ...styleState.blackjack.inputControls.initialBet,
+                            chosenCredits: parseInt(playerState.player.credits/2),
+                        },
+                        sideBet: {
+                            ...styleState.blackjack.inputControls.sideBet,
+                            chosenCredits: parseInt(playerState.player.credits/2),
+                        }
+                    },
                 }))
 
-                if (parseInt(res.data?.status.toString().substr(1, 1)) == 5) {
-                    dispatch(setBlackjack({
-                        ...styleState.blackjack,
-                        inputControls: {
-                            ...styleState.blackjack.inputControls,
-                            initialBet: {
-                                ...styleState.blackjack.inputControls.initialBet,
-                                chosenCredits: parseInt(res.data?.initialBet),
-                            },
-                            sideBet: {
-                                ...styleState.blackjack.inputControls.sideBet,
-                                chosenCredits: 0,
+                if (interval !== null) clearInterval(interval);
+                
+                interval = setInterval(() => {
+                    axios.get(`/api/blackjack?action=update_state&session_id=${localStorage.CAESSINO_SESSION_ID}`).then(newRes => {
+                        if (newRes.data?.success) {
+                            dispatch(setBlackjackGame(newRes.data?.blackjackGame))
+
+                            if (newRes.data?.blackjackGame?.credits !== playerState.player.credits && parseInt(newRes.data?.blackjackGame?.credits) > 0) {
+                                dispatch(setPlayer({
+                                    ...playerState.player,
+                                    displayName: res.data?.displayName,
+                                    session_id: res.data?.session_id,
+                                    credits: newRes.data?.blackjackGame?.credits,
+                                }))
                             }
-                        },
-                        displays: {
-                            ...styleState.blackjack.displays,
-                            initialBet: false,
-                            hitStand: true,
+
+                            dispatch(setStyle({
+                                ...styleState.style,
+                                displayLoadingScreen: false,
+                                notification: {
+                                    ...styleState.style.notification,
+                                    show: false,
+                                },
+                                lostConnectionInfo: {
+                                    show: false,
+                                    message: ''
+                                },
+                                alert: (newRes.data?.blackjackGame?.status?.includes('_5_') && !newRes.data?.blackjackGame?.betOutcomeMessageShown) ? {
+                                    show: true,
+                                    title: newRes.data?.blackjackGame?.messageTitle,
+                                    subtitle: newRes.data?.blackjackGame?.messageDescription,
+                                    button: {
+                                        text: 'Play Again',
+                                        action: 'play_again',
+                                    }
+                                } : (newRes.data?.blackjackGame?.status?.includes('_4_') && !newRes.data?.blackjackGame?.sideBetOutcomeMessageShown && newRes.data?.blackjackGame?.sideBet > 0) ? {
+                                    show: true,
+                                    title: newRes.data?.blackjackGame?.messageTitle,
+                                    subtitle: newRes.data?.blackjackGame?.messageDescription,
+                                    button: {
+                                        text: 'Continue',
+                                        action: 'continue_from_side_bet',
+                                    }
+                                } : {
+                                    ...styleState.style.alert,
+                                    show: false,
+                                },
+                            }))
                         }
-                    }))
-
-                    if (res.data?.outcome === 'player_busted') {
+                    }).catch(error => {
                         dispatch(setStyle({
                             ...styleState.style,
-                            alert: {
+                            displayLoadingScreen: false,
+                            lostConnectionInfo: {
                                 show: true,
-                                title: 'You busted!',
-                                subtitle: `You lost $${-1*res.data?.earnings}`,
-                                button: {
-                                    text: 'Play again',
-                                    action: 'play_again',
-                                }
+                                message: 'Game will resume upon reconnection to the server.'
                             }
                         }))
-                    }
-                    else if (res.data?.outcome === 'dealer_busted') {
-                        dispatch(setStyle({
-                            ...styleState.style,
-                            alert: {
-                                show: true,
-                                title: 'Dealer busted!',
-                                subtitle: `You won $${res.data?.earnings}`,
-                                button: {
-                                    text: 'Play again',
-                                    action: 'play_again',
-                                }
-                            }
-                        }))
-                    }
-                    else if (res.data?.outcome === 'player_won') {
-                        dispatch(setStyle({
-                            ...styleState.style,
-                            alert: {
-                                show: true,
-                                title: 'You won!',
-                                subtitle: `You won $${res.data?.earnings}`,
-                                button: {
-                                    text: 'Play again',
-                                    action: 'play_again',
-                                }
-                            }
-                        }))
-                    }
-                    else if (res.data?.outcome === 'player_lost') {
-                        dispatch(setStyle({
-                            ...styleState.style,
-                            alert: {
-                                show: true,
-                                title: 'You lost!',
-                                subtitle: `You lost $${-1*res.data?.earnings}`,
-                                button: {
-                                    text: 'Play again',
-                                    action: 'play_again',
-                                }
-                            }
-                        }))
-                    }
-                    else if (res.data?.outcome === 'draw') {
-                        dispatch(setStyle({
-                            ...styleState.style,
-                            alert: {
-                                show: true,
-                                title: 'Draw!',
-                                subtitle: `You got your $${res.data?.earnings} back`,
-                                button: {
-                                    text: 'Play again',
-                                    action: 'play_again',
-                                }
-                            }
-                        }))
-                    }
-                }
-
-                if (parseInt(res.data?.status.toString().substr(1, 1)) == 4) {
-                    dispatch(setBlackjack({
-                        ...styleState.blackjack,
-                        inputControls: {
-                            ...styleState.blackjack.inputControls,
-                            initialBet: {
-                                ...styleState.blackjack.inputControls.initialBet,
-                                chosenCredits: parseInt(res.data?.initialBet),
-                            },
-                            sideBet: {
-                                ...styleState.blackjack.inputControls.sideBet,
-                                chosenCredits: 0,
-                            }
-                        },
-                        displays: {
-                            ...styleState.blackjack.displays,
-                            initialBet: false,
-                            hitStand: true,
-                        }
-                    }))
-                }
-
-                if (parseInt(res.data?.status.toString().substr(1, 1)) == 3) {
-                    dispatch(setBlackjack({
-                        ...styleState.blackjack,
-                        inputControls: {
-                            ...styleState.blackjack.inputControls,
-                            initialBet: {
-                                ...styleState.blackjack.inputControls.initialBet,
-                                chosenCredits: parseInt(res.data?.initialBet),
-                            },
-                            sideBet: {
-                                ...styleState.blackjack.inputControls.sideBet,
-                                chosenCredits: parseInt(res.data?.sideBet),
-                            }
-                        },
-                        displays: {
-                            ...styleState.blackjack.displays,
-                            initialBet: false,
-                            hitStand: true,
-                        }
-                    }))
-                }
-
-                if (parseInt(res.data?.status.toString().substr(1, 1)) == 2) {
-                    dispatch(setBlackjack({
-                        ...styleState.blackjack,
-                        inputControls: {
-                            ...styleState.blackjack.inputControls,
-                            initialBet: {
-                                ...styleState.blackjack.inputControls.initialBet,
-                                chosenCredits: parseInt(res.data?.initialBet),
-                            }
-                        },
-                        displays: {
-                            ...styleState.blackjack.displays,
-                            initialBet: false,
-                            sideBet: true,
-                        }
-                    }))
-                }
-
-                if (parseInt(res.data?.status.toString().substr(1, 1)) == 1) {
-                    dispatch(setBlackjack({
-                        ...styleState.blackjack,
-                        inputControls: {
-                            ...styleState.blackjack.inputControls,
-                            initialBet: {
-                                ...styleState.blackjack.inputControls.initialBet,
-                                chosenCredits: parseInt(res.data?.credits/2),
-                            }
-                        },
-                    }))
-                }
+                    });
+                }, 1000);
             }
             else {
@@ -244,4 +130,8 @@
             }
         });
+
+        return () => {
+            if (interval !== null) clearInterval(interval);
+        };
     }, []);
 
