diff --git a/Logic/TicTacTocBoard.cs b/Logic/TicTacTocBoard.cs index 2031dd5..f8d2b7e 100644 --- a/Logic/TicTacTocBoard.cs +++ b/Logic/TicTacTocBoard.cs @@ -11,7 +11,7 @@ namespace ProjectGrid.Models { private List _field; public List Field => _field; - + private int _lastSetValue; public int LastSetValue => _lastSetValue; diff --git a/Logic/TicTacTocManager.cs b/Logic/TicTacTocManager.cs index bcecd00..5682af4 100644 --- a/Logic/TicTacTocManager.cs +++ b/Logic/TicTacTocManager.cs @@ -1,5 +1,6 @@ using ProjectGrid.Models; using System; +using System.Collections.Generic; namespace ProjectGrid { @@ -28,6 +29,8 @@ namespace ProjectGrid private TicTacTocBoard _board; public TicTacTocBoard Board => _board; + public int[] _playerScore = new int[] { 0, 0, 0 }; + public TicTacTocManager(/*ITicTacToctRepository repo*/) { //_repo = repo; @@ -48,12 +51,14 @@ namespace ProjectGrid { response.PlayerWon = _currentPlayer; _state = State.GAME_OVER; + _playerScore[_currentPlayer]++; } // switch between 1 and 2 _currentPlayer = 3 - _currentPlayer; } response.Board = _board.Field; + response.PlayerScore = new List(_playerScore); return response; } diff --git a/Models/TicTacTocResponse.cs b/Models/TicTacTocResponse.cs index a2a2536..4f23bc6 100644 --- a/Models/TicTacTocResponse.cs +++ b/Models/TicTacTocResponse.cs @@ -8,5 +8,7 @@ namespace ProjectGrid.Models public List Winning { get; set; } public int NextPlayer { get; set; } public int PlayerWon { get; set; } + public List PlayerScore { get; set; } + } } \ No newline at end of file diff --git a/ProjectGrid.csproj b/ProjectGrid.csproj index 004c026..cfb4219 100644 --- a/ProjectGrid.csproj +++ b/ProjectGrid.csproj @@ -23,11 +23,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clientapp/src/components/GameUI.vue b/clientapp/src/components/GameUI.vue index eb4012f..554c4f8 100644 --- a/clientapp/src/components/GameUI.vue +++ b/clientapp/src/components/GameUI.vue @@ -66,6 +66,9 @@ this.btnText[i.toString()] = game.players[response.board[i]].sign; } } + + this.game.players[0].score = response.playerScore[1]; + this.game.players[1].score = response.playerScore[2]; }, resetGame() { //UI and backend reset