|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
@ -27,14 +28,20 @@ namespace Models.Game
|
|
|
|
|
public List<BestScore> BestScores { get; set; }
|
|
|
|
|
|
|
|
|
|
private bool _isRunning;
|
|
|
|
|
public bool IsRunning
|
|
|
|
|
{
|
|
|
|
|
get => _isRunning;
|
|
|
|
|
private set => _isRunning = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player CurrentPlayer { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Map UsedMap { get; private set; }
|
|
|
|
|
|
|
|
|
|
private Dice Dice1 { get; }
|
|
|
|
|
private Dice Dice2 { get; }
|
|
|
|
|
public Dice Dice1 { get; private set; }
|
|
|
|
|
public Dice Dice2 { get; private set; }
|
|
|
|
|
|
|
|
|
|
private int Turn { get; set; }
|
|
|
|
|
public int Turn { get; private set; }
|
|
|
|
|
|
|
|
|
|
public Rules.Rules GameRules { get; }
|
|
|
|
|
|
|
|
|
@ -98,25 +105,10 @@ namespace Models.Game
|
|
|
|
|
Games = new List<Game>();
|
|
|
|
|
Maps = new List<Map>();
|
|
|
|
|
BestScores = new List<BestScore>();
|
|
|
|
|
|
|
|
|
|
_isRunning = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="Game"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="player">The player who play the game.</param>
|
|
|
|
|
/// <param name="map">The map to be used in the game.</param>
|
|
|
|
|
public Game(Player player, Map map)
|
|
|
|
|
{
|
|
|
|
|
_isRunning = false;
|
|
|
|
|
UsedMap = map;
|
|
|
|
|
CurrentPlayer = player;
|
|
|
|
|
Dice1 = new Dice();
|
|
|
|
|
Dice2 = new Dice(1);
|
|
|
|
|
Turn = 1;
|
|
|
|
|
|
|
|
|
|
GameRules = new Rules.Rules();
|
|
|
|
|
|
|
|
|
|
IsRunning = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -240,13 +232,30 @@ namespace Models.Game
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes the game.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitializeGame()
|
|
|
|
|
public void InitializeGame(Map map, Player player, bool startImmediately = true)
|
|
|
|
|
{
|
|
|
|
|
UsedMap = map;
|
|
|
|
|
CurrentPlayer = player;
|
|
|
|
|
Turn = 1;
|
|
|
|
|
Dice1 = new Dice();
|
|
|
|
|
Dice2 = new Dice(1);
|
|
|
|
|
|
|
|
|
|
if (startImmediately)
|
|
|
|
|
{
|
|
|
|
|
StartGame();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts the game.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void StartGame()
|
|
|
|
|
{
|
|
|
|
|
_isRunning = true;
|
|
|
|
|
IsRunning = true;
|
|
|
|
|
GameStarted?.Invoke(this, new GameStartedEventArgs(CurrentPlayer));
|
|
|
|
|
GameLoop();
|
|
|
|
|
}
|
|
|
|
@ -256,7 +265,7 @@ namespace Models.Game
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void EndGame(int? pts)
|
|
|
|
|
{
|
|
|
|
|
_isRunning = false;
|
|
|
|
|
IsRunning = false;
|
|
|
|
|
GameEnded?.Invoke(this, new GameEndedEventArgs(CurrentPlayer, pts));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -265,7 +274,7 @@ namespace Models.Game
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void GameLoop()
|
|
|
|
|
{
|
|
|
|
|
while (_isRunning)
|
|
|
|
|
while (IsRunning)
|
|
|
|
|
{
|
|
|
|
|
if (Turn == 20)
|
|
|
|
|
{
|
|
|
|
|