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

43 lines
737 B
JavaScript

const SET_PLAYER = "SET_PLAYER";
const SET_GAME = "SET_GAME";
const SET_AVAILABLE_MOVES = "SET_AVAILABLE_MOVES";
const SET_GAME_ID = "SET_GAME_ID";
const SELECT_PIECE = "SELECT_PIECE";
export const setPlayer = (player) => {
return {
type: SET_PLAYER,
player,
};
};
export const setGame = (data) => {
return {
type: SET_GAME,
board: data.board,
turn: data.turn,
state: data.state,
};
};
export const setAvailableMoves = (availableMoves) => {
return {
type: SET_AVAILABLE_MOVES,
availableMoves,
};
};
export const setGameId = (gameId) => {
return {
type: SET_GAME_ID,
gameId,
};
};
export const selectPiece = (coords) => {
return {
type: SELECT_PIECE,
coords,
};
};