diff --git a/src/app/board/board.component.ts b/src/app/board/board.component.ts index c108103..aec2a85 100644 --- a/src/app/board/board.component.ts +++ b/src/app/board/board.component.ts @@ -10,6 +10,7 @@ export class BoardComponent implements OnInit { draw: boolean; xIsNext: boolean; fields: any[]; + history: any[]; constructor() {} @@ -22,6 +23,7 @@ export class BoardComponent implements OnInit { this.draw = false; this.xIsNext = true; this.fields = Array(9).fill(null); + this.history = []; } get player() { @@ -36,6 +38,8 @@ export class BoardComponent implements OnInit { if (!this.fields[i]) { this.fields.splice(i, 1, this.player); + this.history.push(this.fields.slice()); + this.xIsNext = !this.xIsNext; this.calculateWinner(); }