Example #1
0
        public TournamentSection GetTournaments()
        {
            TournamentSection result = new TournamentSection();
            var opened = GetOpenedTournaments();

            if (opened != null && opened.Any())
            {
                result.All.AddRange(opened.Where(s => s.status.ToLower() != "ended"));
            }

            var known    = GetKnownTournaments();
            var allKnown = new List <TournamentInfo>();

            if (known != null && known.Any())
            {
                //  result.All.AddRange(known.Where(s => s.status.ToLower() != "ended"));
                allKnown = known.Where(s => (s.maxPlayers > s.currentPlayers && s.status.ToLower() != "ended")).ToList();
            }

            // var allOpened = opened.Where(s => (s.maxCapacity>s.playerCount && s.status.ToLower() != "ended"));



            result.All.Sort();
            var allSearchJoinable = result.All.Where(s => s.maxPlayers > s.currentPlayers).ToList();

            allSearchJoinable.Sort();

            List <TournamentInfo> realCheckedJoinable = new List <TournamentInfo>();

            foreach (var tournamentInfo in allSearchJoinable)
            {
                GetTournamentInfo(tournamentInfo.tag);
                if (tournamentInfo.currentPlayers < tournamentInfo.maxPlayers)
                {
                    realCheckedJoinable.Add(tournamentInfo);
                    break;
                }
            }

            // var promotionTournaments = allSearchJoinable.Skip(0).Take(6).ToList();

            var promotionTournaments = allSearchJoinable.Skip(0).Take(6).ToList();

            promotionTournaments.Sort();
            TournamentInfo.SetRealStartDate(promotionTournaments);

            int count = 1;

            result.TournamentPromotion = new List <TournamentPromotion>();
            var promotion = new TournamentPromotion();

            foreach (var promotionTournament in allSearchJoinable)
            {
                if (count == 1)
                {
                    promotion.Title = "Open";
                    result.TournamentPromotion.Add(promotion);
                    promotion.TournamentLeft = promotionTournament;
                }
                if (count == 2)
                {
                    promotion.TournamentMiddle = promotionTournament;
                }
                if (count == 3)
                {
                    promotion.TournamentRight = promotionTournament;
                }
                if (count == 4)
                {
                    promotion = new TournamentPromotion {
                        Title = "Highest Players Capacity"
                    };
                    result.TournamentPromotion.Add(promotion);
                    promotion.TournamentLeft = promotionTournament;
                }
                if (count == 5)
                {
                    promotion.TournamentMiddle = promotionTournament;
                }
                if (count == 6)
                {
                    promotion.TournamentRight = promotionTournament;
                }

                count++;
            }
            result.All.AddRange(allKnown);

            return(result);
        }
Example #2
0
        public TournamentInfo SearchTournaments()
        {
            if (latestFoundTournament != string.Empty)
            {
                var tournamentInfo1 = GetTournamentInfo(latestFoundTournament);
                if (tournamentInfo1.currentPlayers < tournamentInfo1.maxPlayers)
                {
                    return(tournamentInfo1);
                }
            }
            int i = -1;

            //while (i<3)
            //{
            i++;

            TournamentSection result = new TournamentSection();
            var joinable             = GetJoinableTournaments();
            var tournamentInfo       = IsTournamentActive(joinable);

            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }


            var opened            = GetOpenedTournaments();
            var allSearchJoinable = result.All.Where(s => s.maxPlayers > s.currentPlayers).ToList();


            tournamentInfo = IsTournamentActive(allSearchJoinable);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }


            var searched = GetActiveTournamentsbySearch("я в е р т ъ у и о п а с д ф г х");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("й к л з ь ц ж б н м");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("q w e r t");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("1 2 3 4 5 6 7 8 9 0");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("y u i o p [ ]");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("a s d f g h j");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("k l z x c v b");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            searched = GetActiveTournamentsbySearch("n m ; ' , . / ?");

            tournamentInfo = IsTournamentActive(searched);
            if (tournamentInfo != null)
            {
                return(tournamentInfo);
            }

            //    Thread.Sleep(30000);
            // }

            return(new TournamentInfo());
        }
Example #3
0
 public HomePageViewModel()
 {
     ClanMembers = new List <ClanMember>();
     Tournaments = new TournamentSection();
 }