Skip to content

Commit

Permalink
Added extended tooltip (work in progress).
Browse files Browse the repository at this point in the history
Added storage Brimstone Sands - New Corsica
Fixed price overlay for new nwmarketprices API.
Updated game data.
  • Loading branch information
josdemmers committed Nov 21, 2022
1 parent 5f20574 commit 4048c63
Show file tree
Hide file tree
Showing 29 changed files with 4,244 additions and 193 deletions.
1 change: 1 addition & 0 deletions NewWorldCompanion.Constants/StorageLocationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class StorageLocationConstants
{
public const string Brightwood = "Brightwood";
public const string BrimstoneSandsNewCorsica = "Brimstone Sands - New Corsica";
public const string CutlassKeys = "Cutlass Keys";
public const string EbonscaleReach = "Ebonscale Reach";
public const string EdengroveLastStand = "Edengrove - Last Stand";
Expand Down
26 changes: 26 additions & 0 deletions NewWorldCompanion.Entities/CraftingRecipeJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@ namespace NewWorldCompanion.Entities
{
public class CraftingRecipeJson
{
/// <value>Crafted item Category</value>
public string CraftingCategory { get; set; } = string.Empty;
/// <value>Crafted item ItemId</value>
public string ItemID { get; set; } = string.Empty;
/// <value>Matches SalvageAchievement from MasterItemDefinitionsCraftingJson</value>
public string RequiredAchievementID { get; set; } = string.Empty;
public string Tradeskill { get; set; } = string.Empty;

public string Ingredient1 { get; set; } = string.Empty;
public string Ingredient2 { get; set; } = string.Empty;
public string Ingredient3 { get; set; } = string.Empty;
public string Ingredient4 { get; set; } = string.Empty;
public string Ingredient5 { get; set; } = string.Empty;
public string Ingredient6 { get; set; } = string.Empty;
public string Ingredient7 { get; set; } = string.Empty;
public string Type1 { get; set; } = string.Empty;
public string Type2 { get; set; } = string.Empty;
public string Type3 { get; set; } = string.Empty;
public string Type4 { get; set; } = string.Empty;
public string Type5 { get; set; } = string.Empty;
public string Type6 { get; set; } = string.Empty;
public string Type7 { get; set; } = string.Empty;
public int Qty1 { get; set; } = 0;
public int Qty2 { get; set; } = 0;
public int Qty3 { get; set; } = 0;
public int Qty4 { get; set; } = 0;
public int Qty5 { get; set; } = 0;
public int Qty6 { get; set; } = 0;
public int Qty7 { get; set; } = 0;
}
}
4 changes: 4 additions & 0 deletions NewWorldCompanion.Entities/MasterItemDefinitionsJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ public class MasterItemDefinitionsJson : ItemDefinition
public string SalvageAchievement { get; set; } = string.Empty;
/// <value>Used as Tradeskill value for MusicSheets in CraftingRecipe</value>
public string TradingFamily { get; set; } = string.Empty;
/// <value>Item category. Used to categorise, filter, and sort resources.</value>
public string ItemClass { get; set; } = string.Empty;
/// <value>Item tier. Used to sort resources.</value>
public int Tier { get; set; } = 0;
}
}
60 changes: 47 additions & 13 deletions NewWorldCompanion.Entities/NwmarketpriceJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,77 @@
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Windows;

namespace NewWorldCompanion.Entities
{
public class NwmarketpriceJson
{
public string item_name { get; set; } = string.Empty;
public string last_checked { get; set; } = string.Empty;
//public string recent_lowest_price { get; set; } = string.Empty;
public DateTime last_checked { get; set; } = DateTime.MinValue;
public double recent_lowest_price { get; set; } = 0.0;
public List<AvgGraph> avg_graph_data { get; set; } = new List<AvgGraph>();
public List<GrapData> price_graph_data { get; set; } = new List<GrapData>();
public int price_change { get; set; }

[JsonIgnore]
public string last_checked_string
{
get
{
return last_checked.ToString();
}
}

[JsonIgnore]
public string RecentLowestPriceAvg
{
get
get
{
string price = string.Empty;
//NumberStyles style = NumberStyles.AllowDecimalPoint;

try
{
if (avg_graph_data.Count() > 0)
if (price_graph_data.Count() > 0)
{
AvgGraph priceData = avg_graph_data.Last();
price = priceData.price.ToString("F2");
GrapData priceData = price_graph_data.Last();
price = priceData.RollingAverage.ToString("F2");
}
}
catch (Exception){}
catch (Exception) { }

return price;
}
}
}

public class AvgGraph
public class GrapData
{
public DateTime datetime { get; set; }
public double price { get; set; }
/*
// Is the total available of that day. All listings.
[JsonPropertyName("avail")]
public int Avail { get; set; }
[JsonPropertyName("date_only")]
public string DateOnly { get; set; } = string.Empty;
[JsonPropertyName("price_date")]
public DateTime PriceDate { get; set; } = DateTime.MinValue;
// Lowest price seen that day of any scan.
[JsonPropertyName("lowest_price")]
public double LowestPrice { get; set; }
// The available of the lowest price on the server that day.
[JsonPropertyName("single_price_avail")]
public int SinglePriceAvail { get; set; }
// Average price of the lowest 10 prices of the last scan.
[JsonPropertyName("avg_price")]
public double AvgPrice { get; set; }
// Average available of the lowest 10 prices of the last scan
[JsonPropertyName("avg_qty")]
public double AvgQty { get; set; }
*/

/// <summary>
/// The exponential moving average of the lowest prices seen each day for the past 15 days.
/// </summary>
[JsonPropertyName("rolling_average")]
public double RollingAverage { get; set; }
}
}
20 changes: 20 additions & 0 deletions NewWorldCompanion.Entities/PersistableOverlayResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewWorldCompanion.Entities
{
public class PersistableOverlayResource
{
public string ItemId { get; set; } = string.Empty;
public List<PersistableOverlayResourceRecipe> PersistableOverlayResourceRecipes { get; set; } = new List<PersistableOverlayResourceRecipe> { };
}

public class PersistableOverlayResourceRecipe
{
public string ItemId { get; set; } = string.Empty;
public bool IsVisible { get; set; } = false;
}
}
1 change: 1 addition & 0 deletions NewWorldCompanion.Entities/SettingsNWC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SettingsNWC
public bool DebugModeActive { get; set; } = false;

// Overlay
public bool ExtendedTooltipEnabled { get; set; } = false;
public int PriceServerId { get; set; } = 1;

// Shape detection
Expand Down
4 changes: 2 additions & 2 deletions NewWorldCompanion.Helpers/DoubleConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOp
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
reader.TokenType switch
{
JsonTokenType.True => 0.00,
JsonTokenType.True => 1.00,
JsonTokenType.False => 0.00,
JsonTokenType.String => double.TryParse(reader.GetString(), out var b) ? b : 0.00,
JsonTokenType.String => double.TryParse(reader.GetString(), out var d) ? d : 0.00,
JsonTokenType.Number => reader.TryGetDouble(out double d) ? d : 0.00,
JsonTokenType.Null => 0.00,
_ => throw new JsonException(),
Expand Down
29 changes: 29 additions & 0 deletions NewWorldCompanion.Helpers/IntConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace NewWorldCompanion.Helpers
{
public class IntConverter : JsonConverter<int>
{
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) =>
writer.WriteNumberValue(value);

public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
reader.TokenType switch
{
JsonTokenType.True => 1,
JsonTokenType.False => 0,
JsonTokenType.String => int.TryParse(reader.GetString(), out var i) ? i : 0,
JsonTokenType.Number => reader.GetInt32(),
JsonTokenType.Null => 0,
_ => throw new JsonException(),
};


}
}
3 changes: 3 additions & 0 deletions NewWorldCompanion.Interfaces/INewWorldDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ public interface INewWorldDataStore
string GetItemId(string itemName);
ItemDefinition? GetItem(string itemId);
string GetLevenshteinItemName(string itemName);
List<MasterItemDefinitionsJson> GetOverlayResources();
string GetItemLocalisation(string itemMasterName);
List<CraftingRecipeJson> GetRelatedRecipes(string itemId);
}
}
20 changes: 20 additions & 0 deletions NewWorldCompanion.Interfaces/IRelatedPriceManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using NewWorldCompanion.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewWorldCompanion.Interfaces
{
public interface IRelatedPriceManager
{
List<PersistableOverlayResource> PersistableOverlayResources
{
get;
}

void SaveRelatedPricesConfig();
void SetRawResourceRecipeVisibility(string itemIDRawResource, string itemID, bool isVisible);
}
}
Loading

0 comments on commit 4048c63

Please sign in to comment.