omakase/data.jai
2025-11-24 23:24:53 +02:00

65 lines
1.4 KiB
Plaintext

State :: struct {
idTicker : int = 0;
recipes : [..]Recipe;
};
get_id :: () -> string {
state.idTicker += 1;
return sprint("REF-%", state.idTicker);
}
Slot :: struct {
id : string;
tags : [..]string;
}
Ingredient :: struct {
name : string;
amount : float;
}
Component :: struct {
isSlot : bool;
slot : Slot;
ingredient : Ingredient;
}
Recipe :: struct {
id : string;
name : string = "New recipe!";
category : string = "Breakfast";
image : string = "https://images.unsplash.com/photo-1546069901-ba9599a7e63c?q=80&w=500&auto=format&fit=crop";
duration : int = 5;
components: [..]Component;
steps : [..]string;
}
state : State;
init_data :: () {
recipe := Recipe.{};
array_add(*recipe.steps, "Testi 1");
array_add(*recipe.steps, "Testi 2");
array_add(*recipe.steps, "Testi 3");
tags : [..]string;
array_add(*tags, "vegetable side");
array_add(*tags, "asia");
array_add(*recipe.components, .{false, .{}, .{"suola (g)", 5}});
array_add(*recipe.components, .{true, .{"", tags}, .{}});
recipe.id = get_id();
array_add(*state.recipes, recipe);
recipe.id = get_id();
array_add(*state.recipes, recipe);
recipe.id = get_id();
array_add(*state.recipes, recipe);
recipe.id = get_id();
array_add(*state.recipes, recipe);
recipe.id = get_id();
array_add(*state.recipes, recipe);
}