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);