From de561f9eb1ee11609fc1ceb974bbd629c0c26de9 Mon Sep 17 00:00:00 2001 From: mikx Date: Sun, 21 Feb 2021 05:27:54 -0500 Subject: [PATCH] initial commit --- PoEconomist.sln | 25 +++ PoEconomist/App.config | 6 + PoEconomist/PoEconomist.csproj | 60 +++++ PoEconomist/Properties/AssemblyInfo.cs | 36 +++ PoEconomist/json/stash.cs | 297 +++++++++++++++++++++++++ PoEconomist/main.cs | 40 ++++ PoEconomist/msg.cs | 142 ++++++++++++ PoEconomist/packages.config | 4 + PoEconomist/web.cs | 87 ++++++++ 9 files changed, 697 insertions(+) create mode 100644 PoEconomist.sln create mode 100644 PoEconomist/App.config create mode 100644 PoEconomist/PoEconomist.csproj create mode 100644 PoEconomist/Properties/AssemblyInfo.cs create mode 100644 PoEconomist/json/stash.cs create mode 100644 PoEconomist/main.cs create mode 100644 PoEconomist/msg.cs create mode 100644 PoEconomist/packages.config create mode 100644 PoEconomist/web.cs diff --git a/PoEconomist.sln b/PoEconomist.sln new file mode 100644 index 0000000..ab9a1bb --- /dev/null +++ b/PoEconomist.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30225.117 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoEconomist", "PoEconomist\PoEconomist.csproj", "{4E0BC41C-322F-492F-904C-DA21EC13E632}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E0BC41C-322F-492F-904C-DA21EC13E632}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E0BC41C-322F-492F-904C-DA21EC13E632}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E0BC41C-322F-492F-904C-DA21EC13E632}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E0BC41C-322F-492F-904C-DA21EC13E632}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {802994A4-F5E8-4169-B6C7-3C978919562F} + EndGlobalSection +EndGlobal diff --git a/PoEconomist/App.config b/PoEconomist/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/PoEconomist/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PoEconomist/PoEconomist.csproj b/PoEconomist/PoEconomist.csproj new file mode 100644 index 0000000..a7b2c4d --- /dev/null +++ b/PoEconomist/PoEconomist.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {4E0BC41C-322F-492F-904C-DA21EC13E632} + Exe + PoEconomist + PoEconomist + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PoEconomist/Properties/AssemblyInfo.cs b/PoEconomist/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7a6226a --- /dev/null +++ b/PoEconomist/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("PoEconomist")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PoEconomist")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("4e0bc41c-322f-492f-904c-da21ec13e632")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PoEconomist/json/stash.cs b/PoEconomist/json/stash.cs new file mode 100644 index 0000000..a5ca821 --- /dev/null +++ b/PoEconomist/json/stash.cs @@ -0,0 +1,297 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PoEconomist.json +{ + class stash + { + public class Colour + { + public int r { get; set; } + public int g { get; set; } + public int b { get; set; } + } + + public class Tab + { + public string n { get; set; } + public int i { get; set; } + public string id { get; set; } + public string type { get; set; } + public bool selected { get; set; } + public Colour colour { get; set; } + public string srcL { get; set; } + public string srcC { get; set; } + public string srcR { get; set; } + } + + public class Socket + { + public int group { get; set; } + public string attr { get; set; } + public string sColour { get; set; } + } + + public class Property + { + public string name { get; set; } + public List> values { get; set; } + public int displayMode { get; set; } + public int? type { get; set; } + } + + public class Requirement + { + public string name { get; set; } + public List> values { get; set; } + public int displayMode { get; set; } + public string suffix { get; set; } + } + + public class AdditionalProperty + { + public string name { get; set; } + public List> values { get; set; } + public int displayMode { get; set; } + public double progress { get; set; } + public int type { get; set; } + } + + public class NextLevelRequirement + { + public string name { get; set; } + public List> values { get; set; } + public int displayMode { get; set; } + } + + public class SocketedItem + { + public bool verified { get; set; } + public int w { get; set; } + public int h { get; set; } + public string icon { get; set; } + public bool support { get; set; } + public string id { get; set; } + public string name { get; set; } + public string typeLine { get; set; } + public bool identified { get; set; } + public int ilvl { get; set; } + public List properties { get; set; } + public List requirements { get; set; } + public List additionalProperties { get; set; } + public List nextLevelRequirements { get; set; } + public string secDescrText { get; set; } + public List explicitMods { get; set; } + public string descrText { get; set; } + public int frameType { get; set; } + public int socket { get; set; } + public string colour { get; set; } + } + + public class Item + { + public bool verified { get; set; } + public int w { get; set; } + public int h { get; set; } + public string icon { get; set; } + public string league { get; set; } + public string id { get; set; } + public List sockets { get; set; } + public string name { get; set; } + public string typeLine { get; set; } + public bool identified { get; set; } + public int ilvl { get; set; } + public bool corrupted { get; set; } + public int frameType { get; set; } + public int x { get; set; } + public int y { get; set; } + public string inventoryId { get; set; } + public List socketedItems { get; set; } + public List properties { get; set; } + public List requirements { get; set; } + public List implicitMods { get; set; } + public List explicitMods { get; set; } + public List craftedMods { get; set; } + public bool? support { get; set; } + public List additionalProperties { get; set; } + public string secDescrText { get; set; } + public string descrText { get; set; } + public List flavourText { get; set; } + public bool? fractured { get; set; } + public List fracturedMods { get; set; } + public List enchantMods { get; set; } + public int? talismanTier { get; set; } + } + + public class Stash + { + public int numTabs { get; set; } + public List tabs { get; set; } + public bool quadLayout { get; set; } + public List items { get; set; } + } + + public static void GenItemText() + { + var files = Directory.GetFiles("tmp","*.txt"); + foreach (var f in files) + { + File.Delete(f); + } + Stash j = JsonConvert.DeserializeObject(File.ReadAllText("stash.json")); + List prop = new List(); + foreach (var i in j.items) + { + if (i.name != "" && i.frameType == 2) + { + prop.Add($"Rarity: Rare"); + prop.Add($"{i.name}"); + prop.Add($"{i.typeLine}"); + prop.Add("--------"); + if (i.properties != null && i.properties.Count() > 0) + { + foreach (var p in i.properties) + { + if (p.name == "Quality") + { + prop.Add($"Quality: {p.values[0][0]}"); + } + if (p.name == "Armour") + { + prop.Add($"Armour: {p.values[0][0]}"); + } + if (p.name == "Energy Shield") + { + prop.Add($"Energy Shield: {p.values[0][0]}"); + } + if (p.name == "Evasion Rating") + { + prop.Add($"Evasion Rating: {p.values[0][0]}"); + } + if (p.values.Count() == 0) + { + prop.Add($"{p.name}"); + } + if (p.name == "Physical Damage") + { + prop.Add($"Physical Damage: {p.values[0][0]}"); + } + if (p.name == "Elemental Damage") + { + prop.Add($"Elemental Damage: {p.values[0][0]}"); + } + if (p.name == "Critical Strike Chance") + { + prop.Add($"Critical Strike Chance: {p.values[0][0]}"); + } + if (p.name == "Attacks per Second") + { + prop.Add($"Attacks per Second: {p.values[0][0]}"); + } + if (p.name == "Weapon Range") + { + prop.Add($"Weapon Range: {p.values[0][0]}"); + } + } + prop.Add("--------"); + } + prop.Add("Requirements:"); + if (i.requirements != null) + { + foreach (var r in i.requirements) + { + if (r.name == "Level") + { + prop.Add($"Level: {r.values[0][0]}"); + } + if (r.name == "Str") + { + prop.Add($"Str: {r.values[0][0]}"); + } + if (r.name == "Dex") + { + prop.Add($"Dex: {r.values[0][0]}"); + } + if (r.name == "Int") + { + prop.Add($"Int: {r.values[0][0]}"); + } + } + } + prop.Add("--------"); + if (i.sockets != null) + { + List g0 = new List(); + List g1 = new List(); + List g2 = new List(); + List g3 = new List(); + List g4 = new List(); + List g5 = new List(); + foreach (var s in i.sockets) + { + if (s.group == 0) + { + g0.Add(s.sColour.ToString()); + } + if (s.group == 1) + { + g1.Add(s.sColour.ToString()); + } + if (s.group == 2) + { + g2.Add(s.sColour.ToString()); + } + if (s.group == 3) + { + g3.Add(s.sColour.ToString()); + } + if (s.group == 4) + { + g4.Add(s.sColour.ToString()); + } + if (s.group == 5) + { + g5.Add(s.sColour.ToString()); + } + } + string g0f = string.Join("-", g0); + string g1f = string.Join("-", g1); + string g2f = string.Join("-", g2); + string g3f = string.Join("-", g3); + string g4f = string.Join("-", g4); + string g5f = string.Join("-", g5); + prop.Add($"{g0f} {g1f} {g2f} {g3f} {g4f} {g5f}"); + } + prop.Add("--------"); + prop.Add($"Item Level: {i.ilvl}"); + prop.Add("--------"); + if (i.implicitMods != null) + { + foreach (var im in i.implicitMods) + { + prop.Add($"{im}"); + } + prop.Add("--------"); + } + if (i.explicitMods != null) + { + foreach (var em in i.explicitMods) + { + prop.Add($"{em}"); + } + } + + + msg.CMW($"{i.name} - {i.typeLine}",true,1); + File.WriteAllLines($@"tmp\{i.id.Substring(0, Math.Min(10, i.id.Length))}_{i.name}_{i.typeLine}.txt", prop); + prop.Clear(); + } + } + } + } +} diff --git a/PoEconomist/main.cs b/PoEconomist/main.cs new file mode 100644 index 0000000..697f58b --- /dev/null +++ b/PoEconomist/main.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Net.Mime.MediaTypeNames; + +namespace PoEconomist +{ + class main + { + public static string version = "1.0.0"; + + static void Main(string[] args) + { + msg.Splash(); + + web.DownloadFile("https://www.pathofexile.com/character-window/get-stash-items?league=Ritual&tabs=1&tabIndex=1&accountName=Bl00DGuY","stash.json"); + + json.stash.GenItemText(); + + EncodeItem(); + } + + public static void EncodeItem() + { + var files = Directory.GetFiles("tmp","*.txt"); + foreach (var f in files) + { + var raw = File.ReadAllBytes(f); + string enc = Convert.ToBase64String(raw); + + int index = f.IndexOf("."); + string ff = f.Substring(0, index); + File.WriteAllText($"{ff}.b64",enc); + } + } + } +} diff --git a/PoEconomist/msg.cs b/PoEconomist/msg.cs new file mode 100644 index 0000000..eca74cc --- /dev/null +++ b/PoEconomist/msg.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PoEconomist +{ + class msg + { + public static void CMW(string msg, bool time, int color) + { + string seconds = ""; + string minutes = ""; + string hours = ""; + if (DateTime.Now.Second < 10) + { + seconds = String.Format("0{0}", DateTime.Now.Second); + } + else + { + seconds = DateTime.Now.Second.ToString(); + } + + if (DateTime.Now.Minute < 10) + { + minutes = String.Format("0{0}", DateTime.Now.Minute); + } + else + { + minutes = DateTime.Now.Minute.ToString(); + } + + if (DateTime.Now.Hour < 10) + { + hours = String.Format("0{0}", DateTime.Now.Hour); + } + else + { + hours = DateTime.Now.Hour.ToString(); + } + + string date = String.Format("{0}:{1}:{2}", hours, minutes, seconds); + + File.AppendAllText("mxfiltergen.logs", String.Format("[{0}] {1}", date, msg) + Environment.NewLine); + + //color switch + ConsoleColor cc = ConsoleColor.White; + switch (color) + { + case 0: + //nothing + break; + case 1: + cc = ConsoleColor.Cyan; + break; + case 2: + cc = ConsoleColor.Green; + break; + case 3: + cc = ConsoleColor.Red; + break; + } + + if (time) + { + Console.ForegroundColor = cc; + Console.WriteLine(String.Format("[{0}] {1}", date, msg)); + } + else + { + Console.ForegroundColor = cc; + Console.WriteLine(String.Format("")); + } + + Console.ForegroundColor = ConsoleColor.White; + } + + public static void drawProgress(int progress, int total) + { + string seconds = ""; + string minutes = ""; + string hours = ""; + if (DateTime.Now.Second < 10) + { + seconds = String.Format("0{0}", DateTime.Now.Second); + } + else + { + seconds = DateTime.Now.Second.ToString(); + } + + if (DateTime.Now.Minute < 10) + { + minutes = String.Format("0{0}", DateTime.Now.Minute); + } + else + { + minutes = DateTime.Now.Minute.ToString(); + } + + if (DateTime.Now.Hour < 10) + { + hours = String.Format("0{0}", DateTime.Now.Hour); + } + else + { + hours = DateTime.Now.Hour.ToString(); + } + string date = String.Format("{0}:{1}:{2}", hours, minutes, seconds); + string beg = String.Format("[{0}] [", date); + Console.ForegroundColor = ConsoleColor.Cyan; + if (progress == 1) + { + Console.Write(beg); + Console.CursorLeft = total + beg.Length; + Console.Write("]"); + } + Console.CursorLeft = (progress + beg.Length) - 1; + Console.Write($"#"); + Console.CursorLeft = beg.Length + total + 2; + Console.Write($"{progress}/{total}"); + if (progress == total) + { + Console.WriteLine(); + } + } + + public static void Splash() + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine(""); + Console.WriteLine("#### MxPoEconomist"); + Console.WriteLine(string.Format("#### VERSION: {0}", main.version)); + Console.WriteLine("#### DEV: mikx"); + Console.WriteLine("#### POWERED BY: poe.ninja"); + Console.WriteLine(""); + Console.ForegroundColor = ConsoleColor.White; + } + } +} diff --git a/PoEconomist/packages.config b/PoEconomist/packages.config new file mode 100644 index 0000000..a9de8b5 --- /dev/null +++ b/PoEconomist/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/PoEconomist/web.cs b/PoEconomist/web.cs new file mode 100644 index 0000000..b151f8b --- /dev/null +++ b/PoEconomist/web.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace PoEconomist +{ + class web + { + public static void SaveString(string url, string path) + { + WebClient wb = new WebClient(); + wb.Encoding = Encoding.UTF8; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; + try + { + Uri uri = new Uri(url); + var str = wb.DownloadString(uri); + File.AppendAllText(path, str, Encoding.UTF8); + } + catch (WebException ex) + { + msg.CMW(ex.Message, true, 3); + msg.CMW("URL: " + url, true, 3); + } + catch (Exception ex) + { + msg.CMW(ex.Message, true, 3); + } + } + + public static string ReadString(string url) + { + WebClient wb = new WebClient(); + wb.Encoding = Encoding.UTF8; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; + var str = ""; + try + { + Uri uri = new Uri(url); + str = wb.DownloadString(uri); + } + catch (WebException ex) + { + msg.CMW(ex.Message, true, 3); + msg.CMW("URL: " + url, true, 3); + } + catch (Exception ex) + { + msg.CMW(ex.Message, true, 3); + } + return str; + } + + public static void DownloadFile(string url, string path) + { + WebClient wb = new WebClient(); + wb.Encoding = Encoding.UTF8; + wb.Headers.Add(HttpRequestHeader.Cookie, "POESESSID=eb883535d0003cffd22530e8178ce271"); + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; + try + { + Uri uri = new Uri(url); + wb.DownloadFile(uri, path); + } + catch (WebException ex) + { + msg.CMW(ex.Message, true, 3); + msg.CMW("URL: " + url, true, 3); + } + catch (Exception ex) + { + msg.CMW(ex.Message, true, 3); + } + } + + } +}