Patch up some imports and exports.

This commit is contained in:
Sage Vaillancourt 2023-05-18 11:20:11 -04:00
parent 48f9a0f6c0
commit 2f1a169962
5 changed files with 15 additions and 32 deletions

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import React from 'react';
import './style.css';
class Popup extends React.Component {
class Popup extends React.Component {
render() {
return (
<div className='popup'>

View File

@ -6,7 +6,6 @@ import Board from './components/Board';
import './index.css';
const ENDPOINT = "https://quickchess.undercover.cafe";
class NameForm extends React.Component {

View File

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