Skip to content

Commit

Permalink
Add spice and taste soup actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kochaika committed Aug 21, 2024
1 parent af517de commit 5968886
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
24 changes: 24 additions & 0 deletions culinaryFrontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
52 changes: 51 additions & 1 deletion culinaryFrontend/src/components/screens/MainActionsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<JsAction>()
axios.get(spiceUrl).then(async (response) => {
actions = response.data as Array<JsAction>
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!")
}
})
}

Expand Down Expand Up @@ -586,6 +627,15 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr
className={"App-button-base App-button-cook"}
onClick={() => cook()}>Soup!
</button>
<button
className={"App-button-base App-button-spice"}
onClick={() => spice()}>Spice!
</button>
<button
className={"App-button-base App-button-taste"}
onClick={() => taste()}>Taste!
</button>

</div>
</div>
);
Expand Down

0 comments on commit 5968886

Please sign in to comment.