Пример #1
0
        public TurnContext Reroll(BoardContext board, IList <int> dicesToReroll)
        {
            var newDices = Dices.ToList(); //copy

            foreach (int diceToReroll in dicesToReroll)
            {
                if (newDices.Contains(diceToReroll))
                {
                    newDices.RemoveAt(newDices.LastIndexOf(diceToReroll));
                }
                else
                {
                    throw new System.FormatException();
                }
            }
            newDices.AddRange(Enumerable.Range(0, 4 - newDices.Count).Select(_ => RollDice));
            var newDicesArray = newDices.ToArray();

            return(new TurnContext(
                       currentPlayer: CurrentPlayer,
                       dices: newDicesArray,
                       remainReroll: dicesToReroll.Count - 1,
                       remainMove: dicesToReroll.Count,
                       isStuckInThisTurn: board.IsStuck(CurrentPlayer, newDicesArray)
                       ));
        }
Пример #2
0
        static TurnContext Next_(BoardContext board, Player nextPlayer)
        {
            var newDices = RollFourDices;

            return(new TurnContext(
                       currentPlayer: nextPlayer,
                       dices: newDices,
                       remainReroll: 3,
                       remainMove: 4,
                       isStuckInThisTurn: board.IsStuck(nextPlayer, newDices)
                       ));
        }