Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ImLukzy/ChefDash/llms.txt
Use this file to discover all available pages before exploring further.
GameState is the single source of truth that drives every screen in ChefDash. Declared as a class conforming to ObservableObject, it is instantiated exactly once in ChefDashApp as a @StateObject and then injected into the entire view hierarchy via SwiftUI’s @EnvironmentObject. Any view that needs to read or mutate game data — from the main map to the mid-round kitchen — reaches into this shared object, ensuring that a coin earned during gameplay is immediately reflected on the shop screen without any manual synchronisation.
Lifecycle & Injection
GameState is constructed at app launch in ChefDashApp, which calls setupLevels() in init() to build the full 20-level catalogue before the first frame is ever rendered.
Navigation State
Screen routing is driven by a single string property rather than an enum, keeping navigation changes simple one-liners from anywhere in the codebase.house.fill
Home / landing screen shown on launch.
map.fill
The
MainMapView level-selection map.kitchen_round
The active gameplay screen (
RecipesView).level_complete
Post-round results screen (
VictoryView).cart.fill
The in-game shop where power-ups are purchased.
activeTab triggers a SwiftUI animation and swaps the visible view immediately:
Player Data
These four published properties hold player identity and preferences for the lifetime of the currentGameState instance:
| Property | Type | Default | Purpose |
|---|---|---|---|
coins | Int | 150 | Spendable currency for shop purchases |
playerName | String | "Chef Novato" | Display name shown in the HUD |
playerAvatar | String | "👨🍳" | Emoji avatar displayed on the profile screen |
isHapticsEnabled | Bool | true | Toggles UIImpactFeedbackGenerator calls site-wide |
Level Management
levels. When the player taps a level node on the map, MainMapView sets selectedLevelIndex to that node’s array position before presenting the pre-game modal.
currentLevel Computed Property
Rather than passing an index around, every gameplay view accesses the active level through a single computed property that guards against out-of-bounds reads:
Active Gameplay State
These properties are reset at the start of each round bystartNewRound() and mutated in real time during play:
currentBurgerStack
[String] — the ingredients the player has tapped so far in the current order, in sequence.targetRecipeEmojis
[String] — the target emoji sequence the player must match to complete the current order.currentRecipeName
String — human-readable name displayed above the order target (e.g. “Classic Cheeseburger”).ordersCompletedInSession
Int — running count of successfully completed orders; compared against targetOrders for star rating.comboMultiplier
Int — starts at 1, increments by 1 (up to 5×) on each consecutive success, resets to 1 on any error.Visual Feedback Flags
Two short-lived boolean flags control the animated feedback overlays rendered inRecipesView:
true briefly and then cleared after 0.8 seconds via DispatchQueue.main.asyncAfter.
onRecipeSuccessBonusTime Callback
RecipesView owns the countdown timer, but GameState needs to trigger a time bonus on each successful order. Because a model layer should not reach directly into a view, GameState exposes a closure that the view assigns at onAppear:
GameState to signal when a bonus should occur.
Shop State
shopInventory is the in-memory list of purchasable consumables. selectedUpgradesForRound is populated in the pre-game modal when the player toggles an owned power-up on, and is consumed — cleared — the moment startNewRound() runs. See the Economy guide for full details on each item.
setupLevels() — Level Construction
setupLevels() is called once from init(). It builds three hand-crafted levels first, then appends seventeen procedurally generated levels (IDs 4–20).
Hand-crafted Levels (source)
Procedural Generation (Levels 4–20)
For levels 4 through 20, difficulty scales automatically using the level indexi:
Procedural recipes are generated once at app launch with
randomElement(), so the two possible recipes for each of Levels 4–20 are fixed for the lifetime of that GameState instance — they do not re-randomise between rounds.