Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate savefile #13

Merged
merged 16 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/docker-compose-complete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Complete Docker Compose of App

on:
push:
branches: [ $default-branch ]
pull_request:
branches: [ $default-branch ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker-compose build
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,7 @@ server/venv/
.DS_Store

server/egglocke/db.sqlite3

server/server-venv/

*.sqlite3
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.8'

services:
pkhex:
build: ./pkhex
container_name: pkhex_container
hostname: pkhex_host
ports:
- "1234:1234"
networks:
app_network:

server:
build: ./server
container_name: server_container
hostname: server_host
ports:
- "8443:8443"
networks:
app_network:

networks:
app_network:
driver: bridge

3 changes: 1 addition & 2 deletions pkhex/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ WORKDIR /source
# copy pkhex-egglocke folder to the container
COPY pkhex-egglocke .


# Install pkhex dependency
RUN dotnet restore pkhex-egglocke

Expand All @@ -24,4 +23,4 @@ ENV PORT 1234
EXPOSE 1234

WORKDIR /source/pkhex-egglocke
ENTRYPOINT ["dotnet", "run"]
ENTRYPOINT ["dotnet", "run", "-api"]
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
}
Loading
Loading