コード例 #1
0
ファイル: ClubBan.cs プロジェクト: lyosky/CypherCore
        public override int GetHashCode()
        {
            int hash = 1;

            if (HasId)
            {
                hash ^= Id.GetHashCode();
            }
            if (HasBattleTag)
            {
                hash ^= BattleTag.GetHashCode();
            }
            if (HasCreator)
            {
                hash ^= Creator.GetHashCode();
            }
            hash ^= attribute_.GetHashCode();
            if (HasReason)
            {
                hash ^= Reason.GetHashCode();
            }
            if (HasCreationTime)
            {
                hash ^= CreationTime.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (AccountPaid != false)
            {
                hash ^= AccountPaid.GetHashCode();
            }
            if (CountryId != 0)
            {
                hash ^= CountryId.GetHashCode();
            }
            if (BattleTag.Length != 0)
            {
                hash ^= BattleTag.GetHashCode();
            }
            if (ManualReview != false)
            {
                hash ^= ManualReview.GetHashCode();
            }
            if (identity_ != null)
            {
                hash ^= Identity.GetHashCode();
            }
            if (AccountMuted != false)
            {
                hash ^= AccountMuted.GetHashCode();
            }
            return(hash);
        }
コード例 #3
0
        private static Career FetchCareer(BattleTag battleTag, Host host)
        {
            D3Api.Host = host.Url;

            Career career;

            try
            {
                career = Career.CreateFromBattleTag(battleTag);
            }
            catch (FileNotInCacheException)
            {
                MessageBox.Show("Career was not found in cache: go online to retrieve it.");
                return(null);
            }
            catch (BNetResponse403Exception)
            {
                MessageBox.Show("Battle.net sent an http error: 403 - Too much requests ?");
                return(null);
            }
            catch (BNetResponseFailedException)
            {
                MessageBox.Show("Battle.net sent an http error: try again later.");
                return(null);
            }
            catch (BNetFailureObjectReturnedException)
            {
                MessageBox.Show("Battle.net sent an error: verify the battle tag.");
                return(null);
            }

            return(career);
        }
コード例 #4
0
        private void guiProfileLookup_Click(object sender, EventArgs e)
        {
            var battleTag = new BattleTag(guiBattleTag.Text);

            var node = new TreeNode("Career of " + battleTag + " on " + D3Api.Host);

            Career career;

            try
            {
                career = Career.CreateFromBattleTag(battleTag);
            }
            catch (FileNotInCacheException)
            {
                MessageBox.Show("Career was not found in cache: go online to retrieve it.");
                return;
            }
            catch (BNetResponseFailedException)
            {
                MessageBox.Show("Battle.net sent an http error: try again later.");
                return;
            }
            catch (BNetFailureObjectReturnedException)
            {
                MessageBox.Show("Battle.net sent an error: verify the battle tag.");
                return;
            }

            node.Tag = new BNetContext <Career>(D3Api.Host, battleTag, career);

            node.Nodes.AddRange(CreateNodeFromD3Object(career).ToArray());

            guiD3ProfileTreeView.Nodes.Add(node);
        }
コード例 #5
0
        private void guiProfileLookup_Click(object sender, EventArgs e)
        {
            var battleTag = new BattleTag(guiBattleTag.Text);

            var node = new TreeNode("Career of " + battleTag + " on " + D3Api.Host);

            Career career;

            try
            {
                career = Career.CreateFromBattleTag(battleTag);
            }
            catch (FileNotInCacheException)
            {
                MessageBox.Show(Resources.CareerWasNotFoundInCache);
                return;
            }
            catch (BNetResponseFailedException)
            {
                MessageBox.Show(Resources.BattleNetSentHttpError);
                return;
            }
            catch (BNetFailureObjectReturnedException)
            {
                MessageBox.Show(Resources.BattleNetSentError);
                return;
            }

            node.Tag = new BNetContext <Career>(D3Api.Host, battleTag, career);

            node.Nodes.AddRange(CreateNodeFromD3Object(career).ToArray());

            guiD3ProfileTreeView.Nodes.Add(node);
        }
コード例 #6
0
        private void guiAddProfile_Click(object sender, EventArgs e)
        {
            BattleTag battleTag;

            try
            {
                battleTag = new BattleTag(guiBattleTag.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Battle Tag syntax is invalid: verify the battle tag.");
                return;
            }

            var host = (Host)guiBattleNetHostList.SelectedItem;

            var profileExists = config.Profiles.Any(p => p.BattleTag.Id.ToLower() == battleTag.Id.ToLower() && p.Host.Url == host.Url);

            if (profileExists)
            {
                MessageBox.Show("The profile already exists.");
                return;
            }

            FetchCareer(battleTag, host);

            var profileContainer = new D3ProfileContainer(battleTag, host);

            config.Profiles.Add(profileContainer);

            AddProfile(profileContainer);
        }
コード例 #7
0
        private static Hero FetchHero(HeroSummary heroSummary, BattleTag battleTag, Host host)
        {
            D3Api.Host = host.Url;

            Hero hero;

            try
            {
                hero = heroSummary.GetHeroFromBattleTag(battleTag);
            }
            catch (FileNotInCacheException)
            {
                MessageBox.Show("Hero was not found in cache: go online to retrieve it.");
                return(null);
            }
            catch (BNetResponseFailedException)
            {
                MessageBox.Show("Battle.net sent an http error: try again later.");
                return(null);
            }
            catch (BNetFailureObjectReturnedException)
            {
                MessageBox.Show("Battle.net sent an error: verify the battle tag.");
                return(null);
            }

            return(hero);
        }
コード例 #8
0
 public string GetBattleTag()
 {
     if (String.IsNullOrEmpty(BattleTag))
     {
         throw new ArgumentException("Name is not defined");
     }
     return(BattleTag.Replace("#", "-"));
 }
コード例 #9
0
ファイル: D3Api.cs プロジェクト: rangeryu/D3-API-by-ZTn
        public static Career GetCareerFromBattleTag(BattleTag battleTag)
        {
            Career career;

            using (var stream = DataProvider.FetchData(GetCareerUrl(battleTag) + "/index" + ApiLocaleSuffix))
            {
                career = Career.CreateFromJSonStream(stream);
            }
            return(career);
        }
コード例 #10
0
ファイル: D3Api.cs プロジェクト: rangeryu/D3-API-by-ZTn
        public static Hero GetHeroFromHeroId(BattleTag battleTag, String heroId)
        {
            Hero hero;

            using (var stream = DataProvider.FetchData(GetHeroUrlFromHeroId(battleTag, heroId) + ApiLocaleSuffix))
            {
                hero = Hero.CreateFromJSonStream(stream);
            }
            return(hero);
        }
コード例 #11
0
        public static Account Parse(string strAccountString)
        {
            string[] vTemp = strAccountString.Split('_');

            BattleTag battleTag = new BattleTag()
            {
                Name   = vTemp[0],
                Number = Convert.ToInt32(vTemp[1])
            };

            return(new Account(battleTag, (Region)Enum.Parse(typeof(Region), vTemp[2])));
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: ybug/D3-API-by-ZTn
        private static void WriteCareer(BattleTag battleTag)
        {
            var career = Career.CreateFromBattleTag(battleTag);

            Console.WriteLine("BattleTag: " + career.BattleTag.Id);
            Console.WriteLine("Last hero played: {0}", career.LastHeroPlayed);
            Console.WriteLine("Time played on Monk is {0}", career.TimePlayed.Monk);
            Console.WriteLine("Kills: monsters={0} / elites={1} / hardcore monsters={2}", career.Kills.Monsters, career.Kills.Elites,
                              career.Kills.HardcoreMonsters);
            Console.WriteLine();
            Console.WriteLine("Heroes count: " + career.Heroes.Length);
            foreach (var heroDigest in career.Heroes)
            {
                Console.WriteLine("Hero {0}: {1} is {2} level {3} + {4} last updated {5}",
                                  heroDigest.Id,
                                  heroDigest.Name,
                                  heroDigest.HeroClass,
                                  heroDigest.Level,
                                  heroDigest.ParagonLevel, heroDigest.LastUpdated);

                var heroFull = heroDigest.GetHeroFromBattleTag(battleTag);

                if (heroFull.Items.MainHand != null)
                {
                    var mainHand = Item.CreateFromTooltipParams(heroFull.Items.MainHand.TooltipParams);
                    Console.WriteLine("Hero main hand: level {0} {1} (DPS {2}-{3}) is of type {4}",
                                      mainHand.ItemLevel,
                                      mainHand.Name,
                                      mainHand.Dps.Min, mainHand.Dps.Max,
                                      mainHand.TypeName);
                }

                if (heroFull.Items.Torso != null)
                {
                    var torso = Item.CreateFromTooltipParams(heroFull.Items.Torso.TooltipParams);
                    Console.WriteLine("Hero torso: level {0} {1} (armor {2}-{3}) is of type {4}",
                                      torso.ItemLevel,
                                      torso.Name,
                                      torso.Armor.Min, torso.Armor.Max,
                                      torso.TypeName);
                }

                Console.WriteLine("Hero DPS {0}", heroFull.Stats.Damage);
            }
            Console.WriteLine();
            Console.WriteLine("Fallen Heroes count: " + career.FallenHeroes.Length);
            foreach (var heroDigest in career.FallenHeroes)
            {
                Console.WriteLine("Hero {0}: {1} is {2} level {3} + {4} ", heroDigest.Id, heroDigest.Name, heroDigest.Hardcore, heroDigest.Level,
                                  heroDigest.ParagonLevel);
            }
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: ybug/D3-API-by-ZTn
        private static void Main(string[] args)
        {
            D3Api.ApiKey = ApiKey;

            var battleTag = new BattleTag("Tok#2360");

            // WriteCareer(battleTag);
            WriteCalculation(battleTag).Wait();

            Console.WriteLine();
            Console.WriteLine("= = = = END = = = =");
            Console.ReadLine();
        }
コード例 #14
0
        private static void Main(string[] args)
        {
            RegisterPcl.Register();

            var battleTag = new BattleTag("Tok#2360");

            // WriteCareer(battleTag);
            WriteCalculation(battleTag);

            Console.WriteLine();
            Console.WriteLine("= = = = END = = = =");
            Console.ReadLine();
        }
コード例 #15
0
ファイル: DiabloProfile.cs プロジェクト: Xenophik/WContact
 /// <summary>
 /// Handle deserialization of hero collection
 /// </summary>
 /// <param name="heroCollection">hero collection</param>
 private void OnHeroCollectionDeserialized(IList <Hero> heroCollection)
 {
     if (heroCollection != null)
     {
         foreach (var hero in heroCollection)
         {
             if (hero != null)
             {
                 hero.Path = "/api/d3/profile/" + BattleTag.Replace('#', '-') + "/hero/" + hero.Id;
             }
         }
     }
 }
コード例 #16
0
 public Player(int id, string name, int standardRank, int standardLegendRank, int standardStars, int wildRank, int wildLegendRank, int wildStars, int cardBackId, AccountId accountId, BattleTag battleTag)
 {
     Id                 = id;
     Name               = name;
     StandardRank       = standardRank;
     StandardLegendRank = standardLegendRank;
     StandardStars      = standardStars;
     WildRank           = wildRank;
     WildLegendRank     = wildLegendRank;
     WildStars          = wildStars;
     CardBackId         = cardBackId;
     AccountId          = accountId;
     BattleTag          = battleTag;
 }
コード例 #17
0
 public Collection(ulong accountHi, ulong accountLo, BattleTag battleTag, HearthMirror.Objects.Collection collection)
 {
     AccountHi = accountHi;
     AccountLo = accountLo;
     BattleTag = $"{battleTag.Name}#{battleTag.Number}";
     Cards     = new SortedDictionary <int, int[]>(
         collection.Cards.GroupBy(x => x.Id)
         .ToDictionary(x => GetDbfId(x.Key),
                       x => new[] { x.FirstOrDefault(c => !c.Premium)?.Count ?? 0, x.FirstOrDefault(c => c.Premium)?.Count ?? 0 }));
     FavoriteHeroes   = new SortedDictionary <int, int>(collection.FavoriteHeroes.ToDictionary(x => x.Key, x => GetDbfId(x.Value.Id)));
     CardBacks        = collection.CardBacks.OrderBy(x => x).ToList();
     FavoriteCardBack = collection.FavoriteCardBack;
     Dust             = collection.Dust;
 }
コード例 #18
0
        public Account(BattleTag battleTag, Region region)
        {
            BattleTag = battleTag;
            Region    = region;

            if (BattleTag != null)
            {
                AccountString = $"{battleTag.Name}_{battleTag.Number}_{region}";
            }
            else
            {
                AccountString = string.Empty;
            }
        }
コード例 #19
0
        private void ShowCareer(Career career, BattleTag battleTag, Host host)
        {
            if (career == null)
            {
                return;
            }

            guiHeroesPanel.Controls.Clear();
            foreach (var hero in career.Heroes)
            {
                var control = new D3HeroControl(hero);
                control.Click += d3HeroControl_Click;
                control.Tag    = new D3HeroContainer(hero, battleTag, host);
                guiHeroesPanel.Controls.Add(control);
            }

            guiRefreshCareer.Visible = true;
        }
コード例 #20
0
 public MockGameData(MatchInfo matchinfo   = null, GameServerInfo serverInfo = null, AccountId accountId                 = null,
                     ArenaInfo arenaInfo   = null, BattleTag battleTag       = null, BrawlInfo brawlInfo                 = null,
                     Collection collection = null, Card[] draftChoices       = null, List <Card> packCards               = null,
                     int packId            = 0, DungeonInfo[] dungeonInfo    = null, bool friendlyChallengeDialogVisible = false)
 {
     _matchinfo    = matchinfo;
     _serverInfo   = serverInfo;
     _accountId    = accountId;
     _arenaInfo    = arenaInfo;
     _battleTag    = battleTag;
     _brawlInfo    = brawlInfo;
     _collection   = collection;
     _draftChoices = draftChoices;
     _packCards    = packCards;
     _packId       = packId;
     _dungeonInfo  = dungeonInfo;
     _friendlyChallengeDialogVisible = friendlyChallengeDialogVisible;
 }
コード例 #21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (HasAccountId)
            {
                hash ^= AccountId.GetHashCode();
            }
            if (HasBattleTag)
            {
                hash ^= BattleTag.GetHashCode();
            }
            hash ^= role_.GetHashCode();
            if (HasPrivileges)
            {
                hash ^= Privileges.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #22
0
ファイル: D3Api.cs プロジェクト: rangeryu/D3-API-by-ZTn
 public static String GetHeroUrlFromHeroId(BattleTag battleTag, String heroId)
 {
     return(GetCareerUrl(battleTag) + "hero/" + heroId);
 }
コード例 #23
0
 public string GetCareerUrl(BattleTag battleTag, bool fullUrl = false)
 {
     return(fullUrl ?
            $"{ApiUrl}profile/{Uri.EscapeUriString(battleTag.Name)}-{battleTag.Code}/index{ApiLocaleSuffix}{ApiKeySuffix}" :
            $"{ApiUrl}profile/{Uri.EscapeUriString(battleTag.Name)}-{battleTag.Code}/");
 }
コード例 #24
0
ファイル: D3Api.cs プロジェクト: rangeryu/D3-API-by-ZTn
 public static String GetCareerUrl(BattleTag battleTag)
 {
     return(ApiUrl + "profile/" + Uri.EscapeUriString(battleTag.Name) + "-" + battleTag.Code + "/");
 }
コード例 #25
0
 public Career GetCareerFromBattleTag(BattleTag battleTag) =>
 GetFromDataProvider <Career>(GetCareerUrl(battleTag, true));
コード例 #26
0
 public Task <Career> GetCareerFromBattleTagAsync(BattleTag battleTag) =>
 GetFromDataProviderAsync <Career>(GetCareerUrl(battleTag, true));
コード例 #27
0
 public string GetHeroUrlFromHeroId(BattleTag battleTag, string heroId, bool fullUrl = false)
 {
     return(fullUrl ?
            $"{GetCareerUrl(battleTag)}hero/{heroId}{ApiLocaleSuffix}{ApiKeySuffix}" :
            $"{GetCareerUrl(battleTag)}hero/{heroId}");
 }
コード例 #28
0
 public Task <Hero> GetHeroFromHeroIdAsync(BattleTag battleTag, string heroId) =>
 GetFromDataProviderAsync <Hero>(GetHeroUrlFromHeroId(battleTag, heroId, true));
コード例 #29
0
 public Hero GetHeroFromHeroId(BattleTag battleTag, string heroId) =>
 GetFromDataProvider <Hero>(GetHeroUrlFromHeroId(battleTag, heroId, true));
コード例 #30
0
		private void FindProfile()
		{
			Action<Profile> action = delegate(Profile profile)
			{
				this.Dispatcher.BeginInvoke(delegate
				{
					try
					{
						if (!string.IsNullOrEmpty(profile.ErrorCode))
						{
							App.ShowAlert(string.Format("{0}: {1}", profile.ErrorCode, profile.ErrorReason));
							this.MyViewModel.ProfileViewModel = null;
							this.AppButtons[1].IsEnabled = false;
							this.tbBattleTag.Focus();
						}
						else
						{
							this.MyViewModel.ProfileViewModel = new ProfileViewModel(profile);
							this.AppButtons[1].IsEnabled = true;
							this.lbHero.Focus();
						}
					}
					catch (Exception ex)
					{
						App.ShowAlert(ex.Message);
					}

					this.MyViewModel.ShowProgressBar = false;
					this.profile = profile;
				});
			};

			this.Dispatcher.BeginInvoke(delegate
			{
				this.MyViewModel.ShowProgressBar = true;
				var battleTag = new BattleTag(this.tbBattleTag.Text.Trim());
				new D3Client().GetProfile(this.lpRealm.SelectedItem as Realm, battleTag.Tag, action);
			});
		}
コード例 #31
0
 public D3ProfileContainer(BattleTag battleTag, Host host)
 {
     BattleTag = battleTag;
     Host      = host;
 }