Skip to content

Commit

Permalink
Added automatically clearing artifact FILTERS, sorting detection not …
Browse files Browse the repository at this point in the history
…implemented.

Improved artifact substat detection for percent boosts?
  • Loading branch information
Cupcak3 committed Feb 2, 2024
1 parent 497bfbc commit 5ba2fce
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 55 deletions.
7 changes: 4 additions & 3 deletions InventoryKamera/InventoryKamera.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
Expand Down Expand Up @@ -236,6 +237,9 @@
<PackageReference Include="InputSimulator">
<Version>1.0.4</Version>
</PackageReference>
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell">
<Version>1.1.5</Version>
</PackageReference>
<PackageReference Include="Microsoft.Win32.Primitives">
<Version>4.3.0</Version>
</PackageReference>
Expand Down Expand Up @@ -269,9 +273,6 @@
<PackageReference Include="Tesseract">
<Version>5.2.0</Version>
</PackageReference>
<PackageReference Include="WindowsAPICodePack">
<Version>7.0.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
12 changes: 2 additions & 10 deletions InventoryKamera/data/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,8 @@ public bool UpdateAvailable()
}

private Version CheckRemoteVersion()
{
var client = new HttpClient
{
BaseAddress = new Uri(commitsAPIURL)
};
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json") );


using (var response = client.GetAsync(commitsAPIURL))
{
using (var response = new HttpClient().GetAsync(commitsAPIURL))
{
string pattern = @"(\d+\.\d+\.\d+)";

Expand Down
50 changes: 14 additions & 36 deletions InventoryKamera/game/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ public static void SelectWeaponInventory()
SetCursor(buttonX, buttonY);
Click();
SystemWait(Speed.UI);

// Scroll item preview hotfix
buttonX = (int)(975 / 1280.0 * GetWidth());
buttonY = (int)(360 / 720.0 * GetHeight());

SetCursor(buttonX, buttonY);
Click();
Scroll(Direction.UP, 15);
Wait(200);
}

public static void SelectArtifactInventory()
Expand All @@ -169,15 +160,6 @@ public static void SelectArtifactInventory()
SetCursor(buttonX, buttonY);
Click();
SystemWait(Speed.UI);

// Scroll item preview hotfix
buttonX = (int)(975 / 1280.0 * GetWidth());
buttonY = (int)(360 / 720.0 * GetHeight());

SetCursor(buttonX, buttonY);
Click();
Scroll(Direction.UP, 15);
Wait(200);
}

public static void SelectCharacterDevelopmentInventory()
Expand All @@ -187,15 +169,6 @@ public static void SelectCharacterDevelopmentInventory()
SetCursor(buttonX, buttonY);
Click();
SystemWait(Speed.UI);

// Scroll item preview hotfix
buttonX = (int)(975 / 1280.0 * GetWidth());
buttonY = (int)(360 / 720.0 * GetHeight());

SetCursor(buttonX, buttonY);
Click();
Scroll(Direction.UP, 15);
Wait(200);
}

public static void SelectMaterialInventory()
Expand All @@ -205,15 +178,6 @@ public static void SelectMaterialInventory()
SetCursor(buttonX, buttonY);
Click();
SystemWait(Speed.UI);

// Scroll item preview hotfix
buttonX = (int)(975 / 1280.0 * GetWidth());
buttonY = (int)(360 / 720.0 * GetHeight());

SetCursor(buttonX, buttonY);
Click();
Scroll(Direction.UP, 15);
Wait(200);
}

public static void SelectCharacterAttributes()
Expand Down Expand Up @@ -575,6 +539,20 @@ public static double GetDelay()
return delay;
}

internal static void ClearArtifactFilters()
{
var x = (IsNormal ? 0.0875 : 0.0868) * GetWidth();
var y = (IsNormal ? 0.9389 : 0.9444) * GetHeight();

for (var i = 0; i < 2; ++i)
{
Click((int)x, (int)y);
SystemWait(Speed.Normal);
}
sim.Keyboard.KeyPress(escapeKey);
SystemWait(Speed.Fast);
}

public enum Speed
{
Slowest,
Expand Down
33 changes: 27 additions & 6 deletions InventoryKamera/scraping/ArtifactScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void ScanArtifacts(int count = 0)

Logger.Info("Found {0} for artifact count.", artifactCount);

ClearFilters();

//if (SortByLevel)
//{
Expand Down Expand Up @@ -145,7 +146,25 @@ public void ScanArtifacts(int count = 0)
}
}

public async void QueueScan(int id)
private void ClearFilters()
{

using (var x = Navigation.CaptureRegion(
x: (int)((Navigation.IsNormal ? 0.0750 : 0.0757) * Navigation.GetWidth()),
y: (int)((Navigation.IsNormal ? 0.8522 : 0.8678) * Navigation.GetHeight()),
width: (int)((Navigation.IsNormal ? 0.2244 : 0.2236) * Navigation.GetWidth()),
height: (int)((Navigation.IsNormal ? 0.0422 : 0.0367) * Navigation.GetHeight())))
{
//Navigation.DisplayBitmap(x);
var t = GenshinProcesor.AnalyzeText(x).Trim().ToLower();
if (t != null && t.Contains("filter"))
{
Navigation.ClearArtifactFilters();
}
}
}

public async void QueueScan(int id)
{
var card = GetItemCard();
Bitmap name, gearSlot, mainStat, subStats, level, equipped, locked;
Expand Down Expand Up @@ -428,7 +447,7 @@ private static List<SubStat> ScanArtifactSubStats(Bitmap artifactImage)
if (line.Any(char.IsDigit))
{
SubStat substat = new SubStat();
Regex re = new Regex(@"([\w]+\W*)(\d+.*\d+)");
Regex re = new Regex(@"^(.*?)(\d+)");
var result = re.Match(line);
var stat = Regex.Replace(result.Groups[1].Value, @"[^\w]", string.Empty);
var value = result.Groups[2].Value;
Expand All @@ -441,14 +460,16 @@ private static List<SubStat> ScanArtifactSubStats(Bitmap artifactImage)
value = Regex.Replace(value, @"[^0-9]", string.Empty);

// Try to parse number
var cultureInfo = new CultureInfo("en-US");
if (!decimal.TryParse(value, NumberStyles.Number, cultureInfo, out substat.value))
if (!decimal.TryParse(value, NumberStyles.Number, CultureInfo.CurrentCulture, out substat.value))
{
Logger.Debug("Failed to parse stat value from: {1}", line);
substat.value = -1;
}

// Need to retain the decimal place for percent boosts
if (substat.stat.Contains("_")) substat.value /= 10;
if (string.IsNullOrWhiteSpace(substat.stat))
{
Logger.Debug("Failed to parse stat from: {1}", line);
}

substats.Insert(i, substat);
}
Expand Down

0 comments on commit 5ba2fce

Please sign in to comment.