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

Remove move-piece reducer

We're handling moves on the server side now.
This commit is contained in:
Daniel Barber 2017-01-18 17:33:19 +00:00
parent 7ff1b03f89
commit 31d08cdad1
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
3 changed files with 0 additions and 33 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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
};
}