Skip to main content

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.

The Level struct is the core data model for every stage in ChefDash. It bundles everything the game engine needs to run a single kitchen round: which ingredients are available, which recipes can appear, how long the player has, and how far they’ve progressed. All 20 levels are represented as Level values stored in GameState.levels, with the first three hand-crafted and levels 4–20 procedurally generated at app launch.

Struct Definition

import Foundation

struct Level: Identifiable {
    let id: Int                  // Número de nivel (1, 2, 3...)
    let name: String             // Nombre del nivel (ej: "Fast Food Inicial", "Burger Palace")
    let targetOrders: Int        // Cuántas comandas se necesitan para pasar el nivel
    let availableIngredients: [String] // Emojis de ingredientes activos en este nivel
    let possibleRecipes: [[String]]    // Lista de recetas (arrays de emojis) que pueden salir
    let baseTime: Int            // Tiempo disponible en segundos para este nivel

    var isUnlocked: Bool = false // Control de progreso en el mapa
    var starsEarned: Int = 0     // Estrellas conseguidas (0 a 3)
}

Fields

id
Int
required
Unique level number in the range 1–20. Used as the canonical identifier for sequential unlock logic: when a round is completed, GameState.finishRound(starsEarned:) searches levels for the entry whose id equals currentLevelId + 1 and sets its isUnlocked to true.
name
String
required
Human-readable display name shown on map nodes and in the post-round VictoryView. The three hand-crafted levels carry descriptive names ("Burger Station", "Green Diner", "Bacon & Grill"), while procedurally generated levels follow the pattern "Kitchen Arcade Expo <N>".
targetOrders
Int
required
The number of orders the player must complete to earn 3 stars and unlock the next level. Difficulty scales with level number: levels 1–3 require 3, 4, and 5 orders respectively; procedurally generated levels use the formula 4 + (id / 2).
availableIngredients
[String]
required
Array of emoji strings rendered as tappable buttons in RecipesView. Only ingredients listed here are available to the player during a round — tapping an ingredient calls GameState.addIngredient(_:). The pool grows with difficulty: Level 1 provides ["🍞", "🥩", "🧀"] while higher levels add "🥬", "🍅", "🥓", "🧅", and "🍄".
possibleRecipes
[[String]]
required
Array of recipe arrays, where each inner array is an ordered sequence of emoji strings representing a complete burger from bottom to top. At the start of every order, GameState.generateNextOrder() calls .randomElement() on this array to select the target recipe for that round. Each Level always contains exactly two possible recipes.
baseTime
Int
required
Countdown timer duration in seconds for the round. The three hand-crafted levels use 40 s, 45 s, and 50 s. Procedural levels apply the formula max(30, 55 - (id * id / 15)), ensuring the timer never drops below 30 seconds even at the highest levels.
isUnlocked
Bool
Controls whether the level node on the map is interactive. Defaults to false for all levels except Level 1, which initialises with isUnlocked: true. Updated in-place by GameState.finishRound(starsEarned:) using array-index mutation.
starsEarned
Int
Highest star rating the player has achieved on this level, in the range 0–3. Persisted for the lifetime of the session (not written to disk). GameState.finishRound(starsEarned:) updates this value with max(existing, new) so replaying a level never lowers the recorded best.

Example: Level 1 Initialisation

The following snippet is taken directly from GameState.setupLevels() and shows the canonical way a Level value is constructed:
Level(
    id: 1,
    name: "Burger Station",
    targetOrders: 3,
    availableIngredients: ["🍞", "🥩", "🧀"],
    possibleRecipes: [
        ["🍞", "🥩", "🍞"],
        ["🍞", "🥩", "🧀", "🍞"]
    ],
    baseTime: 40,
    isUnlocked: true,
    starsEarned: 0
)

Mutability Note

Level is a Swift value type (struct). Although most fields are declared let and are therefore immutable after initialisation, isUnlocked and starsEarned are declared var. This is intentional: GameState stores levels in a @Published var levels: [Level] array and mutates individual entries directly via their index (e.g. self.levels[index].isUnlocked = true), which triggers SwiftUI’s observation machinery and re-renders the level map.
Levels 4–20 are procedurally generated at app launch inside GameState.setupLevels(). Their possibleRecipes arrays are built by calling .randomElement() on the shared ingredient pool at generation time, so the exact recipes inside each procedural level can vary between app launches. Only levels 1–3 have fixed, designer-authored recipes.

Build docs developers (and LLMs) love