From 31d08cdad1f10d1a1ce63863e8c43da81a9a4eea Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Wed, 18 Jan 2017 17:33:19 +0000 Subject: [PATCH] Remove move-piece reducer We're handling moves on the server side now. --- web/static/js/reducers/chess-board.js | 7 ------- web/static/js/reducers/move-piece.js | 17 ----------------- web/static/js/store/actions.js | 9 --------- 3 files changed, 33 deletions(-) delete mode 100644 web/static/js/reducers/move-piece.js 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 - }; -}