Exemplo n.º 1
0
        /// <summary>
        /// Bypasses the specified top clan.
        /// </summary>
        /// <param name="TopClan">The top clan.</param>
        /// <param name="BypassedClan">The bypassed clan.</param>
        /// <param name="NewlyRanked">if set to <c>true</c> [newly ranked].</param>
        public void Bypass(AllianceRankingEntry TopClan, AllianceRankingEntry BypassedClan, bool NewlyRanked)
        {
            int BypassedIndex = this.Clans.IndexOf(BypassedClan);
            int CurrentIndex  = this.Clans.IndexOf(TopClan);

            if (NewlyRanked)
            {
                if (this.Clans.Count == LeaderboardClans.SeasonMaxClans)
                {
                    this.Clans.RemoveAt(LeaderboardClans.SeasonMaxClans - 1);
                }
            }
            else
            {
                this.Clans.RemoveAt(CurrentIndex);
            }

            this.Clans.Insert(BypassedIndex, TopClan);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the entry.
        /// </summary>
        /// <param name="HeaderEntry">The alliance header entry.</param>
        public async void AddEntry(AllianceHeaderEntry HeaderEntry)
        {
            AllianceRankingEntry TopAlliance  = this.Clans.Find(T => T.EntryId == HeaderEntry.ClanId);
            AllianceRankingEntry BypassedClan = null;

            if (TopAlliance != null)
            {
                TopAlliance.Initialize(HeaderEntry);

                await Task.Run(() =>
                {
                    foreach (AllianceRankingEntry ScoredClan in this.Clans)
                    {
                        if (ScoredClan.EntryId == TopAlliance.EntryId)
                        {
                            continue;
                        }

                        if (ScoredClan.IsBetter(TopAlliance))
                        {
                            break;
                        }

                        BypassedClan = ScoredClan;
                    }
                });

                if (BypassedClan != null)
                {
                    this.Bypass(TopAlliance, BypassedClan, false);
                }
                else
                {
                    Logging.Info(this.GetType(), "The alliance is not good or bad enough to move in leaderboard.");
                }
            }
            else
            {
                TopAlliance = new AllianceRankingEntry(HeaderEntry);

                await Task.Run(() =>
                {
                    foreach (AllianceRankingEntry ScoredClan in this.Clans)
                    {
                        if (ScoredClan.IsBetter(TopAlliance))
                        {
                            break;
                        }

                        BypassedClan = ScoredClan;
                    }
                });

                if (BypassedClan != null)
                {
                    this.Bypass(TopAlliance, BypassedClan, true);
                }
                else
                {
                    int AllianceCount = this.Clans.Count;

                    if (AllianceCount < LeaderboardClans.SeasonMaxClans)
                    {
                        TopAlliance.Order         = AllianceCount;
                        TopAlliance.PreviousOrder = AllianceCount;

                        this.Clans.Add(TopAlliance);
                    }
                    else
                    {
                        Logging.Info(this.GetType(), "The alliance is not good enough to be ranked.");
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Determines whether the specified scored clan is better.
 /// </summary>
 /// <param name="ScoredClan">The scored clan.</param>
 /// <returns>
 ///   <c>true</c> if the specified scored clan is better; otherwise, <c>false</c>.
 /// </returns>
 public bool IsBetter(AllianceRankingEntry ScoredClan)
 {
     return(this.Score > ScoredClan.Score);
 }