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.

ChefDash’s shop system is built around two tightly coupled types: the UpgradeType enum, which names each possible power-up effect, and the ShopItem struct, which pairs that effect with a price, an icon, and a quantity counter. Items are consumables — buying one increments quantityOwned, and each use during a round decrements it back. The three items in the shop ("oven", "knife", "sauce") map directly to gameplay mechanics in GameState.

Type Definitions

UpgradeType Enum

import Foundation

// Identificador del tipo de ventaja para aplicar la lógica exacta en la partida
enum UpgradeType: String, Codable {
    case extraTime      // Otorga segundos adicionales (ej: Horno Industrial)
    case comboBooster   // Aumenta el multiplicador inicial (ej: Cuchillo Pro)
    case instantServe   // Permite auto-completar una orden difícil (ej: Salsa Secreta)
}

ShopItem Struct

struct ShopItem: Identifiable {
    let id: String
    let title: String
    let description: String
    let emoji: String
    let price: Int
    let type: UpgradeType

    // Al ser consumibles, controlamos cuántos ha comprado el jugador
    var quantityOwned: Int = 0
}

UpgradeType Cases

CaseItem NameEffect
.extraTimeHorno Industrial 🌋Grants +15 s to the round timer via the onRecipeSuccessBonusTime callback, which fires in triggerSuccess() each time a recipe is completed successfully
.comboBoosterCuchillo Afilado 🔪Sets comboMultiplier = 2 at round start inside startNewRound(), giving the player a head-start on the combo chain instead of beginning at ×1
.instantServeSalsa Secreta 🥫Adds +10 bonus coins per perfect order; triggerSuccess() checks whether a "sauce" item with quantityOwned > 0 exists in shopInventory and includes the bonus in the coin calculation
The .instantServe name is slightly misleading from the source enum comment — in practice the "sauce" item does not auto-complete orders. It awards extra coins per perfect serve. The in-game description ("Añade +10 monedas extra por cada hamburguesa perfecta servida.") is the authoritative description of its effect.

ShopItem Fields

id
String
required
Unique string identifier used for inventory lookup and membership checks in selectedUpgradesForRound: Set<String>. The three valid values are "oven" (Horno Industrial), "knife" (Cuchillo Afilado), and "sauce" (Salsa Secreta).
title
String
required
Display name rendered in ShopView and in the pre-game upgrade selection modal. Examples: "Horno Industrial", "Cuchillo Afilado", "Salsa Secreta".
description
String
required
One-line effect description shown beneath the title in the shop UI. Written to inform the player of the mechanical effect before purchase.
emoji
String
required
Single emoji icon displayed alongside the item title. The three values are "🌋" (oven), "🔪" (knife), and "🥫" (sauce).
price
Int
required
Coin cost to purchase one unit of the item. Deducted from GameState.coins at purchase time. Current prices: Horno Industrial — 50 coins, Cuchillo Afilado — 30 coins, Salsa Secreta — 40 coins.
type
UpgradeType
required
Determines which branch of game logic is activated when this item is consumed. See the UpgradeType cases table above for how each value maps to a concrete in-game effect.
quantityOwned
Int
Number of units currently in the player’s inventory. Defaults to 0. Incremented when purchased in ShopView; decremented inside GameState.startNewRound() for every item whose id appears in selectedUpgradesForRound. A value of 0 means the item cannot be selected for the next round.

Shop Inventory Initialisation

GameState initialises the full shop inventory as a @Published array of ShopItem values:
@Published var shopInventory: [ShopItem] = [
    ShopItem(
        id: "oven",
        title: "Horno Industrial",
        description: "Consumible: Otorga +15s de tiempo extra para la ronda actual.",
        emoji: "🌋",
        price: 50,
        type: .extraTime,
        quantityOwned: 0
    ),
    ShopItem(
        id: "knife",
        title: "Cuchillo Afilado",
        description: "Consumible: Empiezas la ronda con un multiplicador de Combo x2.",
        emoji: "🔪",
        price: 30,
        type: .comboBooster,
        quantityOwned: 0
    ),
    ShopItem(
        id: "sauce",
        title: "Salsa Secreta",
        description: "Consumible: Añade +10 monedas extra por cada hamburguesa perfecta servida.",
        emoji: "🥫",
        price: 40,
        type: .instantServe,
        quantityOwned: 0
    )
]

Consume Flow

Power-ups move through a three-step lifecycle before their effect is applied:
  1. Purchase — The player buys one or more units in ShopView. quantityOwned is incremented and GameState.coins is decremented by price.
  2. Selection — Before starting a round, the player chooses which owned items to activate. Each selected item’s id is inserted into GameState.selectedUpgradesForRound: Set<String>.
  3. Activation & Decrement — When GameState.startNewRound() is called:
    • If "knife" is in selectedUpgradesForRound, comboMultiplier is set to 2 immediately.
    • For every id in selectedUpgradesForRound, the matching ShopItem in shopInventory has its quantityOwned decremented by 1 (only if it was > 0).
    • selectedUpgradesForRound is then cleared.
    • The "oven" effect (+15 s) is delivered later, each time onRecipeSuccessBonusTime fires during the round.
    • The "sauce" bonus coins are checked inside triggerSuccess() for each completed order.
func startNewRound() {
    ordersCompletedInSession = 0
    currentBurgerStack.removeAll()

    comboMultiplier = 1
    if selectedUpgradesForRound.contains("knife") {
        comboMultiplier = 2
    }

    for upgradeId in selectedUpgradesForRound {
        if let index = shopInventory.firstIndex(where: { $0.id == upgradeId }) {
            if shopInventory[index].quantityOwned > 0 {
                shopInventory[index].quantityOwned -= 1
            }
        }
    }

    selectedUpgradesForRound.removeAll()
    generateNextOrder()
}
Because selectedUpgradesForRound is a Set<String>, selecting the same item id twice has no effect — each item is activated at most once per round regardless of quantityOwned. Purchasing multiple units simply means you can use the item across multiple consecutive rounds.

Build docs developers (and LLMs) love