From 6e97d11f430d5b61940ce3db4c043082e2817852 Mon Sep 17 00:00:00 2001 From: OezmenK Date: Tue, 19 Jul 2022 13:40:44 +0200 Subject: [PATCH] added history --- src/app/board/board.component.ts | 4 ++++ 1 file changed, 4 insertions(+) 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(); }