From 3b57334dde680bd98db289c52c15bc7c070542a5 Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 24 Apr 2024 17:27:56 +0200 Subject: [PATCH 1/3] Remove porsjonspizza from the rollable pizzas --- config/pizzas.json | 49 ---------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/config/pizzas.json b/config/pizzas.json index 0442fb3..de5e92b 100644 --- a/config/pizzas.json +++ b/config/pizzas.json @@ -13,55 +13,6 @@ "vegetarian": true, "vegan": true }, - { - "description": "ost, tomatsaus og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "101 DEN SINGLE", - "vegetarian": true, - "vegan": false - }, - { - "description": "ost, tomatsaus, pepperoni, r\u00f8dl\u00f8k, r\u00f8d paprika, gul paprika og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "102 VINNEREN", - "vegetarian": false, - "vegan": false - }, - { - "description": "ost, tomatsaus, skinke, sjampinjong, og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "103 FAVORITTEN", - "vegetarian": false, - "vegan": false - }, - { - "description": "ost, tomatsaus, chorizo, r\u00f8dl\u00f8k, pesto og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "104 OPPLEVELSEN", - "vegetarian": false, - "vegan": false - }, - { - "description": "ost, tomatsaus, marinert kylling, pepperoni, r\u00f8dl\u00f8k og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "106 BLANDINGEN", - "vegetarian": false, - "vegan": false - }, - { - "description": "ost, tomatsaus, marinert biff, r\u00f8dl\u00f8k, sjampinjong og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "107 L\u00d8SNINGEN", - "vegetarian": false, - "vegan": false - }, - { - "description": "ost, tomatsaus, r\u00f8dl\u00f8k, sjampinjong, gul paprika, v\u00e5rl\u00f8k og oregano.", - "extra": "Allergener: hvete, melk, selleri", - "name": "108 ENTUSIASTEN", - "vegetarian": true, - "vegan": false - }, { "description": "ost, tomatsaus - og bare det!", "extra": "Allergener: hvete, melk, selleri", From f1345dd6fad9faf9ed3b1e95b0f7413263547279 Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 24 Apr 2024 17:36:55 +0200 Subject: [PATCH 2/3] Kill the VF ones too --- config/pizzas.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/config/pizzas.json b/config/pizzas.json index de5e92b..0b42f36 100644 --- a/config/pizzas.json +++ b/config/pizzas.json @@ -1,18 +1,4 @@ [ - { - "description": "vegansk osteerstatning, tomatsaus - og bare det!\u00a0P\u00e5 30 cm melke-og glutenfri bunn.", - "extra": "Allergener: selleri", - "name": "V-GF01 DEN ENKLE VEGANSK", - "vegetarian": true, - "vegan": true - }, - { - "description": "vegansk osteerstating, tomatsaus, sjampinjong, r\u00f8d paprika, gul paprika og v\u00e5rl\u00f8k. P\u00e5 30 cm melke-og glutenfri bunn.", - "extra": "Allergener: selleri", - "name": "V-GF18 VEGETARIANEREN VEGANSK", - "vegetarian": true, - "vegan": true - }, { "description": "ost, tomatsaus - og bare det!", "extra": "Allergener: hvete, melk, selleri", From e1b7b52d122b896565e5f154d17d9c5ed966ba9b Mon Sep 17 00:00:00 2001 From: Mats Larsen Date: Wed, 24 Apr 2024 18:21:48 +0200 Subject: [PATCH 3/3] Make sure that you can only get personal pizzas in vegan spins --- config/pizzas.json | 133 ++++++++++++++++----------------------------- src/roulette.rs | 20 ++++++- 2 files changed, 64 insertions(+), 89 deletions(-) diff --git a/config/pizzas.json b/config/pizzas.json index 0b42f36..bdc1768 100644 --- a/config/pizzas.json +++ b/config/pizzas.json @@ -1,212 +1,171 @@ [ + { + "description": "vegansk osteerstatning, tomatsaus - og bare det!\u00a0P\u00e5 30 cm melke-og glutenfri bunn.", + "extra": "Allergener: selleri", + "name": "V-GF01 DEN ENKLE VEGANSK", + "vegetarian": true, + "vegan": true, + "personal": true + }, + { + "description": "vegansk osteerstating, tomatsaus, sjampinjong, r\u00f8d paprika, gul paprika og v\u00e5rl\u00f8k. P\u00e5 30 cm melke-og glutenfri bunn.", + "extra": "Allergener: selleri", + "name": "V-GF18 VEGETARIANEREN VEGANSK", + "vegetarian": true, + "vegan": true, + "personal": true + }, { "description": "ost, tomatsaus - og bare det!", "extra": "Allergener: hvete, melk, selleri", "name": "01 DEN ENKLE", - "vegetarian": true, - "vegan": false + "vegetarian": true }, { "description": "ost, tomatsaus, skinke og sjampinjong.", "extra": "Allergener: hvete, melk, selleri", - "name": "02 KVESS", - "vegetarian": false, - "vegan": false + "name": "02 KVESS" }, { "description": "ost, tomatsaus, kj\u00f8ttdeig og r\u00f8d paprika.", "extra": "Allergener: hvete, melk, selleri", - "name": "03 DR\u00d8MMEN", - "vegetarian": false, - "vegan": false + "name": "03 DR\u00d8MMEN" }, { "description": "ost, tomatsaus, kj\u00f8ttdeig, l\u00f8k og bacon.", "extra": "Allergener: hvete, melk, selleri", - "name": "04 PIZZABAKEREN SPESIAL", - "vegetarian": false, - "vegan": false + "name": "04 PIZZABAKEREN SPESIAL" }, { "description": "ost, tomatsaus, kj\u00f8ttdeig, l\u00f8k og ananas.", "extra": "Allergener: hvete, melk, selleri", - "name": "05 SNADDER", - "vegetarian": false, - "vegan": false + "name": "05 SNADDER" }, { "description": "ost, tomatsaus, pepperoni, l\u00f8k og r\u00f8d paprika.", "extra": "Allergener: hvete, melk, selleri", - "name": "06 MIX", - "vegetarian": false, - "vegan": false + "name": "06 MIX" }, { "description": "ost, tomatsaus, marinert kylling, marinert biff, nachoschips, hvitl\u00f8k, mais og chili.", "extra": "Allergener: hvete, melk, selleri", - "name": "07 MEKSIKANEREN", - "vegetarian": false, - "vegan": false + "name": "07 MEKSIKANEREN" }, { "description": "ost, tomatsaus, marinert biff i strimler, bacon og hvitl\u00f8k.", "extra": "Allergener: hvete, melk, selleri", - "name": "08 BIFFEN", - "vegetarian": false, - "vegan": false + "name": "08 BIFFEN" }, { "description": "ost, tomatsaus, marinert biff i strimler, sjampinjong og l\u00f8k.", "extra": "Allergener: hvete, melk, selleri", - "name": "09 DEN MARINERTE", - "vegetarian": false, - "vegan": false + "name": "09 DEN MARINERTE" }, { "description": "ost, tomatsaus, pepperbiff i strimler, sjampinjong, l\u00f8k og r\u00f8d paprika.", "extra": "Allergener: hvete, melk, sennep, selleri", - "name": "10 PEPPERSVENNEN", - "vegetarian": false, - "vegan": false + "name": "10 PEPPERSVENNEN" }, { "description": "ost, tacosaus, kj\u00f8ttdeig, nachoschips og jalape\u00f1os.", "extra": "Allergener: hvete, melk", - "name": "11 FLAMMEN", - "vegetarian": false, - "vegan": false + "name": "11 FLAMMEN" }, { "description": "ost, tacosaus, marinert kylling, nachoschips og\u00a0jalape\u00f1os.", "extra": "Allergener: hvete, melk", - "name": "12 TACOKYLLINGEN", - "vegetarian": false, - "vegan": false + "name": "12 TACOKYLLINGEN" }, { "description": "ost, tomatsaus, marinert kylling, l\u00f8k, mais og sjampinjong.", "extra": "Allergener: hvete, melk, selleri", - "name": "13 KOKKENS KYLLING", - "vegetarian": false, - "vegan": false + "name": "13 KOKKENS KYLLING" }, { "description": "ost, tomatsaus, kj\u00f8ttdeig, luksusbacon og ananas.", "extra": "Allergener: hvete, melk, selleri", - "name": "14 KOKKENS FAVORITT", - "vegetarian": false, - "vegan": false + "name": "14 KOKKENS FAVORITT" }, { "description": "ost, tomatsaus, marinert kylling, luksusbacon, l\u00f8k og r\u00f8d paprika.", "extra": "Allergener: hvete, melk, selleri", - "name": "16 LUKSUSKYLLING", - "vegetarian": false, - "vegan": false + "name": "16 LUKSUSKYLLING" }, { "description": "ost, tomatsaus, marinert kylling, chili, pesto og tomater i skiver.", "extra": "Allergener: hvete, melk, selleri", - "name": "17 KYLLINGFARMEN", - "vegetarian": false, - "vegan": false + "name": "17 KYLLINGFARMEN" }, { "description": "ost, tomatsaus, sjampinjong, r\u00f8d paprika, gul paprika og v\u00e5rl\u00f8k.", "extra": "Allergener: hvete, melk, selleri", "name": "18 VEGETARIANEREN", - "vegetarian": true, - "vegan": false + "vegetarian": true }, { "description": "ost, tomatsaus med chili, kebabkj\u00f8tt, mais, r\u00f8dl\u00f8k og jalape\u00f1o.", "extra": "Toppes med kebab hvitl\u00f8ksdressing", - "name": "19 KEBABEN", - "vegetarian": false, - "vegan": false + "name": "19 KEBABEN" }, { "description": "ost, tomatsaus, skinke og bacon.", "extra": "Allergener: hvete, melk, selleri", - "name": "20 DRENGEN", - "vegetarian": false, - "vegan": false + "name": "20 DRENGEN" }, { "description": "ost, tomatsaus, kj\u00f8ttdeig, pepperoni, l\u00f8k og ananas.", "extra": "Allergener: hvete, melk, selleri", - "name": "21 MR.X", - "vegetarian": false, - "vegan": false + "name": "21 MR.X" }, { "description": "ost, tomatsaus, chorizo, marinert biff og l\u00f8k.", "extra": "Allergener: hvete, melk, selleri", - "name": "22 CHORIZO SPESIAL", - "vegetarian": false, - "vegan": false + "name": "22 CHORIZO SPESIAL" }, { "description": "ost, tomatsaus, skinke, kj\u00f8ttdeig og oregano.", "extra": "Allergener: hvete, melk, selleri", - "name": "23 DOBBELDEKKER", - "vegetarian": false, - "vegan": false + "name": "23 DOBBELDEKKER" }, { "description": "ost, tomatsaus, sterk og marinert kylling, bacon og ananas.", "extra": "Allergener: hvete, melk, selleri", - "name": "24 HEIT KYLLING", - "vegetarian": false, - "vegan": false + "name": "24 HEIT KYLLING" }, { "description": "ost, tomatsaus, chorizo, pesto, oregano og tomat.", "extra": "Allergener: hvete, melk, selleri", - "name": "25 CHORIZOEN", - "vegetarian": false, - "vegan": false + "name": "25 CHORIZOEN" }, { "description": "ost, tomatsaus, pepperoni, skinke og ananas.", "extra": "Allergener: hvete, melk, selleri", - "name": "26 TOSPANNET", - "vegetarian": false, - "vegan": false + "name": "26 TOSPANNET" }, { "description": "ost, tomatsaus, pepperbiff, pepperoni og r\u00f8d paprika.", "extra": "Allergener: hvete, melk, sennep, selleri", - "name": "28 HOTTENTOPPEN", - "vegetarian": false, - "vegan": false + "name": "28 HOTTENTOPPEN" }, { "description": "ost, tomatsaus, marinert svinekj\u00f8tt, bacon, mais, r\u00f8dl\u00f8k. Toppes med deilig BBQ-saus.", "extra": "Allergener: hvete, melk, soya, selleri", - "name": "29 BBQen", - "vegetarian": false, - "vegan": false + "name": "29 BBQen" }, { "description": "ost, tomatsaus med chili, sterk og marinert kylling, r\u00f8dl\u00f8k og jalapeno.", "extra": "Allergener: hvete, melk, selleri", - "name": "31 KRUTTSTERK", - "vegetarian": false, - "vegan": false + "name": "31 KRUTTSTERK" }, { "description": "ost, hvit saus, sterk og marinert kylling, pepperoni, r\u00f8dl\u00f8k, chili og v\u00e5rl\u00f8k.", "extra": "Allergener: hvete, melk, sennep, egg", - "name": "51 T\u00d8FFINGEN", - "vegetarian": false, - "vegan": false + "name": "51 T\u00d8FFINGEN" }, { "description": "ost, hvit saus, r\u00f8d paprika, gul paprika, r\u00f8dl\u00f8k, mais, chili, hvitl\u00f8k og v\u00e5rl\u00f8k.", "extra": "Allergener: hvete, melk, sennep, egg", "name": "52 VEGGIS", - "vegetarian": true, - "vegan": false + "vegetarian": true } ] diff --git a/src/roulette.rs b/src/roulette.rs index a99b6e6..26809f3 100644 --- a/src/roulette.rs +++ b/src/roulette.rs @@ -24,8 +24,15 @@ pub struct PizzaEntry { pub name: String, pub extra: String, pub description: String, + /// Indicates that the pizza contains only vegan-friendly ingredients + #[serde(default)] + /// Indicates that the pizza contains only vegetarian-friendly ingredients pub vegan: bool, + #[serde(default)] pub vegetarian: bool, + /// Indicates that the pizza is a personal size + #[serde(default)] + pub personal: bool, } #[derive(Debug, Clone, Deserialize)] @@ -48,13 +55,22 @@ fn get_random_element(source: &[T]) -> Option<&T> { source.choose(&mut rng) } +/// Get a random pizza from the registry given a filter +/// +/// If the filter is [SpinMode::Any], then you cannot get a personal size pizza. +/// If the filter is [SpinMode::Vegan], then you can only get a vegan pizza, which also implies that +/// the pizza is personal size (see the menu) +/// If the filter is [SpinMode::Vegetarian], then you can only get a vegetarian pizza, and you +/// cannot get a personal size pizza. pub fn get_random_pizza(filter: SpinMode) -> &'static PizzaEntry { let filtered_pizzas: Vec<&PizzaEntry> = PIZZAS .iter() .filter(|pizza_entry| match filter { - SpinMode::Any => true, + SpinMode::Any => !pizza_entry.personal, SpinMode::Vegan => pizza_entry.vegan, - SpinMode::Vegetarian => pizza_entry.vegetarian, + SpinMode::Vegetarian => { + !pizza_entry.personal && pizza_entry.vegetarian && pizza_entry.vegan + } }) .collect();