SwiftData @Model + 状態管理 (@Observable)
@Model final class HighScoreRecord {
var score: Int = 0
var achievedAt: Date = Date()
}
@Model final class StatRecord {
var score: Int = 0
var playedAt: Date = Date()
}
| クラス | 責務 |
|---|---|
GameEngine | グリッド・配置・ライン消去・スコア・アンドゥ・演出 |
AdManager | 広告表示制御 |
StoreManager | 課金(広告除去) |
SoundManager | サウンド再生 |
HapticManager | ハプティクス |
StreakManager | 連続プレイ日数 |
struct Block: Identifiable, Sendable {
let id: UUID
let shape: BlockShape // 19種類
let color: BlockColor // 12色
}
struct BlockShape: Sendable {
let offsets: [(row: Int, col: Int)]
func rotated() -> BlockShape // 4回転対応
func cells(at anchor: GridPosition) -> [GridPosition]
}
struct GridPosition: Hashable, Sendable {
let row: Int // 0-7
let col: Int // 0-7
}
enum CellState {
case empty
case filled(BlockColor)
}
enum GameState {
case playing
case gameOver
case rescued // リワード広告で救済中
}
dot / domino2H/V / line3H/V / lShape3A〜3D / line4H/V / square2x2 / tShapeDown/Up / sShape / zShape / bigLShapeA/B / plusShape
red, blue, green, yellow, orange, purple, cyan, pink, mint, indigo, teal, brown
classic / ocean / sakura / neon / monochrome
struct UndoSnapshot {
let grid: [[CellState]]
let blocks: [Block?]
let score: Int
let comboCount: Int
}
| キー | 用途 |
|---|---|
currentTheme | 選択中ColorTheme |
soundEnabled | 効果音有効 |
hapticEnabled | ハプティクス有効 |
lastPlayedDate | ストリーク管理 |
streakCount | 連続プレイ日数 |
| バージョン | 日付 | 変更内容 |
|---|---|---|
| 1.0 | 2026-05-09 | 初版作成 |