From 59688864fc95a6691535e0067bdb00299164ab6b Mon Sep 17 00:00:00 2001 From: Konstantin Chaika Date: Wed, 21 Aug 2024 16:26:02 +0400 Subject: [PATCH] Add spice and taste soup actions --- culinaryFrontend/src/App.css | 24 +++++++++ .../components/screens/MainActionsScreen.tsx | 52 ++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/culinaryFrontend/src/App.css b/culinaryFrontend/src/App.css index 80741d7..fe2f45c 100644 --- a/culinaryFrontend/src/App.css +++ b/culinaryFrontend/src/App.css @@ -139,6 +139,30 @@ background-image: url('assets/buttons/cook_hover.svg'); } +.App-button-spice { + background-size: contain; + width: 15vmin; + height: 5vmin; + color: black; + font-weight: 600; + background-image: url('assets/buttons/cook.svg'); +} +.App-button-spice:hover { + background-image: url('assets/buttons/cook_hover.svg'); +} + +.App-button-taste { + background-size: contain; + width: 15vmin; + height: 5vmin; + color: black; + font-weight: 600; + background-image: url('assets/buttons/cook.svg'); +} +.App-button-taste:hover { + background-image: url('assets/buttons/cook_hover.svg'); +} + /* PRODUCT COUNTER */ .App-counter-container { diff --git a/culinaryFrontend/src/components/screens/MainActionsScreen.tsx b/culinaryFrontend/src/components/screens/MainActionsScreen.tsx index e0a7be2..d0665f5 100644 --- a/culinaryFrontend/src/components/screens/MainActionsScreen.tsx +++ b/culinaryFrontend/src/components/screens/MainActionsScreen.tsx @@ -19,6 +19,8 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr const refillUrl = "/functions/refill-fridge" const soupUrl = "/functions/tomato-soup" + const spiceUrl = "/functions/soup-spices" + const tasteUrl = "/functions/check-soup" type BlenderOptions = { visible: boolean, @@ -540,7 +542,46 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr ) await delay(1500); } - infoTextSetter("🎉 Cooking is done! 🎉") + infoTextSetter("Cooking is done!") + }) + } + + function spice() { + const delay = (ms: number) => new Promise(res => setTimeout(res, ms)); + + let actions = Array() + axios.get(spiceUrl).then(async (response) => { + actions = response.data as Array + console.log("GOT: " + actions) + if (actions.length == 0){ + infoTextSetter("You need to cook the soup first!") + return + } + infoTextSetter("Let's add some spices!") + equipKitchen(actions) + console.log("equipKitchen() DONE") + await delay(1500); + for (const action of actions) { + console.log(infoTextActionMap[String(action.type)] + " " + (action.parameter ? infoTextItemMap[String(action.parameter)] : "")) + infoTextSetter(infoTextActionMap[String(action.type)] + " " + (action.parameter ? infoTextItemMap[String(action.parameter)] : "")) + actionMap[String(action.type)]( + action.parameter ? String(action.parameter) : null + ) + await delay(1500); + } + infoTextSetter("Adding the spices is done!") + }) + } + + function taste() { + axios.get(tasteUrl).then(async (response) => { + let isTasteGood = response.data as boolean + console.log("isTasteGood: " + isTasteGood) + if(isTasteGood){ + infoTextSetter("It tastes great! 🎉") + } else { + infoTextSetter("It tastes so bad... Try it again!") + } }) } @@ -586,6 +627,15 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr className={"App-button-base App-button-cook"} onClick={() => cook()}>Soup! + + + );