import View from './common/View' ; import Point from '../common/Point' ; import Move from '../common/Move' ; import { PLAYER , PIECE , opponent } from '../common/define' ; import ManagerBase from '../ManagerBase' ; import Layout from './setting/Layout' ; import BoardStyle from './setting/BoardStyle' ; import Record from './Record' ; export default abstract class BoardBase extends View { protected human : PLAYER ; protected computer : PLAYER ; public isThreadCompleted : boolean ; public lock : boolean ; protected mover : PLAYER ; protected messager : ManagerBase | null = null ; protected history : Array < Record > ; constructor ( canvas ) { super ( canvas ) ; this . human = PLAYER . Red ; this . computer = PLAYER . Black ; this . mover = PLAYER . Red ; this . isThreadCompleted = true ; this . lock = false ; this . history = [ ] ; } get currentMover ( ) : PLAYER { return this . mover ; } public isLegalMove ( from , to ) { return this . messager ! . isLegalMove ( new Move ( from . clone ( ) , to . clone ( ) ) ) ; } public isCompuer ( ) { return this . mover === this . computer ; } protected switchMover ( ) { this . mover = opponent ( this . mover ) ; } public setMessager ( messager ) { this . messager = messager ; } abstract update ( move ) ; }