🐛 items not going into inventory

This commit is contained in:
Chase Manning 2023-11-29 13:41:36 +00:00
commit be0e7d3018
2 changed files with 5 additions and 2 deletions
src
components
state

View file

@ -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 }));
},
})
);
}

View file

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