Skip to content

Commit

Permalink
feat: add tier 7 minions and optional tiers
Browse files Browse the repository at this point in the history
  • Loading branch information
azeier committed Aug 22, 2023
1 parent 6d63023 commit be8e09b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<local:BattlegroundsTier x:Name="BgTier4" Tier="4" MouseUp="BgTier_MouseUp"/>
<local:BattlegroundsTier x:Name="BgTier5" Tier="5" MouseUp="BgTier_MouseUp"/>
<local:BattlegroundsTier x:Name="BgTier6" Tier="6" MouseUp="BgTier_MouseUp"/>
<local:BattlegroundsTier x:Name="BgTier7" Tier="7" MouseUp="BgTier_MouseUp"/>
</StackPanel>
</Border>
<ScrollViewer x:Name="MinionScrollViewer" HorizontalAlignment="Right" Margin="0,0,6,0" VerticalScrollBarVisibility="Auto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ private void BgTier_MouseUp(object sender, System.Windows.Input.MouseButtonEvent
Core.Game.Metrics.IncrementBattlegroundsMinionsTabClick();
}

private HashSet<int> _availableTiers = BattlegroundsUtils.GetAvailableTiers(null);
public void SetAvailableTiers(HashSet<int> tiers)
{
_availableTiers = tiers;
for(var i = 0; i < 7; i++)
_tierIcons[i].SetAvailable(_availableTiers.Contains(i + 1));
}

public void Reset()
{
_availableTiers = BattlegroundsUtils.GetAvailableTiers(null);
for(var i = 0; i < 7; i++)
_tierIcons[i].SetAvailable(_availableTiers.Contains(i + 1));
Update(0, _db.Value.Races);
}

Expand Down Expand Up @@ -74,15 +85,16 @@ private void Update(int tier, IEnumerable<Race> availableRaces)
ActiveTier = tier;
foreach(var item in _tierIcons)
item.Active = tier == item.Tier;
if(tier < 1 || tier > 6)

if(tier < 1 || tier > 7)
{
for(var i = 0; i < 6; i++)
for(var i = 0; i < 7; i++)
_tierIcons[i].SetFaded(false);
Groups.Clear();
UnavailableTypes.UnavailableTypesVisibility = System.Windows.Visibility.Collapsed;
return;
}
for(var i = 0; i < 6; i++)
for(var i = 0; i < 7; i++)
_tierIcons[i].SetFaded(i != tier - 1);

var resort = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public bool Active
}

private bool _faded;

public void SetFaded(bool faded)
{
if(faded == _faded || Active)
Expand All @@ -66,6 +65,15 @@ public void SetFaded(bool faded)
Update(true);
}

private bool _available = true;
public void SetAvailable(bool available)
{
if(available == _available)
return;
_available = available;
Update(true);
}

private void Update(bool updateRemove)
{
if(updateRemove)
Expand All @@ -77,7 +85,11 @@ private void Update(bool updateRemove)

private double GetOpacity()
{
if(Active || _hovering || !_faded)
if(Active)
return 1;
if(!_available)
return _hovering ? 0.6 : 0.3;
if(_hovering || !_faded)
return 1;
return 0.3;
}
Expand Down
17 changes: 13 additions & 4 deletions Hearthstone Deck Tracker/Hearthstone/BattlegroundsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static HearthDb.CardIds;

namespace Hearthstone_Deck_Tracker.Hearthstone
{
public static class BattlegroundsUtils
{
private static readonly Dictionary<Guid, HashSet<Race>> _availableRacesCache = new Dictionary<Guid, HashSet<Race>>();

const string UntransformedArannaCardid = HearthDb.CardIds.NonCollectible.Neutral.ArannaStarseekerTavernBrawl1;
const string TransformedArannaCardid = HearthDb.CardIds.NonCollectible.Neutral.ArannaStarseeker_ArannaUnleashedTokenTavernBrawl;
const string UntransformedArannaCardid = NonCollectible.Neutral.ArannaStarseekerTavernBrawl1;
const string TransformedArannaCardid = NonCollectible.Neutral.ArannaStarseeker_ArannaUnleashedTokenTavernBrawl;

const string UntransformedQueenAzshara = HearthDb.CardIds.NonCollectible.Neutral.QueenAzsharaBATTLEGROUNDS;
const string TransformedQueenAzshara = HearthDb.CardIds.NonCollectible.Neutral.QueenAzshara_NagaQueenAzsharaToken;
const string UntransformedQueenAzshara = NonCollectible.Neutral.QueenAzsharaBATTLEGROUNDS;
const string TransformedQueenAzshara = NonCollectible.Neutral.QueenAzshara_NagaQueenAzsharaToken;

private static readonly Dictionary<string, string> TransformableHeroCardidTable = new Dictionary<string, string>()
{
Expand Down Expand Up @@ -48,5 +49,13 @@ private static HashSet<Race>? AvailableRaces
}

public static string GetOriginalHeroId(string heroId) => TransformableHeroCardidTable.TryGetValue(heroId, out var mapped) ? mapped : heroId;

public static HashSet<int> GetAvailableTiers(string? anomalyCardId) => anomalyCardId switch
{
NonCollectible.Neutral.BigLeague => new HashSet<int> { 3, 4, 5, 6 },
NonCollectible.Neutral.LittleLeague => new HashSet<int> { 1, 2, 3, 4 },
NonCollectible.Invalid.SecretsOfNorgannon => new HashSet<int> { 1, 2, 3, 4, 5, 6, 7 },
_ => new HashSet<int> { 1, 2, 3, 4, 5, 6 },
};
}
}
Binary file added Hearthstone Deck Tracker/Resources/tier-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ internal void HideBattlegroundsHeroPanel()
internal void ShowBgsTopBar()
{
TurnCounter.Visibility = Config.Instance.ShowBattlegroundsTurnCounter ? Visible : Collapsed;

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

BattlegroundsMinionsPanel.Visibility = Config.Instance.ShowBattlegroundsTiers ? Visible : Collapsed;

_bgsTopBarBehavior.Show();
Expand Down

0 comments on commit be8e09b

Please sign in to comment.