Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import { Thing } from '../world/thing';
  2. import { things } from './reducer.things';
  3. import { Room } from '../world/room';
  4. import { IAction, IInventoryAction, IRoomAction } from '../actions/createAction';
  5. import { ACTION_GET, ACTION_MOVE } from '../actions/ActionList';
  6.  
  7. export const room = (state: Room = new Room(), action: IAction) => {
  8.  
  9. let room = new Room();
  10. room.idx = state.idx;
  11. room.directions = [...state.directions];
  12. room.walls = [...state.walls];
  13. room.name = state.name;
  14. room.description = state.description;
  15. room.visited = state.visited;
  16. room.things = action.type === ACTION_GET ? things(state.things, action) : [...state.things];
  17.  
  18. if (action.type === ACTION_MOVE && (<IRoomAction>action).newRoom.visited === false) {
  19. room.visited = true;
  20. }
  21.  
  22. return room;
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement