|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Models.Events;
|
|
|
|
using Models.Events;
|
|
|
|
|
|
|
|
using Models.Rules;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Models.Game
|
|
|
|
namespace Models.Game
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -18,13 +19,13 @@ namespace Models.Game
|
|
|
|
|
|
|
|
|
|
|
|
private int Turn { get; set; }
|
|
|
|
private int Turn { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
private IRules GameRules { get; }
|
|
|
|
private Rules.Rules GameRules { get; }
|
|
|
|
|
|
|
|
|
|
|
|
// == Events ==
|
|
|
|
// == Events ==
|
|
|
|
public event GameStartedEventArgs OnGameStarted;
|
|
|
|
public event GameStartedEventArgs OnGameStarted;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public event GameStartedEventArgs GameStarted; public Game(Player player, Map map)
|
|
|
|
public Game(Player player, Map map)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UsedMap = map;
|
|
|
|
UsedMap = map;
|
|
|
|
CurrentPlayer = player;
|
|
|
|
CurrentPlayer = player;
|
|
|
@ -32,7 +33,6 @@ namespace Models.Game
|
|
|
|
Dice2 = new Dice(1);
|
|
|
|
Dice2 = new Dice(1);
|
|
|
|
Turn = 0;
|
|
|
|
Turn = 0;
|
|
|
|
GameRules = new Rules.Rules();
|
|
|
|
GameRules = new Rules.Rules();
|
|
|
|
ropePaths = new HashSet<RopePath>();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RollAllDice()
|
|
|
|
public void RollAllDice()
|
|
|
@ -46,19 +46,19 @@ namespace Models.Game
|
|
|
|
switch (o)
|
|
|
|
switch (o)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Operation.LOWER:
|
|
|
|
case Operation.LOWER:
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice1.Nb : Dice2.Nb;
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice1.Value : Dice2.Value;
|
|
|
|
|
|
|
|
|
|
|
|
case Operation.HIGHER:
|
|
|
|
case Operation.HIGHER:
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice2.Nb : Dice1.Nb;
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice2.Value : Dice1.Value;
|
|
|
|
|
|
|
|
|
|
|
|
case Operation.SUBTRACTION:
|
|
|
|
case Operation.SUBTRACTION:
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice2.Nb - Dice1.Nb : Dice1.Nb - Dice2.Nb;
|
|
|
|
return Dice1.IsLower(Dice2) ? Dice2.Value - Dice1.Value : Dice1.Value - Dice2.Value;
|
|
|
|
|
|
|
|
|
|
|
|
case Operation.ADDITION:
|
|
|
|
case Operation.ADDITION:
|
|
|
|
return Dice2.Nb + Dice1.Nb;
|
|
|
|
return Dice2.Value + Dice1.Value;
|
|
|
|
|
|
|
|
|
|
|
|
case Operation.MULTIPLICATION:
|
|
|
|
case Operation.MULTIPLICATION:
|
|
|
|
return Dice2.Nb * Dice1.Nb;
|
|
|
|
return Dice2.Value * Dice1.Value;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
@ -67,7 +67,7 @@ namespace Models.Game
|
|
|
|
|
|
|
|
|
|
|
|
public void PlaceResult (Cell playerChoice, int result)
|
|
|
|
public void PlaceResult (Cell playerChoice, int result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Turn == 1 || GameRules.NearCell(playerChoice, UsedMap.Cells))
|
|
|
|
if (Turn == 1 || GameRules.NearCell(playerChoice, UsedMap.Boards))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
playerChoice.Value = result;
|
|
|
|
playerChoice.Value = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|