xchess
Version:
Chess Engine
142 lines (103 loc) • 1.83 kB
JavaScript
export {ProxyState, Immediate}
import {GameState} from './game-state.js'
function Immediate(State){
return class ImmediateState extends State {
get isImmediate(){
return true;
}
undo(){
this.target.undo();
}
redo(){
this.target.redo();
}
}
}
class ProxyState extends GameState {
#target;
constructor(target, prev){
super(target.context, prev);
this.#target = target.target;
}
// State
get target(){
return this.#target;
}
// Config
get color(){
return this.#target.color;
}
get gameColor(){
return this.#target.gameColor;
}
get count(){
return this.#target.count;
}
get fullmoveNumber(){
return this.#target.fullmoveNumber;
}
get halfmoveClock(){
return this.#target.halfmoveClock;
}
get doubleMovePawn(){
return this.#target.doubleMovePawn;
}
get castling(){
return this.#target.castling;
}
get prevCastling(){
return this.#target.prevCastling;
}
get wk(){
return this.#target.wk;
}
get wq(){
return this.#target.wq;
}
get bk(){
return this.#target.bk;
}
get bq(){
return this.#target.bq;
}
get lastMove(){
return this.#target.lastMove;
}
get moves(){
return this.#target.moves;
}
get isCheck(){
return this.#target.isCheck;
}
get checkKing(){
return this.#target.checkKing;
}
get checkKingTarget(){
return this.#target.checkKingTarget;
}
get hash(){
return this.#target.hash;
}
get repetition(){
return this.#target.repetition;
}
get ownRepetition(){
return this.#target.ownRepetition;
}
get newRepetition(){
return this.#target.newRepetition;
}
get drawOffer(){
return this.#target.drawOffer;
}
setDrawOffer(drawOffer){
this.#target.setDrawOffer(drawOffer);
}
// Stat
get isProxy(){
return true;
}
get isDrawOffer(){
return this.#target.isDrawOffer;
}
}