initial commit

This commit is contained in:
mikx 2021-02-21 05:27:54 -05:00
parent 931ad42990
commit de561f9eb1
9 changed files with 697 additions and 0 deletions

25
PoEconomist.sln Normal file
View File

@ -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

6
PoEconomist/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4E0BC41C-322F-492F-904C-DA21EC13E632}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>PoEconomist</RootNamespace>
<AssemblyName>PoEconomist</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="json\stash.cs" />
<Compile Include="main.cs" />
<Compile Include="msg.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="web.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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")]

297
PoEconomist/json/stash.cs Normal file
View File

@ -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<List<object>> values { get; set; }
public int displayMode { get; set; }
public int? type { get; set; }
}
public class Requirement
{
public string name { get; set; }
public List<List<object>> values { get; set; }
public int displayMode { get; set; }
public string suffix { get; set; }
}
public class AdditionalProperty
{
public string name { get; set; }
public List<List<object>> 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<List<object>> 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<Property> properties { get; set; }
public List<Requirement> requirements { get; set; }
public List<AdditionalProperty> additionalProperties { get; set; }
public List<NextLevelRequirement> nextLevelRequirements { get; set; }
public string secDescrText { get; set; }
public List<string> 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<Socket> 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<SocketedItem> socketedItems { get; set; }
public List<Property> properties { get; set; }
public List<Requirement> requirements { get; set; }
public List<string> implicitMods { get; set; }
public List<string> explicitMods { get; set; }
public List<string> craftedMods { get; set; }
public bool? support { get; set; }
public List<AdditionalProperty> additionalProperties { get; set; }
public string secDescrText { get; set; }
public string descrText { get; set; }
public List<string> flavourText { get; set; }
public bool? fractured { get; set; }
public List<string> fracturedMods { get; set; }
public List<string> enchantMods { get; set; }
public int? talismanTier { get; set; }
}
public class Stash
{
public int numTabs { get; set; }
public List<Tab> tabs { get; set; }
public bool quadLayout { get; set; }
public List<Item> 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<Stash>(File.ReadAllText("stash.json"));
List<string> prop = new List<string>();
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<string> g0 = new List<string>();
List<string> g1 = new List<string>();
List<string> g2 = new List<string>();
List<string> g3 = new List<string>();
List<string> g4 = new List<string>();
List<string> g5 = new List<string>();
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();
}
}
}
}
}

40
PoEconomist/main.cs Normal file
View File

@ -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);
}
}
}
}

142
PoEconomist/msg.cs Normal file
View File

@ -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;
}
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
</packages>

87
PoEconomist/web.cs Normal file
View File

@ -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);
}
}
}
}