Skip to content

Commit

Permalink
CardMark: implement cost reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zeier committed Apr 1, 2016
1 parent 6d24f19 commit ba7cd1c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Hearthstone Deck Tracker/Controls/CardMarker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Hearthstone_Deck_Tracker.Controls"
xmlns:Hearthstone_Deck_Tracker="clr-namespace:Hearthstone_Deck_Tracker" x:Class="Hearthstone_Deck_Tracker.Controls.CardMarker"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hearthstoneDeckTracker="clr-namespace:Hearthstone_Deck_Tracker"
x:Class="Hearthstone_Deck_Tracker.Controls.CardMarker"
mc:Ignorable="d"
d:DesignHeight="34" d:DesignWidth="36">
<Canvas>
<Canvas Width="32" Height="32">
<Canvas.Background>
<ImageBrush ImageSource="/HearthstoneDeckTracker;component/Images/card-marker.png"/>
</Canvas.Background>
<Hearthstone_Deck_Tracker:HearthstoneTextBlock x:Name="CardAge" FontSize="18" Text="0" Canvas.Left="0" Width="32" Height="32" Canvas.Top="0" TextAlignment="Center" />
<hearthstoneDeckTracker:HearthstoneTextBlock x:Name="CardAge" FontSize="18" Text="0" Canvas.Left="0" Width="32" Height="32" Canvas.Top="0" TextAlignment="Center" />
</Canvas>
<Image x:Name="CardIcon" Width="16" Height="16" Canvas.Left="20" Canvas.Top="18" Source="/HearthstoneDeckTracker;component/Images/card-icon-coin.png" />

<hearthstoneDeckTracker:HearthstoneTextBlock x:Name="TextCostReduction" Fill="DodgerBlue" FontSize="13" Text="-1" Canvas.Left="17" Canvas.Top="-2" Width="16" Height="16" TextAlignment="Right"/>
</Canvas>
</UserControl>
6 changes: 6 additions & 0 deletions Hearthstone Deck Tracker/Controls/CardMarker.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ public CardMark Mark
CardIcon.Visibility = Collapsed;
}
}

public void SetCostReduction(int i)
{
TextCostReduction.Text = (-i).ToString();
TextCostReduction.Visibility = i > 0 ? Visible : Collapsed;
}
}
}
17 changes: 13 additions & 4 deletions Hearthstone Deck Tracker/Windows/OverlayWindow.Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Hearthstone_Deck_Tracker.Utility.BoardDamage;
using Hearthstone_Deck_Tracker.Utility.Logging;
using static System.Windows.Visibility;
using static HearthDb.CardIds.NonCollectible;
using static Hearthstone_Deck_Tracker.Enums.GAME_TAG;

namespace Hearthstone_Deck_Tracker.Windows
{
Expand All @@ -29,20 +31,27 @@ public void Update(bool refresh)
{
if (i < opponentHandCount)
{
var entity = _game.Opponent.Hand.FirstOrDefault(x => x.GetTag(GAME_TAG.ZONE_POSITION) == i + 1);
var entity = _game.Opponent.Hand.FirstOrDefault(x => x.GetTag(ZONE_POSITION) == i + 1);
if(entity == null)
continue;
_cardMarks[i].Text = !Config.Instance.HideOpponentCardAge ? entity.Info.Turn.ToString() : "";
_cardMarks[i].Mark = !Config.Instance.HideOpponentCardMarks ? entity.Info.CardMark : CardMark.None;
if(!Config.Instance.HideOpponentCardMarks)
{
_cardMarks[i].Mark = entity.Info.CardMark;
var impFavor = _game.Opponent.Board.FirstOrDefault(x => x.CardId == Neutral.ImperialFavorEnchantment && x.GetTag(ATTACHED) == entity.Id);
_cardMarks[i].SetCostReduction(impFavor?.GetTag(NUM_TURNS_IN_PLAY) ?? 0);
}
else
_cardMarks[i].Mark = CardMark.None;
_cardMarks[i].Visibility = (_game.IsInMenu || (Config.Instance.HideOpponentCardAge && Config.Instance.HideOpponentCardMarks))
? Hidden : Visible;
}
else
_cardMarks[i].Visibility = Collapsed;
}

var oppBoard = Core.Game.Opponent.Board.Where(x => x.IsMinion).OrderBy(x => x.GetTag(GAME_TAG.ZONE_POSITION)).ToList();
var playerBoard = Core.Game.Player.Board.Where(x => x.IsMinion).OrderBy(x => x.GetTag(GAME_TAG.ZONE_POSITION)).ToList();
var oppBoard = Core.Game.Opponent.Board.Where(x => x.IsMinion).OrderBy(x => x.GetTag(ZONE_POSITION)).ToList();
var playerBoard = Core.Game.Player.Board.Where(x => x.IsMinion).OrderBy(x => x.GetTag(ZONE_POSITION)).ToList();
UpdateMouseOverDetectionRegions(oppBoard, playerBoard);
if(!_game.IsInMenu && _game.IsMulliganDone && User32.IsHearthstoneInForeground())
DetectMouseOver(playerBoard, oppBoard);
Expand Down

0 comments on commit ba7cd1c

Please sign in to comment.