Skip to content

Commit

Permalink
Tribes and Documentation
Browse files Browse the repository at this point in the history
Support for Beasts, Demons, Murlocs, Pirates, Elementals added.
Added some comments.
  • Loading branch information
PyroGenesis committed Feb 3, 2018
1 parent 95e8e6f commit 69f460a
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## __v0.2.0 - 2018-02-04__

- Minion quest category added to interface
- Full support for Minion Tribes (Beasts, Demons, Murlocs, Pirates, Elementals) added
- Documentation added (for when I inevitably forget)

## __v0.1.0 - 2017-12-24__

- Interface for picking quests added (using HDT menu)
Expand Down
8 changes: 6 additions & 2 deletions Hearthstone-Quest-Tracker/Quest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
namespace Hearthstone_Quest_Tracker
{
/// <summary>
/// Description of Quest.
/// This class describes a quest
/// quest name - display name
/// category = class, minion, other
/// count = cards played that satisfy that quest
/// reward not used yet
/// </summary>
public class Quest
{
Expand All @@ -34,7 +38,7 @@ public Quest(string qname)
this.quest_name = qname;
if(qname.Equals("Hero Power"))
this.category = "other";
else if(qname.Equals("Murloc") || qname.Equals("Demon"))
else if(qname.Equals("Beast") || qname.Equals("Demon") || qname.Equals("Murloc") || qname.Equals("Pirate") || qname.Equals("Demon") || qname.Equals("Elemental"))
this.category = "minion";
else if(qname.Equals("Warrior") || qname.Equals("Shaman") || qname.Equals("Rogue") || qname.Equals("Paladin") || qname.Equals("Hunter") || qname.Equals("Druid") || qname.Equals("Warlock") || qname.Equals("Mage") || qname.Equals("Priest"))
this.category = "class";
Expand Down
11 changes: 8 additions & 3 deletions Hearthstone-Quest-Tracker/QuestOverlay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
namespace Hearthstone_Quest_Tracker
{
/// <summary>
/// Interaction logic for QuestOverlay.xaml
/// Stuff overlays do
/// </summary>
public partial class QuestOverlay : UserControl
{
// Initialization: just clear all fields
public QuestOverlay()
{
InitializeComponent();
Expand All @@ -40,6 +41,8 @@ public QuestOverlay()
Log.Info("----- Display did get initialized -----");
}

// Displays/Hides the overlay in a match and sets its location on screen
// TODO: if count is < 3 shorten the overlay
public void UpdatePosition(int qcount)
{
this.Visibility = (qcount > 0) ? Visibility.Visible : Visibility.Hidden;
Expand All @@ -48,6 +51,9 @@ public void UpdatePosition(int qcount)
Log.Info("----- Display tried to get shown -----");
}

// Erases everything and puts the quest_list back in overlay
// Also calls updatePosition
// TODO: Add a blink effect
public void UpdateQuests(List<Quest> quest_list)
{
classBlock1.Text = "";
Expand Down Expand Up @@ -80,8 +86,7 @@ public void UpdateQuests(List<Quest> quest_list)
default:
Log.Info("----- Invalid quests number -----");
break;
}

}
UpdatePosition(quest_list.Count);
}

Expand Down
20 changes: 17 additions & 3 deletions Hearthstone-Quest-Tracker/QuestPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,37 @@

namespace Hearthstone_Quest_Tracker
{
//Okay so we start here by just extending the Iplugin class
public class QuestPlugin : IPlugin
{
// I needed to create the overlay here so that I could add/remove it from CoreAPI.OverlayCanvas easily (I think)
private QuestOverlay overlay;

// MenuItem to create the choose quests menu
MenuItem menuItem = null;

public void OnLoad()
{
//when it's loaded upon each restart/turned on by the user
// When it's loaded upon each restart/turned on by the user
Log.Info("Hello from quest this is load");

// Overlay created and added on plugin load
overlay = new QuestOverlay();
CoreAPI.OverlayCanvas.Children.Add(overlay);

// Overlay added to Mai class to actually modiy it
QuestTracker tracker = new QuestTracker(overlay);

// Mapping GameEvents from API.GameEvents
GameEvents.OnGameStart.Add(tracker.GameStart);
GameEvents.OnTurnStart.Add(tracker.TurnStart);
GameEvents.OnPlayerPlay.Add(tracker.CardPlay);
GameEvents.OnGameEnd.Add(tracker.GameEnd);
GameEvents.OnPlayerHeroPower.Add(tracker.HeroPower);

// Adding Choose Quest menu label
this.menuItem = new MenuItem() { Header = "Choose Quests" };
// Adding Click event to menuitem which just initializes the QuestSelection overlay
this.menuItem.Click += (sender, e) => {
var x = new QuestSelection(tracker);
};
Expand Down Expand Up @@ -82,12 +93,14 @@ public void OnLoad()
public void OnUnload()
{
// handle unloading here. HDT does not literally unload the assembly
// Removes the tracker overlay
CoreAPI.OverlayCanvas.Children.Remove(overlay);
}

public void OnButtonPress()
{
//when user presses the menu button
// TODO: Add settings to change tracker location
// when user presses the menu button
}

public void OnUpdate()
Expand Down Expand Up @@ -126,7 +139,8 @@ public MenuItem MenuItem

public Version Version
{
get { return new Version(0, 1, 0); }
// Increment to get Dopamine rush
get { return new Version(0, 2, 0); }
}
}
}
2 changes: 2 additions & 0 deletions Hearthstone-Quest-Tracker/QuestSelection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
Width="120">
<ComboBoxItem
x:Name="Class">Class</ComboBoxItem>
<ComboBoxItem
x:Name="Minion">Minion</ComboBoxItem>
<ComboBoxItem
x:Name="Other">Misc</ComboBoxItem>
</ComboBox>
Expand Down
38 changes: 38 additions & 0 deletions Hearthstone-Quest-Tracker/QuestSelection.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,28 @@

namespace Hearthstone_Quest_Tracker
{
/// <summary>
/// A trigger-happy set of dropdowns that is my GUI for choosing quests based on categories
/// May become obsolete once I learn to read Achievements.Log
///
/// I started by using OnSelection but since I reset some fields it led to a cascade of OnSelections firing which were causing a mess
/// So I used DropDownClosed which is much better
/// A set of two methods: loadComboQuestData() and comboItemsGenerator() are used to repopulate the quest dropdown
///
/// TODO: Add support for custom count
/// </summary>
public partial class QuestSelection : Window
{
// Stores actual cateegory and quest chosen
internal string category;
internal string quest;

// The ObservableCollection is a collection that will force UI using it to update (the quest dropdown)
// The tracker object is used for Setting quests (which I get from main tracker)
private ObservableCollection<ComboBoxItem> quest_list;
private QuestTracker tracker;

// Initialize stuff, display the window, empty out category and quest and set the source of quest dropdown to the ObservableCollection
public QuestSelection(QuestTracker _tracker)
{
InitializeComponent();
Expand All @@ -38,6 +53,8 @@ public QuestSelection(QuestTracker _tracker)
comboQuest.ItemsSource = quest_list;
}

// Category should reset everything else so do that
// Plus change the label of, and make quest dropdown visible, and trigger the function that loads data into it based on category
void ComboCategory_DropDownClosed(object sender, EventArgs e)
{
category = ((ComboBoxItem)comboCategory.SelectedItem).Content.ToString();
Expand All @@ -46,6 +63,8 @@ void ComboCategory_DropDownClosed(object sender, EventArgs e)

if(category.Equals("Class"))
labelQuest.Content = "Choose class:";
else if(category.Equals("Minion"))
labelQuest.Content = "Choose minion:";
else if(category.Equals("Misc"))
labelQuest.Content = "Choose quest:";
labelQuest.Visibility = Visibility.Visible;
Expand All @@ -57,6 +76,10 @@ void ComboQuest_DropDownClosed(object sender, EventArgs e)
quest = ((ComboBoxItem)comboQuest.SelectedItem).Content.ToString();
}

// If every data is OK, try to add quest
// If not display error
// If failure display error (>3 quests not possible)
// TODO: Clear everyhing after success or failure
void BtnAddQuest_Click(object sender, RoutedEventArgs e)
{
if(category.Equals("") || quest.Equals(""))
Expand All @@ -77,6 +100,8 @@ void BtnAddQuest_Click(object sender, RoutedEventArgs e)
}
}

// This puts the items in an string array form so that editing and adding is easier
// Triggers comboItemsGenerator() with the appropriate array
private void loadComboQuestData(string _category)
{
string[] classes =
Expand All @@ -91,6 +116,14 @@ private void loadComboQuestData(string _category)
"Warlock",
"Warrior"
};
string[] minions =
{
"Beast",
"Demon",
"Murloc",
"Pirate",
"Elemental"
};
string[] others =
{
"Hero Power"
Expand All @@ -100,12 +133,17 @@ private void loadComboQuestData(string _category)
{
comboItemsGenerator(classes);
}
else if(_category.Equals("Minion"))
{
comboItemsGenerator(minions);
}
else if(_category.Equals("Misc"))
{
comboItemsGenerator(others);
}
}

// Clear the ObservableCollection, convert string array to ComboBoxItem/s and add it to it. Boom, quest dropdown updated.
private void comboItemsGenerator(String[] quests)
{
quest_list.Clear();
Expand Down
23 changes: 18 additions & 5 deletions Hearthstone-Quest-Tracker/QuestTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
namespace Hearthstone_Quest_Tracker
{
/// <summary>
/// Description of QuestTracker.
/// Main class wihich tracks quests
/// </summary>
public class QuestTracker
{
// The tracker overlay
internal QuestOverlay overlay;
// The List of Quests (objects)
internal List<Quest> quest_list;

// Basic initialization and hiding overlay (triggered on plugin load)
public QuestTracker(QuestOverlay _overlay)
{
this.overlay = _overlay;
Expand All @@ -40,6 +43,9 @@ public QuestTracker(QuestOverlay _overlay)
overlay.Hide();
}

// Adding a quest to the list (triggered by QuestSelection)
// Quests are set using display name
// returns status to QuestSelection
internal bool SetQuest(string qname)
{
Quest q = new Quest(qname);
Expand All @@ -64,7 +70,8 @@ internal void TurnStart(ActivePlayer player)
internal void GameStart()
{
Log.Info("Internal GameStart just triggered !!!");
// TODO: Tracker should not run in practice or Spectate mode
// TODO: Tracker should not run in practice or Spectate mode or Dungeon
// Puts quests in overlay and displays overlay
overlay.UpdateQuests(quest_list);
}

Expand All @@ -77,21 +84,26 @@ internal void GameEnd()

internal void CardPlay(Card card)
{
// Booleans to see if tracker should check the card with a particular category of quest
bool classQuest = quest_list.Any(quest => quest.category.Equals("class"));
bool minionQuest = quest_list.Any(quest => quest.category.Equals("minion"));
bool cardTypeQuest = quest_list.Any(quest => quest.category.Equals("cardtype"));
bool otherQuest = quest_list.Any(quest => quest.category.Equals("other"));

Log.Info("----- This card has Race: " + card.Race + " and RaceorType: " + card.RaceOrType + " -----");

if(classQuest)
{
// foreach used instead of searching because Tri-class cards
foreach(var q in quest_list)
{
// card.IsClass used over card.GetPlayerClass because Tri-class cardes go confused
if(card.IsClass(q.quest_name))
q.count++;
}

}

if(minionQuest)
{
foreach(var q in quest_list)
Expand All @@ -101,15 +113,17 @@ internal void CardPlay(Card card)
}
}

// updating overlay count
overlay.UpdateQuests(quest_list);

string oldClass = card.GetPlayerClass;
Log.Info("----- You just played " + oldClass + " " + card.RaceOrType + " card -----");
overlay.UpdateQuests(quest_list);
}

// Only used for the hero power quest
internal void HeroPower()
{
bool otherQuest = quest_list.Any(quest => quest.category.Equals("other"));

if(otherQuest)
{
foreach(var q in quest_list)
Expand All @@ -118,7 +132,6 @@ internal void HeroPower()
q.count++;
}
}

overlay.UpdateQuests(quest_list);
}
}
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@ Hearthstone Quest Tracker
========================
This is a plugin for [Hearthstone Deck Tracker](https://github.com/Epix37/Hearthstone-Deck-Tracker)

Hearthstone has a lot of daily play quests, many of which warrant their own decks. However, there is no way to know the progress of these quests while playing a match.
Hearthstone does not track Daily Quests from within a match. This plugin attempts to fix that. Useful for when you play matches just to complete quests (which I do often).

This plugin attempts to solve this problem by allowing you to set and keep track of progress in your daily quests by tracking played cards.
This plugin does this by allowing you to set and keep track of progress in your daily quests by tracking played cards.


## Features
![overlay](Hearthstone-Quest-Tracker/images/Screenshots/overlay.png)

Keeps track of the following quests (currently)
- Class quests
- Play X Druid cards
- Play X Hunter cards
- Play X Mage cards
- Play X Paladin cards
- Play X Priest cards
- Play X Shaman cards
- Play X Rogue cards
- Play X Warlock cards
- Play X Warrior cards
- Class quests: Play X "Class" cards
- Supports all classes (Druid, Hunter, Mage, Paladin, Priest, Shaman, Rogue, Warlock, Warrior)
- Minion quests
- Play Tribe cards (Beasts, Demons, Murlocs, Pirates, Elementals)
- Miscellaneous quests
- Use Hero Power X times

Expand Down Expand Up @@ -55,6 +49,8 @@ Note: This list will expand as I add support for the rest of play quests.


## Feedback
Currently this tracker is active in all game modes as it is still under development.

I will try to make/keep this plugin functional to the best of my ability. I am very new to C# development so any improvements or suggestions are welcome.

Use the [Issue tracker](https://github.com/PyroGenesis/Hearthstone-Quest-Tracker/issues/new) to send feedback

0 comments on commit 69f460a

Please sign in to comment.