예제 #1
0
        /// <summary>
        /// Attempts to refresh all heroes.
        /// </summary>
        private async Task<bool> RefreshHeroesAsync() {
            if (asyncLock) {
                return false;
            }
            try {
                asyncLock = true;
                var packet = await packetWriter.SendCommandAsync("41100", "0");
                if (packet == null) {
                    return false;
                }

                barracks = Barracks.Parse(JToken.Parse(packet.Message));
                var details = new List<HeroDetail>();
                var heroIds = new List<int>();
                foreach (var hero in barracks.Heroes) {
                    heroIds.Add(hero.Id);
                    var p1 = await packetWriter.SendCommandAsync("41107", hero.Id.ToString());
                    if (p1 == null) {
                        return false;
                    }
                    var detail = HeroDetail.Parse(JToken.Parse(p1.Message));
                    details.Add(detail);
                }

                heroDetails = details;
                heroList.SetObjects(heroIds, true);
                return true;
            } finally {
                asyncLock = false;
            }
        }
예제 #2
0
파일: HeroDetail.cs 프로젝트: enrevol/tqtk
        public static HeroDetail Parse(JToken token)
        {
            var result     = new HeroDetail();
            var generaldto = token["generaldto"];

            result.Id         = (int)generaldto["generalid"];
            result.Name       = (string)generaldto["generalname"];
            result.Level      = (int)generaldto["generallevel"];
            result.ShiftLevel = (int)generaldto["shiftlv"];
            return(result);
        }