Skip to content

Commit

Permalink
Arena updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rembound committed Mar 14, 2018
1 parent 55a5256 commit 02f7bef
Show file tree
Hide file tree
Showing 8 changed files with 7,860 additions and 14,154 deletions.
8 changes: 1 addition & 7 deletions ArenaHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
<Private>False</Private>
</Reference>
<Reference Include="MahApps.Metro">
<HintPath>packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\..\Software\Games\Hearthstone Deck Tracker\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\..\..\..\Software\Games\Hearthstone Deck Tracker\Newtonsoft.Json.dll</HintPath>
Expand All @@ -58,10 +57,6 @@
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity">
<HintPath>packages\MahApps.Metro.1.1.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down Expand Up @@ -107,7 +102,6 @@
<Compile Include="Update.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Resource Include="resources\font.ttf" />
</ItemGroup>
<ItemGroup>
Expand Down
52 changes: 47 additions & 5 deletions Detection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,48 @@ namespace ArenaHelper
{
public class Detection
{
public class HashData
{
public List<ulong> hashes;

public HashData(params ulong[] hashes)
{
this.hashes = new List<ulong>();

// Store hashes
for (int i = 0; i < hashes.Length; i++)
{
this.hashes.Add(hashes[i]);
}
}
}

public class CardHashData : HashData
{
public string id;

public CardHashData(string id, ulong hash)
: base(hash)
{
this.id = id;
}
}

public class HeroHashData : HashData
{
public int index;
public string name;
public string image;

public HeroHashData(int index, string name, string image, params ulong[] hashes)
: base(hashes)
{
this.index = index;
this.name = name;
this.image = image;
}
}

private const int maxcarddistance = 10;
private const int maxherodistance = 14;

Expand Down Expand Up @@ -92,7 +134,7 @@ public int ConfirmDetected(List<DetectedInfo> detected, List<int> indices, int c
return confirmed;
}

public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectCards(IEnumerable<Plugin.HashData> cardhashlist)
public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectCards(IEnumerable<HashData> cardhashlist)
{
// [cardhash, [cardindex, hashdistance]]
List<Tuple<ulong, List<Tuple<int, int>>>> detected = new List<Tuple<ulong, List<Tuple<int, int>>>>();
Expand All @@ -118,7 +160,7 @@ public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectCards(I
return new Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>>(indices, detected);
}

public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectHeroes(IEnumerable<Plugin.HeroHashData> herohashlist)
public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectHeroes(IEnumerable<HeroHashData> herohashlist)
{
// [herohash, [heroindex, hashdistance]]
List<Tuple<ulong, List<Tuple<int, int>>>> detected = new List<Tuple<ulong, List<Tuple<int, int>>>>();
Expand All @@ -144,7 +186,7 @@ public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectHeroes(
return new Tuple<List<int>,List<Tuple<ulong,List<Tuple<int,int>>>>>(indices, detected);
}

public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectBigHero(IEnumerable<Plugin.HeroHashData> herohashlist)
public Tuple<List<int>, List<Tuple<ulong, List<Tuple<int, int>>>>> DetectBigHero(IEnumerable<HeroHashData> herohashlist)
{
// [bigherohash, [heroindex, hashdistance]]
List<Tuple<ulong, List<Tuple<int, int>>>> detected = new List<Tuple<ulong, List<Tuple<int, int>>>>();
Expand Down Expand Up @@ -347,7 +389,7 @@ public int GetHashDistance(ulong hash1, ulong hash2)
return distance;
}

public List<Tuple<int, int>> FindHashIndex(ulong hash, IEnumerable<Plugin.HashData> hashlist, int maxdistance)
public List<Tuple<int, int>> FindHashIndex(ulong hash, IEnumerable<HashData> hashlist, int maxdistance)
{
int bestindex = -1;
int bestdistance = 100;
Expand Down Expand Up @@ -383,7 +425,7 @@ public List<Tuple<int, int>> FindHashIndex(ulong hash, IEnumerable<Plugin.HashDa
return indices;
}

public List<Tuple<int, int>> FindAllHashIndex(ulong hash, IList<Plugin.CardHashData> hashlist, int maxdistance)
public List<Tuple<int, int>> FindAllHashIndex(ulong hash, IList<CardHashData> hashlist, int maxdistance)
{
List<Tuple<int, int>> indices = new List<Tuple<int, int>>();
for (var i = 0; i < hashlist.Count; i++)
Expand Down
Loading

0 comments on commit 02f7bef

Please sign in to comment.