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 void CancelManualPairing() { foreach (Player player in Rounds.Last().Matches.SelectMany(match => match.Players)) { Rounds.Last().Players.Add(player); } Rounds.Last().Matches.Clear(); }
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 RoundBase GetLastRound() { bool hasNoRounds = Rounds.Count == 0; if (hasNoRounds) { return(null); } return(Rounds.Last()); }
public PlayStateEnum GetPlayState() { bool hasNotBegun = Rounds.First().GetPlayState() == PlayStateEnum.NotBegun; if (hasNotBegun) { return(PlayStateEnum.NotBegun); } bool lastRoundIsFinished = Rounds.Last().GetPlayState() == PlayStateEnum.Finished; return(lastRoundIsFinished ? PlayStateEnum.Finished : PlayStateEnum.Ongoing); }
public async Task <IActionResult> OnGetAsync([Range(0, 1000)] int round = 0) { if (!ModelState.IsValid) { return(NotFound()); } var now = DateTime.UtcNow; var date = new DateTime(2020, 1, 1); int offset = now.Month - date.Month + (now.Year - date.Year) * 12; Rounds = await _context.Challenges.Where(x => x.State == 3).Select(x => (x.ReleaseDate.Month - date.Month) + (x.ReleaseDate.Year - date.Year) * 12).Distinct().OrderBy(x => x).ToListAsync(); round--; if (!Rounds.Contains(round)) { if (Rounds.Any()) { round = Rounds.Last(); } else { round = offset; } } Index = round; int pageMonthOffset = round % 12; int pageYearOffset = round / 12; int month = date.Month + pageMonthOffset; int year = date.Year + pageYearOffset; if (month < 1) { month += 12; year -= 1; } Round = $"{new DateTime(2020, month, 1).ToString("MMMM", CultureInfo.InvariantCulture)} {year}"; Challenges = await _context.Challenges.Where(x => x.State == 3 && x.ReleaseDate.Month == month && x.ReleaseDate.Year == year).OrderBy(x => x.ReleaseDate).ToListAsync(); Categories = Challenges.Select(x => x.Category).Distinct().ToList(); return(Page()); }
public bool?BetweenRoundsMovementOutcome(BaseCharacter character) { int roll = DiceRoller.TwentySidedDie(); if (roll == 20) { return(true); //Outmaneuver! Advantage on next attack } else if (roll == 1) { return(false); //Stumbled! Disadvantage on next attack } else { if (Rounds.Count > 0 && Rounds.Last().EarnedAdvantage == character) { return(true); //The enemy stumbled at the end of last round (Critical Miss) } return(null); //no significant outcome } }
public async Task PlayerFirst() { //Player's part AddInfoLabel.Content = $"Waiting for the {PlayerHum.Name}'s move."; var plrMove = await PlayersShot(); MoveTask = null; HOS.OutputTheHit(PlayerShotInfo, plrMove, PlayerHum, PlayerPC); Rounds.Add(new Round(plrMove, null)); MovesGrid.Items.Refresh(); AddInfoLabel.Content = ""; //Computer's part var pcMove = CurrentGame.ComputerMove(); HOS.OutputTheHit(PCShotInfo, pcMove, PlayerPC, PlayerHum); Rounds.Last().ComputerMove = pcMove; MovesGrid.Items.Refresh(); }
public IPlayer GetCurrentPlayer() { return(Rounds.Last().CurrentPlayer); }
public void SetResult(Quest quest) { Rounds.Last().Add(quest); }
/// <summary> /// Checks if the game is the bronze match (for playoff scheme) /// </summary> /// <param name="game">Game to check</param> /// <returns>True, if game is the bronze match</returns> public bool IsBronzeMatch(GameResultViewModel game) { return(MaxNumberOfRounds != 0 && game.GameNumber == Rounds.Last().Value.Last().GameNumber - 1); }
/// <summary> /// Checks if the game is the final game (for playoff scheme) /// </summary> /// <param name="game">Game to check</param> /// <returns>True, if game is the final</returns> public bool IsFinal(GameResultViewModel game) { return(MaxNumberOfRounds != 0 && game.GameNumber == Rounds.Last().Value.Last().GameNumber); }