107 lines
3.1 KiB
Swift
107 lines
3.1 KiB
Swift
//
|
|
// GameSettingsProtocol.swift
|
|
// CasinoKit
|
|
//
|
|
// Protocol defining common settings shared across all casino games.
|
|
// Each game can conform to this protocol and add game-specific settings.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// Protocol defining the minimum required settings for any casino game.
|
|
/// Games conforming to this protocol share common UI settings and behaviors.
|
|
@MainActor
|
|
public protocol GameSettingsProtocol: AnyObject {
|
|
// MARK: - Table Configuration
|
|
|
|
/// The table limits preset (affects min/max bets).
|
|
var tableLimits: TableLimits { get set }
|
|
|
|
/// Minimum bet amount (derived from tableLimits).
|
|
var minBet: Int { get }
|
|
|
|
/// Maximum bet amount (derived from tableLimits).
|
|
var maxBet: Int { get }
|
|
|
|
/// Starting balance for new sessions.
|
|
var startingBalance: Int { get set }
|
|
|
|
// MARK: - Animation Settings
|
|
|
|
/// Whether to show card dealing and other animations.
|
|
var showAnimations: Bool { get set }
|
|
|
|
/// Speed multiplier for dealing (1.0 = normal).
|
|
var dealingSpeed: Double { get set }
|
|
|
|
// MARK: - Display Settings
|
|
|
|
/// Whether to show hints and recommendations.
|
|
var showHints: Bool { get set }
|
|
|
|
// MARK: - Sound Settings
|
|
|
|
/// Whether sound effects are enabled.
|
|
var soundEnabled: Bool { get set }
|
|
|
|
/// Whether haptic feedback is enabled.
|
|
var hapticsEnabled: Bool { get set }
|
|
|
|
/// Volume level for sound effects (0.0 to 1.0).
|
|
var soundVolume: Float { get set }
|
|
|
|
// MARK: - Persistence
|
|
|
|
/// Saves settings to persistent storage.
|
|
func save()
|
|
|
|
/// Loads settings from persistent storage.
|
|
func load()
|
|
|
|
/// Resets all settings to defaults.
|
|
func resetToDefaults()
|
|
}
|
|
|
|
// MARK: - Default Implementations
|
|
|
|
public extension GameSettingsProtocol {
|
|
/// Minimum bet derived from table limits.
|
|
var minBet: Int {
|
|
tableLimits.minBet
|
|
}
|
|
|
|
/// Maximum bet derived from table limits.
|
|
var maxBet: Int {
|
|
tableLimits.maxBet
|
|
}
|
|
}
|
|
|
|
// MARK: - Settings Persistence Helpers
|
|
|
|
/// Common settings keys for persistence.
|
|
public enum SettingsKeys {
|
|
public static let tableLimits = "settings.tableLimits"
|
|
public static let startingBalance = "settings.startingBalance"
|
|
public static let showAnimations = "settings.showAnimations"
|
|
public static let dealingSpeed = "settings.dealingSpeed"
|
|
public static let showHints = "settings.showHints"
|
|
public static let soundEnabled = "settings.soundEnabled"
|
|
public static let hapticsEnabled = "settings.hapticsEnabled"
|
|
public static let soundVolume = "settings.soundVolume"
|
|
}
|
|
|
|
// MARK: - Settings Defaults
|
|
|
|
/// Default values for common settings.
|
|
public enum SettingsDefaults {
|
|
public static let tableLimits: TableLimits = .casual
|
|
public static let startingBalance: Int = 1_000
|
|
public static let showAnimations: Bool = true
|
|
public static let dealingSpeed: Double = 1.0
|
|
public static let showHints: Bool = true
|
|
public static let soundEnabled: Bool = true
|
|
public static let hapticsEnabled: Bool = true
|
|
public static let soundVolume: Float = 1.0
|
|
}
|
|
|