Skip to content

Commit 2112988

Browse files
committed
- Updated game data to 4.0
- Fixed connection issue with nwmarketprices.com
1 parent 79504fb commit 2112988

41 files changed

Lines changed: 831495 additions & 849133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NewWorldCompanion.Services/HttpClientHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public HttpClientHandler(IEventAggregator eventAggregator, ILogger<HttpClientHan
3838
_client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue
3939
{
4040
NoCache = true
41-
};
41+
};
42+
_client.DefaultRequestHeaders.Add("User-Agent", "NewWorldCompanion");
4243
_client.DefaultRequestHeaders.Add("X-Requested-With", "XMLHttpRequest");
4344
}
4445

NewWorldCompanion.Services/NewWorldDataStore.cs

Lines changed: 246 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,65 @@ public void UpdateStoreData()
257257
_masterItemDefinitionsJson.AddRange(masterItemDefinitionsJson);
258258
}
259259
}
260-
260+
261261
_loadStatusItemDefinitions = $"ItemDefinitions: {_masterItemDefinitionsJson.Count}";
262262
_loadStatusCraftingRecipes = $"CraftingRecipes: 0. Loading recipes";
263263
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
264264
Thread.Sleep(50);
265265

266-
// CraftingRecipe Json
267266
_craftingRecipesJson.Clear();
268-
resourcePath = @".\Data\CraftingRecipes.json";
267+
268+
// CraftingRecipe Json (CraftingRecipesArcana)
269+
var craftingRecipesJson = new List<CraftingRecipeJson>();
270+
resourcePath = @".\Data\CraftingRecipesArcana.json";
271+
using (FileStream? stream = File.OpenRead(resourcePath))
272+
{
273+
if (stream != null)
274+
{
275+
// create the options
276+
var options = new JsonSerializerOptions()
277+
{
278+
WriteIndented = true
279+
};
280+
// register the converter
281+
options.Converters.Add(new BoolConverter());
282+
options.Converters.Add(new IntConverter());
283+
284+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
285+
_craftingRecipesJson.AddRange(craftingRecipesJson);
286+
}
287+
}
288+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Arcana";
289+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
290+
Thread.Sleep(50);
291+
292+
// CraftingRecipe Json (CraftingRecipesArmorer)
293+
craftingRecipesJson.Clear();
294+
resourcePath = @".\Data\CraftingRecipesArmorer.json";
295+
using (FileStream? stream = File.OpenRead(resourcePath))
296+
{
297+
if (stream != null)
298+
{
299+
// create the options
300+
var options = new JsonSerializerOptions()
301+
{
302+
WriteIndented = true
303+
};
304+
// register the converter
305+
options.Converters.Add(new BoolConverter());
306+
options.Converters.Add(new IntConverter());
307+
308+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
309+
_craftingRecipesJson.AddRange(craftingRecipesJson);
310+
}
311+
}
312+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Armorer";
313+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
314+
Thread.Sleep(50);
315+
316+
// CraftingRecipe Json (CraftingRecipesCooking)
317+
craftingRecipesJson.Clear();
318+
resourcePath = @".\Data\CraftingRecipesCooking.json";
269319
using (FileStream? stream = File.OpenRead(resourcePath))
270320
{
271321
if (stream != null)
@@ -279,10 +329,202 @@ public void UpdateStoreData()
279329
options.Converters.Add(new BoolConverter());
280330
options.Converters.Add(new IntConverter());
281331

282-
_craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
332+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
333+
_craftingRecipesJson.AddRange(craftingRecipesJson);
283334
}
284335
}
336+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Cooking";
337+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
338+
Thread.Sleep(50);
285339

340+
// CraftingRecipe Json (CraftingRecipesDungeon)
341+
craftingRecipesJson.Clear();
342+
resourcePath = @".\Data\CraftingRecipesDungeon.json";
343+
using (FileStream? stream = File.OpenRead(resourcePath))
344+
{
345+
if (stream != null)
346+
{
347+
// create the options
348+
var options = new JsonSerializerOptions()
349+
{
350+
WriteIndented = true
351+
};
352+
// register the converter
353+
options.Converters.Add(new BoolConverter());
354+
options.Converters.Add(new IntConverter());
355+
356+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
357+
_craftingRecipesJson.AddRange(craftingRecipesJson);
358+
}
359+
}
360+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Dungeon";
361+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
362+
Thread.Sleep(50);
363+
364+
// CraftingRecipe Json (CraftingRecipesEngineer)
365+
craftingRecipesJson.Clear();
366+
resourcePath = @".\Data\CraftingRecipesEngineer.json";
367+
using (FileStream? stream = File.OpenRead(resourcePath))
368+
{
369+
if (stream != null)
370+
{
371+
// create the options
372+
var options = new JsonSerializerOptions()
373+
{
374+
WriteIndented = true
375+
};
376+
// register the converter
377+
options.Converters.Add(new BoolConverter());
378+
options.Converters.Add(new IntConverter());
379+
380+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
381+
_craftingRecipesJson.AddRange(craftingRecipesJson);
382+
}
383+
}
384+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Engineer";
385+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
386+
Thread.Sleep(50);
387+
388+
// CraftingRecipe Json (CraftingRecipesGypKilm)
389+
craftingRecipesJson.Clear();
390+
resourcePath = @".\Data\CraftingRecipesGypKilm.json";
391+
using (FileStream? stream = File.OpenRead(resourcePath))
392+
{
393+
if (stream != null)
394+
{
395+
// create the options
396+
var options = new JsonSerializerOptions()
397+
{
398+
WriteIndented = true
399+
};
400+
// register the converter
401+
options.Converters.Add(new BoolConverter());
402+
options.Converters.Add(new IntConverter());
403+
404+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
405+
_craftingRecipesJson.AddRange(craftingRecipesJson);
406+
}
407+
}
408+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading GypKilm";
409+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
410+
Thread.Sleep(50);
411+
412+
// CraftingRecipe Json (CraftingRecipesJeweler)
413+
craftingRecipesJson.Clear();
414+
resourcePath = @".\Data\CraftingRecipesJeweler.json";
415+
using (FileStream? stream = File.OpenRead(resourcePath))
416+
{
417+
if (stream != null)
418+
{
419+
// create the options
420+
var options = new JsonSerializerOptions()
421+
{
422+
WriteIndented = true
423+
};
424+
// register the converter
425+
options.Converters.Add(new BoolConverter());
426+
options.Converters.Add(new IntConverter());
427+
428+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
429+
_craftingRecipesJson.AddRange(craftingRecipesJson);
430+
}
431+
}
432+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Jeweler";
433+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
434+
Thread.Sleep(50);
435+
436+
// CraftingRecipe Json (CraftingRecipesMisc)
437+
craftingRecipesJson.Clear();
438+
resourcePath = @".\Data\CraftingRecipesMisc.json";
439+
using (FileStream? stream = File.OpenRead(resourcePath))
440+
{
441+
if (stream != null)
442+
{
443+
// create the options
444+
var options = new JsonSerializerOptions()
445+
{
446+
WriteIndented = true
447+
};
448+
// register the converter
449+
options.Converters.Add(new BoolConverter());
450+
options.Converters.Add(new IntConverter());
451+
452+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
453+
_craftingRecipesJson.AddRange(craftingRecipesJson);
454+
}
455+
}
456+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Misc";
457+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
458+
Thread.Sleep(50);
459+
460+
// CraftingRecipe Json (CraftingRecipesRefining)
461+
craftingRecipesJson.Clear();
462+
resourcePath = @".\Data\CraftingRecipesRefining.json";
463+
using (FileStream? stream = File.OpenRead(resourcePath))
464+
{
465+
if (stream != null)
466+
{
467+
// create the options
468+
var options = new JsonSerializerOptions()
469+
{
470+
WriteIndented = true
471+
};
472+
// register the converter
473+
options.Converters.Add(new BoolConverter());
474+
options.Converters.Add(new IntConverter());
475+
476+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
477+
_craftingRecipesJson.AddRange(craftingRecipesJson);
478+
}
479+
}
480+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Refining";
481+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
482+
Thread.Sleep(50);
483+
484+
// CraftingRecipe Json (CraftingRecipesSeasons)
485+
craftingRecipesJson.Clear();
486+
resourcePath = @".\Data\CraftingRecipesSeasons.json";
487+
using (FileStream? stream = File.OpenRead(resourcePath))
488+
{
489+
if (stream != null)
490+
{
491+
// create the options
492+
var options = new JsonSerializerOptions()
493+
{
494+
WriteIndented = true
495+
};
496+
// register the converter
497+
options.Converters.Add(new BoolConverter());
498+
options.Converters.Add(new IntConverter());
499+
500+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
501+
_craftingRecipesJson.AddRange(craftingRecipesJson);
502+
}
503+
}
504+
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}. Loading Seasons";
505+
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();
506+
Thread.Sleep(50);
507+
508+
// CraftingRecipe Json (CraftingRecipesWeapon)
509+
craftingRecipesJson.Clear();
510+
resourcePath = @".\Data\CraftingRecipesWeapon.json";
511+
using (FileStream? stream = File.OpenRead(resourcePath))
512+
{
513+
if (stream != null)
514+
{
515+
// create the options
516+
var options = new JsonSerializerOptions()
517+
{
518+
WriteIndented = true
519+
};
520+
// register the converter
521+
options.Converters.Add(new BoolConverter());
522+
options.Converters.Add(new IntConverter());
523+
524+
craftingRecipesJson = JsonSerializer.Deserialize<List<CraftingRecipeJson>>(stream, options) ?? new List<CraftingRecipeJson>();
525+
_craftingRecipesJson.AddRange(craftingRecipesJson);
526+
}
527+
}
286528
_loadStatusCraftingRecipes = $"CraftingRecipes: {_craftingRecipesJson.Count}";
287529
_loadStatusHouseItems = $"HouseItems: 0. Loading items";
288530
_eventAggregator.GetEvent<NewWorldDataStoreStatusUpdated>().Publish();

0 commit comments

Comments
 (0)