You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Models.Game
|
|
{
|
|
public class Game
|
|
{
|
|
public Player CurrentPlayer { get; private set; }
|
|
|
|
public Map UsedMap { get; private set; }
|
|
|
|
private Dice Dice1 { get; }
|
|
private Dice Dice2 { get; }
|
|
|
|
private int Turn { get; set; }
|
|
|
|
private Rules.Rules GameRules { get; }
|
|
|
|
private HashSet<RopePath> ropePaths { get; }
|
|
|
|
|
|
public Game(Player player, Map map)
|
|
{
|
|
UsedMap = map;
|
|
CurrentPlayer = player;
|
|
Dice1 = new Dice();
|
|
Dice2 = new Dice(1);
|
|
Turn = 0;
|
|
GameRules = new Rules.Rules();
|
|
ropePaths = new HashSet<RopePath>();
|
|
}
|
|
|
|
public void RollAllDice()
|
|
{
|
|
Dice1.Lancer();
|
|
Dice2.Lancer();
|
|
}
|
|
|
|
public int ResultOperation(Operation o)
|
|
{
|
|
switch (o)
|
|
{
|
|
case Operation.LOWER:
|
|
return Dice1.IsLower(Dice2) ? Dice1.Nb : Dice2.Nb;
|
|
|
|
case Operation.HIGHER:
|
|
return Dice1.IsLower(Dice2) ? Dice2.Nb : Dice1.Nb;
|
|
|
|
case Operation.SUBTRACTION:
|
|
return Dice1.IsLower(Dice2) ? Dice2.Nb - Dice1.Nb : Dice1.Nb - Dice2.Nb;
|
|
|
|
case Operation.ADDITION:
|
|
return Dice2.Nb + Dice1.Nb;
|
|
|
|
case Operation.MULTIPLICATION:
|
|
return Dice2.Nb * Dice1.Nb;
|
|
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public void PlaceResult (Cell playerChoice,int result)
|
|
{
|
|
if (Turn == 1 || GameRules.NearCell(playerChoice, UsedMap.Cells))
|
|
{
|
|
playerChoice.Value = result;
|
|
}
|
|
}
|
|
|
|
public void AddToRopePath(Cell cell)
|
|
{
|
|
if (GameRules.IsRopePath(cell, ropePaths)) return;
|
|
|
|
}
|
|
|
|
}
|
|
}
|