예제 #1
0
        } //TODO!!!!!!!!!!!!!!

        //Играет все матчи текущей стадии и формирует новую стадию
        public TournamentStage PlayCurrentStage()
        {
            Console.WriteLine("Играем стадию 1/" + current_stage + "\n");
            TournamentStage cur_stage = stages.Find(x => x.position == current_stage);

            cur_stage.players.ForEach(x => x.position = current_stage);
            this.players.ForEach(x => { if (cur_stage.players.Select(y => y.user_id).Contains(x.user_id))
                                        {
                                            x.position = current_stage;
                                        }
                                 });
            if (cur_stage.position == 0)
            {
                return(cur_stage);                         //турнир окончен
            }
            cur_stage.players = RandomMixPlayers(cur_stage.players);
            List <TournamentMatch> matches = SplitToPairs(cur_stage.players);

            //cur_stage.players.ForEach(x => { if (x.user_id == m.user1_id || x.user_id == m.user2_id) x.match_number = current_match; });
            PlayMatches(ref matches);

            List <int> winners = GetWinnersFromMatchList(matches);

            WriteStageInfoToDB();
            Console.WriteLine("Стадия 1/" + current_stage + " сыграна\n============================\n");
            return(MakeStage(winners));
        }
예제 #2
0
        //Формирует новую стадию по списку победителей прошлой стадии
        public TournamentStage MakeStage(List <int> players)
        {
            //TournamentStage cur_stage = stages.Where(x => x.position == current_stage).First();
            current_stage /= 2;
            TournamentStage stage = new TournamentStage();

            stage.position = current_stage;
            stage.players  = new List <Player>();
            foreach (var x in players)
            {
                Player pl = new Player();
                pl.tour_id = tour_id;
                pl.user_id = x;
                stage.players.Add(pl);
            }
            return(stage);
        }