diff --git a/src/backend.js b/src/backend.js index eb5bf58..0bd3616 100644 --- a/src/backend.js +++ b/src/backend.js @@ -1,16 +1,4 @@ -const { Piece, startingBoard } = require('./logic') - - -const BLACK = 0; const WHITE = 1; - -const PAWN = 0; -const ROOK = 1; -const KNIGHT = 2; -const BISHOP = 3; -const QUEEN = 4; -const KING = 5; - -const EMPTY = -1; +const { Piece, startingBoard, BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY } = require('./logic') const SHUFFLING_ENABLED = 0; diff --git a/src/components/Board.js b/src/components/Board.js index dd8ca8f..467cda9 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -4,7 +4,6 @@ import Popup from './Popup'; import '../index.css'; import { Piece, startingBoard, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY, BLACK, WHITE } from '../logic'; - const Images = [ './white_pawn.svg', './white_rook.svg', @@ -620,5 +619,4 @@ class Board extends React.Component { } export default Board; -export {Piece}; -export { BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY }; +export { Piece, BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY }; diff --git a/src/components/Popup.js b/src/components/Popup.js index 9911746..55e91c2 100644 --- a/src/components/Popup.js +++ b/src/components/Popup.js @@ -1,7 +1,7 @@ import React from 'react'; import './style.css'; -class Popup extends React.Component { +class Popup extends React.Component { render() { return (
diff --git a/src/index.js b/src/index.js index 042f4bc..442f48b 100644 --- a/src/index.js +++ b/src/index.js @@ -6,7 +6,6 @@ import Board from './components/Board'; import './index.css'; - const ENDPOINT = "https://quickchess.undercover.cafe"; class NameForm extends React.Component { diff --git a/src/logic.js b/src/logic.js index 6e6f181..520742f 100644 --- a/src/logic.js +++ b/src/logic.js @@ -1,16 +1,16 @@ -const BLACK = 0; -const WHITE = 1; +export const BLACK = 0; +export const WHITE = 1; -const PAWN = 0; -const ROOK = 1; -const KNIGHT = 2; -const BISHOP = 3; -const QUEEN = 4; -const KING = 5; +export const PAWN = 0; +export const ROOK = 1; +export const KNIGHT = 2; +export const BISHOP = 3; +export const QUEEN = 4; +export const KING = 5; -const EMPTY = -1; +export const EMPTY = -1; -class Piece { +export class Piece { constructor(color, type) { this.color = color; this.type = type; @@ -75,7 +75,7 @@ class Piece { } } -const startingBoard = () => { +export const startingBoard = () => { let squares = []; const mainRow = [ROOK, KNIGHT, BISHOP, QUEEN, KING, BISHOP, KNIGHT, ROOK]; function add(num, color, type) { @@ -101,7 +101,7 @@ const startingBoard = () => { }); } -const textFromBoard = ({ state }) => { +export const textFromBoard = ({ state }) => { const turn = state?.blackIsNext ? 'B' : 'W'; return turn + state?.squares.map(square => { if (!square) { @@ -128,5 +128,3 @@ const textFromBoard = ({ state }) => { } }).join(''); } - -module.exports = { Piece, startingBoard, textFromBoard, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY, BLACK, WHITE }