diff --git a/src/components/GameDetail.module.css b/src/components/GameDetail.module.css index 0ba5d78..2bd1c27 100644 --- a/src/components/GameDetail.module.css +++ b/src/components/GameDetail.module.css @@ -192,4 +192,43 @@ } .rerack-btn:hover { background-color: #4a6fbf; +} + +.foul-controls { + display: flex; + justify-content: center; + gap: 1rem; + margin-top: 1.5rem; +} + +.foul-btn { + padding: 0.8rem 1.5rem; + font-size: 1rem; + font-weight: bold; + border-radius: 8px; + border: 1px solid #c0392b; + background-color: #e74c3c; + color: #fff; + cursor: pointer; + transition: background-color 0.2s; +} + +.foul-btn:hover { + background-color: #c0392b; +} + +.foul-indicator { + font-size: 1rem; + font-weight: bold; + color: #fff; + background-color: #c0392b; + padding: 4px 8px; + border-radius: 4px; + margin-top: 8px; + display: inline-block; +} + +.foul-warning { + background-color: #f39c12; + color: #000; } \ No newline at end of file diff --git a/src/components/GameDetail141.jsx b/src/components/GameDetail141.jsx index 2cd6bbf..d175d6a 100644 --- a/src/components/GameDetail141.jsx +++ b/src/components/GameDetail141.jsx @@ -46,7 +46,7 @@ const GameDetail141 = ({ game, onUpdate, onBack }) => { const newScore = currentPlayer.score + ballsPotted - foulPoints; const updatedPlayers = game.players.map((p, index) => - index === game.currentPlayer ? { ...p, score: newScore } : p + index === game.currentPlayer ? { ...p, score: newScore, consecutiveFouls: 0 } : p ); const nextPlayer = (game.currentPlayer + 1) % game.players.length; @@ -60,6 +60,56 @@ const GameDetail141 = ({ game, onUpdate, onBack }) => { }); }; + const handleFoul = (foulType) => { + let foulPoints = 0; + let penalty = 0; + const newConsecutiveFouls = (currentPlayer.consecutiveFouls || 0) + 1; + + if (foulType === 'standard') { + foulPoints = 1; + } else if (foulType === 'break') { + foulPoints = 2; + } + + if (newConsecutiveFouls === 3) { + penalty = 15; + } + + const totalDeduction = foulPoints + penalty; + const newScore = currentPlayer.score - totalDeduction; + + const updatedPlayers = game.players.map((p, index) => { + if (index === game.currentPlayer) { + return { + ...p, + score: newScore, + consecutiveFouls: newConsecutiveFouls === 3 ? 0 : newConsecutiveFouls, + }; + } + return p; + }); + + const nextPlayer = (game.currentPlayer + 1) % game.players.length; + + onUpdate({ + ...game, + players: updatedPlayers, + currentPlayer: nextPlayer, + history: [ + ...game.history, + { + player: currentPlayer.name, + foul: foulType, + foulPoints, + penalty, + totalDeduction, + newScore, + consecutiveFouls: newConsecutiveFouls + }, + ], + }); + }; + const handleReRack = (ballsToAdd) => { const newBallsOnTable = game.ballsOnTable + ballsToAdd; onUpdate({ @@ -83,6 +133,11 @@ const GameDetail141 = ({ game, onUpdate, onBack }) => { > {p.name} {p.score} + {p.consecutiveFouls > 0 && ( + + Fouls: {p.consecutiveFouls} + + )} ))} @@ -112,9 +167,9 @@ const GameDetail141 = ({ game, onUpdate, onBack }) => { - {/* Placeholder for future buttons */}
-

Fouls & Re-Racks (nächste Phase)

+ +