tagraves / es6-chess Goto Github PK
View Code? Open in Web Editor NEWA simple chess game built on ES6 and node.
A simple chess game built on ES6 and node.
It makes sense to build an extensive test suite. The test suite should send pieces through a preset list of moves that cover every possibility and impossibility.
Use Karma or QUnit.
In some cases, algebraic notation is ambiguous - e.g. there are some cases where two rooks can move to the same spot, so Re8 doesn't convey enough information. The game should specify which rook is moving in these cases (e.g. Rfe8), but it currently doesn't.
Notation is all over the place in the code; this should be moved into a controller Notation.js that gets called by the View when it needs to update the notation pane.
Also, moves are not really being tracked - pieces just have a lot of unnecessary properties that indicate what the previous move was. Why not add a Move class that tracks all of this logic (and stores each move's notation, etc.)? This will eliminate, for example, the justMovedTwo
property of pieces - instead, the game will just check the last move and see if it was a Pawn moving two.
As it is now, we have to manually specify how the DOM should be updated whenever we perform an update. Instead, we should create a representation DOM (ala React) using ES6 maps and have a View.updateDOM() method that checks for changes in the representation and updates accordingly.
As it stands now, pawns cannot promote.
class Pawn {
this.promote = function (pieceType) {
let piece = new pieceType(this.location, this.owner);
//then what?
}
}
The prototype GUI is using the DOM. But why not draw the chessboard and pieces in WebGL with canvas fallback?
As it is now, all of the functions that change one of these also change the other. But why not use a setter to make them watch each other?
class Location {
set occupant (piece) {
this.occupant = piece;
piece.location = this;
}
}
class Piece {
set location (location) {
this.location = location;
location.occupant = this;
}
}
This may fail testing at the moment because of the en passant method which does some tricky stuff.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.