예제 #1
0
        public CensusEventService(DiscordSocketClient client, XIVAPIService XIVAPI, DbService db)
        {
            _client = client;
            _db     = db;
            _XIVAPI = XIVAPI;

            _cemUnverifiedMembers = new List <ulong>();
        }
예제 #2
0
파일: Program.cs 프로젝트: rreminy/Prima2
        public static async Task Main()
        {
            var http       = new HttpClient();
            var xivapi     = new XIVAPIService(http);
            var exceptions = 0;

            for (var i = 0; i < 20; i++)
            {
                Console.WriteLine("Request {0}/{1}...", i + 1, 20);
                try
                {
                    await xivapi.SearchCharacter("Coeurl", "Karashiir Akhabila");
                }
                catch (XIVAPICharacterNotFoundException)
                {
                    exceptions++;
                }

                await Task.Delay(5000);
            }
            Console.WriteLine("{0} exceptions caught", exceptions);
        }
예제 #3
0
        public static async Task <long> GetCharacterLastActivityTime(GameDataService gameData, XIVAPIService xivapi, JObject fullCharacter)
        {
            long lastActivityTime = -1;

            if (fullCharacter["AchievementsPublic"].ToObject <bool>())
            {
                foreach (AchievementEntry achievement in fullCharacter["Achievements"]["List"].ToObject <IList <AchievementEntry> >())
                {
                    if (achievement.Date * 1000 > lastActivityTime)
                    {
                        lastActivityTime = achievement.Date * 1000;
                    }
                }
            }

            /*foreach (MinionMountEntry minion in fullCharacter["Minions"].Children().ToList() as IList<MinionMountEntry>)
             * {
             *  // Check against minions by patch
             * }
             *
             * foreach (MinionMountEntry mount in fullCharacter["Mounts"].Children().ToList() as IList<MinionMountEntry>)
             * {
             *  // Check against mounts by patch
             * }*/

            // Check gear release times
            List <GearItem> gearItems    = new List <GearItem>();
            var             gearItemsRaw = fullCharacter["Character"]["GearSet"]["Gear"];

            foreach (string piece in _gearPieces)
            {
                if (gearItemsRaw.SelectToken(piece) == null)
                {
                    continue;
                }
                gearItems.Add(gearItemsRaw[piece].ToObject <GearItem>());
            }
            var releaseDates = await xivapi.GetItemsReleaseDates(gearItems
                                                                 .Where(item => item.ID != null)
                                                                 .Select(item => (ushort)item.ID));

            foreach (KeyValuePair <ushort, long> result in releaseDates)
            {
                if (result.Value > lastActivityTime)
                {
                    lastActivityTime = result.Value;
                }
            }

            return(await Task.FromResult(lastActivityTime));
        }
예제 #4
0
 public static async Task <long> GetCharacterLastActivityTime(GameDataService gameData, XIVAPIService xivapi, ulong id)
 => await GetCharacterLastActivityTime(gameData, xivapi, await xivapi.GetCharacter(id));