Skip to content

Commit

Permalink
Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
siegrest committed Feb 16, 2018
1 parent 63e9604 commit ca72279
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 22 deletions.
122 changes: 104 additions & 18 deletions Pricer/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,111 @@ private void Parse_GemData() {
// Last line will contain "Note:" if item has a note
bool isCorrupted = splitRaw[splitRaw.Length - 1].Contains("Corrupted");

// Different sources have different gem categories
if (Settings.source.ToLower() == "poe.ovh") {
// Special gems have special needs
if (name.Contains("Empower") || name.Contains("Enlighten") || name.Contains("Enhance")) {
if (quality < 6) quality = 0;
else if (quality < 16) quality = 10;
else if (quality >= 16) quality = 20;

// Quality doesn't matter for lvl 3 and 4
if (level > 2) quality = 0;
} else {
if (level < 7) level = 1; // 1 = 1,2,3,4,5,6
else if (level < 19) level = 10; // 10 = 7,8,9,10,11,12,13,14,15,16,17,18
else if (level < 21) level = 20; // 20 = 19,20
// 21 = 21

if (quality < 7) quality = 0; // 0 = 0,1,2,3,4,5,6
else if (quality < 18) quality = 10; // 10 = 7,8,9,10,11,12,13,14,15,16,17
else if (quality < 23) quality = 20; // 20 = 16,17,18,19,20,21,22
// 23 = 23

// Gets rid of specific gems
if (level < 20 && quality > 20) quality = 20; // |4| 1|23|1 and |4|10|23|1
else if (level == 21 && quality < 20) quality = 0; // |4|21|10|1

if (level < 20 && quality < 20) isCorrupted = false;
if (key.Contains("Vaal")) isCorrupted = true;
}
} else if (Settings.source.ToLower() == "poe.ninja") {
// Special gems have special needs
if (name.Contains("Empower") || name.Contains("Enlighten") || name.Contains("Enhance")) {
if (level == 1) {
// Quality can only be 0(1,2,3,4,5,6,7) otherwise set it to -1
if (quality < 8) quality = 0;
else quality = -1;
} else if (level == 2) {
// Quality can be either 0(1,2,3,4,5,6,7) or 20(17,18,19,20) otherwise set it to -1
if (quality < 8) {
quality = 0;
isCorrupted = false;
} else if (quality > 16) {
quality = 20;
isCorrupted = true;
} else quality = -1;
} else if (level == 3) {
// Quality can be either 0(1,2,3,4,5,6,7) or 20(17,18,19,20) otherwise set it to -1
if (quality < 8) {
quality = 0;
isCorrupted = true;
} else if (quality > 16) {
quality = 20;
isCorrupted = false;
} else quality = -1;
} else if (level == 4) {
quality = 0;
}
} else {
if (key.Contains("Vaal")) {
// Level can only be 20(17,18,19,20) otherwise set it to -1
if (level > 16) level = 20;
else level = -1;

// Quality can be either 0(1,2,3,4,5,6,7) or 20(17,18,19,20) otherwise set it to -1
if (quality < 8) quality = 0;
else if (quality > 16) quality = 20;
else quality = -1;
} else {
// Level can be either 1(1,2,3,4,5,6,7) 20(17,18,19,20) or 21(21) otherwise set it to -1
if (level < 8) level = 1;
else if (level > 16 && level < 21) level = 20;
else if (level != 21) level = -1;

// Match quality
switch (level) {
case 1:
// Quality can only be 20(17,18,19,20) otherwise set it to -1
if (quality > 16) {
isCorrupted = true;
quality = 20;
} else quality = -1;
break;
case 20:
// Quality can be either 0(1,2,3,4,5,6,7) or 20(17,18,19,20) or 23(23) otherwise set it to -1
if (quality < 8) quality = 0;
else if (quality > 16 && quality < 23) quality = 20;
else if (quality == 23) quality = 23;
else quality = -1;
break;
case 21:
// Quality can be either 0(1,2,3,4,5,6,7) or 20(17,18,19,20) otherwise set it to -1
if (quality < 8) quality = 0;
else if (quality > 16) quality = 20;
else quality = -1;
break;
default:
break;
}
}
}


// Special gems have special needs
if (name.Contains("Empower") || name.Contains("Enlighten") || name.Contains("Enhance")) {
if (isCorrupted) quality = 0;
else if (quality < 10) quality = 0;
else if (quality < 20) quality = 10;
else if (quality > 20) quality = 20;

if (level == 3) quality = 0;
} else {
if (level < 10) level = 1;
else if (level < 20) level = 10;
if (quality < 10) quality = 0;
else if (quality < 20) quality = 10;
else if (quality == 21) quality = 20;
else if (quality > 21) quality = 23;

if (level < 20) isCorrupted = false;
// Poe.ninja does not have enough data to price most gems
if (quality < 0 || level < 0) {
errorCode = 3;
discard = true;
}
}

// Build key in the format of "<gem name>|4|<lvl>|<quality>"
Expand Down
2 changes: 1 addition & 1 deletion Pricer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void ClipBoard_ItemParseTask(string clipboardString) {
Log("Unable to price items with notes", 2);
break;
case 3:
Log("Unable to price magic items", 2);
Log("Poe.ninja does not have any data for that item. Try Poe.ovh instead", 2);
break;
}
return;
Expand Down
6 changes: 3 additions & 3 deletions Pricer/PriceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ private void DownloadPoeNinjaData() {
Dictionary<string, List<PoeNinjaEntry>> tempDict = new JavaScriptSerializer()
.Deserialize<Dictionary<string, List<PoeNinjaEntry>>>(jsonString);

if (tempDict == null) continue;
if (tempDict == null) throw new Exception("Received no JSON for: " + key);

tempDict.TryGetValue("lines", out List<PoeNinjaEntry> entryList);

if (entryList == null) continue;
if (entryList == null) throw new Exception("Got invalid JSON format for:" + key);

foreach(PoeNinjaEntry ninjaEntry in entryList) {
foreach (PoeNinjaEntry ninjaEntry in entryList) {
// Quick and dirty workarounds
Entry entry = new Entry { count = ninjaEntry.count };
string itemKey;
Expand Down
4 changes: 4 additions & 0 deletions Pricer/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ private void ComboBox_Source_SelectionChanged(object sender, SelectionChangedEve
/// Runs database download task
/// </summary>
private void Button_Download_Click(object sender, RoutedEventArgs e) {
Settings.source = (string)ComboBox_Source.SelectedValue;
Settings.method = (string)ComboBox_Method.SelectedValue;
Settings.league = (string)ComboBox_League.SelectedValue;

Button_Download.IsEnabled = false;

MainWindow.Log("Downloading " + ComboBox_Method.SelectedValue +
Expand Down

0 comments on commit ca72279

Please sign in to comment.