private void initFromData(ILudoData ludoData) { _ludoData = ludoData; _players = _ludoData.Players; _homeYards = _ludoData.HomeYards; _squares = _ludoData.Squares; _diceHistory = ludoData.DiceHistory; _diceTossed = ludoData.DiceTossed; _playerCount = _ludoData.PlayerCount; _currentPlayer = _ludoData.CurrentPlayer - 1; _winners = _ludoData.Winners.ToList(); _dice = new Dice(); }
public LudoEngine(ILudoRules ludoRules, ILudoData ludoData, int playerCount = 4) { _ludoRules = ludoRules; _ludoData = ludoData; if (ludoData.Exists) { initFromData(ludoData); return; } if (playerCount < 2 || playerCount > MaximumPlayers) { throw new InvalidPlayerCountException("You need 2 - " + MaximumPlayers + " players to play Ludo"); } _playerCount = playerCount; _winners = new List <int>(); initPlayers(); initHomeYards(); initSquares(); _dice = new Dice(); _diceHistory = new List <int>(); _currentPlayer = 0; _diceTossed = false; }