Compare commits
2 Commits
bfcd8f8761
...
8483168c96
| Author | SHA1 | Date |
|---|---|---|
|
|
8483168c96 | |
|
|
90218f1af2 |
|
|
@ -1,5 +1,6 @@
|
||||||
using ProjectGrid.Models;
|
using ProjectGrid.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ProjectGrid
|
namespace ProjectGrid
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +29,8 @@ namespace ProjectGrid
|
||||||
private TicTacTocBoard _board;
|
private TicTacTocBoard _board;
|
||||||
public TicTacTocBoard Board => _board;
|
public TicTacTocBoard Board => _board;
|
||||||
|
|
||||||
|
public int[] _playerScore = new int[] { 0, 0, 0 };
|
||||||
|
|
||||||
public TicTacTocManager(/*ITicTacToctRepository repo*/)
|
public TicTacTocManager(/*ITicTacToctRepository repo*/)
|
||||||
{
|
{
|
||||||
//_repo = repo;
|
//_repo = repo;
|
||||||
|
|
@ -42,21 +45,25 @@ namespace ProjectGrid
|
||||||
if (_state != State.GAME_OVER)
|
if (_state != State.GAME_OVER)
|
||||||
{
|
{
|
||||||
_board.SetFieldValue(_currentPlayer, move.Field);
|
_board.SetFieldValue(_currentPlayer, move.Field);
|
||||||
// switch between 1 and 2
|
|
||||||
_currentPlayer = 3 - _currentPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
response.Winning = _board.ValueWon(_currentPlayer);
|
response.Winning = _board.ValueWon(_currentPlayer);
|
||||||
if (_currentPlayer > 0 && response.Winning != null)
|
if (_currentPlayer > 0 && response.Winning != null)
|
||||||
{
|
{
|
||||||
response.PlayerWon = _currentPlayer;
|
response.PlayerWon = _currentPlayer;
|
||||||
_state = State.GAME_OVER;
|
_state = State.GAME_OVER;
|
||||||
|
_playerScore[_currentPlayer]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch between 1 and 2
|
||||||
|
_currentPlayer = 3 - _currentPlayer;
|
||||||
}
|
}
|
||||||
response.Board = _board.Field;
|
response.Board = _board.Field;
|
||||||
|
response.PlayerScore = new List<int>(_playerScore);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Restart()
|
public void Restart()
|
||||||
{
|
{
|
||||||
_currentPlayer = new Random().Next(1, 2);
|
_currentPlayer = new Random().Next(1, 2);
|
||||||
|
|
@ -64,6 +71,7 @@ namespace ProjectGrid
|
||||||
_state = State.PLAYING;
|
_state = State.PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TicTacTocResponse GetBoard()
|
public TicTacTocResponse GetBoard()
|
||||||
{
|
{
|
||||||
TicTacTocResponse response = new TicTacTocResponse();
|
TicTacTocResponse response = new TicTacTocResponse();
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,7 @@ namespace ProjectGrid.Models
|
||||||
public List<int> Winning { get; set; }
|
public List<int> Winning { get; set; }
|
||||||
public int NextPlayer { get; set; }
|
public int NextPlayer { get; set; }
|
||||||
public int PlayerWon { get; set; }
|
public int PlayerWon { get; set; }
|
||||||
|
public List<int> PlayerScore { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,11 +23,62 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Don't publish the SPA source files, but do show them in the project files list -->
|
<!-- Don't publish the SPA source files, but do show them in the project files list -->
|
||||||
|
<Compile Remove="clientapp\**" />
|
||||||
<Content Remove="$(SpaRoot)**" />
|
<Content Remove="$(SpaRoot)**" />
|
||||||
|
<Content Remove="clientapp\**" />
|
||||||
|
<EmbeddedResource Remove="clientapp\**" />
|
||||||
<None Remove="$(SpaRoot)**" />
|
<None Remove="$(SpaRoot)**" />
|
||||||
|
<None Remove="clientapp\**" />
|
||||||
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="clientapp\.editorconfig" />
|
||||||
|
<None Remove="clientapp\.gitignore" />
|
||||||
|
<None Remove="clientapp\.vs\clientapp\v16\.suo" />
|
||||||
|
<None Remove="clientapp\.vs\ProjectGrid.frontend\v16\.suo" />
|
||||||
|
<None Remove="clientapp\.vs\ProjectSettings.json" />
|
||||||
|
<None Remove="clientapp\.vs\slnx.sqlite" />
|
||||||
|
<None Remove="clientapp\.vs\tasks.vs.json" />
|
||||||
|
<None Remove="clientapp\.vs\VSWorkspaceState.json" />
|
||||||
|
<None Remove="clientapp\babel.config.js" />
|
||||||
|
<None Remove="clientapp\bin\Microsoft.NodejsTools.WebRole.dll" />
|
||||||
|
<None Remove="clientapp\dist\css\app.91da2c62.css" />
|
||||||
|
<None Remove="clientapp\dist\css\chunk-vendors.55204a1e.css" />
|
||||||
|
<None Remove="clientapp\dist\favicon.ico" />
|
||||||
|
<None Remove="clientapp\dist\index.html" />
|
||||||
|
<None Remove="clientapp\dist\js\app.30ea16fe.js" />
|
||||||
|
<None Remove="clientapp\dist\js\app.30ea16fe.js.map" />
|
||||||
|
<None Remove="clientapp\dist\js\chunk-vendors.e49ff54c.js" />
|
||||||
|
<None Remove="clientapp\dist\js\chunk-vendors.e49ff54c.js.map" />
|
||||||
|
<None Remove="clientapp\obj\Debug\ProjectGrid.frontend.njsproj.AssemblyReference.cache" />
|
||||||
|
<None Remove="clientapp\obj\Debug\ProjectGrid.frontend.njsproj.CoreCompileInputs.cache" />
|
||||||
|
<None Remove="clientapp\obj\Debug\ProjectGrid.frontend.njsproj.FileListAbsolute.txt" />
|
||||||
|
<None Remove="clientapp\package-lock.json" />
|
||||||
|
<None Remove="clientapp\package.json" />
|
||||||
|
<None Remove="clientapp\ProjectGrid.frontend.njsproj" />
|
||||||
|
<None Remove="clientapp\ProjectGrid.frontend.njsproj.user" />
|
||||||
|
<None Remove="clientapp\ProjectGrid.frontend.sln" />
|
||||||
|
<None Remove="clientapp\public\favicon.ico" />
|
||||||
|
<None Remove="clientapp\public\index.html" />
|
||||||
|
<None Remove="clientapp\README.md" />
|
||||||
|
<None Remove="clientapp\src\App.vue" />
|
||||||
|
<None Remove="clientapp\src\assets\logo.png" />
|
||||||
|
<None Remove="clientapp\src\assets\styles\global.css" />
|
||||||
|
<None Remove="clientapp\src\components\CreateUser.vue" />
|
||||||
|
<None Remove="clientapp\src\components\Dashboard.vue" />
|
||||||
|
<None Remove="clientapp\src\components\DisplayBoard.vue" />
|
||||||
|
<None Remove="clientapp\src\components\GameUI.vue" />
|
||||||
|
<None Remove="clientapp\src\components\Header.vue" />
|
||||||
|
<None Remove="clientapp\src\components\Users.vue" />
|
||||||
|
<None Remove="clientapp\src\Game.js" />
|
||||||
|
<None Remove="clientapp\src\main.js" />
|
||||||
|
<None Remove="clientapp\src\Player.js" />
|
||||||
|
<None Remove="clientapp\src\services\TicTacTocService.js" />
|
||||||
|
<None Remove="clientapp\src\services\UserService.js" />
|
||||||
|
<None Remove="clientapp\vue.config.js" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Util\" />
|
<Folder Include="Util\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,9 @@
|
||||||
this.btnText[i.toString()] = game.players[response.board[i]].sign;
|
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() {
|
resetGame() {
|
||||||
//UI and backend reset
|
//UI and backend reset
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue