Skip to content

Commit

Permalink
Merge branch 'Arakys7-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
RedHatter committed Jan 22, 2018
2 parents b9d9dcb + 2fa822a commit a2532b2
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 65 deletions.
2 changes: 2 additions & 0 deletions Graveyard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="src\ChancesTracker.cs" />
<Compile Include="src\HadronoxView.cs" />
<Compile Include="src\GuldanView.cs" />
<Compile Include="src\Properties\AssemblyInfo.cs" />
<Compile Include="src\DiscardView.cs" />
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ Displays Murlocs killed by both the player and opponent as well as a damage calc
* **N'Zoth the Corruptor**
Displays deathrattle minions that have died.

* **Resurrect** or **Onyx Bishop** or **Kazakus**
* **Hadronox**
Displays taunt minions that have died.

* **Bloodraver Gul'dan**
Displays friendly demons that have died.

* **Resurrect** or **Onyx Bishop** or **Eternal Servitude** or **Kazakus**
Displays resurrect chance next to each minion that has died.

* **Cruel Dinomancer**
Expand Down
39 changes: 39 additions & 0 deletions src/ChancesTracker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Collections.Generic;
using Hearthstone_Deck_Tracker;
using Hearthstone_Deck_Tracker.Controls;
using Card = Hearthstone_Deck_Tracker.Hearthstone.Card;

namespace HDT.Plugins.Graveyard
{
public class ChancesTracker
{
private Dictionary<Card, HearthstoneTextBlock> _chances = new Dictionary<Card, HearthstoneTextBlock>();

public void Update(Card card, List<Card> Cards, AnimatedCardList View)
{
var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count);
for (var i = 0; i < Cards.Count(); i++)
{
if (!_chances.ContainsKey(Cards[i]))
{
var chance = new HearthstoneTextBlock();
chance.FontSize = 18;
chance.TextAlignment = TextAlignment.Left;
var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid;
grid.Width = 260;
(grid.Children[0] as Hearthstone_Deck_Tracker.Controls.Card).HorizontalAlignment = HorizontalAlignment.Right;
(grid.Children[1] as Rectangle).Width = 260;
grid.Children.Add(chance);
_chances.Add(Cards[i], chance);
}

_chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%";
}
}
}
}
29 changes: 2 additions & 27 deletions src/DiscardView.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Collections.Generic;
using Hearthstone_Deck_Tracker;
using Hearthstone_Deck_Tracker.Hearthstone;

namespace HDT.Plugins.Graveyard
{
public class DiscardView : NormalView
{
private Dictionary<Card, HearthstoneTextBlock> _chances;
private ChancesTracker _chances = new ChancesTracker();

public static bool isValid()
{
Expand All @@ -22,8 +16,6 @@ public DiscardView()
{
// Section Label
Label.Text = "Discarded";

_chances = new Dictionary<Card, HearthstoneTextBlock>();
}

new public bool Update(Card card)
Expand All @@ -34,24 +26,7 @@ public DiscardView()
}

// Silverware Golem and Clutchmother Zaras are still counted as discarded, even when their effects trigger
var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count);
for (var i = 0; i < Cards.Count(); i++)
{
if (!_chances.ContainsKey(Cards[i]))
{
var chance = new HearthstoneTextBlock();
chance.FontSize = 18;
chance.TextAlignment = TextAlignment.Left;
var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid;
grid.Width = 260;
(grid.Children[0] as Rectangle).HorizontalAlignment = HorizontalAlignment.Right;
(grid.Children[1] as Rectangle).Width = 260;
grid.Children.Add(chance);
_chances.Add(Cards[i], chance);
}

_chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%";
}
_chances.Update(card, Cards, View);

return true;
}
Expand Down
16 changes: 14 additions & 2 deletions src/Graveyard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Graveyard
public ResurrectView Resurrect;
public AnyfinView Anyfin;
public NZothView NZoth;
public HadronoxView Hadronox;
public DiscardView Discard;
public GuldanView Guldan;

Expand Down Expand Up @@ -136,6 +137,16 @@ public void Reset()
NZoth = null;
}

if (Settings.Default.HadronoxEnabled && HadronoxView.isValid())
{
Hadronox = new HadronoxView();
_friendlyPanel.Children.Add(Hadronox);
}
else
{
Hadronox = null;
}

if (Settings.Default.DiscardEnabled && DiscardView.isValid())
{
Discard = new DiscardView();
Expand All @@ -161,9 +172,10 @@ public void PlayerGraveyardUpdate(Card card)
{
var any = Anyfin?.Update(card) ?? false;
var nzoth = NZoth?.Update(card) ?? false;
var rez = Resurrect?.Update(card) ?? false;
var hadr = Hadronox?.Update(card) ?? false;
var guldan = Guldan?.Update(card) ?? false;
if (!(any || nzoth || rez || guldan))
var rez = Resurrect?.Update(card) ?? false;
if (!(any || nzoth || hadr || guldan || rez))
{
Normal?.Update(card);
}
Expand Down
10 changes: 8 additions & 2 deletions src/GraveyardPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public string ButtonText

public string Description
{
get { return "Displays minions that have died this game. Includes specialized displays: deathrattle minions for N'Zoth decks, resurrect chance for Resurrect Priest, and Murloc minions with a damage calculator for Anyfin Can Happen."; }
get { return @"Displays minions that have died this game. Includes specialized displays:
deathrattle minions for N'Zoth,
taunt minions for Hadronox,
demons for Bloodreaver Gul'dan,
resurrect chance for priest resurrect cards,
Murloc minions with a damage calculator for Anyfin Can Happen,
and resurrect chance for Cruel Dinomancer."; }
}

public MenuItem MenuItem
Expand Down Expand Up @@ -53,7 +59,7 @@ public void OnUpdate() {}

public Version Version
{
get { return new Version(1, 2, 0); }
get { return new Version(1, 3, 0); }
}
}
}
1 change: 0 additions & 1 deletion src/GuldanView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using Hearthstone_Deck_Tracker;
using Hearthstone_Deck_Tracker.Hearthstone;

Expand Down
25 changes: 25 additions & 0 deletions src/HadronoxView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Linq;
using Hearthstone_Deck_Tracker;
using Hearthstone_Deck_Tracker.Hearthstone;

namespace HDT.Plugins.Graveyard
{
public class HadronoxView : NormalView
{
public static bool isValid()
{
return Core.Game.Player.PlayerCardList.FindIndex(card => card.Id == HearthDb.CardIds.Collectible.Druid.Hadronox) > -1;
}

public HadronoxView()
{
// Section Label
Label.Text = "Hadronox";
}

new public bool Update(Card card)
{
return card.Mechanics.Contains("Taunt") && base.Update(card);
}
}
}
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
29 changes: 2 additions & 27 deletions src/ResurrectView.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Collections.Generic;
using Hearthstone_Deck_Tracker;
using Hearthstone_Deck_Tracker.Hearthstone;

namespace HDT.Plugins.Graveyard
{
public class ResurrectView : NormalView
{
private Dictionary<Card, HearthstoneTextBlock> _chances;
private ChancesTracker _chances = new ChancesTracker();

public static bool isValid()
{
Expand All @@ -27,8 +21,6 @@ public ResurrectView()
{
// Section Label
Label.Text = "Resurrect";

_chances = new Dictionary<Card, HearthstoneTextBlock>();
}

new public bool Update(Card card)
Expand All @@ -38,24 +30,7 @@ public ResurrectView()
return false;
}

var count = (double)Cards.Aggregate(0, (total, c) => total + c.Count);
for (var i = 0; i < Cards.Count(); i++)
{
if (!_chances.ContainsKey(Cards[i]))
{
var chance = new HearthstoneTextBlock();
chance.FontSize = 18;
chance.TextAlignment = TextAlignment.Left;
var grid = (View.Items.GetItemAt(i) as UserControl).Content as Grid;
grid.Width = 260;
(grid.Children[0] as Rectangle).HorizontalAlignment = HorizontalAlignment.Right;
(grid.Children[1] as Rectangle).Width = 260;
grid.Children.Add(chance);
_chances.Add(Cards[i], chance);
}

_chances[Cards[i]].Text = $"{Math.Round(Cards[i].Count / count * 100)}%";
}
_chances.Update(card, Cards, View);

return true;
}
Expand Down
12 changes: 12 additions & 0 deletions src/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@
<Setting Name="DiscardEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="HadronoxEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="DKGuldanEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
9 changes: 6 additions & 3 deletions src/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</StackPanel.Resources>
<Button Name="BtnUnlock" Width="150" Content="Unlock Graveyards" Click="BtnUnlock_Click" />
<TextBlock Text="Friendly" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="All frendly minions that have died." Style="{StaticResource DescStyle}"/>
<TextBlock Text="All friendly minions that have died." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding NormalEnabled, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable friendly graveyard display." Style="{StaticResource ToggleStyle}"/>
<DockPanel Style="{StaticResource SliderStyle}">
<Slider x:Name="SliderFriendlyOpacity" VerticalAlignment="Center" DockPanel.Dock="Right" Width="150"
Expand All @@ -55,15 +55,18 @@
<Label Content="Scale" VerticalAlignment="Center" DockPanel.Dock="Left" />
</DockPanel>
<TextBlock Text="Resurrect" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="When the deck contains 'Resurrect', 'Onyx Bishop', 'Eternal Servitude', or 'Lesser Diamond Spellstone', show the resurrect chance of frendly minions that have died." Style="{StaticResource DescStyle}"/>
<TextBlock Text="When the deck contains 'Resurrect', 'Onyx Bishop', 'Eternal Servitude', or 'Lesser Diamond Spellstone', show the resurrect chance of friendly minions that have died." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding ResurrectEnabled, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable display for resurrect chances." Style="{StaticResource ToggleStyle}"/>
<TextBlock Text="Also show when the deck contains 'Kazakus'." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding ResurrectKazakus, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable display for resurrect chances with Kazakus." Style="{StaticResource ToggleStyle}"/>
<TextBlock Text="N'Zoth" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="When the deck contains 'N'Zoth, the Corruptor', show the deathrattle minions that have died." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding NZothEnabled, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable display for deathrattle minions." Style="{StaticResource ToggleStyle}"/>
<TextBlock Text="Hadronox" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="When the deck contains 'Hadronox', show the friendly taunt minions that have died." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding HadronoxEnabled, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable display for taunt minions." Style="{StaticResource ToggleStyle}"/>
<TextBlock Text="Discard" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="When the deck contains 'Cruel Dinomancer', show resurrect chance of frendly minions that have been discarded." Style="{StaticResource DescStyle}"/>
<TextBlock Text="When the deck contains 'Cruel Dinomancer', show resurrect chance of friendly minions that have been discarded." Style="{StaticResource DescStyle}"/>
<mah:ToggleSwitch IsChecked="{Binding DiscardEnabled, Source={x:Static local:Settings.Default}}" ToolTip="Enable/Disable display for discarded minions." Style="{StaticResource ToggleStyle}"/>
<TextBlock Text="Anyfin" Style="{StaticResource TitleStyle}"/>
<TextBlock Text="When the deck contains 'Anyfin Can Happen', show murlocs that have died and display minimum and maximum possible damage." Style="{StaticResource DescStyle}"/>
Expand Down

0 comments on commit a2532b2

Please # to comment.