Skip to content

Commit

Permalink
Add platinum and fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evinjaff committed Jul 9, 2024
1 parent a038f8a commit ae152e4
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PKHeX.Core;

namespace pkhexEgglockeTests
{
Expand Down
55 changes: 55 additions & 0 deletions pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/SaveWriterTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using PKHeX.Core;
using pkhexEgglocke;
using System.Reflection;

Expand Down Expand Up @@ -60,6 +61,60 @@ public void TestMassAddWorks()

}

[TestMethod]
public void TestNaturesSetCorrectifNotShiny()
{
SaveWriter sw = new SaveWriter(testConstants.JOHTO_PLUS_SOUL_SILVER_SAVE);

EggCreator ec = EggCreator.decodeJSON(testConstants.BLANK_GEN4_MAREEP_VALID, true);

sw.addEgg(ec, 1);

// get egg at box index 1
IList<PKM> boxData = sw.getBox();

Nature expectedNature = Nature.Adamant;

Assert.AreEqual(expectedNature, boxData[1].Nature);

}

[TestMethod]
public void TestNaturesSetCorrectifShiny()
{
SaveWriter sw = new SaveWriter(testConstants.JOHTO_PLUS_SOUL_SILVER_SAVE);

EggCreator ec = EggCreator.decodeJSON(testConstants.BLANK_GEN4_SHINY_MAREEP_VALID, true);

sw.addEgg(ec, 1);

// get egg at box index 1
IList<PKM> boxData = sw.getBox();

Nature expectedNature = Nature.Adamant;

Assert.AreEqual(expectedNature, boxData[1].Nature);

}

[TestMethod]
public void TestShinyCorrect()
{
SaveWriter sw = new SaveWriter(testConstants.JOHTO_PLUS_SOUL_SILVER_SAVE);

EggCreator ec = EggCreator.decodeJSON(testConstants.BLANK_GEN4_SHINY_MAREEP_VALID, true);

sw.addEgg(ec, 1);

// get egg at box index 1
IList<PKM> boxData = sw.getBox();

bool isShiny = boxData[1].IsShiny;

Assert.IsTrue(isShiny);

}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="PKHeX.Core" Version="24.7.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -26,17 +27,16 @@
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

<ItemGroup>
<Folder Include="testSources\" />
</ItemGroup>

<ItemGroup>
<None Update="testSources\emptySoulSilver.sav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testSources\LegendaryTrio.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testSources\MareepShiny.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testSources\Mareep.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class testConstants
// Gen 4 - Egg JSONs
public static string BLANK_GEN4_MAREEP_VALID => Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"testSources"), "Mareep.json");
public static string BLANK_GEN4_LEGENDARY_TRIO => Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"testSources"), "LegendaryTrio.json");

public static string BLANK_GEN4_SHINY_MAREEP_VALID => Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"testSources"), "MareepShiny.json");

// Gen 6 - Omega Ruby Save File
public static string BLANK_OMEGARUBY_SAVE => Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"testSources"), "emptyOmegaRuby.sav");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
[
{
"dexNumber": 483,
"ball": 2,
"language": 1,
"ability": 28,
"nature": 1,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Dialga",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 0, 0, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ]

},
{
"dexNumber": 484,
"ball": 2,
"language": 1,
"ability": 30,
"nature": 1,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Palkia",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 0, 0, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ]

},
{
"dexNumber": 487,
"ball": 2,
"language": 1,
"ability": 5,
"nature": 1,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Giratina",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 0, 0, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ]

}
{
"dexNumber": 483,
"ball": 2,
"language": 1,
"ability": 28,
"nature": 3,
"heldItem": 135,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Dialga",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 252, 252, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ],
"isShiny": true
},
{
"dexNumber": 484,
"ball": 2,
"language": 1,
"ability": 28,
"nature": 3,
"heldItem": 135,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Palkia",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 252, 252, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ],
"isShiny": true
},
{
"dexNumber": 487,
"ball": 2,
"language": 1,
"ability": 28,
"nature": 3,
"heldItem": 135,
"OT": "Dawn",
"OTGender": 1,
"nickname": "Giratina",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 252, 252, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ],
"isShiny": true
}
]
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"dexNumber": 179,
"ball": 2,
"language": 1,
"ability":9,
"nature": 1,
"OT": "Dawn",
"OTGender": 1,
"nickname": "WLW",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 0, 0, 0, 0, 0, 0 ],
"moves": [ 425, 262 ],
"movespp": [ 30, 40 ]

"dexNumber": 179,
"ball": 2,
"language": 1,
"ability": 99,
"nature": 3,
"OT": "Red",
"OTGender": 1,
"nickname": "sheepy2",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 252, 252, 0, 0, 0, 0 ],
"moves": [ 344, 1, 124, 26 ],
"movespp": [ 0, 0, 0, 0 ],
"heldItem": 135,
"isShiny": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dexNumber": 179,
"ball": 2,
"language": 1,
"ability": 99,
"nature": 3,
"OT": "Red",
"OTGender": 1,
"nickname": "sheepy2",
"IV": [ 31, 31, 31, 31, 31, 31 ],
"EV": [ 252, 252, 0, 0, 0, 0 ],
"moves": [ 344, 1, 124, 26 ],
"movespp": [ 0, 0, 0, 0 ],
"heldItem": 135,
"isShiny": true
}
5 changes: 5 additions & 0 deletions pkhex/pkhex-egglocke/pkhex-egglocke/HTTPRoutes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public string getGameSavPath(uint gamecode) {
return @"support/Complete_SoulSilver.sav";
case 10:
return @"support/Blank_Diamond.sav";
case 11:
return @"support/Blank_Pearl.sav";
case 12:
return @"support/Blank_Platinum.sav";

default:
throw new Exception("Invalid game code");
}
Expand Down
12 changes: 12 additions & 0 deletions pkhex/pkhex-egglocke/pkhex-egglocke/PokemonPorter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pkhex_egglocke
{
internal class PokemonPorter
{
}
}
32 changes: 17 additions & 15 deletions pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,20 @@ public void addEgg( EggCreator pokemon, int boxIndex) {

var box = this.currentSave.BoxData;

// FOR SOME REASON PKHEX.CORE DOESN'T F***ING SET NATURES CORRECTLY
// SO I NEED TO RUN THIS LOOP UNTIL IT KICKS OUT THE RIGHT NATURE
// THIS TOOK ME 2 HOURS TO FIGURE OUT
Console.WriteLine((Nature)(mew.PID % 25) == pokemon.Nature);
for (; !( (Nature)(mew.PID % 25) == pokemon.Nature ); )
// Logic to confirm that the PID matches the nature and shininess
for (; !( (Nature)(mew.PID % 25) == pokemon.Nature) && (pokemon.isShiny == pokemon.isShiny); )

Check warning on line 178 in pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs

View workflow job for this annotation

GitHub Actions / build

Comparison made to same variable; did you mean to compare something else?
{
// Attempt to set the nature
mew.SetPIDNature(pokemon.Nature);
Console.WriteLine("Nature after setting");
Console.WriteLine(mew.Nature);
MakeShiny(mew);

}


Console.WriteLine(pokemon.isShiny);
// Set shiny after nature is set
if (pokemon.isShiny)
{
Console.WriteLine("Making Shiny");
MakeShiny(mew);
}


Console.WriteLine("Nature after setting");
Console.WriteLine(mew.Nature);

#if DEBUG
// Check legality of the pokemon
Expand Down Expand Up @@ -249,11 +242,20 @@ public byte[] exportRawBytes() {
public string getOTString() {
if (currentSave == null)
{
throw new Exception("OT field in save file is null- possibly corrupted?");
throw new Exception("Save file is null- possibly corrupted?");
}
return this.currentSave.OT;
}

public IList<PKM> getBox() {
// return the box data
if (currentSave == null)
{
throw new Exception("Save File is null- possibly corrupted?");
}
return this.currentSave.BoxData;
}

// Other utility functions

public void validateConstructor(string filePath) {
Expand Down
6 changes: 6 additions & 0 deletions pkhex/pkhex-egglocke/pkhex-egglocke/pkhexEgglocke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
</ItemGroup>

<ItemGroup>
<None Update="support\Blank_Diamond.sav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="support\Blank_Pearl.sav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="support\Blank_SoulSilver.sav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
10 changes: 10 additions & 0 deletions pkhex/pkhex-egglocke/pkhex-egglocke/support/Blank_Pearl.sav

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions pkhex/pkhex-egglocke/pkhex-egglocke/support/Blank_Platinum.sav

Large diffs are not rendered by default.

Binary file not shown.
4 changes: 3 additions & 1 deletion server/pokepoll/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

PKHEX_GAMECODES = {
"Pokemon SoulSilver": 8,
"Pokemon Diamond": 10
"Pokemon Diamond": 10,
"Pokemon Pearl": 11,
"Pokemon Platinum": 12,
}

@require_GET
Expand Down

0 comments on commit ae152e4

Please sign in to comment.