mirror of
https://github.com/chase-manning/pokemon-js.git
synced 2025-08-21 17:08:49 +00:00
🐛 items not going into inventory
This commit is contained in:
parent
bf86dc93f8
commit
be0e7d3018
2 changed files with 5 additions and 2 deletions
src
|
@ -8,6 +8,7 @@ import useEvent from "../app/use-event";
|
||||||
import { Event } from "../app/emitter";
|
import { Event } from "../app/emitter";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import {
|
import {
|
||||||
|
addInventory,
|
||||||
collectItem,
|
collectItem,
|
||||||
selectCollectedItems,
|
selectCollectedItems,
|
||||||
selectDirection,
|
selectDirection,
|
||||||
|
@ -66,7 +67,10 @@ const Item = ({ item }: Props) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
showTextThenAction({
|
showTextThenAction({
|
||||||
text: [`${name} found ${itemData[item.item].name}!`],
|
text: [`${name} found ${itemData[item.item].name}!`],
|
||||||
action: () => dispatch(collectItem(item)),
|
action: () => {
|
||||||
|
dispatch(collectItem(item));
|
||||||
|
dispatch(addInventory({ item: item.item, amount: 1 }));
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,6 @@ export const gameSlice = createSlice({
|
||||||
collectItem: (state, action: PayloadAction<MapItemType>) => {
|
collectItem: (state, action: PayloadAction<MapItemType>) => {
|
||||||
const id = `${state.map}-${action.payload.pos.x}-${action.payload.pos.y}`;
|
const id = `${state.map}-${action.payload.pos.x}-${action.payload.pos.y}`;
|
||||||
state.collectedItems.push(id);
|
state.collectedItems.push(id);
|
||||||
addInventory({ item: action.payload.item, amount: 1 });
|
|
||||||
},
|
},
|
||||||
completeQuest: (state, action: PayloadAction<string>) => {
|
completeQuest: (state, action: PayloadAction<string>) => {
|
||||||
state.completedQuests.push(action.payload);
|
state.completedQuests.push(action.payload);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue