Skip to content

Commit

Permalink
convenience changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pifopi committed Nov 19, 2024
1 parent 231b3ff commit 4a056c4
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/csharp-ci-pkhex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: C# CI PKHex

on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: windows-2022
strategy:
matrix:
configuration: [Debug, Release]

steps:
- uses: actions/checkout@v4
with:
repository: 'pifopi/PKHeX'
path: PKHex
- uses: actions/checkout@v4
with:
repository: 'pifopi/PKHeX-Plugins'
path: PKHeX-Plugins
- uses: actions/checkout@v4
with:
repository: 'pifopi/HOME-Live-Plugin'
path: HOME-Live-Plugin
- uses: microsoft/setup-msbuild@v1
- name: Generate binaries
run: |
cd PKHeX
dotnet restore /p:Configuration=${{ matrix.configuration }} /p:Platform="Any CPU"
MSBuild.exe PKHeX.WinForms/PKHeX.WinForms.csproj /p:Configuration=${{ matrix.configuration }}
cd ../PKHeX-Plugins
dotnet restore /p:Configuration=${{ matrix.configuration }} /p:Platform="Any CPU"
MSBuild.exe AutoLegalityMod/AutoModPlugins.csproj /p:Configuration=${{ matrix.configuration }}
robocopy AutoLegalityMod\bin\${{ matrix.configuration }}\net8.0-windows ..\PKHeX\PKHeX.WinForms\bin\${{ matrix.configuration }}\net8.0-windows\win-x64\plugins\ AutoModPlugins.dll
$PKHeXPlugins = $lastexitcode
write-host "Robocopy PKHeX-Plugins exited with exit code:" $PKHeXPlugins
cd ../HOME-Live-Plugin
dotnet restore /p:Configuration=${{ matrix.configuration }} /p:Platform="Any CPU"
MSBuild.exe HomeLive.Plugins/HomeLive.Plugins.csproj /p:Configuration=${{ matrix.configuration }}
robocopy HomeLive.Plugins\bin\${{ matrix.configuration }}\net8.0-windows7.0 ..\PKHeX\PKHeX.WinForms\bin\${{ matrix.configuration }}\net8.0-windows\win-x64\plugins\ HomeLive.Plugins.dll
$HOMELivePlugin = $lastexitcode
write-host "Robocopy HOME-Live-Plugin exited with exit code:" $HOMELivePlugin
if ($PKHeXPlugins -ne 1 -or $HOMELivePlugin -ne 1)
{
exit 1
}
else
{
exit 0
}
- uses: actions/upload-artifact@v4
with:
name: PKHeX for windows (${{ matrix.configuration }})
path: PKHeX/PKHeX.WinForms/bin/${{ matrix.configuration }}/net8.0-windows/win-x64
18 changes: 16 additions & 2 deletions PKHeX.Core/PKM/Util/EntityFileNamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@ public string GetName(PKM obj)
private static string GetRegular(PKM pk)
{
var chk = pk is ISanityChecksum s ? s.Checksum : Checksums.Add16(pk.Data.AsSpan()[8..pk.SIZE_STORED]);
var form = pk.Form != 0 ? $"-{pk.Form:00}" : string.Empty;
var form = $"-{pk.Form:00}";
var star = pk.IsShiny ? " ★" : string.Empty;
return $"{pk.Species:0000}{form}{star} - {pk.Nickname} - {chk:X4}{pk.EncryptionConstant:X8}";
var IV = $"{pk.IV_HP}_{pk.IV_ATK}_{pk.IV_DEF}_{pk.IV_SPA}_{pk.IV_SPD}_{pk.IV_SPE}";
var ball = "other";
switch (pk.Ball)
{
case 4:
ball = "poke";
break;
case 25:
ball = "dream";
break;
case 26:
ball = "beast";
break;
}
return $"{pk.Species:0000}{form}{star} - {pk.Nickname} - {IV} - {ball} - {chk:X4}{pk.EncryptionConstant:X8}";
}

private static string GetGBPKM(GBPKM gb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ public int GiveItem(SaveFile sav, ushort itemID, int count = -1)

var newItem = Items[emptyIndex];
newItem.Index = itemID;
newItem.SetNewDetails(0);
return AddCountTo(newItem, count, sav);
}

Expand Down
47 changes: 47 additions & 0 deletions PKHeX.Core/Saves/Util/BoxUtil.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

Expand All @@ -21,6 +22,12 @@ public static class BoxUtil
/// <returns>-1 if aborted, otherwise the amount of files dumped.</returns>
public static int DumpBoxes(this SaveFile sav, string path, bool boxFolders = false)
{
string pokemonList = "";
pokemonList += $"National dex,Form,Regional dex,French name,English name,Inside raids Poke,Inside raids Beast,Inside raids Dream,Outside raids Poke,Outside raids Beast,Outside raids Dream\n";

string filter = "[";
bool first = true;

if (!sav.HasBox)
return -1;

Expand Down Expand Up @@ -50,7 +57,47 @@ public static int DumpBoxes(this SaveFile sav, string path, bool boxFolders = fa

File.WriteAllBytes(fn, pk.DecryptedPartyData);
ctr++;

var basePath = "C:\\Users\\dotte\\Documents\\GitHub\\PokemonDatabase\\SV\\living dex shiny\\";
var basePathInsideRaids = basePath + "inside raids\\";
var filesPokeInsideRaids = Directory.EnumerateFiles(basePathInsideRaids + "poke\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);
var filesBeastInsideRaids = Directory.EnumerateFiles(basePathInsideRaids + "beast\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);
var filesDreamInsideRaids = Directory.EnumerateFiles(basePathInsideRaids + "dream\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);
var basePathOutsideRaids = basePath + "outside raids\\";
var filesPokeOutsideRaids = Directory.EnumerateFiles(basePathOutsideRaids + "poke\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);
var filesBeastOutsideRaids = Directory.EnumerateFiles(basePathOutsideRaids + "beast\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);
var filesDreamOutsideRaids = Directory.EnumerateFiles(basePathOutsideRaids + "dream\\", $"{pk.Species:0000}-{pk.Form:00}*", SearchOption.AllDirectories);

var french_name = SpeciesName.GetSpeciesNameGeneration(pk.Species, (int)LanguageID.French, pk.Format);
var english_name = SpeciesName.GetSpeciesNameGeneration(pk.Species, (int)LanguageID.English, pk.Format);
pokemonList += $"{pk.Species:0000},{pk.Form:00},{((PersonalInfo9SV)pk.PersonalInfo).DexPaldea},{french_name},{english_name}";
pokemonList += $",{filesPokeInsideRaids.Count()},{filesBeastInsideRaids.Count()},{filesDreamInsideRaids.Count()}";
pokemonList += $",{filesPokeOutsideRaids.Count()},{filesBeastOutsideRaids.Count()},{filesDreamOutsideRaids.Count()}\n";

if (!filesPokeInsideRaids.Any() &&
!filesBeastInsideRaids.Any() &&
!filesDreamInsideRaids.Any() &&
!filesPokeOutsideRaids.Any() &&
!filesBeastOutsideRaids.Any() &&
!filesDreamOutsideRaids.Any())
{
if (first)
{
first = false;
}
else
{
filter += ",";
}
filter += $"{{\"Name\":\"{pk.Species:0000} {french_name} {english_name} shiny\",\"Species\":{pk.Species},\"Form\":{pk.Form},\"Shiny\":true,\"Enabled\":true}}";
}
}

File.WriteAllText("pokemon_list.csv", pokemonList);

filter += "]";
File.WriteAllText("filters.json", filter);

return ctr;
}

Expand Down
17 changes: 17 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
for %%X in (Debug Release) do (
pushd %~dp0
dotnet restore /p:Configuration=%%X /p:Platform="Any CPU"
MSBuild.exe PKHeX.WinForms/PKHeX.WinForms.csproj /p:Configuration=%%X

cd ../PKHeX-Plugins
dotnet restore /p:Configuration=%%X /p:Platform="Any CPU"
MSBuild.exe AutoLegalityMod/AutoModPlugins.csproj /p:Configuration=%%X
robocopy AutoLegalityMod\bin\%%X\net8.0-windows ..\PKHeX\PKHeX.WinForms\bin\%%X\net8.0-windows\win-x64\plugins\ AutoModPlugins.dll

cd ../HOME-Live-Plugin
dotnet restore /p:Configuration=%%X /p:Platform="Any CPU"
MSBuild.exe HomeLive.Plugins/HomeLive.Plugins.csproj /p:Configuration=%%X
robocopy HomeLive.Plugins\bin\%%X\net8.0-windows7.0 ..\PKHeX\PKHeX.WinForms\bin\%%X\net8.0-windows\win-x64\plugins\ HomeLive.Plugins.dll

popd
)

0 comments on commit 4a056c4

Please sign in to comment.