コード例 #1
0
ファイル: Tournament.cs プロジェクト: medegor44/Students
        protected void PlayGame(Game game)
        {
            if (!game.IsPlayed)
            {
                if (game.SecondPlayer != null)
                {
                    _printer.EnterPlayerScore(game.FirstPlayer);
                    var firstPlayerScore = _printer.GetPlayerScore();

                    _printer.EnterPlayerScore(game.SecondPlayer);
                    var secondPlayerScore = _printer.GetPlayerScore();

                    while (firstPlayerScore == secondPlayerScore)
                    {
                        _printer.DrawIsNotPossible();

                        _printer.EnterPlayerScore(game.FirstPlayer);
                        firstPlayerScore = _printer.GetPlayerScore();

                        _printer.EnterPlayerScore(game.SecondPlayer);
                        secondPlayerScore = _printer.GetPlayerScore();
                    }

                    game.Play(firstPlayerScore, secondPlayerScore);

                    _printer.PrintGameResult(game);
                }
                else
                {
                    game.Play();
                }

                SaveLoadSystem.Save(this);
            }
        }
コード例 #2
0
ファイル: Tournament.cs プロジェクト: medegor44/Students
        public virtual void StartTournament()
        {
            WinnersGrid = new List <List <Game> >();
            WinnersGrid.Add(new List <Game>());

            DataInput dataInput = new DataInput(_printer);

            CountOfPlayers = dataInput.GetCountOfPlayers();
            var players = dataInput.GetPlayersList(CountOfPlayers);

            for (int i = 0; i < players.Count; i += 2)
            {
                var    firstPlayer  = players[i];
                Player secondPlayer = null;

                if (i != players.Count - 1)
                {
                    secondPlayer = players[i + 1];
                }

                WinnersGrid[_currentWinnersStage].Add(new Game(firstPlayer, secondPlayer));
                _gamesOnCurrentWinnersStage++;
            }

            SaveLoadSystem.Save(this);
        }
コード例 #3
0
ファイル: Tournament.cs プロジェクト: medegor44/Students
        protected void InitNewWinnersGridStage()
        {
            _currentWinnersStage++;
            FillNewStage(WinnersGrid, _currentWinnersStage);
            _gamesOnCurrentWinnersStage = WinnersGrid[_currentWinnersStage].Count;

            SaveLoadSystem.Save(this);
        }
コード例 #4
0
        public override void StartTournament()
        {
            base.StartTournament();

            LosersGrid = new List <List <Game> >();
            LosersGrid.Add(new List <Game>());

            SaveLoadSystem.Save(this);
        }
コード例 #5
0
        private void InitNewLosersGridStage()
        {
            _currentLosersStage++;

            if (_currentLosersStage > 0)
            {
                FillNewStage(LosersGrid, _currentLosersStage);
                _gamesOnCurrentLosersStage = LosersGrid[_currentLosersStage].Count;
            }

            if (_currentLosersStage <= _currentWinnersStage)
            {
                FillLosersStageByWinnersGrid();
            }

            SaveLoadSystem.Save(this);
        }