本アプリは SwiftData/Realm を使わず、UserDefaults のみでローカルデータを管理。スコア・設定・ストリーク・課金状態を全て UserDefaults に保存。
UserDefaults キー(StorageKey)
| キー | 型 | 用途 |
chromatic_best_score_normal | Int | NORMAL ベストスコア |
chromatic_best_score_fast | Int | FAST ベストスコア |
chromatic_best_score_insane | Int | INSANE ベストスコア |
chromatic_sound_enabled | Bool | 効果音有効(デフォルト true) |
chromatic_color_blind_mode | Bool | 色覚サポートモード |
chromatic_has_seen_onboarding | Bool | オンボーディング済 |
chromatic_ads_removed | Bool | 広告削除済(オフラインキャッシュ) |
chromatic_streak_count | Int | 連続プレイ日数 |
chromatic_last_played_date | String | 最終プレイ日(YYYY-MM-DD) |
状態管理(@Observable @MainActor)
| クラス | 責務 |
GameViewModel | ラウンド進行・入力判定・速度計算・マイルストーン |
PurchaseManager | StoreKit 課金(広告除去 IAP) |
SoundManager | WAVサウンド再生 |
StreakManager | 連続プレイ日数 |
GameCenterManager | Game Center 認証・スコア送信・LB表示 |
InterstitialAdManager | 全画面広告(2ゲームに1回) |
主要 Enum
Difficulty
enum Difficulty: String {
case normal = "NORMAL" // roundOffset: 0
case fast = "FAST" // roundOffset: 9
case insane = "INSANE" // roundOffset: 19
}
GameState
enum GameState {
case idle // START画面
case showing // CPUがシーケンス表示中
case playerTurn // プレイヤー入力待ち
case gameOver // ゲーム終了
}
色インデックス
| Index | 色 | 周波数(音) |
| 0 | 赤 | 329.63 Hz (E4) |
| 1 | 緑 | 415.30 Hz (G#4) |
| 2 | 青 | 523.25 Hz (C5) |
| 3 | 黄 | 659.25 Hz (E5) |
速度テーブル
| 実効ラウンド | litMs(点灯時間) | gapMs(間隔) | ラベル |
| 1-4 | 650 | 195 | NORMAL |
| 5-9 | 500 | 150 | NORMAL+ |
| 10-14 | 400 | 120 | FAST |
| 15-19 | 320 | 96 | FAST+ |
| 20+ | 250 | 75 | INSANE |
マイルストーン演出
| ラウンド | メッセージ | 背景色 |
| 5 | GREAT! | green |
| 10 | AMAZING! | blue |
| 15 | INCREDIBLE! | purple |
| 20 | LEGENDARY! | gold |
変更履歴
| バージョン | 日付 | 変更内容 |
|---|
| 1.0 | 2026-05-09 | 初版作成 |