Пример #1
0
        public static async Task <LogicArrayList <AllianceHeaderEntry> > GetAllianceHeaderList(LogicArrayList <LogicLong> ids)
        {
            LogicArrayList <AllianceHeaderEntry> allianceList = new LogicArrayList <AllianceHeaderEntry>(ids.Size());

            Task <IOperationResult <string> >[] results = new Task <IOperationResult <string> > [ids.Size()];

            for (int i = 0; i < ids.Size(); i++)
            {
                results[i] = ServerSearch.AllianceDatabase.Get(ids[i]);
            }

            for (int i = 0; i < ids.Size(); i++)
            {
                IOperationResult <string> result = await results[i];

                if (result.Success)
                {
                    LogicJSONObject     jsonObject          = LogicJSONParser.ParseObject(result.Value);
                    AllianceHeaderEntry allianceHeaderEntry = new AllianceHeaderEntry();

                    allianceHeaderEntry.Load(jsonObject);
                    allianceHeaderEntry.SetAllianceId(new LogicLong(jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_HIGH).GetIntValue(),
                                                                    jsonObject.GetJSONNumber(CouchbaseDocument.JSON_ATTRIBUTE_ID_LOW).GetIntValue()));
                    allianceList.Add(allianceHeaderEntry);
                }
            }

            return(allianceList);
        }
Пример #2
0
        /// <summary>
        /// Initializes the specified alliance.
        /// </summary>
        /// <param name="Clan">The alliance.</param>
        public void Initialize(AllianceHeaderEntry HeaderEntry)
        {
            base.Initialize(HeaderEntry.HighId, HeaderEntry.Name, HeaderEntry.Score, 1, 1);

            this.RegionData   = HeaderEntry.Region;
            this.BadgeData    = HeaderEntry.Badge;
            this.MembersCount = HeaderEntry.MembersCount;
        }
Пример #3
0
        /// <summary>
        /// Decodes this instance.
        /// </summary>
        public override void Decode()
        {
            this.Entries = new AllianceHeaderEntry[this.Stream.ReadVInt()];

            for (int i = 0; i < this.Entries.Length; i++)
            {
                AllianceHeaderEntry Entry = new AllianceHeaderEntry();
                Entry.Decode(this.Stream);
                this.Entries[i] = Entry;
            }
        }
Пример #4
0
        public static AllianceHeaderEntry LoadAllianceHeaderEntry(JObject jsonObject)
        {
            AllianceHeaderEntry allianceHeaderEntry = new AllianceHeaderEntry();

            allianceHeaderEntry.SetAllianceId(new LogicLong((int)jsonObject[CouchbaseDocument.JSON_ATTRIBUTE_ID_HIGH],
                                                            (int)jsonObject[CouchbaseDocument.JSON_ATTRIBUTE_ID_LOW]));
            allianceHeaderEntry.SetAllianceName((string)jsonObject["alliance_name"]);
            allianceHeaderEntry.SetAllianceBadgeId((int)jsonObject["badge_id"]);
            allianceHeaderEntry.SetAllianceType((AllianceType)(int)jsonObject["type"]);
            allianceHeaderEntry.SetNumberOfMembers((int)jsonObject["member_count"]);
            allianceHeaderEntry.SetScore((int)jsonObject["score"]);
            allianceHeaderEntry.SetDuelScore((int)jsonObject["duel_score"]);
            allianceHeaderEntry.SetAllianceLevel((int)jsonObject["xp_level"]);

            return(allianceHeaderEntry);
        }
        public override void Decode()
        {
            base.Decode();

            int count = this.m_stream.ReadInt();

            if (count >= 0)
            {
                this.m_allianceList = new LogicArrayList <AllianceHeaderEntry>(count);

                for (int i = 0; i < count; i++)
                {
                    AllianceHeaderEntry headerEntry = new AllianceHeaderEntry();
                    headerEntry.Decode(this.m_stream);
                    this.m_allianceList.Add(headerEntry);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Clan"/> class.
 /// </summary>
 public Clan()
 {
     this.HeaderEntry = new AllianceHeaderEntry();
     this.Members     = new AllianceMemberEntries();
     this.Messages    = new AllianceStreamEntries();
 }
Пример #7
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.");
                    }
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Alliance"/> class.
 /// </summary>
 internal Alliance()
 {
     this.HeaderEntry = new AllianceHeaderEntry();
     this.Members     = new AllianceMemberEntries(this);
     this.Messages    = new AllianceStreamEntries(this);
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AllianceRankingEntry"/> class.
 /// </summary>
 /// <param name="HeaderEntry">The header entry.</param>
 public AllianceRankingEntry(AllianceHeaderEntry HeaderEntry)
 {
     this.Initialize(HeaderEntry);
 }