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) )); }
TurnState( DisboardGame ctx, BoardContext board, TurnContext turn ) : base(ctx) { Board = board; Turn = turn; }
static public TurnState New(DisboardGame ctx, IReadOnlyList <DisboardPlayer> players) { new XanthFactory().OnHelp(ctx.Channel); var board = BoardContext.New(players); var turn = TurnContext.New(board); var next = StartTurn(ctx: ctx, board: board, turn: turn); return(next); }
static TurnState StartTurn(DisboardGame ctx, BoardContext board, TurnContext turn) { TurnState next = new TurnState( ctx: ctx, board: board, turn: turn ); next.PrintTurn(); return(next); }
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) )); }
public TurnContext Next(BoardContext board) => Next_( board: board, nextPlayer: CurrentPlayer.NextPlayer );
public static TurnContext New(BoardContext board) => Next_( board: board, nextPlayer: board.Players.First() );