diff --git a/web/static/js/reducers/chess-board.js b/web/static/js/reducers/chess-board.js index 6ac6728..bb1a86f 100644 --- a/web/static/js/reducers/chess-board.js +++ b/web/static/js/reducers/chess-board.js @@ -2,7 +2,6 @@ import Immutable from "immutable"; import { Map } from "immutable"; import defaultState from "../store/default-state"; -import movePiece from "./move-piece"; const chessBoardReducer = (state = defaultState, action) => { switch (action.type) { @@ -17,12 +16,6 @@ const chessBoardReducer = (state = defaultState, action) => { .set("gameId", action.gameId) .toJS(); - case "MOVE_PIECE": - return Immutable.fromJS(state) - .set("board", movePiece(state.board)) - .set("selectedSquare", null) - .toJS(); - case "SELECT_PIECE": return Immutable.fromJS(state) .set("selectedSquare", action.coords) diff --git a/web/static/js/reducers/move-piece.js b/web/static/js/reducers/move-piece.js deleted file mode 100644 index bd97c71..0000000 --- a/web/static/js/reducers/move-piece.js +++ /dev/null @@ -1,17 +0,0 @@ -import Immutable from "immutable"; -import { Map } from "immutable"; - -const movePiece = (board, from, to) => { - const newBoard = Immutable.fromJS(board); - const piece = board[from.rank][from.file]; - - const boardChange = Map([ - [from.rank, Map([[from.file, null]])] - ]).mergeDeep(Map([ - [to.rank, Map([[to.file, piece]])] - ])); - - return newBoard.mergeDeep(boardChange).toJS(); -} - -export default movePiece; diff --git a/web/static/js/store/actions.js b/web/static/js/store/actions.js index 80a95a2..a32b0db 100644 --- a/web/static/js/store/actions.js +++ b/web/static/js/store/actions.js @@ -1,7 +1,6 @@ const SET_BOARD = "SET_BOARD"; const SET_GAME_ID = "SET_GAME_ID"; const SELECT_PIECE = "SELECT_PIECE"; -const MOVE_PIECE = "MOVE_PIECE"; export const setBoard = (board) => { return { @@ -23,11 +22,3 @@ export const selectPiece = (coords) => { coords: coords }; } - -export const movePiece = (from, to) => { - return { - type: MOVE_PIECE, - from: from, - to: to - }; -}