From be0e7d3018b4913a1840894413d2d03b75f37a25 Mon Sep 17 00:00:00 2001 From: Chase Manning <chase@manning.dev> Date: Wed, 29 Nov 2023 13:41:36 +0000 Subject: [PATCH] :bug: items not going into inventory --- src/components/Item.tsx | 6 +++++- src/state/gameSlice.ts | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Item.tsx b/src/components/Item.tsx index 61f6331..327f726 100644 --- a/src/components/Item.tsx +++ b/src/components/Item.tsx @@ -8,6 +8,7 @@ import useEvent from "../app/use-event"; import { Event } from "../app/emitter"; import { useDispatch, useSelector } from "react-redux"; import { + addInventory, collectItem, selectCollectedItems, selectDirection, @@ -66,7 +67,10 @@ const Item = ({ item }: Props) => { dispatch( showTextThenAction({ text: [`${name} found ${itemData[item.item].name}!`], - action: () => dispatch(collectItem(item)), + action: () => { + dispatch(collectItem(item)); + dispatch(addInventory({ item: item.item, amount: 1 })); + }, }) ); } diff --git a/src/state/gameSlice.ts b/src/state/gameSlice.ts index bf09eee..13889ff 100644 --- a/src/state/gameSlice.ts +++ b/src/state/gameSlice.ts @@ -334,7 +334,6 @@ export const gameSlice = createSlice({ collectItem: (state, action: PayloadAction<MapItemType>) => { const id = `${state.map}-${action.payload.pos.x}-${action.payload.pos.y}`; state.collectedItems.push(id); - addInventory({ item: action.payload.item, amount: 1 }); }, completeQuest: (state, action: PayloadAction<string>) => { state.completedQuests.push(action.payload);