class GameConfig { constructor() { this.key = new Uint8Array(4); this.name = ""; //this.user = null; this.pieces = [ ]; this.layout = new GameConfig.Layout(); this.pool = new Uint8Array(14); this.rules = { reverse:0, turn:true, cpu:false, }; //this.actions = [ ]; //this.states = [ ]; } add_piece(piece) { this.pieces.push(piece); return this; } set_pieces(pieces) { this.pieces = pieces; return this; } set_layout(layout) { this.layout = layout; return this; } set_pool(pool) { this.pool = pool; return this; } set_rule(rule, value) { this.rules[rule] = value; return this; } count_pieces() { let count = this.layout.pieces.length; for(let i = 0; i < this.pool.length; ++i) { count += this.pool[i]; } return count; } } GameConfig.Layout = class { constructor() { this.pieces = [ ]; } add_piece(piece_id, player, promote, hex) { this.pieces.push({ piece:piece_id, player:player, promote:promote, hex:hex, }); return this; } mirror(player) { let length = this.pieces.length; for(let i = 0; i < length; ++i) { this.pieces.push({ piece:this.pieces[i].piece, player:player, promote:this.pieces[i].promote, hex:new MATH.Vec2(8 - this.pieces[i].hex.x, 8 - this.pieces[i].hex.y), }); } return this; } }