public async Task MakeSureTwoRunningRoundsAsync(Money feePerInputs = null, Money feePerOutputs = null) { using (await RoundsListLock.LockAsync().ConfigureAwait(false)) { int runningRoundCount = Rounds.Count(x => x.Status == CoordinatorRoundStatus.Running); int confirmationTarget = await AdjustConfirmationTargetAsync(lockCoinJoins : true).ConfigureAwait(false); if (runningRoundCount == 0) { var round = new CoordinatorRound(RpcClient, UtxoReferee, RoundConfig, confirmationTarget, RoundConfig.ConfirmationTarget, RoundConfig.ConfirmationTargetReductionRate); round.CoinJoinBroadcasted += Round_CoinJoinBroadcasted; round.StatusChanged += Round_StatusChangedAsync; await round.ExecuteNextPhaseAsync(RoundPhase.InputRegistration, feePerInputs, feePerOutputs).ConfigureAwait(false); Rounds.Add(round); var round2 = new CoordinatorRound(RpcClient, UtxoReferee, RoundConfig, confirmationTarget, RoundConfig.ConfirmationTarget, RoundConfig.ConfirmationTargetReductionRate); round2.StatusChanged += Round_StatusChangedAsync; round2.CoinJoinBroadcasted += Round_CoinJoinBroadcasted; await round2.ExecuteNextPhaseAsync(RoundPhase.InputRegistration, feePerInputs, feePerOutputs).ConfigureAwait(false); Rounds.Add(round2); } else if (runningRoundCount == 1) { var round = new CoordinatorRound(RpcClient, UtxoReferee, RoundConfig, confirmationTarget, RoundConfig.ConfirmationTarget, RoundConfig.ConfirmationTargetReductionRate); round.StatusChanged += Round_StatusChangedAsync; round.CoinJoinBroadcasted += Round_CoinJoinBroadcasted; await round.ExecuteNextPhaseAsync(RoundPhase.InputRegistration, feePerInputs, feePerOutputs).ConfigureAwait(false); Rounds.Add(round); } } }
/// <summary> /// Add a given Poker round to the Player /// </summary> /// <param name="convertedRound"> /// The converted Round. /// </param> public IConvertedPokerPlayer Add(IConvertedPokerRound convertedRound) { try { if (convertedRound == null) { throw new ArgumentNullException("convertedRound"); } if (Rounds.Count < 4) { Rounds.Add(convertedRound); } else { throw new ArgumentOutOfRangeException("convertedRound"); } } catch (Exception excep) { Log.Error("Unexpected", excep); } return(this); }
public int Throw(int number = 10) { Round last = Rounds.Last(); if (last.FirstThrow == 0) { last.FirstThrow = number; Sum += number; } else { if (number == 10) { last.IsStrike = true; last.SecondThrow = 0; } else { last.SecondThrow = number; Sum += number; } if (last.FirstThrow + last.SecondThrow == 10 && last.IsStrike == false) { last.IsSpare = true; } last.RoundPoints = last.FirstThrow + last.SecondThrow; AddSpareBonus(); AddStrikeBonus(); Rounds.Add(new Round()); } return(number); }
public async Task MakeSureTwoRunningRoundsAsync() { using (await RoundsListLock.LockAsync()) { int runningRoundCount = Rounds.Count(x => x.Status == CcjRoundStatus.Running); if (runningRoundCount == 0) { var round = new CcjRound(RpcClient, UtxoReferee, RoundConfig); round.StatusChanged += Round_StatusChangedAsync; await round.ExecuteNextPhaseAsync(CcjRoundPhase.InputRegistration); Rounds.Add(round); var round2 = new CcjRound(RpcClient, UtxoReferee, RoundConfig); round2.StatusChanged += Round_StatusChangedAsync; await round2.ExecuteNextPhaseAsync(CcjRoundPhase.InputRegistration); Rounds.Add(round2); } else if (runningRoundCount == 1) { var round = new CcjRound(RpcClient, UtxoReferee, RoundConfig); round.StatusChanged += Round_StatusChangedAsync; await round.ExecuteNextPhaseAsync(CcjRoundPhase.InputRegistration); Rounds.Add(round); } } }
public RoundIdResponse StartNewRound(StartNewRoundRequest newRoundRequest) { string heroName = newRoundRequest.Players[newRoundRequest.HeroIndex].Name; string buttonName = newRoundRequest.Players[newRoundRequest.ButtonIndex].Name; List <Contracts.Player> sittingInPlayers = newRoundRequest.Players.Where(p => !p.SittingOut).ToList(); int heroIndex = sittingInPlayers.FindIndex(p => string.Equals(p.Name, heroName)); int buttonIndex = sittingInPlayers.FindIndex(p => string.Equals(p.Name, buttonName)); var round = new Round(new RoundInput(sittingInPlayers.Count, buttonIndex, sittingInPlayers.Select(p => p.Name).ToList(), sittingInPlayers.Select(p => (int)p.StackSize).ToList(), newRoundRequest.SmallBlindSize, newRoundRequest.BigBlindSize)); Rounds.Add(round.RoundId, round); RoundSetups.Add(round.RoundId, new RoundSetup() { HeroIndex = heroIndex }); Brains.Add(round.RoundId, new Brain()); round.RecordMove(new Move(round.GetCurrentPlayer(), new Decision(DecisionType.Ante, round.SmallBlindSize), StageEnum.Preflop)); round.MoveToNextPlayer(); round.RecordMove(new Move(round.GetCurrentPlayer(), new Decision(DecisionType.Ante, round.BigBlindSize), StageEnum.Preflop)); round.MoveToNextPlayer(); return(new RoundIdResponse() { RoundId = round.RoundId, Action = new ExpectedAction { Action = ExpectedActionEnum.HeroHoles } }); }
public Round Run(IEnumerable <UserInGame> userGames) { if (!_gameStarted) { throw new GameNotStartedException(); } if (TotalRounds == CurrentRound) { throw new GameOverException(); } var randomNumber = _randomGenerator.Generate(_maxGuessNo); var winner = userGames .Select(u => new { Id = u.UserId, Diff = Math.Abs(u.Number - randomNumber) }) .OrderBy(a => a.Diff) .First(); CurrentRound++; RoundsLeft--; var lastRound = TotalRounds == CurrentRound; var newRound = new Round(Id, randomNumber, winner.Id, CurrentRound, lastRound); Rounds.Add(newRound); return(newRound); }
public void StartNewRound() { var newRound = new Round(); Rounds.Add(newRound); _currentRound = newRound; }
public void ThrowRound(int number = 10) { Round round = new Round(); AddStrikeBonus(); int firtsThrow = Throw(number); int secondThrow; AddSpareBonus(); if (firtsThrow == 10) { round.IsStrike = true; secondThrow = 0; } else { secondThrow = Throw(firtsThrow); } if (firtsThrow + secondThrow == 10 && round.IsStrike == false) { round.IsSpare = true; } round.FirstThrow = firtsThrow; round.SecondThrow = secondThrow; round.RoundPoints = firtsThrow + secondThrow; Rounds.Add(round); }
public Round StartNextRound() { var newRound = CreateNewRound(); Rounds.Add(newRound); State = GameState.InProgress; return(newRound); }
public BattleRound DoRound(List <BattleAction> userActions) { var round = new BattleRound(this, userActions); round.DoRound(); Rounds.Add(round); return(round); }
private void OnTimedEvent(object source, ElapsedEventArgs e) { if (FirstWrestler.lifePoint > 0 & SecondWrestler.lifePoint > 0 && Iteration < IterationMax) { if (!midRound) { Rounds.Add(new Round(Iteration + 1)); CurrentRound = Rounds.Last(); Console.WriteLine($"\nRound #{CurrentRound.id}"); Profit += 5000; Console.WriteLine($"{WrestlerRound.Name} choisit sa stratégie!"); CurrentRound.Beginner = WrestlerRound; CurrentRound.FirstAction = WrestlerRound.ChooseAction(SecondWrestler); if (WrestlerRound == FirstWrestler) { WrestlerRound = SecondWrestler; } else { WrestlerRound = FirstWrestler; } midRound = true; } else { Console.WriteLine($"{WrestlerRound.Name} choisit sa stratégie!"); CurrentRound.Second = WrestlerRound; CurrentRound.SecondAction = WrestlerRound.ChooseAction(FirstWrestler); if (WrestlerRound == FirstWrestler) { WrestlerRound = SecondWrestler; } else { WrestlerRound = FirstWrestler; } midRound = false; CurrentRound.PlayRound(); Iteration++; } } else { EndOfMatch(); Console.WriteLine($"Bravo ! Vous avez gagné {Profit} euros"); timer.Enabled = false; timer.Close(); isEnd = true; isReady = false; } }
public override Entities.RoundAuctionsStatus AddRound(RoundAuction newRoundAuction) { if (Rounds == null) { Rounds = new List <RoundAuction>(); } Rounds.Add(newRoundAuction); return(this); }
public void NextRound() { GetNextTeam(); GetNextPlayer(); var round = new Round() { Player = currentPlayer, Team = currentTeam }; Rounds.Add(round); }
public void PlayGame() { while (!IsFinished()) { var round = new RoundModel(new TeamModel[] { Team1, Team2 }); round.PlayRound(); Rounds.Add(round); } }
public void CreateRounds(int holeCount) { if (Rounds.Any()) { throw new InvalidOperationException("Rounds have already been set."); } for (int i = 1; i <= holeCount; i++) { Rounds.Add(new Round(i, 3, this)); } }
protected GameRound MakeRound(GameRound lastRound) { var round = m_gameRoundFactory.Invoke(lastRound); if (round != null) { round.FirstPlayer += m_playerRoundList.GetFirst; round.NextPlayer += m_playerRoundList.GetNext; Rounds.Add(round); } return(round); }
private bool IntegrateRoundToTournament(RoundBase round) { if (CanAddNewRound()) { Rounds.Add(round); round.Construct(); FindIssues(); return(true); } return(false); }
public void StartNewRound() { Round round = new Round(new Wheel(new NumberGenerator()), RoundTime) { RoomId = this.Id }; Rounds.Add(round); roomDAL.Save(round); //Update statement needs to happen here. numberOfRounds++; }
public void SimulateRound() { if (Player.Dead || Enemy.Dead) { return; } var round = new Round(Player, Enemy); FightIsOver = Player.Dead || Enemy.Dead; Rounds.Add(round); Log.Add(round.Description); }
public GameDataViewModel(IUnityContainer container) : base(container) { container.RegisterInstance(this); Players.CollectionChanged += (s, e) => this.UpdatePlayerMap(); for (var i = 0; i < ModuleConstants.DefaultRoundCount; i++) { Rounds.Add(new RoundViewModel { Number = i + 1 }); } }
private Round NextRound() { if (combatant.CurHitPoints > 0 && opponent.CurHitPoints > 0) { Round round = new Round(Rounds.Count + 1, startingCharacterStatistics, characterGoingLastStatistics, combatantAdvantage: BetweenRoundsMovementOutcome(StartingCharacter), opponentAdvantage: BetweenRoundsMovementOutcome(CharacterGoingLast)); Rounds.Add(round); Log.Add(round.ToString()); return(round); } else { return(null); } }
public void AddOrReplaceRound(CcjClientRound round) { lock (StateLock) { foreach (var r in Rounds.Where(x => x.State.RoundId == round.State.RoundId)) { r?.Registration?.AliceClient?.Dispose(); Logger.LogInfo <CcjClientState>($"Round ({round.State.RoundId}) removed. Reason: It's being replaced."); } Rounds.RemoveAll(x => x.State.RoundId == round.State.RoundId); Rounds.Add(round); Logger.LogInfo <CcjClientState>($"Round ({round.State.RoundId}) added."); } }
/// <summary> /// Begins a new round. /// </summary> /// <param name="title">The title of the new round.</param> /// <returns>True on success, false if there is already an active round going.</returns> public bool BeginNewRound(string title) { if (ActiveRound != null) { return(false); } Round r = new Round(title); r.OnCardsFlipped += AutoSortOnFlip; Rounds.Add(r); BroadcastGameState(); return(true); }
/// <summary> /// A method that starts a Round /// </summary> public void StartRound() { // initialize current puzzle CurrentPuzzle = new Puzzle(); // initialize current round CurrentRound = new Round(CurrentPuzzle); // so long as CurrentRound.Winner == null, call StartTurn() while (CurrentRound.Winner == null) { Prompt.StartRound(Rounds.Count + 1); StartTurn(); } // add CurrentRound to Round <List> Rounds.Add(CurrentRound); }
public IRound Play() { IRound round; List <IMovie> roundWinners = Movies.ToList(); do { round = new Round(); round.SetupRound(roundWinners); roundWinners = round.PlayRound().ToList(); Rounds.Add(round); } while (round.Type != Enums.RoundType.Final); return(round); }
public async Task AddMoveAsync(bool isFirst, Move move) { if (RoundTimeOut) { throw new GameFinishedException(GameEndReason.RoundTimeOut); } if (IsFinished) { throw new GameFinishedException(GameEndReason.RivalLeftGame); } await _lockSlim.WaitAsync(); try { Round round; if (Rounds.Count == 0) { round = new Round(); Rounds.Add(round); } else { var lastRound = Rounds[Rounds.Count - 1]; if (lastRound.Player1Move != null && lastRound.Player2Move != null) { round = new Round(); Rounds.Add(round); } else { round = lastRound; } } if (isFirst) { round.Player1Move = move; } else { round.Player2Move = move; } LastMoveTime = DateTime.UtcNow; } finally { _lockSlim.Release(); } }
private void LoadRounds() { Rounds.Clear(); Rounds.Add(1); int currentRound = 1; foreach (List <MatchupModel> matchups in Tournament.Rounds) { if (matchups.First().MatchupRound > currentRound) { currentRound = matchups.First().MatchupRound; Rounds.Add(currentRound); } } }
/// <summary> /// Sets up the default tournament parameters. Creates a first round and sets default judging criterais /// </summary> public void InitializeDefaults() { EnsureListsAreInitialized(); Rounds.Clear(); JudgingCriteria = DefaultDataFactory.GetJudgingCriteria(); foreach (var crit in JudgingCriteria) { crit.Tournament = this; } // Adds a single round called "Finale" var round = new Round(Resources.Text.Finals); round.Tournament = this; round.RoundNo = 1; Rounds.Add(round); }
public void StartNewRound() { Round newRound = new Round(this.Rounds.Count + 1, _roundDAL, _wheel) { RoomId = this.Id, RoundTime = RoundTime }; if (_roomDAL.SaveRound(newRound)) { Rounds.Add(newRound); newRound.Start(); } //Update statement needs to happen here. }
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; } } } }
public static Rounds ParseRounds(XmlNodeList roundsNodeList) { Rounds rounds = new Rounds(); if (roundsNodeList.Count > 0) { foreach (XmlNode round in roundsNodeList) { int roundID = int.Parse(round["ID"].InnerText); TimeSpan bestTime; if (!TimeSpan.TryParse(round["BestTime"].InnerText, out bestTime)) { bestTime = TimeSpan.Zero; } rounds.Add(new Round(roundID, round["Name"].InnerText, round["Variant"].InnerText, bestTime)); } } return rounds; }