Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import { Thing } from '../world/thing';
  2. import { IAction, IInventoryAction } from '../actions/createAction';
  3. import { ACTION_GET } from '../actions/ActionList';
  4.  
  5. export const things = (state: Thing[] = [], action: IAction) => {
  6.  
  7. if (action.type === ACTION_GET) {
  8. let inventoryAction = action as IInventoryAction;
  9. let idx = state.indexOf(inventoryAction.item);
  10. return [...state.slice(0, idx), ...state.slice(idx+1)];
  11. }
  12.  
  13. return state;
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement