Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the right number of heroes in bg to account for custom lobbies #4345

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/BobsBuddy/BobsBuddyInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private void SnapshotBoardState(int turn)
input.availableRaces = BattlegroundsUtils.GetAvailableRaces(_currentGameId).ToList();

var livingHeroes = _game.Entities.Values.Where(x => x.IsHero && x.Health > 0 && !x.IsInZone(Zone.REMOVEDFROMGAME) && x.HasTag(GameTag.PLAYER_TECH_LEVEL) && (x.IsControlledBy(_game.Player.Id) || !x.IsInPlay));
input.HeroHasDied = livingHeroes.Count() < 8;
input.HeroHasDied = livingHeroes.Count() < _game.BattlegroundsHeroCount();

var opponentHero = _game.Opponent.Board.FirstOrDefault(x => x.IsHero);
var playerHero = _game.Player.Board.FirstOrDefault(x => x.IsHero);
Expand Down
6 changes: 6 additions & 0 deletions Hearthstone Deck Tracker/Hearthstone/GameV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using HearthDb.Enums;
using HearthMirror.Objects;
Expand Down Expand Up @@ -32,6 +33,7 @@ public class GameV2 : IGame
private BrawlInfo _brawlInfo;
private BattlegroundRatingInfo _battlegroundsRatingInfo;
private BattlegroundsBoardState _battlegroundsBoardState;
Regex BattlegroundsHeroRegex = new Regex(@"(TB_BaconShop_HERO_\d\d)|(BG20_HERO_\d\d)");

public GameV2()
{
Expand Down Expand Up @@ -295,6 +297,10 @@ public int GetTurnNumber()
return (GameEntity?.GetTag(GameTag.TURN) + 1) / 2 ?? 0;
}

//We do count+1 because if you're playing against an opponent it will count their hero in play and the hero in the hero list, so instead we only count the heroes in the hero list and add 1 for the player hero.
public int BattlegroundsHeroCount() => Entities.Values.Where(x => x.IsHero && BattlegroundsHeroRegex.IsMatch(x.CardId) && x.IsInSetAside).Count()+1;


public void SnapshotBattlegroundsBoardState() => _battlegroundsBoardState.SnapshotCurrentBoard();

public BoardSnapshot GetBattlegroundsBoardStateFor(string cardId) => _battlegroundsBoardState.GetSnapshot(cardId);
Expand Down
9 changes: 3 additions & 6 deletions Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Hearthstone_Deck_Tracker.Utility;
using System.Threading.Tasks;
using System.Linq;
using System.Text.RegularExpressions;
using HearthDb.Enums;
using Hearthstone_Deck_Tracker.Utility.Analytics;
using Hearthstone_Deck_Tracker.Utility.Extensions;
Expand Down Expand Up @@ -74,8 +73,6 @@ public partial class OverlayWindow : Window, INotifyPropertyChanged
private const int LevelResetDelay = 500;
private const int ExperienceFadeDelay = 6000;

Regex BattlegroundsHeroRegex = new Regex(@"(TB_BaconShop_HERO_\d\d)|(BG20_HERO_\d\d)");

public OverlayWindow(GameV2 game)
{
// These need to be set before InitializeComponent is called
Expand Down Expand Up @@ -427,11 +424,11 @@ internal async Task ExperienceChangedAsync(int experience, int experienceNeeded,
if(_game.CurrentMode != Enums.Hearthstone.Mode.HUB)
HideExperienceCounter();
}



internal void UpdateOpponentDeadForTurns(List<int> turns)
{
var presentHeroes = _game.Entities.Values.Where(x => x.IsHero && BattlegroundsHeroRegex.IsMatch(x.CardId) && (x.IsInPlay || x.IsInSetAside)).ToList();
var index = presentHeroes.Count() - 1;
var index = _game.BattlegroundsHeroCount() - 1;
foreach(var text in _leaderboardDeadForText)
text.Text = "";
foreach(var text in _leaderboardDeadForTurnText)
Expand Down