diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/EggCreatorTests.cs b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/EggCreatorTests.cs index 82ba435..7bc0c87 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/EggCreatorTests.cs +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/EggCreatorTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using PKHeX.Core; namespace pkhexEgglockeTests { diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/SaveWriterTest.cs b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/SaveWriterTest.cs index 78b79ee..59fda37 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/SaveWriterTest.cs +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/SaveWriterTest.cs @@ -1,3 +1,4 @@ +using PKHeX.Core; using pkhexEgglocke; using System.Reflection; @@ -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 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 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 boxData = sw.getBox(); + + bool isShiny = boxData[1].IsShiny; + + Assert.IsTrue(isShiny); + + } + } } \ No newline at end of file diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/pkhexEgglockeTests.csproj b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/pkhexEgglockeTests.csproj index 71b3f02..2f389bf 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/pkhexEgglockeTests.csproj +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/pkhexEgglockeTests.csproj @@ -16,6 +16,7 @@ + @@ -26,10 +27,6 @@ - - - - Always @@ -37,6 +34,9 @@ Always + + Always + Always diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testConstants.cs b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testConstants.cs index d6a1cfa..659f9d3 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testConstants.cs +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testConstants.cs @@ -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"); diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/LegendaryTrio.json b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/LegendaryTrio.json index b17a451..0ca5c31 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/LegendaryTrio.json +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/LegendaryTrio.json @@ -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 + } ] \ No newline at end of file diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/Mareep.json b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/Mareep.json index 7500fb5..9594ba2 100644 --- a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/Mareep.json +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/Mareep.json @@ -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 } \ No newline at end of file diff --git a/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/MareepShiny.json b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/MareepShiny.json new file mode 100644 index 0000000..70fa354 --- /dev/null +++ b/pkhex/pkhex-egglocke-tests/pkhex-egglocke-tests/testSources/MareepShiny.json @@ -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 +} \ No newline at end of file diff --git a/pkhex/pkhex-egglocke/pkhex-egglocke/HTTPRoutes.cs b/pkhex/pkhex-egglocke/pkhex-egglocke/HTTPRoutes.cs index 14d7026..ff4c27e 100644 --- a/pkhex/pkhex-egglocke/pkhex-egglocke/HTTPRoutes.cs +++ b/pkhex/pkhex-egglocke/pkhex-egglocke/HTTPRoutes.cs @@ -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"); } diff --git a/pkhex/pkhex-egglocke/pkhex-egglocke/PokemonPorter.cs b/pkhex/pkhex-egglocke/pkhex-egglocke/PokemonPorter.cs new file mode 100644 index 0000000..1d5d47e --- /dev/null +++ b/pkhex/pkhex-egglocke/pkhex-egglocke/PokemonPorter.cs @@ -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 + { + } +} diff --git a/pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs b/pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs index c4db04f..0268ec6 100644 --- a/pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs +++ b/pkhex/pkhex-egglocke/pkhex-egglocke/SaveWriter.cs @@ -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); ) { // 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 @@ -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 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) { diff --git a/pkhex/pkhex-egglocke/pkhex-egglocke/pkhexEgglocke.csproj b/pkhex/pkhex-egglocke/pkhex-egglocke/pkhexEgglocke.csproj index d65da40..109a0bd 100644 --- a/pkhex/pkhex-egglocke/pkhex-egglocke/pkhexEgglocke.csproj +++ b/pkhex/pkhex-egglocke/pkhex-egglocke/pkhexEgglocke.csproj @@ -20,6 +20,12 @@ + + Always + + + Always + Always diff --git a/pkhex/pkhex-egglocke/pkhex-egglocke/support/Blank_Pearl.sav b/pkhex/pkhex-egglocke/pkhex-egglocke/support/Blank_Pearl.sav new file mode 100644 index 0000000..3658181 --- /dev/null +++ b/pkhex/pkhex-egglocke/pkhex-egglocke/support/Blank_Pearl.sav @@ -0,0 +1,10 @@ + "3"/".BE/KKa # }wnҜ|F2ha XUauLSk4W45i6d7S߂|VzOn-'?ܐ?AC_ "&7'yS\B }v_jd;7RELuLH56•n |f.W䣢)eagV <}_L?LkX̾.N̥1Xh/(/3AeaG`EB:zę]->ic+I7Eudl3*:0>h5+ DW.nB{E [uO0HFL_IHwFśaW8Ch