Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine(string.Format("Reading in participants from file: {0}", NEW_PARTICIPANTS_FILEPATH));
            var newParticipants = GetParticipantsFromFile(NEW_PARTICIPANTS_FILEPATH);

            Console.WriteLine();

            //Console.WriteLine(string.Format("Reading in participants from file: {0}", PARTICIPANTS_FILEPATH));
            //var existingParticipants = GetParticipantsFromFile(PARTICIPANTS_FILEPATH);
            //Console.WriteLine();

            //var mergedParticipants = newParticipants.Concat(existingParticipants.Where(np => !newParticipants.Any(ep => ep.Name == np.Name))).ToList();

            //Console.WriteLine(string.Format("Updating participants in file: {0}", PARTICIPANTS_FILEPATH));
            //UpdateParticipantFile(PARTICIPANTS_FILEPATH, mergedParticipants);
            //Console.WriteLine();

            Console.WriteLine(string.Format("Adding participants to tournament: {0}", CHALLONGE_TOURNAMENT_KEY));
            ChallongeApiWrapper.BulkAddParticipants(CHALLONGE_TOURNAMENT_KEY, CHALLONGE_USERNAME, CHALLONGE_APIKEY, newParticipants);
            //ChallongeApiWrapper.BulkAddParticipants(CHALLONGE_TOURNAMENT_KEY, CHALLONGE_USERNAME, CHALLONGE_APIKEY, mergedParticipants);
            Console.WriteLine();

            Console.WriteLine("Processing complete. Press any key to exit...");
            Console.ReadKey();
        }
Exemple #2
0
        private static void UpdateTournamentMatches(Object source, ElapsedEventArgs e)
        {
            var participants = ChallongeApiWrapper.GetParticipantList(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY);

            foreach (var participant in participants)
            {
                if (_tournament.Participants.Any(p => p.Id == participant.Id))
                {
                    var tp = _tournament.Participants.Single(p => p.Id == participant.Id);
                    if (tp.Name != participant.Name)
                    {
                        tp.Name = participant.Name;
                    }
                    if (tp.Email != participant.Email)
                    {
                        tp.Email = participant.Email;
                    }
                }
            }

            var matches = ChallongeApiWrapper.GetMatchList(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY);

            ProcessMatches(_tournament, matches);
            AssignStations(_tournament);
            //SendNotifications(_tournament);
        }
Exemple #3
0
        //static void OldMain(string[] args)
        //{
        //    var tournaments = ChallongeApiWrapper.GetTournamentList(CHALLONGE_USERNAME, CHALLONGE_APIKEY, CHALLONGE_SUBDOMAIN);

        //    CsvWriter.WriteLine("tournament-list.csv", "Name of Event, Challonge URL, Participants");
        //    foreach (var tournament in tournaments)
        //    {
        //        var tdata = ChallongeApiWrapper.GetTournament(tournament.ApiUrl, CHALLONGE_USERNAME, CHALLONGE_APIKEY);
        //        var name = tdata.Name;
        //        var url = tdata.UrlAddress();
        //        var numParticipants = tdata.Participants.Count;

        //        CsvWriter.WriteLine("tournament-list.csv", "{0}, {1}, {2}", name, url, numParticipants);

        //        var filename = string.Format("{0}-participants.csv", tdata.ApiUrl);
        //        CsvWriter.WriteLine(filename, "Tournament Name, Participant Name");

        //        foreach (var particiapant in tdata.Participants)
        //        {
        //            var participantName = particiapant.Name;

        //            CsvWriter.WriteLine(filename, "{0}, {1}", name, participantName);
        //        }

        //        filename = string.Format("{0}-results.csv", tdata.ApiUrl);
        //        CsvWriter.WriteLine(filename, "Tournament Name, Winner, Loser");

        //        foreach (var match in tdata.CompleteMatches)
        //        {
        //            var p1name = match.Player1 == null ? "Bye" : match.Player1.Name;
        //            var p2name = match.Player2 == null ? "Bye" : match.Player2.Name;

        //            if (match.WinnerId == match.Player1Id)
        //                CsvWriter.WriteLine(filename, "{0}, {1}, {2}", name, p1name, p2name);
        //            else
        //                CsvWriter.WriteLine(filename, "{0}, {1}, {2}", name, p2name, p1name);
        //        }
        //    }
        //}

        private static void Main(string[] args)
        {
            TournamentKey = ConsoleInputProvider.GetTournamentKey();
            Console.WriteLine();
            var numStations = ConsoleInputProvider.GetNumberOfStations();

            Console.WriteLine();
            var stationsToExclude = ConsoleInputProvider.GetStationsToExclude();

            _tournament = ChallongeApiWrapper.GetTournament(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY);

            // Console Settings
            Console.Title       = string.Format("Challonge Match Viewer - {0}", _tournament.Name);
            Console.WindowWidth = 100;
            //Console.WindowHeight = 84;
            Console.CursorVisible = false;

            // Wait for the tournament to start
            Console.WriteLine(string.Format("Waiting for the '{0}' tournament to start...", _tournament.Name));
            while (_tournament.OpenMatches.Count == 0)
            {
                System.Threading.Thread.Sleep(UPDATE_INTERVAL_SEC * 1000);

                _tournament = ChallongeApiWrapper.GetTournament(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY);
            }

            _tournament.StationManager.AddNewStations(numStations);
            foreach (var station in stationsToExclude)
            {
                _tournament.StationManager.RemoveStation(station);
                _tournament.StationManager.RemoveStation(string.Format("TV {0}", station));
            }

            // Create a timer to ping Challonge for updates to bracket
            var timer = new Timer(UPDATE_INTERVAL_SEC * 1000);

            timer.Elapsed += UpdateTournamentMatches;
            timer.Enabled  = true;
            var startTime = DateTime.Now;

            UpdateTournamentMatches(null, null);

            while (_tournament.OpenMatches.Count != 0)
            {
                OutputMatchesToConsole(_tournament, startTime);

                System.Threading.Thread.Sleep(1000);
            }
        }