Skip to content

Commit 0dd084a

Browse files
committed
3.12.4
1 parent cd17c4e commit 0dd084a

22 files changed

+1738
-1527
lines changed

DataModel.cs

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
using System;
2020
using System.Collections.Generic;
21+
using System.ComponentModel;
2122
using System.IO;
2223
using System.Linq;
2324
using System.Text;
@@ -69,16 +70,16 @@ public class DataModel
6970
public IReadOnlyList<string> Enchantments { get; private set; }
7071

7172
private const int MaxErrors = 5;
72-
private int ErrorCount = 0;
7373

7474
private List<IReadOnlyList<string>> conflicts { get; } = new List<IReadOnlyList<string>>();
7575
public IReadOnlyList<IReadOnlyList<string>> DivinationCardNameConflicts => conflicts;
7676

7777
public void Load()
7878
{
79-
ErrorCount = 0;
8079
LoadUniquesCsv();
8180
LoadEnchantsCsv();
81+
UniquesErrors.Clear();
82+
EnchantsErrors.Clear();
8283
GetJsonData(HC);
8384
GetJsonData(SC);
8485
string filterString = Util.ReadWebPage(FiltersUrl + filterFile);
@@ -93,6 +94,19 @@ public void Load()
9394
VersionMinor = int.Parse(m.Groups[2].Value);
9495
VersionRelease = int.Parse(m.Groups[3].Value);
9596
Version = VersionMajor.ToString() + "." + VersionMinor + "." + VersionRelease;
97+
98+
if (UniquesErrors.Count > 0 || EnchantsErrors.Count > 0) {
99+
UniquesErrors = UniquesErrors.Distinct().OrderBy(x => x.BaseType).ThenBy(x => x.Name).ToList();
100+
EnchantsErrors = EnchantsErrors.Distinct().OrderBy(x => x.BaseType).ThenBy(x => x.Name).ToList();
101+
List<string> errs = new List<string>();
102+
if (UniquesErrors.Count > 0) {
103+
errs.Add(UniquesErrors.Count + " uniques");
104+
}
105+
if (EnchantsErrors.Count > 0) {
106+
errs.Add(EnchantsErrors.Count + " enchantments");
107+
}
108+
MessageBox.Show("Missing " + string.Join(", ", errs) + "\n\nThese will be copied to the clipboard. Add them to the CSV files.", "Load JSON", MessageBoxButtons.OK, MessageBoxIcon.Error);
109+
}
96110
}
97111

98112
public void Load(string filename)
@@ -109,9 +123,6 @@ public void Load(string filename)
109123

110124
public void Load(string[] lines)
111125
{
112-
ErrorCount = 0;
113-
//HC.ClearFilterValues();
114-
//SC.ClearFilterValues();
115126
GetFilterData(lines);
116127

117128
DivinationCards = SC.DivinationCards.Keys.OrderBy(x => x).ToList();
@@ -133,6 +144,17 @@ public void Load(string[] lines)
133144
Enchantments = SC.Enchantments.Keys.OrderBy(x => x).ToList();
134145
}
135146

147+
private List<JsonData> UniquesErrors = new List<JsonData>();
148+
private List<JsonData> EnchantsErrors = new List<JsonData>();
149+
150+
public string GetErrorsString()
151+
{
152+
return "Type\tBaseType\tName" + Environment.NewLine +
153+
string.Join(Environment.NewLine,
154+
UniquesErrors.Select(e => "Unique\t" + e.BaseType + "\t" + e.Name)
155+
.Concat(EnchantsErrors.Select(e => "Enchants\t" + e.BaseType + "\t" + e.Name)));
156+
}
157+
136158
private void GetJsonData(LeagueData data)
137159
{
138160
string leagueStr = data.IsHardcore ? "Hardcore " + league : league;
@@ -167,13 +189,9 @@ private void EnchantJsonHandler(JsonData jdata, LeagueData data)
167189
if (!data.EnchantmentsDescriptions.TryGetValue(description, out Enchantment ench)) {
168190
ench = new Enchantment(description);
169191
data.EnchantmentsDescriptions.Add(description, ench);
170-
MessageBox.Show("JSON: The CSV file is missing Enchantment: " + description, "Error", MessageBoxButtons.OK);
171-
ErrorCount++;
192+
EnchantsErrors.Add(jdata);
172193
}
173194
ench.Load(jdata);
174-
if (ErrorCount > MaxErrors) {
175-
Environment.Exit(1);
176-
}
177195
}
178196

179197
private void UniqueJsonHandler(JsonData jdata, LeagueData data)
@@ -182,25 +200,17 @@ private void UniqueJsonHandler(JsonData jdata, LeagueData data)
182200
if (!data.Uniques.TryGetValue(baseTy, out UniqueBaseType uniq)) {
183201
uniq = new UniqueBaseType(baseTy);
184202
data.Uniques.Add(baseTy, uniq);
185-
if (!data.IsHardcore) {
186-
MessageBox.Show("JSON: The CSV file is missing BaseType: " + baseTy, "Error", MessageBoxButtons.OK);
187-
ErrorCount++;
188-
}
189-
}
190-
if (!uniq.Add(jdata) && !data.IsHardcore) {
191-
MessageBox.Show("JSON: The CSV file is missing: " + jdata.BaseType + " " + jdata.Name, "Error", MessageBoxButtons.OK);
192-
ErrorCount++;
193203
}
194-
if (ErrorCount > MaxErrors) {
195-
Environment.Exit(1);
204+
if (!uniq.Add(jdata)) {
205+
UniquesErrors.Add(jdata);
196206
}
197207
}
198208

199209
private void DivinationJsonHandler(JsonData jdata, LeagueData data)
200210
{
201211
string name = jdata.Name;
202-
if (!data.DivinationCards.TryGetValue(name, out DivinationCard div)) {
203-
div = new DivinationCard();
212+
if (!data.DivinationCards.ContainsKey(name)) {
213+
DivinationCard div = new DivinationCard();
204214
data.DivinationCards.Add(name, div);
205215
}
206216
data.DivinationCards[name].Load(jdata);
@@ -241,6 +251,10 @@ private void LoadEnchantsCsv()
241251
: Util.ReadWebPage(repoURL + helmEnchantCsvFile, "", Encoding.UTF8);
242252
EnchantCsv[] records = engine.ReadString(csvText);
243253
foreach (EnchantCsv csvdata in records) {
254+
if (string.IsNullOrWhiteSpace(csvdata.Description))
255+
continue; // skip unknowns
256+
if (csvdata.Description[0] == '=')
257+
csvdata.Description = csvdata.Description.Substring(1);
244258
if (!SC.Enchantments.ContainsKey(csvdata.Description)) {
245259
Enchantment scData = new Enchantment(csvdata.Name);
246260
SC.Enchantments.Add(csvdata.Name, scData);
@@ -364,8 +378,6 @@ private void GetFilterEnchantsData(IEnumerable<string> lines)
364378
else if (line.Contains("10c+"))
365379
value = EnchantmentValue.Chaos10;
366380
else {
367-
//if (!line.Contains("Other"))
368-
// MessageBox.Show("Unexpected Enchant input: " + line, "Error", MessageBoxButtons.OK);
369381
lines = lines.Skip(1);
370382
continue;
371383
}

Enchants/EnchantCsv.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace PoE_Price_Lister
2525
[IgnoreFirst(1)]
2626
public class EnchantCsv
2727
{
28+
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForRead)]
29+
public string Item { get; set; }
30+
2831
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForRead)]
2932
public string Name { get; set; }
3033

@@ -40,6 +43,8 @@ internal class DifficultyConverter : ConverterBase
4043
{
4144
public override object StringToField(string from)
4245
{
46+
if (from.Equals("Eternal Labyrinth of Potential"))
47+
return EnchantmentSource.EternalLabyrinthOfPotential;
4348
if (from.Equals("Merciless Labyrinth"))
4449
return EnchantmentSource.MercilessLab;
4550
if (from.Equals("Eternal Labyrinth"))

Enchants/EnchantmentSource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ public enum EnchantmentSource
2626
CruelLab,
2727
MercilessLab,
2828
EternalLab,
29+
EternalLabyrinthOfPotential,
2930
}
3031
}

JsonData.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
#endregion
1818

1919
using System;
20-
20+
using System.Collections.Generic;
2121
using Newtonsoft.Json;
2222

2323
namespace PoE_Price_Lister
2424
{
2525
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
26-
public class JsonData
27-
{
26+
public sealed class JsonData : IEquatable<JsonData>
27+
{
2828
public JsonData() { }
2929

3030
//[JsonProperty(PropertyName = "id")]
@@ -98,7 +98,27 @@ public JsonData() { }
9898
[JsonProperty(PropertyName = "count")]
9999
public int Count { get; set; } // too low means low accuracy
100100

101-
public override string ToString()
101+
public override bool Equals(object obj)
102+
{
103+
return Equals(obj as JsonData);
104+
}
105+
106+
public bool Equals(JsonData other)
107+
{
108+
return other != null &&
109+
Name == other.Name &&
110+
BaseType == other.BaseType;
111+
}
112+
113+
public override int GetHashCode()
114+
{
115+
int hashCode = -1412448124;
116+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
117+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(BaseType);
118+
return hashCode;
119+
}
120+
121+
public override string ToString()
102122
{
103123
return JsonConvert.SerializeObject(this, Formatting.Indented);
104124
}

MainForm.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ await Task.Run(
268268
buttonGenFilter.Enabled = true;
269269
buttonLoad.Enabled = true;
270270
Text += " (v" + model.Version + ")";
271+
272+
string errors = model.GetErrorsString();
273+
if (errors.Length > 0) {
274+
Invoke(new Action(() => {
275+
Clipboard.SetText(errors);
276+
}));
277+
}
271278
}
272279

273280
private void LoadDataGridViews()

PoE Price Lister.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<DependentUpon>Resources.resx</DependentUpon>
118118
<DesignTime>True</DesignTime>
119119
</Compile>
120+
<None Include="poe_helm_enchants.csv" />
120121
<None Include="README.md" />
121122
<None Include="Resources\FilterNova-AutoUpdater.ahk" />
122123
<None Include="Resources\Filters\filter font enlarger.ahk" />

Resources/Filters/Filters.zip

-2.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)