diff --git a/src/components/CrapsGame.tsx b/src/components/CrapsGame.tsx index 88ae92a..31774a4 100644 --- a/src/components/CrapsGame.tsx +++ b/src/components/CrapsGame.tsx @@ -2,7 +2,9 @@ import React, { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; -import { Dice1, Dice2, Dice3, Dice4, Dice5, Dice6, RotateCcw } from 'lucide-react'; +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; +import { Checkbox } from '@/components/ui/checkbox'; +import { Dice1, Dice2, Dice3, Dice4, Dice5, Dice6, RotateCcw, Settings } from 'lucide-react'; import SocialShare from '@/components/SocialShare'; interface CrapsGameProps { @@ -27,6 +29,12 @@ const CrapsGame: React.FC = ({ showSocialShare = false }) => { const [isRolling, setIsRolling] = useState(false); const [gameResult, setGameResult] = useState<'win' | 'lose' | 'continue' | null>(null); const [rollCount, setRollCount] = useState(0); + + // Custom rules state + const [customWinSums, setCustomWinSums] = useState([7, 11]); + const [customLoseSums, setCustomLoseSums] = useState([2, 3, 12]); + const [isCustomRules, setIsCustomRules] = useState(false); + const [isRulesModalOpen, setIsRulesModalOpen] = useState(false); const rollDice = () => { setIsRolling(true); @@ -42,10 +50,13 @@ const CrapsGame: React.FC = ({ showSocialShare = false }) => { setDice2(newDice2); setRollCount(prev => prev + 1); - // Determine game result based on craps rules - if (sum === 2 || sum === 3 || sum === 12) { + // Determine game result based on current rules + const winSums = isCustomRules ? customWinSums : [7, 11]; + const loseSums = isCustomRules ? customLoseSums : [2, 3, 12]; + + if (loseSums.includes(sum)) { setGameResult('lose'); - } else if (sum === 7 || sum === 11) { + } else if (winSums.includes(sum)) { setGameResult('win'); } else { setGameResult('continue'); @@ -118,22 +129,107 @@ const CrapsGame: React.FC = ({ showSocialShare = false }) => { {/* Rules */} - - Rules + + + {isCustomRules ? 'Custom Rules' : 'Classic Rules'} + + + + + + + + Customize Craps Rules + + Select which dice sums result in immediate wins or losses on the first throw. + + +
+
+

Loss Sums

+
+ {Array.from({ length: 12 }, (_, i) => i + 1).map((sum) => ( +
+ { + if (checked) { + setCustomLoseSums([...customLoseSums.filter(s => s !== sum), sum]); + setCustomWinSums(customWinSums.filter(s => s !== sum)); + } else { + setCustomLoseSums(customLoseSums.filter(s => s !== sum)); + } + }} + /> + +
+ ))} +
+
+
+

Win Sums

+
+ {Array.from({ length: 12 }, (_, i) => i + 1).map((sum) => ( +
+ { + if (checked) { + setCustomWinSums([...customWinSums.filter(s => s !== sum), sum]); + setCustomLoseSums(customLoseSums.filter(s => s !== sum)); + } else { + setCustomWinSums(customWinSums.filter(s => s !== sum)); + } + }} + /> + +
+ ))} +
+
+
+
+ + +
+
+
Immediate Loss -

Rolling 2, 3, or 12

+

{isCustomRules ? (customLoseSums.length > 0 ? customLoseSums.join(', ') : 'None') : 'Rolling 2, 3, or 12'}

Immediate Win -

Rolling 7 or 11

+

{isCustomRules ? (customWinSums.length > 0 ? customWinSums.join(', ') : 'None') : 'Rolling 7 or 11'}

Game Continues -

Rolling 4, 5, 6, 8, 9, or 10

+

All other sums