231 lines
7.6 KiB
Markdown
231 lines
7.6 KiB
Markdown
# Onboarding System Implementation Summary
|
|
|
|
## Overview
|
|
|
|
A comprehensive, non-intrusive onboarding system has been implemented for both Blackjack and Baccarat games. The system provides a great first-time user experience without annoying experienced players.
|
|
|
|
## Components Created (in CasinoKit)
|
|
|
|
### 1. OnboardingState.swift
|
|
- Tracks first-time user progress
|
|
- Manages which hints have been shown
|
|
- Persists state to UserDefaults
|
|
- Supports tutorial mode (replay hints)
|
|
- Game-specific identifiers (separate state per game)
|
|
|
|
**Key Methods:**
|
|
- `shouldShowHint(key:)` - Check if hint should be displayed
|
|
- `markHintShown(key:)` - Mark hint as seen (persisted)
|
|
- `completeWelcome()` - Mark welcome sheet as completed
|
|
- `startTutorialMode()` / `endTutorialMode()` - Enable/disable tutorial replay
|
|
- `reset()` - Clear all onboarding data (for testing)
|
|
|
|
### 2. WelcomeSheet.swift
|
|
- First-launch welcome screen
|
|
- Lists key features with icons
|
|
- Two CTAs: "Show Me How" (tutorial) or "Start Playing" (skip)
|
|
- Automatically shows game emoji (🃏 for Blackjack, 🎴 for Baccarat)
|
|
- Fully localized
|
|
|
|
### 3. ContextualTooltip.swift
|
|
- In-game hint tooltips
|
|
- Appears at the right moment
|
|
- "Got it" button to dismiss
|
|
- Animated entry/exit
|
|
- Automatically marks hint as shown on dismiss
|
|
- View modifier for easy integration
|
|
|
|
### 4. PulsingModifier.swift
|
|
- Visual pulse animation to draw attention
|
|
- Optional enhancement for interactive elements
|
|
- Configurable color and scale
|
|
- Currently available but not actively used (can be added later)
|
|
|
|
## Integration in Games
|
|
|
|
### Blackjack
|
|
|
|
**Welcome Sheet Features:**
|
|
1. Beat the Dealer - Get closer to 21
|
|
2. Learn Strategy - Built-in hints
|
|
3. Practice Free - Start with $1,000
|
|
4. Customize Rules - Change settings
|
|
|
|
**Contextual Hints:**
|
|
- **Betting Zone**: "Tap chips, then tap here to bet" (when entering betting phase for first time)
|
|
- **Deal Button**: "Tap Deal to start the round" (after placing first bet)
|
|
- **Player Actions**: "Choose your action based on the hint above" (during first player turn)
|
|
|
|
### Baccarat
|
|
|
|
**Welcome Sheet Features:**
|
|
1. Bet on Player, Banker, or Tie
|
|
2. Track Patterns - Road maps show history
|
|
3. Practice Free - Start with $1,000
|
|
4. Customize Settings - Change table limits
|
|
|
|
**Contextual Hints:**
|
|
- **Betting Zone**: "Tap chips, then tap a betting zone" (when entering betting phase for first time)
|
|
- **Deal Button**: "Tap Deal to start the round" (after placing first bet)
|
|
- **Result Display**: "Results appear here, then in the road maps below" (after first round completes)
|
|
|
|
## Settings Changes
|
|
|
|
Both games now default to more beginner-friendly settings:
|
|
|
|
| Setting | Old Default | New Default |
|
|
|---------|-------------|-------------|
|
|
| Table Limits | Low Stakes ($10-$1,000) | Casual ($5-$500) |
|
|
| Starting Balance | $10,000 | $1,000 |
|
|
|
|
**Rationale:**
|
|
- Lower minimum bet ($5) is less intimidating for beginners
|
|
- $1,000 balance creates more meaningful decisions (not too much/little)
|
|
- Still allows ~200 hands at $5/hand for good learning experience
|
|
- Users can always increase in settings
|
|
|
|
## Bug Fix
|
|
|
|
**Blackjack Late Surrender:**
|
|
- Fixed inconsistency where `resetToDefaults()` set it to `true` but Vegas preset overrode to `false`
|
|
- Now correctly defaults to `false` to match Vegas rules
|
|
|
|
## User Flow
|
|
|
|
### First Launch:
|
|
1. App loads
|
|
2. Welcome sheet appears automatically after 500ms delay
|
|
3. User chooses:
|
|
- **"Show Me How"**: Enables tutorial mode, shows contextual hints during first round
|
|
- **"Start Playing"**: Skips tutorial, hints still appear once naturally during gameplay
|
|
|
|
### Subsequent Launches:
|
|
- Welcome sheet never shows again
|
|
- Contextual hints appear once at the right moment
|
|
- Each hint only shows once per hint key
|
|
- Completely transparent to returning users
|
|
|
|
### Tutorial Mode:
|
|
- User can replay tutorial by tapping "Show Me How" on welcome
|
|
- All hints re-enabled for that session
|
|
- Tutorial mode doesn't persist across app launches
|
|
|
|
## Technical Details
|
|
|
|
### Hint Timing
|
|
- Hints are shown with delays using `Task.sleep(for:)` on MainActor
|
|
- Animations use spring duration for smooth transitions
|
|
- onChange modifiers trigger hints based on game state changes
|
|
|
|
### Persistence
|
|
- Uses UserDefaults with game-specific keys
|
|
- Format: `"onboarding.{gameIdentifier}.{property}"`
|
|
- Examples: `"onboarding.blackjack.hasLaunched"`, `"onboarding.baccarat.hintsShown"`
|
|
|
|
### Thread Safety
|
|
- All onboarding state is @MainActor
|
|
- Safe to use from SwiftUI views
|
|
- No threading concerns
|
|
|
|
## Documentation Updates
|
|
|
|
### Blackjack README
|
|
- Added "First-Time User Experience" section at top of features
|
|
- Documents welcome sheet, tutorial mode, and contextual hints
|
|
|
|
### Baccarat README
|
|
- Added "First-Time User Experience" section at top of features
|
|
- Same structure as Blackjack for consistency
|
|
|
|
### CasinoKit README
|
|
- New "Onboarding & Tutorials" section with full API documentation
|
|
- Code examples for WelcomeSheet, ContextualTooltip, OnboardingState
|
|
- Updated file structure to show new components
|
|
- Added Blackjack to "Apps Using CasinoKit" list
|
|
|
|
## Best Practices Followed
|
|
|
|
✅ **Non-intrusive**: All onboarding is skippable
|
|
✅ **One-time only**: Hints never show twice (unless tutorial mode)
|
|
✅ **Right moment**: Hints appear contextually, not all at once
|
|
✅ **Short & visual**: Messages are concise with icons
|
|
✅ **Localized**: All strings use String Catalog
|
|
✅ **Accessible**: Uses standard SwiftUI components
|
|
✅ **Persistent**: User's progress is saved
|
|
✅ **Game-specific**: Each game has independent onboarding state
|
|
|
|
## Testing Recommendations
|
|
|
|
### Manual Testing:
|
|
1. **Fresh install**: Delete app, reinstall, verify welcome sheet appears
|
|
2. **Tutorial mode**: Tap "Show Me How", verify hints appear in sequence
|
|
3. **Skip mode**: Tap "Start Playing", verify hints still appear once naturally
|
|
4. **Second launch**: Relaunch app, verify welcome doesn't show again
|
|
5. **Settings reset**: Check if onboarding can be reset (could add to settings)
|
|
|
|
### Reset for Testing:
|
|
Add this to a development menu if needed:
|
|
```swift
|
|
Button("Reset Onboarding") {
|
|
gameState.onboarding.reset()
|
|
}
|
|
```
|
|
|
|
## Future Enhancements (Not Implemented)
|
|
|
|
These could be added later if desired:
|
|
|
|
1. **Progressive discovery hints**: Tips after 5/10/20 hands
|
|
- "Enable card counting in settings" (Blackjack)
|
|
- "Side bets offer bigger payouts" (both games)
|
|
|
|
2. **Onboarding analytics**: Track which hints are most helpful
|
|
|
|
3. **User-requested replay**: "Show tutorial again" in settings
|
|
|
|
4. **Pulsing hints**: Use PulsingModifier on interactive elements during tutorial
|
|
|
|
5. **Accessibility announcements**: Post VoiceOver announcements for key moments
|
|
|
|
## Files Created
|
|
|
|
```
|
|
CasinoKit/Sources/CasinoKit/
|
|
├── Models/OnboardingState.swift
|
|
└── Views/
|
|
├── ContextualTooltip.swift
|
|
├── WelcomeSheet.swift
|
|
└── PulsingModifier.swift
|
|
```
|
|
|
|
## Files Modified
|
|
|
|
```
|
|
Blackjack/
|
|
├── Models/GameSettings.swift (defaults changed, bug fix)
|
|
├── Engine/GameState.swift (added onboarding property)
|
|
└── Views/Game/GameTableView.swift (integrated onboarding UI)
|
|
|
|
Baccarat/
|
|
├── Models/GameSettings.swift (defaults changed)
|
|
├── Engine/GameState.swift (added onboarding property)
|
|
└── Views/Game/GameTableView.swift (integrated onboarding UI)
|
|
|
|
README Files:
|
|
├── Blackjack/README.md
|
|
├── Baccarat/README.md
|
|
└── CasinoKit/README.md
|
|
```
|
|
|
|
## Conclusion
|
|
|
|
The onboarding system provides a polished first-time user experience that:
|
|
- Helps new users understand the game quickly
|
|
- Never annoys experienced players
|
|
- Maintains the premium feel of the apps
|
|
- Follows iOS best practices
|
|
- Is fully reusable for future casino games
|
|
|
|
All code follows the project's Swift/SwiftUI guidelines, uses design constants, and includes proper accessibility support.
|
|
|