private Round.Round GetNextRound() { if (_scores.Values.Any(s => s >= WinningScore)) { return(null); } var deck = Shuffle(); int playerIndex; if (CurrentRound == null) { var maxPlayerIndex = Players.Count() - 1; playerIndex = _randomService.GetInclusive(0, maxPlayerIndex); } else { var playerId = CurrentRound.GetWinningPlayerId().Value; _scores[playerId] = _scores[playerId] + 1; playerIndex = Players .SelectMany((value, index) => value.Id == playerId ? new[] { index } : Enumerable.Empty <int>()) .DefaultIfEmpty(-1).First(); CurrentRound.Cleanup(); } var players = Players.Skip(playerIndex).Concat(Players.Take(playerIndex)); CurrentRound = new Round.Round(players, deck); return(CurrentRound); }
public Ring(Point startPoint, double innerRadius, double outerRadius) : base(startPoint) { if (outerRadius > innerRadius) { this.inner = new Round.Round(startPoint, radius: innerRadius) ?? throw new ArgumentNullException(nameof(innerRadius)); this.outer = new Round.Round(startPoint, radius: outerRadius) ?? throw new ArgumentNullException(nameof(outerRadius)); } else { throw new ArgumentException("The outer radius must be greater than the inner radius"); } }
public Ring(int innerR, int outerR, Round.Point point) { if (innerR >= outerR) { throw new ArgumentException("Outer radius must be greater than inner radius"); } if (innerR <= 0 || outerR <= 0) { throw new ArgumentException("Outer radius and inner radius must be positive "); } this.innerRound = new Round.Round(new Round.Point(point.X, point.Y), innerR); this.outerRound = new Round.Round(new Round.Point(point.X, point.Y), outerR); }
public void StartGame(List <IPlayer> players, Prompt prompt) { DealCards(players); prompt(PromptType.CardsDealt, new Dictionary <PromptData, object> { { PromptData.Players, players }, { PromptData.Blind, Blind } }); // The dealer is the first, so skip them until last foreach (IPlayer player in players.Skip(1)) { if (player.WantPick(prompt, players.Skip(1).Concat(players.Take(1)).ToList())) { ForcedToPick = false; Picker = player; break; } } // If nobody else picked, then dealer is forced if (Picker == null) { ForcedToPick = true; Picker = players[0]; } PartnerCard = Picker.Pick(prompt, this.Blind, ForcedToPick, PartnerCard); Partner = players.Aggregate((IPlayer)null, (agg, player) => player.Hand.Cards.Contains(PartnerCard) && Picker != player ? player : agg); IPlayer roundStarter = players[1]; while (Rounds.Count < 6) { IRound newRound = new Round.Round(Rounds.Count, roundStarter); Rounds.Add(newRound); int i = players.IndexOf(roundStarter); roundStarter = newRound.Start(prompt, players.Skip(i).Concat(players.Take(i)).ToList(), Rounds, Picker, Blind, PartnerCard); while (true) { var answer = prompt(PromptType.RoundOver, new Dictionary <PromptData, object> { { PromptData.Round, newRound } }); if (answer == "done") { break; } } } }