Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut on counter now placing sliced item on counter #87

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading