private void CheckForCardOpened(BnetGameAccount oldPlayerAccount, BnetGameAccount newPlayerAccount, BnetPlayer newPlayer) { if (newPlayerAccount.GetCardsOpened() != oldPlayerAccount.GetCardsOpened()) { string cardsOpened = newPlayerAccount.GetCardsOpened(); if (!string.IsNullOrEmpty(cardsOpened)) { char[] separator = new char[] { ',' }; string[] strArray = cardsOpened.Split(separator); if (strArray.Length == 2) { EntityDef entityDef = DefLoader.Get().GetEntityDef(strArray[0]); if (entityDef != null) { if (strArray[1] == "1") { object[] args = new object[] { "5ecaf0ff", newPlayer.GetBestName(), entityDef.GetName(), "ffd200" }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_GOLDEN_LEGENDARY", args)); } else { object[] objArray2 = new object[] { "5ecaf0ff", newPlayer.GetBestName(), entityDef.GetName(), "ff9c00" }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_LEGENDARY", objArray2)); } } } } } }
private void OnPlayersChanged(BnetPlayerChangelist changelist, object userData) { BnetPlayer myPlayer = BnetPresenceMgr.Get().GetMyPlayer(); if (changelist.FindChange(myPlayer) != null) { BnetGameAccount hearthstoneGameAccount = myPlayer.GetHearthstoneGameAccount(); if (((hearthstoneGameAccount != null) && !this.m_myPlayerReady) && (hearthstoneGameAccount.HasGameField(20) && hearthstoneGameAccount.HasGameField(0x13))) { this.m_myPlayerReady = true; this.UpdateMyAvailability(); } if (!this.AmIAvailable() && this.m_challengerPending) { Network.DeclineFriendChallenge(this.m_partyId); this.CleanUpChallengeData(true); } } if (this.m_challengerPending) { BnetPlayerChange change = changelist.FindChange(this.m_challengerId); if (change != null) { BnetPlayer player = change.GetPlayer(); if (player.IsDisplayable()) { this.m_challenger = player; this.m_challengerPending = false; this.FireChangedEvent(FriendChallengeEvent.I_RECEIVED_CHALLENGE, this.m_challenger); } } } }
private void CacheMyself(BnetGameAccount gameAccount, BnetPlayer player) { if ((player != this.m_myPlayer) && (gameAccount.GetId() == this.m_myGameAccountId)) { this.m_myPlayer = player; } }
public BnetGameAccount GetGameAccount(BnetGameAccountId id) { BnetGameAccount account = null; this.m_gameAccounts.TryGetValue(id, out account); return(account); }
public BnetGameAccount Clone() { BnetGameAccount account = (BnetGameAccount)base.MemberwiseClone(); if (this.m_id != null) { account.m_id = this.m_id.Clone(); } if (this.m_ownerId != null) { account.m_ownerId = this.m_ownerId.Clone(); } if (this.m_programId != null) { account.m_programId = this.m_programId.Clone(); } if (this.m_battleTag != null) { account.m_battleTag = this.m_battleTag.Clone(); } account.m_gameFields = new Map <uint, object>(); foreach (KeyValuePair <uint, object> pair in this.m_gameFields) { account.m_gameFields.Add(pair.Key, pair.Value); } return(account); }
private void CheckForMageLevelChanged(BnetGameAccount oldPlayerAccount, BnetGameAccount newPlayerAccount, BnetPlayer newPlayer) { if (this.ShouldToastThisLevel(oldPlayerAccount.GetMageLevel(), newPlayerAccount.GetMageLevel())) { object[] args = new object[] { "5ecaf0ff", newPlayer.GetBestName(), newPlayerAccount.GetMageLevel() }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_MAGE_LEVEL", args)); } }
private void CheckForMissionComplete(BnetGameAccount oldPlayerAccount, BnetGameAccount newPlayerAccount, BnetPlayer newPlayer) { if ((newPlayerAccount.GetTutorialBeaten() != oldPlayerAccount.GetTutorialBeaten()) && (newPlayerAccount.GetTutorialBeaten() == 1)) { object[] args = new object[] { "5ecaf0ff", newPlayer.GetBestName() }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_ILLIDAN_COMPLETE", args)); } }
private void CreateGameAccount(BnetGameAccountId id, BattleNet.PresenceUpdate update, BnetPlayerChangelist changelist) { BnetGameAccount account = new BnetGameAccount(); this.m_gameAccounts.Add(id, account); account.SetId(id); this.UpdateGameAccount(account, update, changelist); }
public void AddGameAccount(BnetGameAccount gameAccount) { BnetGameAccountId key = gameAccount.GetId(); if (!this.m_gameAccounts.ContainsKey(key)) { this.m_gameAccounts.Add(key, gameAccount); this.CacheSpecialGameAccounts(); } }
public string GetStatusText(BnetPlayer player) { List <string> stringArgs = new List <string>(); string statusKey = null; if (this.GetStatus_Internal(player, ref statusKey, stringArgs, null) == PresenceStatus.UNKNOWN) { BnetGameAccount bestGameAccount = player.GetBestGameAccount(); return((bestGameAccount != null) ? bestGameAccount.GetRichPresence() : null); } string[] args = stringArgs.ToArray(); return(GameStrings.Format(statusKey, args)); }
private void CheckArenaGameStarted(BnetPlayer player) { if (PresenceMgr.Get().GetStatus(player) == PresenceStatus.ARENA_GAME) { ArenaRecord record; BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount(); if (((hearthstoneGameAccount != null) && ArenaRecord.TryParse(hearthstoneGameAccount.GetArenaRecord(), out record)) && (record.wins >= 8)) { object[] args = new object[] { "5ecaf0ff", player.GetBestName(), record.wins }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_ARENA_START_WITH_MANY_WINS", args)); } } }
public override bool Equals(object obj) { if (obj == null) { return(false); } BnetGameAccount account = obj as BnetGameAccount; if (account == null) { return(false); } return(this.m_id.Equals((BnetEntityId)account.m_id)); }
public BnetBattleTag GetBattleTag() { if ((this.m_account != null) && (this.m_account.GetBattleTag() != null)) { return(this.m_account.GetBattleTag()); } BnetGameAccount firstGameAccount = this.GetFirstGameAccount(); if (firstGameAccount != null) { return(firstGameAccount.GetBattleTag()); } return(null); }
public BnetAccountId GetAccountId() { if (this.m_accountId != null) { return(this.m_accountId); } BnetGameAccount firstGameAccount = this.GetFirstGameAccount(); if (firstGameAccount != null) { return(firstGameAccount.GetOwnerId()); } return(null); }
public bool CanChallenge(BnetPlayer player) { if (player == null) { return(false); } BnetPlayer myPlayer = BnetPresenceMgr.Get().GetMyPlayer(); if (player == myPlayer) { return(false); } if (!this.AmIAvailable()) { return(false); } if ((TavernBrawlManager.Get().ShouldNewFriendlyChallengeBeTavernBrawl() && TavernBrawlManager.Get().CurrentMission().canCreateDeck) && !TavernBrawlManager.Get().HasValidDeck()) { return(false); } BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount(); if (hearthstoneGameAccount == null) { return(false); } if (!hearthstoneGameAccount.IsOnline()) { return(false); } if (!hearthstoneGameAccount.CanBeInvitedToGame()) { return(false); } if (ApplicationMgr.IsPublic()) { BnetGameAccount account2 = myPlayer.GetHearthstoneGameAccount(); if (string.Compare(hearthstoneGameAccount.GetClientVersion(), account2.GetClientVersion()) != 0) { return(false); } if (string.Compare(hearthstoneGameAccount.GetClientEnv(), account2.GetClientEnv()) != 0) { return(false); } } return(true); }
private BnetPlayerChangelist ChangeGameField(BnetGameAccount hsGameAccount, uint fieldId, object val) { if (hsGameAccount == null) { return(null); } BnetPlayerChange change = new BnetPlayerChange(); change.SetOldPlayer(this.m_myPlayer.Clone()); change.SetNewPlayer(this.m_myPlayer); hsGameAccount.SetGameField(fieldId, val); BnetPlayerChangelist changelist = new BnetPlayerChangelist(); changelist.AddChange(change); return(changelist); }
private void CacheSpecialGameAccounts() { this.m_hsGameAccount = null; this.m_bestGameAccount = null; ulong lastOnlineMicrosec = 0L; foreach (BnetGameAccount account in this.m_gameAccounts.Values) { BnetProgramId programId = account.GetProgramId(); if (programId != null) { if (programId == BnetProgramId.HEARTHSTONE) { this.m_hsGameAccount = account; if (account.IsOnline() || !BnetFriendMgr.Get().IsFriend(account.GetId())) { this.m_bestGameAccount = account; } break; } if (this.m_bestGameAccount == null) { this.m_bestGameAccount = account; lastOnlineMicrosec = this.m_bestGameAccount.GetLastOnlineMicrosec(); } else { BnetProgramId id2 = this.m_bestGameAccount.GetProgramId(); if (programId.IsGame() && !id2.IsGame()) { this.m_bestGameAccount = account; lastOnlineMicrosec = this.m_bestGameAccount.GetLastOnlineMicrosec(); } else if ((account.IsOnline() && programId.IsGame()) && id2.IsGame()) { ulong num2 = account.GetLastOnlineMicrosec(); if (num2 > lastOnlineMicrosec) { this.m_bestGameAccount = account; lastOnlineMicrosec = num2; } } } } } }
public MedalInfoTranslator GetRankPresenceField(BnetGameAccount gameAccount) { byte[] buffer; if ((gameAccount == null) || !gameAccount.TryGetGameFieldBytes(0x12, out buffer)) { return(null); } if (buffer == null) { return(null); } if (buffer.Length < 3) { return(null); } int rank = Convert.ToInt32(buffer[0]); return(new MedalInfoTranslator(rank, BitConverter.ToUInt16(buffer, 1))); }
public virtual void UpdateFriend() { this.m_ChatIcon.UpdateIcon(); if (this.m_player != null) { Color color; if (this.m_player.IsOnline()) { if (this.m_player.IsAway()) { color = TEXT_COLOR_AWAY; } else if (this.m_player.IsBusy()) { color = TEXT_COLOR_BUSY; } else { color = TEXT_COLOR_NORMAL; } } else { color = TEXT_COLOR_OFFLINE; } this.m_StatusText.TextColor = color; BnetGameAccount hearthstoneGameAccount = this.m_player.GetHearthstoneGameAccount(); this.m_medal = (hearthstoneGameAccount != null) ? RankMgr.Get().GetRankPresenceField(hearthstoneGameAccount) : null; if ((this.m_medal == null) || (this.m_medal.GetCurrentMedal().rank == 0x19)) { this.m_rankMedal.gameObject.SetActive(false); this.m_PlayerIcon.Show(); } else { this.m_PlayerIcon.Hide(); this.m_rankMedal.gameObject.SetActive(true); this.m_rankMedal.SetMedal(this.m_medal, false); } } }
public bool AmIAvailable() { if (!this.m_netCacheReady) { return(false); } if (!this.m_myPlayerReady) { return(false); } if (SpectatorManager.Get().IsInSpectatorMode()) { return(false); } BnetGameAccount hearthstoneGameAccount = BnetPresenceMgr.Get().GetMyPlayer().GetHearthstoneGameAccount(); if (hearthstoneGameAccount == null) { return(false); } return(hearthstoneGameAccount.CanBeInvitedToGame()); }
private void CheckArenaRecordChanged(BnetPlayer player) { ArenaRecord record; BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount(); if ((hearthstoneGameAccount != null) && ArenaRecord.TryParse(hearthstoneGameAccount.GetArenaRecord(), out record)) { if (record.isFinished) { if (record.wins >= 3) { object[] args = new object[] { "5ecaf0ff", player.GetBestName(), record.wins, record.losses }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_ARENA_COMPLETE", args)); } } else if ((record.wins == 0) && (record.losses == 0)) { object[] objArray2 = new object[] { "5ecaf0ff", player.GetBestName() }; this.AddToast(GameStrings.Format("GLOBAL_SOCIAL_TOAST_FRIEND_ARENA_START", objArray2)); } } }
public bool IsDisplayable() { if (this.m_gameAccountId == null) { return(false); } if (!this.IsBnetPlayer()) { if (this.ShouldUseHeroName() && (this.GetHeroEntityDef() == null)) { return(false); } return(true); } BnetPlayer player = BnetPresenceMgr.Get().GetPlayer(this.m_gameAccountId); if (player == null) { return(false); } if (!player.IsDisplayable()) { return(false); } if (GameUtils.ShouldShowRankedMedals()) { BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount(); if (hearthstoneGameAccount == null) { return(false); } if (!hearthstoneGameAccount.HasGameField(0x12)) { return(false); } } return(true); }
private PresenceStatus GetStatus_Internal(BnetPlayer player, ref string statusKey, List <string> stringArgs = null, List <Enum> enumVals = null) { byte[] buffer; PresenceStatus uNKNOWN = PresenceStatus.UNKNOWN; if (player == null) { return(uNKNOWN); } if (player.GetBestGameAccount() == null) { return(uNKNOWN); } BnetGameAccount hearthstoneGameAccount = player.GetHearthstoneGameAccount(); if (hearthstoneGameAccount == null) { return(uNKNOWN); } if (!hearthstoneGameAccount.TryGetGameFieldBytes(0x11, out buffer)) { return(uNKNOWN); } Enum enumVal = 0; using (MemoryStream stream = new MemoryStream(buffer)) { using (BinaryReader reader = new BinaryReader(stream)) { if (this.DecodeStatusVal(reader, ref enumVal, ref statusKey)) { uNKNOWN = (PresenceStatus)((int)enumVal); if (enumVals != null) { enumVals.Add(uNKNOWN); } if ((stringArgs == null) && (enumVals == null)) { return(uNKNOWN); } while (stream.Position < buffer.Length) { string key = null; if (!this.DecodeStatusVal(reader, ref enumVal, ref key)) { return(uNKNOWN); } if (enumVals != null) { enumVals.Add(enumVal); } if (stringArgs != null) { string item = GameStrings.Get(key); stringArgs.Add(item); } } } return(uNKNOWN); } } }