From 6e6c8b5a4245ac1abe4757e8b81c992698805d3b Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:59:30 +0000 Subject: [PATCH] Add "Random Start" to Bulgarian Solitaire Added a "Random Start" option to the Bulgarian Solitaire game, allowing players to begin with a randomized initial setup. -edited src/components/BulgarianSolitaire.tsx --- src/components/BulgarianSolitaire.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/BulgarianSolitaire.tsx b/src/components/BulgarianSolitaire.tsx index 119cb4b..9c5a029 100644 --- a/src/components/BulgarianSolitaire.tsx +++ b/src/components/BulgarianSolitaire.tsx @@ -285,6 +285,25 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare setIsAnimating(false); }; + const randomStart = () => { + // Reset first + reset(); + + // Randomly distribute all boxes into columns + const newBoxes: Box[] = []; + const newColumns = Array.from({ length: totalBoxes }, () => []); + + for (let i = 0; i < totalBoxes; i++) { + // Pick a random column index (ensure we use at least some columns) + const columnIndex = Math.floor(Math.random() * Math.min(totalBoxes, 8)); // Limit to 8 columns for better visualization + newBoxes.push({ id: i, columnIndex }); + newColumns[columnIndex].push(i); + } + + setBoxes(newBoxes); + setColumns(newColumns); + }; + const containerBoxes = boxes.filter(box => box.columnIndex === null); const handleBackgroundClick = () => { @@ -321,6 +340,9 @@ const BulgarianSolitaire: React.FC = ({ showSocialShare + {/* Container */}