예제 #1
0
        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);
        }
예제 #2
0
        public void CancelManualPairing()
        {
            foreach (Player player in Rounds.Last().Matches.SelectMany(match => match.Players))
            {
                Rounds.Last().Players.Add(player);
            }

            Rounds.Last().Matches.Clear();
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
파일: Tournament.cs 프로젝트: Gherks/slask
        public RoundBase GetLastRound()
        {
            bool hasNoRounds = Rounds.Count == 0;

            if (hasNoRounds)
            {
                return(null);
            }

            return(Rounds.Last());
        }
예제 #5
0
파일: Tournament.cs 프로젝트: Gherks/slask
        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());
        }
예제 #7
0
        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
            }
        }
예제 #8
0
        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();
        }
예제 #9
0
 public IPlayer GetCurrentPlayer()
 {
     return(Rounds.Last().CurrentPlayer);
 }
예제 #10
0
 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);
 }