Patch up some imports and exports.
This commit is contained in:
parent
48f9a0f6c0
commit
2f1a169962
|
@ -1,16 +1,4 @@
|
||||||
const { Piece, startingBoard } = require('./logic')
|
const { Piece, startingBoard, BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY } = 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 SHUFFLING_ENABLED = 0;
|
const SHUFFLING_ENABLED = 0;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import Popup from './Popup';
|
||||||
import '../index.css';
|
import '../index.css';
|
||||||
import { Piece, startingBoard, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY, BLACK, WHITE } from '../logic';
|
import { Piece, startingBoard, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY, BLACK, WHITE } from '../logic';
|
||||||
|
|
||||||
|
|
||||||
const Images = [
|
const Images = [
|
||||||
'./white_pawn.svg',
|
'./white_pawn.svg',
|
||||||
'./white_rook.svg',
|
'./white_rook.svg',
|
||||||
|
@ -620,5 +619,4 @@ class Board extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Board;
|
export default Board;
|
||||||
export {Piece};
|
export { Piece, BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY };
|
||||||
export { BLACK, WHITE, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY };
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './style.css';
|
import './style.css';
|
||||||
|
|
||||||
class Popup extends React.Component {
|
class Popup extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className='popup'>
|
<div className='popup'>
|
||||||
|
|
|
@ -6,7 +6,6 @@ import Board from './components/Board';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
|
|
||||||
const ENDPOINT = "https://quickchess.undercover.cafe";
|
const ENDPOINT = "https://quickchess.undercover.cafe";
|
||||||
|
|
||||||
class NameForm extends React.Component {
|
class NameForm extends React.Component {
|
||||||
|
|
26
src/logic.js
26
src/logic.js
|
@ -1,16 +1,16 @@
|
||||||
const BLACK = 0;
|
export const BLACK = 0;
|
||||||
const WHITE = 1;
|
export const WHITE = 1;
|
||||||
|
|
||||||
const PAWN = 0;
|
export const PAWN = 0;
|
||||||
const ROOK = 1;
|
export const ROOK = 1;
|
||||||
const KNIGHT = 2;
|
export const KNIGHT = 2;
|
||||||
const BISHOP = 3;
|
export const BISHOP = 3;
|
||||||
const QUEEN = 4;
|
export const QUEEN = 4;
|
||||||
const KING = 5;
|
export const KING = 5;
|
||||||
|
|
||||||
const EMPTY = -1;
|
export const EMPTY = -1;
|
||||||
|
|
||||||
class Piece {
|
export class Piece {
|
||||||
constructor(color, type) {
|
constructor(color, type) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -75,7 +75,7 @@ class Piece {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const startingBoard = () => {
|
export const startingBoard = () => {
|
||||||
let squares = [];
|
let squares = [];
|
||||||
const mainRow = [ROOK, KNIGHT, BISHOP, QUEEN, KING, BISHOP, KNIGHT, ROOK];
|
const mainRow = [ROOK, KNIGHT, BISHOP, QUEEN, KING, BISHOP, KNIGHT, ROOK];
|
||||||
function add(num, color, type) {
|
function add(num, color, type) {
|
||||||
|
@ -101,7 +101,7 @@ const startingBoard = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const textFromBoard = ({ state }) => {
|
export const textFromBoard = ({ state }) => {
|
||||||
const turn = state?.blackIsNext ? 'B' : 'W';
|
const turn = state?.blackIsNext ? 'B' : 'W';
|
||||||
return turn + state?.squares.map(square => {
|
return turn + state?.squares.map(square => {
|
||||||
if (!square) {
|
if (!square) {
|
||||||
|
@ -128,5 +128,3 @@ const textFromBoard = ({ state }) => {
|
||||||
}
|
}
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { Piece, startingBoard, textFromBoard, PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING, EMPTY, BLACK, WHITE }
|
|
||||||
|
|
Loading…
Reference in New Issue