Skip to content

Commit

Permalink
Add back egg seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Admiral-Fish committed Jul 13, 2024
1 parent 212fd6f commit 25abf5e
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 52 deletions.
1 change: 1 addition & 0 deletions Source/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ add_library(PokeFinderCore STATIC
Gen8/Profile8.cpp
Gen8/Profile8.hpp
Gen8/Raid.hpp
Gen8/States/EggState8.hpp
Gen8/States/IDState8.hpp
Gen8/States/State8.hpp
Gen8/States/WildState8.hpp
Expand Down
17 changes: 7 additions & 10 deletions Source/Core/Gen8/Generators/EggGenerator8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#include "EggGenerator8.hpp"
#include <Core/Enum/Method.hpp>
#include <Core/Gen8/States/EggState8.hpp>
#include <Core/Parents/PersonalInfo.hpp>
#include <Core/Parents/PersonalLoader.hpp>
#include <Core/Parents/States/EggState.hpp>
#include <Core/RNG/RNGList.hpp>
#include <Core/RNG/Xoroshiro.hpp>
#include <Core/RNG/Xorshift.hpp>
Expand All @@ -39,7 +39,7 @@ EggGenerator8::EggGenerator8(u32 initialAdvances, u32 maxAdvances, u32 delay, u8
{
}

std::vector<EggGeneratorState> EggGenerator8::generate(u64 seed0, u64 seed1) const
std::vector<EggState8> EggGenerator8::generate(u64 seed0, u64 seed1) const
{
const PersonalInfo *base = PersonalLoader::getPersonal(profile.getVersion(), daycare.getEggSpecie());
const PersonalInfo *male;
Expand Down Expand Up @@ -74,17 +74,14 @@ std::vector<EggGeneratorState> EggGenerator8::generate(u64 seed0, u64 seed1) con
inheritanceCount = 5;
}

std::vector<EggGeneratorState> states;
std::vector<EggState8> states;
for (u32 cnt = 0; cnt <= maxAdvances; cnt++, rngList.advanceState())
{
if ((rngList.next() % 100) < compatability)
{
// Sign extend seed to signed 64bit
u64 seed = rngList.next();
if (seed & 0x80000000)
{
seed |= 0xffffffff00000000;
}
constexpr u32 SIGN_EXTEND_MASK = 0x80000000;
u64 seed = (static_cast<u64>(rngList.next()) ^ SIGN_EXTEND_MASK) - SIGN_EXTEND_MASK;

XoroshiroBDSP rng(seed);

Expand Down Expand Up @@ -191,8 +188,8 @@ std::vector<EggGeneratorState> EggGenerator8::generate(u64 seed0, u64 seed1) con
// Ball handling check
// Uses a rand call, maybe add later

EggGeneratorState state(initialAdvances + cnt, ec, pid, ivs, ability, gender, 1, nature, Utilities::getShiny<false>(pid, tsv),
inheritance, info);
EggState8 state(initialAdvances + cnt, ec, pid, ivs, ability, gender, 1, nature, Utilities::getShiny<false>(pid, tsv),
inheritance, seed, info);
if (filter.compareState(static_cast<const State &>(state)))
{
states.emplace_back(state);
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Gen8/Generators/EggGenerator8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <Core/Parents/Filters/StateFilter.hpp>
#include <Core/Parents/Generators/EggGenerator.hpp>

class EggGeneratorState;
class EggState8;

/**
* @brief Egg generator for Gen8
Expand Down Expand Up @@ -54,7 +54,7 @@ class EggGenerator8 : public EggGenerator<Profile8, StateFilter>
*
* @return Vector of computed states
*/
std::vector<EggGeneratorState> generate(u64 seed0, u64 seed1) const;
std::vector<EggState8> generate(u64 seed0, u64 seed1) const;

private:
bool shinyCharm;
Expand Down
67 changes: 67 additions & 0 deletions Source/Core/Gen8/States/EggState8.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* This file is part of PokéFinder
* Copyright (C) 2017-2024 by Admiral_Fish, bumba, and EzPzStreamz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef EGGSTATE8_HPP
#define EGGSTATE8_HPP

#include <Core/Parents/States/EggState.hpp>

/**
* @brief State class for Gen8 eggs
*/
class EggState8 : public EggGeneratorState
{
public:
/**
* @brief Construct a new EggState8 object
*
* @param advances Advances of the state
* @param ec Pokemon EC
* @param pid Pokemon PID
* @param ivs Pokemon IVs
* @param ability Pokemon ability
* @param gender Pokemon gender
* @param level Pokemon level
* @param nature Pokemon nature
* @param shiny Pokemon shininess
* @param inheritance Pokemon IV inheritance
* @param seed Egg generation seed
* @param info Pokemon information
*/
EggState8(u32 advances, u32 ec, u32 pid, const std::array<u8, 6> &ivs, u8 ability, u8 gender, u8 level, u8 nature, u8 shiny,
const std::array<u8, 6> &inheritance, u32 seed, const PersonalInfo *info) :
EggGeneratorState(advances, ec, pid, ivs, ability, gender, level, nature, shiny, inheritance, info), seed(seed)
{
}

/**
* @brief Returns the egg seed of the pokemon
*
* @return Pokemon egg seed
*/
u32 getSeed() const
{
return seed;
}

private:
u32 seed;
};

#endif // EGGSTATE8_HPP
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation>Nein</translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation>KP</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation>No</translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation>PS</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation>PV</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation>Quadrato</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation>Stella</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation>PS</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
11 changes: 8 additions & 3 deletions Source/Form/i18n/PokeFinder_zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,17 @@
<context>
<name>EggModel8</name>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Square</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>Star</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.cpp" line="49"/>
<location filename="../../Model/Gen8/EggModel8.cpp" line="51"/>
<source>No</source>
<translation>否</translation>
</message>
Expand Down Expand Up @@ -896,6 +896,11 @@
<source>HP</source>
<translation>HP</translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="86"/>
<source>Egg Seed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../Model/Gen8/EggModel8.hpp" line="87"/>
<source>Atk</source>
Expand Down
Loading

0 comments on commit 25abf5e

Please sign in to comment.