Skip to content

Commit

Permalink
Cut on counter now placing sliced item on counter
Browse files Browse the repository at this point in the history
  • Loading branch information
kochaika committed Oct 17, 2024
1 parent 23d3192 commit 41c4492
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion culinaryFrontend/src/components/screens/MainActionsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,34 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr
blenderMap[arg]()
}

let cuttedMap: { [key: string]: string } = {
"FRESH_TOMATO": "CUT_TOMATO",
"FRESH_CUCUMBER": "CUT_CUCUMBER",
"FRESH_CARROT": "CUT_CARROT",
}

function cutOnCounter(arg: string | null){
console.log("cutOnCounter", arg)
if (!arg){
return
}
console.log("counter: ", counterProducts)
if (cuttedMap.hasOwnProperty(arg)) {
let cuttedArg = cuttedMap[arg];
console.log("counter: ", counterProducts)
console.log("filter: ", counterProducts.filter(item => JsItemType[item] !== arg))
counterProductsSetter((prevState) => {
const index = prevState.findIndex(item => JsItemType[item] === arg);
if (index > -1) {
const newState = [...prevState];
newState.splice(index, 1, JsItemType[cuttedArg as keyof typeof JsItemType]);
return newState;
}
return prevState;
});
}
}

function removeFromCounter(arg: string | null) {
console.log("removeFromCounter", arg)
if (!arg){
Expand Down Expand Up @@ -478,7 +505,7 @@ export default function MainActionsScreen({gameStateSetter}: MainActionsScreenPr
"BLEND": blend,
"ADD_TO_BLENDER": addToBlender,
"REMOVE_FROM_COUNTER": removeFromCounter,
"CUT_ON_COUNTER": removeFromCounter
"CUT_ON_COUNTER": cutOnCounter
};

function refill(){
Expand Down

0 comments on commit 41c4492

Please sign in to comment.