Skip to content

Commit

Permalink
chore: clean up Battlegrounds anomaly fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
beheh committed Aug 23, 2023
1 parent 4dd024b commit f942fe7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/BobsBuddy/BobsBuddyInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private void SnapshotBoardState(int turn)
var opponentTechLevel = opponentHero.GetTag(GameTag.PLAYER_TECH_LEVEL);
input.SetTiers(playerTechLevel, opponentTechLevel);

var anomalyDbfId = _game.GameEntity?.GetTag(GameTag.BACON_GLOBAL_ANOMALY_DBID);
var anomalyDbfId = BattlegroundsUtils.GetBattlegroundsAnomalyDbfId(_game.GameEntity);
var anomalyCardId = anomalyDbfId.HasValue ? Database.GetCardFromDbfId(anomalyDbfId.Value, false)?.Id : null;
if(anomalyCardId != null)
input.Anomaly = simulator.AnomalyFactory.Create(anomalyCardId);
Expand Down
9 changes: 9 additions & 0 deletions Hearthstone Deck Tracker/Hearthstone/BattlegroundsUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HearthDb.Enums;
using HearthMirror;
using Hearthstone_Deck_Tracker.Hearthstone.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -57,5 +58,13 @@ private static HashSet<Race>? AvailableRaces
NonCollectible.Invalid.SecretsOfNorgannon => new HashSet<int> { 1, 2, 3, 4, 5, 6, 7 },
_ => new HashSet<int> { 1, 2, 3, 4, 5, 6 },
};

public static int? GetBattlegroundsAnomalyDbfId(Entity game)
{
var anomalyDbfId = game.GetTag(GameTag.BACON_GLOBAL_ANOMALY_DBID);
if (anomalyDbfId > 0)
return anomalyDbfId;
return null;
}
}
}
10 changes: 1 addition & 9 deletions Hearthstone Deck Tracker/Live/BoardStateWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@ private int DbfId(Entity? e)
return player.QuestRewards.FirstOrDefault(x => x.HasTag(GameTag.BACON_IS_HEROPOWER_QUESTREWARD) == heroPower)?.Card.DbfId;
}

private int? BgsAnomaly(Entity game)
{
var anomaly = game.GetTag(GameTag.BACON_GLOBAL_ANOMALY_DBID);
if (anomaly != 0)
{
return anomaly;
}
return null;
}
private int? BgsAnomaly(Entity game) => BattlegroundsUtils.GetBattlegroundsAnomalyDbfId(game);

// Return the dbf id for an entity, but blacklisted against common hero cards we don't want want to show in the overlay.
private int HeroDbfId(Entity? entity)
Expand Down
2 changes: 1 addition & 1 deletion Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ internal void ShowBgsTopBar()
{
TurnCounter.Visibility = Config.Instance.ShowBattlegroundsTurnCounter ? Visible : Collapsed;

var anomalyDbfId = _game.GameEntity?.GetTag(GameTag.BACON_GLOBAL_ANOMALY_DBID);
var anomalyDbfId = BattlegroundsUtils.GetBattlegroundsAnomalyDbfId(_game.GameEntity);
var anomalyCardId = anomalyDbfId.HasValue ? Database.GetCardFromDbfId(anomalyDbfId.Value, false)?.Id : null;
BattlegroundsMinionsPanel.SetAvailableTiers(BattlegroundsUtils.GetAvailableTiers(anomalyCardId));

Expand Down

0 comments on commit f942fe7

Please sign in to comment.