- getAllLongestCaptures(color) {
- let caps = [];
- if (!!this.lastCapture) {
- let locSteps = [ this.lastCapture.step ];
- let res =
- this.getLongestCapturesFrom(this.lastCapture.square, color, locSteps);
- Array.prototype.push.apply(
- caps,
- res.map(r => Object.assign({ square: this.lastCapture.square }, r))
- );
- }
- else {
- for (let i = 0; i < this.size.x; i++) {
- for (let j=0; j < this.size.y; j++) {
- if (
- this.board[i][j] != "" &&
- this.getColor(i, j) == color
- ) {
- let locSteps = [];
- let res = this.getLongestCapturesFrom([i, j], color, locSteps);
- Array.prototype.push.apply(
- caps,
- res.map(r => Object.assign({ square: [i, j] }, r))
- );
- }
- }
- }
- }
- return this.maxLengthIndices(caps).map(i => caps[i]);
- }
-