1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00
chess/app/reducers/chess-board.js

26 lines
641 B
JavaScript

import defaultState from "store/default-state";
const chessBoardReducer = (state = defaultState, action) => {
switch (action.type) {
case "MOVE_PIECE":
var piece = state.board[from.rank][from.file];
state.board[to.rank][to.file] = piece;
state.board[from.rank][from.file] = null;
return state;
var newBoard = state.board.map((item, index) => {
});
return Object.assign({}, state, {
board: newBoard
});
case "SELECT_PIECE":
return Object.assign({}, state, { selectedSquare: action.coords });
default:
return state;
}
}
export default chessBoardReducer;