Skip to content

Commit d2d8d06

Browse files
committed
Add Playful Mode
1 parent 0a96d0a commit d2d8d06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3171
-1
lines changed

DEBUG.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Debug Mode
2+
3+
## Enabling Debug Mode
4+
5+
To enable debug mode in the Fortune Tiger slot machine, open your browser console and run:
6+
7+
```javascript
8+
localStorage.setItem('debug_mode', 'true');
9+
```
10+
11+
Then refresh the page. You'll see a purple "🐛 Debug Spin" button in the top-left corner.
12+
13+
## Disabling Debug Mode
14+
15+
To disable debug mode:
16+
17+
```javascript
18+
localStorage.removeItem('debug_mode');
19+
// or
20+
localStorage.setItem('debug_mode', 'false');
21+
```
22+
23+
Then refresh the page.
24+
25+
## What Does Debug Mode Do?
26+
27+
The debug button allows you to test the spinning animation and transaction flow without actually:
28+
- Connecting a wallet
29+
- Placing a real bet
30+
- Spending any tokens
31+
32+
When you click "🐛 Debug Spin", it will:
33+
1. **Ask you to choose**: Click OK to WIN, or Cancel to LOSE
34+
2. Start the spinning animation immediately
35+
3. Show "CONFIRMING..." state for 2 seconds (simulating wallet confirmation)
36+
4. Show "Transaction confirmed! Spinning..." toast
37+
5. Continue spinning for 5 seconds (simulating blockchain confirmation)
38+
6. Stop at the result you chose (guaranteed win or guaranteed lose)
39+
7. If you chose WIN, show the "WINNER CHICKEN DINNER" animation
40+
8. Play spinning sound effect (if `spin.mp3` exists in `public/sounds/`)
41+
42+
This is useful for:
43+
- Testing the UI/UX flow
44+
- Checking animations
45+
- Debugging audio playback
46+
- Testing the winning animation
47+
- Demonstrating the app without needing a wallet connection
48+
49+
## Audio
50+
51+
The app will automatically play a spinning sound effect when the reels are spinning.
52+
53+
### Automatic Fallback Sound
54+
55+
**No setup required!** If the `spin.mp3` file is missing, the app will automatically generate a spinning sound using Web Audio API. You'll see this console message:
56+
- `🔊 Playing Web Audio API fallback sound`
57+
58+
### Optional: Add Better Sound
59+
60+
For a more realistic casino experience:
61+
62+
1. Download a free slot machine spin sound (MP3 format)
63+
- Mixkit: https://mixkit.co/free-sound-effects/casino/
64+
- Freesound: https://freesound.org/ (search "slot machine spin")
65+
- Pixabay: https://pixabay.com/sound-effects/search/slot%20machine/
66+
67+
2. Rename the file to `spin.mp3`
68+
69+
3. Place it in `public/sounds/spin.mp3`
70+
71+
4. Refresh the browser
72+
73+
5. Check console for "✅ Audio file loaded successfully" and "🔊 Playing MP3 audio" messages
74+
75+
See `public/sounds/README.md` for detailed audio setup instructions.
76+
77+
## Notes
78+
79+
- The debug button is only visible when debug mode is enabled
80+
- You can toggle debug mode at any time by changing localStorage
81+
- Debug spins don't affect your real balance or create real transactions
82+
- You can choose to win or lose before each debug spin
83+
- Audio will only play if `spin.mp3` exists in the `public/sounds/` folder
84+
- If audio is blocked by browser, it will play after user interaction (clicking debug button)

app/page.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import RecentOperationsTable from '@/components/RecentOperationsTable';
1010
import ProfitLossCard from '@/components/ProfitLossCard';
1111
import TokenSelector from '@/components/TokenSelector';
1212
import PlaceBetCard from '@/components/PlaceBetCard';
13+
import FortuneTigerBetCard from '@/components/FortuneTigerBetCard';
1314
import AddLiquidityCard from '@/components/AddLiquidityCard';
1415
import RemoveLiquidityCard from '@/components/RemoveLiquidityCard';
1516
import { ContractInfoCompact } from '@/components/ContractInfoCompact';
1617
import { NetworkSelector } from '@/components/NetworkSelector';
18+
import { UIModeSwitcher, type UIMode } from '@/components/UIModeSwitcher';
1719
import HelpIcon from '@/components/HelpIcon';
1820
import { formatBalance } from '@/lib/utils';
1921
import { toast } from '@/lib/toast';
@@ -31,6 +33,20 @@ export default function Home() {
3133
const [isRefreshingContract, setIsRefreshingContract] = useState(false);
3234
const [showWithdrawModal, setShowWithdrawModal] = useState(false);
3335
const [withdrawAmount, setWithdrawAmount] = useState('');
36+
const [uiMode, setUIMode] = useState<UIMode>('classic');
37+
38+
// Load UI mode preference from localStorage
39+
useEffect(() => {
40+
const storedMode = localStorage.getItem('ui_mode') as UIMode | null;
41+
if (storedMode && (storedMode === 'classic' || storedMode === 'fortune-tiger')) {
42+
setUIMode(storedMode);
43+
}
44+
}, []);
45+
46+
const handleModeChange = (mode: UIMode) => {
47+
setUIMode(mode);
48+
localStorage.setItem('ui_mode', mode);
49+
};
3450

3551
const handleCardToggle = (cardId: string) => {
3652
setExpandedCard(expandedCard === cardId ? null : cardId);
@@ -160,6 +176,16 @@ export default function Home() {
160176

161177
const contractState = getContractStateForToken(selectedToken);
162178

179+
// If in Fortune Tiger mode, render full-screen slot machine
180+
if (uiMode === 'fortune-tiger') {
181+
return (
182+
<div className="relative">
183+
<FortuneTigerBetCard selectedToken={selectedToken} />
184+
<UIModeSwitcher currentMode={uiMode} onModeChange={handleModeChange} />
185+
</div>
186+
);
187+
}
188+
163189
return (
164190
<div className="min-h-screen bg-slate-900">
165191
<Header />
@@ -359,6 +385,9 @@ export default function Home() {
359385
<footer className="mt-8 text-center text-slate-500 text-sm">
360386
<p>HathorDice {APP_VERSION}</p>
361387
</footer>
388+
389+
{/* UI Mode Switcher - Only show in classic mode */}
390+
<UIModeSwitcher currentMode={uiMode} onModeChange={handleModeChange} />
362391
</div>
363392
);
364393
}

0 commit comments

Comments
 (0)