diff --git a/index.js b/index.js new file mode 100644 index 0000000..5fd059f --- /dev/null +++ b/index.js @@ -0,0 +1,4 @@ +import { registerRootComponent } from 'expo'; +import App from './App'; + +registerRootComponent(App); diff --git a/package.json b/package.json index c56aa29..99e4ad2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "blackjack-mobile", "version": "0.1.0", "private": true, - "main": "node_modules/expo/AppEntry.js", + "main": "index.js", "scripts": { "start": "expo start", "android": "expo run:android", diff --git a/src/screens/TableScreen.js b/src/screens/TableScreen.js index 7aedacf..c1096d3 100644 --- a/src/screens/TableScreen.js +++ b/src/screens/TableScreen.js @@ -14,6 +14,7 @@ export default function TableScreen({ token, tableId, user, onLeave }) { const [balance, setBalance] = useState(user.balance); const [message, setMessage] = useState(''); const [betAmount, setBetAmount] = useState(10); + const [turnSeconds, setTurnSeconds] = useState(null); const wsRef = useRef(null); const pulse = useRef(new Animated.Value(0)).current; @@ -62,6 +63,22 @@ export default function TableScreen({ token, tableId, user, onLeave }) { const isMyTurn = table?.phase === 'playing' && table?.currentSeatIndex === mySeat?.index; const bettingLocked = ['playing', 'dealer', 'payout'].includes(table?.phase); + useEffect(() => { + if (!table?.turnEndsAt || !isMyTurn) { + setTurnSeconds(null); + return; + } + + const update = () => { + const msLeft = Math.max(0, table.turnEndsAt - Date.now()); + setTurnSeconds(Math.ceil(msLeft / 1000)); + }; + + update(); + const interval = setInterval(update, 250); + return () => clearInterval(interval); + }, [table?.turnEndsAt, isMyTurn]); + useEffect(() => { if (!isMyTurn) { pulse.stopAnimation(); @@ -151,6 +168,9 @@ export default function TableScreen({ token, tableId, user, onLeave }) { send({ type: 'ready' })} variant="green" disabled={bettingLocked} /> + {isMyTurn && turnSeconds !== null ? ( + Idő: {turnSeconds} mp + ) : null} send({ type: 'action', action: 'hit' })} variant="gold" disabled={!isMyTurn} /> send({ type: 'action', action: 'stand' })} variant="gold" disabled={!isMyTurn} /> @@ -252,5 +272,11 @@ const styles = StyleSheet.create({ textAlign: 'center', marginTop: 10, fontFamily: fonts.body + }, + timer: { + color: colors.goldBright, + textAlign: 'center', + marginBottom: 8, + fontFamily: fonts.mono } });