Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions LoLMasteryManager/ChampionGG.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Imports System.Net
Imports System.Net.Http
Imports HtmlAgilityPack
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

Module ChampionGG

Expand Down Expand Up @@ -419,19 +420,63 @@ Module ChampionGG
With oMastery
.ID = oRiotMastery.ID
.Name = oRiotMastery.Name
.Tree = oRiotMastery.Tree
.Tree = GetTree(sJson, oRiotMastery.ID)
End With

Return oMastery

Catch ex As Exception

Throw

End Try

End Function

Private Function GetTree(ByVal json As String, ByVal masteryId As Integer) As String

Dim jobj = JObject.Parse(json)

Dim ferocityMasteryIds As List(Of Integer) = ParseMasteryTree("Ferocity", jobj)
Dim cunningMasteryIds As List(Of Integer) = ParseMasteryTree("Cunning", jobj)
Dim resolveMasteryIds As List(Of Integer) = ParseMasteryTree("Resolve", jobj)

If ferocityMasteryIds.Contains(masteryId) Then
Return "Ferocity"
End If

If cunningMasteryIds.Contains(masteryId) Then
Return "Cunning"
End If

If resolveMasteryIds.Contains(masteryId) Then
Return "Resolve"
End If

Throw New IndexOutOfRangeException

End Function

Private Function ParseMasteryTree(ByVal tree As String, ByVal jobj As JObject) As List(Of Integer)

Dim myMasteryIds As List(Of Integer) = New List(Of Integer)()

Dim myMasteryJson = jobj("tree")(tree)
Dim myMasteryGroupJson = myMasteryJson.Children()
For Each grp In myMasteryGroupJson

For Each leafMastery In grp.Children(Of JObject)

Dim masteryIdStr = leafMastery("masteryId").ToString()
Dim masteryIdInt = Int32.Parse(masteryIdStr)
myMasteryIds.Add(masteryIdInt)

Next
Next

Return myMasteryIds

End Function

''' <summary>
''' Extracts the number of assigned mastery ranks from the given node.
''' </summary>
Expand Down
12 changes: 7 additions & 5 deletions LoLMasteryManager/Coordinates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"mastery_coordinates_menu": {
"6111": "387, 267",
"6114": "521, 267",
"6121": "422, 339",
"6122": "489, 339",
"6121": "388, 339",
"6122": "455, 339",
"6123": "522, 339",
"6131": "388, 410",
"6134": "522, 410",
"6141": "422, 481",
Expand Down Expand Up @@ -45,8 +46,9 @@
"mastery_coordinates_champion_select": {
"6111": "397, 186",
"6114": "531, 186",
"6121": "432, 258",
"6122": "499, 258",
"6121": "398, 258",
"6122": "465, 258",
"6123": "532, 258",
"6131": "398, 329",
"6134": "532, 329",
"6141": "432, 400",
Expand Down Expand Up @@ -84,4 +86,4 @@
"6362": "740, 542",
"6363": "807, 542"
}
}
}
89 changes: 89 additions & 0 deletions LoLMasteryManager/Json Utilities/Coordinates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"reference_client_size": "1280, 800",
"mastery_coordinates_menu": {
"6111": "387, 267",
"6114": "521, 267",
"6121": "388, 339",
"6122": "455, 339",
"6123": "522, 339",
"6131": "388, 410",
"6134": "522, 410",
"6141": "422, 481",
"6142": "489, 481",
"6151": "388, 552",
"6154": "522, 552",
"6161": "388, 623",
"6162": "455, 623",
"6164": "522, 623",
"6211": "937, 267",
"6212": "1071, 267",
"6221": "972, 339",
"6223": "1039, 339",
"6231": "938, 410",
"6232": "1072, 410",
"6241": "972, 481",
"6242": "1039, 481",
"6251": "938, 552",
"6252": "1072, 552",
"6261": "938, 623",
"6262": "1005, 623",
"6263": "1072, 623",
"6311": "662, 267",
"6312": "796, 267",
"6321": "663, 339",
"6322": "730, 339",
"6323": "797, 339",
"6331": "663, 410",
"6332": "797, 410",
"6342": "697, 481",
"6343": "764, 481",
"6351": "663, 552",
"6352": "797, 552",
"6361": "663, 623",
"6362": "730, 623",
"6363": "797, 623"
},
"mastery_coordinates_champion_select": {
"6111": "397, 186",
"6114": "531, 186",
"6121": "398, 258",
"6122": "465, 258",
"6123": "532, 258",
"6131": "398, 329",
"6134": "532, 329",
"6141": "432, 400",
"6142": "499, 400",
"6151": "398, 471",
"6154": "532, 471",
"6161": "398, 542",
"6162": "465, 542",
"6164": "532, 542",
"6211": "947, 186",
"6212": "1081, 186",
"6221": "982, 258",
"6223": "1049, 258",
"6231": "948, 329",
"6232": "1082, 329",
"6241": "982, 400",
"6242": "1049, 400",
"6251": "948, 471",
"6252": "1082, 471",
"6261": "948, 542",
"6262": "1015, 542",
"6263": "1082, 542",
"6311": "672, 186",
"6312": "806, 186",
"6321": "673, 258",
"6322": "740, 258",
"6323": "807, 258",
"6331": "673, 329",
"6332": "807, 329",
"6342": "707, 400",
"6343": "774, 400",
"6351": "673, 471",
"6352": "807, 471",
"6361": "673, 542",
"6362": "740, 542",
"6363": "807, 542"
}
}
Loading