id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,536,262
|
utils.cpp
|
FlagBrew_PKSM-Core/source/utils/utils.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "utils/utils.hpp"
#include "g1text.hpp"
#include "g2text.hpp"
#include "g3text.hpp"
#include "g4text.hpp"
#include "utils/endian.hpp"
#include <algorithm>
#include <array>
#include <map>
#include <queue>
#include <vector>
namespace
{
char32_t swapCodepoints45(char32_t codepoint)
{
switch (codepoint)
{
case u'\u2227':
codepoint = u'\uE0A9';
break;
case u'\u2228':
codepoint = u'\uE0AA';
break;
case u'\u2460':
codepoint = u'\uE081';
break;
case u'\u2461':
codepoint = u'\uE082';
break;
case u'\u2462':
codepoint = u'\uE083';
break;
case u'\u2463':
codepoint = u'\uE084';
break;
case u'\u2464':
codepoint = u'\uE085';
break;
case u'\u2465':
codepoint = u'\uE086';
break;
case u'\u2466':
codepoint = u'\uE087';
break;
case u'\u2469':
codepoint = u'\uE068';
break;
case u'\u246A':
codepoint = u'\uE069';
break;
case u'\u246B':
codepoint = u'\uE0AB';
break;
case u'\u246C':
codepoint = u'\uE08D';
break;
case u'\u246D':
codepoint = u'\uE08E';
break;
case u'\u246E':
codepoint = u'\uE08F';
break;
case u'\u246F':
codepoint = u'\uE090';
break;
case u'\u2470':
codepoint = u'\uE091';
break;
case u'\u2471':
codepoint = u'\uE092';
break;
case u'\u2472':
codepoint = u'\uE093';
break;
case u'\u2473':
codepoint = u'\uE094';
break;
case u'\u2474':
codepoint = u'\uE095';
break;
case u'\u2475':
codepoint = u'\uE096';
break;
case u'\u2476':
codepoint = u'\uE097';
break;
case u'\u2477':
codepoint = u'\uE098';
break;
case u'\u2478':
codepoint = u'\uE099';
break;
case u'\u2479':
codepoint = u'\uE09A';
break;
case u'\u247A':
codepoint = u'\uE09B';
break;
case u'\u247B':
codepoint = u'\uE09C';
break;
case u'\u247C':
codepoint = u'\uE09D';
break;
case u'\u247D':
codepoint = u'\uE09E';
break;
case u'\u247E':
codepoint = u'\uE09F';
break;
case u'\u247F':
codepoint = u'\uE0A0';
break;
case u'\u2480':
codepoint = u'\uE0A1';
break;
case u'\u2481':
codepoint = u'\uE0A2';
break;
case u'\u2482':
codepoint = u'\uE0A3';
break;
case u'\u2483':
codepoint = u'\uE0A4';
break;
case u'\u2484':
codepoint = u'\uE0A5';
break;
case u'\u2485':
codepoint = u'\uE06A';
break;
case u'\u2486':
codepoint = u'\uE0A7';
break;
case u'\u2487':
codepoint = u'\uE0A8';
break;
case u'\uE0A9':
codepoint = u'\u2227';
break;
case u'\uE0AA':
codepoint = u'\u2228';
break;
case u'\uE081':
codepoint = u'\u2460';
break;
case u'\uE082':
codepoint = u'\u2461';
break;
case u'\uE083':
codepoint = u'\u2462';
break;
case u'\uE084':
codepoint = u'\u2463';
break;
case u'\uE085':
codepoint = u'\u2464';
break;
case u'\uE086':
codepoint = u'\u2465';
break;
case u'\uE087':
codepoint = u'\u2466';
break;
case u'\uE068':
codepoint = u'\u2469';
break;
case u'\uE069':
codepoint = u'\u246A';
break;
case u'\uE0AB':
codepoint = u'\u246B';
break;
case u'\uE08D':
codepoint = u'\u246C';
break;
case u'\uE08E':
codepoint = u'\u246D';
break;
case u'\uE08F':
codepoint = u'\u246E';
break;
case u'\uE090':
codepoint = u'\u246F';
break;
case u'\uE091':
codepoint = u'\u2470';
break;
case u'\uE092':
codepoint = u'\u2471';
break;
case u'\uE093':
codepoint = u'\u2472';
break;
case u'\uE094':
codepoint = u'\u2473';
break;
case u'\uE095':
codepoint = u'\u2474';
break;
case u'\uE096':
codepoint = u'\u2475';
break;
case u'\uE097':
codepoint = u'\u2476';
break;
case u'\uE098':
codepoint = u'\u2477';
break;
case u'\uE099':
codepoint = u'\u2478';
break;
case u'\uE09A':
codepoint = u'\u2479';
break;
case u'\uE09B':
codepoint = u'\u247A';
break;
case u'\uE09C':
codepoint = u'\u247B';
break;
case u'\uE09D':
codepoint = u'\u247C';
break;
case u'\uE09E':
codepoint = u'\u247D';
break;
case u'\uE09F':
codepoint = u'\u247E';
break;
case u'\uE0A0':
codepoint = u'\u247F';
break;
case u'\uE0A1':
codepoint = u'\u2480';
break;
case u'\uE0A2':
codepoint = u'\u2481';
break;
case u'\uE0A3':
codepoint = u'\u2482';
break;
case u'\uE0A4':
codepoint = u'\u2483';
break;
case u'\uE0A5':
codepoint = u'\u2484';
break;
case u'\uE06A':
codepoint = u'\u2485';
break;
case u'\uE0A7':
codepoint = u'\u2486';
break;
case u'\uE0A8':
codepoint = u'\u2487';
break;
default:
break;
}
return codepoint;
}
char32_t swapCodepoints67(char32_t codepoint)
{
switch (codepoint)
{
case u'\uE088':
codepoint = u'\u00D7';
break;
case u'\uE089':
codepoint = u'\u00F7';
break;
case u'\uE08A':
codepoint = u'\uE068';
break;
case u'\uE08B':
codepoint = u'\uE069';
break;
case u'\uE08C':
codepoint = u'\uE0AB';
break;
case u'\uE0A6':
codepoint = u'\uE06A';
break;
case u'\u00D7':
codepoint = u'\uE088';
break;
case u'\u00F7':
codepoint = u'\uE089';
break;
case u'\uE068':
codepoint = u'\uE08A';
break;
case u'\uE069':
codepoint = u'\uE08B';
break;
case u'\uE0AB':
codepoint = u'\uE08C';
break;
case u'\uE06A':
codepoint = u'\uE0A6';
break;
}
return codepoint;
}
// Converts a single latin character from half-width to full-width
char16_t tofullwidth(char16_t c)
{
if (c == ' ')
{
c = u' ';
}
else if (c >= '!' && c <= '~')
{
c += 0xFEE0;
}
return c;
}
}
std::u16string StringUtils::UTF8toUTF16(const std::string_view& src)
{
std::u16string ret;
ret.reserve(src.size());
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF8toCodepoint(src.data() + i, src.size() - i);
auto [data, newSize] = codepointToUTF16(codepoint);
ret.append(data.data(), newSize);
i += advance;
}
return ret;
}
// Nearly identical, just without the 21-bit case
std::u16string StringUtils::UTF8toUCS2(const std::string_view& src)
{
std::u16string ret;
ret.reserve(src.size());
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF8toCodepoint(src.data() + i, src.size() - i);
ret.push_back(codepointToUCS2(codepoint));
i += advance;
}
return ret;
}
std::u32string StringUtils::UTF8toUTF32(const std::string_view& src)
{
std::u32string ret;
ret.reserve(src.size());
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF8toCodepoint(src.data() + i, src.size() - i);
ret.push_back(codepoint);
i += advance;
}
return ret;
}
std::string StringUtils::UTF16toUTF8(const std::u16string_view& src)
{
std::string ret;
ret.reserve(src.size()); // Size must be greater than or equal to this
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF16toCodepoint(src.data() + i, src.size() - i);
auto [data, newSize] = codepointToUTF8(codepoint);
ret.append(data.data(), newSize);
i += advance;
}
return ret;
}
std::u16string StringUtils::UTF16toUCS2(const std::u16string_view& src)
{
std::u16string ret;
ret.reserve(src.size());
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF16toCodepoint(src.data() + i, src.size() - i);
ret.push_back(codepointToUCS2(codepoint));
i += advance;
}
return ret;
}
std::u32string StringUtils::UTF16toUTF32(const std::u16string_view& src)
{
std::u32string ret;
ret.reserve(src.size());
size_t i = 0;
while (i < src.size())
{
auto [codepoint, advance] = UTF16toCodepoint(src.data() + i, src.size() - i);
ret.push_back(codepoint);
i += advance;
}
return ret;
}
std::string StringUtils::UTF32toUTF8(const std::u32string_view& src)
{
std::string ret;
ret.reserve(src.size()); // Length *must* be greater than or equal to this.
for (const char32_t codepoint : src)
{
auto [data, size] = codepointToUTF8(codepoint);
ret.append(data.data(), size);
}
return ret;
}
std::u16string StringUtils::UTF32toUTF16(const std::u32string_view& src)
{
std::u16string ret;
ret.reserve(src.size());
for (char32_t codepoint : src)
{
auto [data, size] = codepointToUTF16(codepoint);
ret.append(data.data(), size);
}
return ret;
}
std::u16string StringUtils::UTF32toUCS2(const std::u32string_view& src)
{
std::u16string ret;
for (const char32_t& codepoint : src)
{
ret.push_back(codepointToUCS2(codepoint));
}
return ret;
}
std::pair<std::array<char, 4>, size_t> StringUtils::codepointToUTF8(char32_t codepoint)
{
if (codepoint < 0x0000'0080)
{
return {
{(char)codepoint, 0, 0, 0},
1
};
}
else if (codepoint < 0x0000'0800)
{
return {
{(char)(0xC0 | ((codepoint >> 6) & 0x1F)), (char)(0x80 | (codepoint & 0x3F)), 0, 0},
2
};
}
else if (codepoint < 0x0001'0000)
{
return {
{(char)(0xE0 | ((codepoint >> 12) & 0x0F)), (char)(0x80 | ((codepoint >> 6) & 0x3F)),
(char)(0x80 | (codepoint & 0x3F)), 0},
3
};
}
// Current maximum codepoint is defined to be U+10FFFF
else if (codepoint < 0x0011'0000)
{
return {
{(char)(0xF0 | ((codepoint >> 18) & 0x07)), (char)(0x80 | ((codepoint >> 12) & 0x3F)),
(char)(0x80 | ((codepoint >> 6) & 0x3F)), (char)(0x80 | (codepoint & 0x3F))},
4
};
}
else
{
return {
{(char)(0xE0 | ((CODEPOINT_INVALID >> 12) & 0x1F)),
(char)(0x80 | ((CODEPOINT_INVALID >> 6) & 0x3F)),
(char)(0x80 | (CODEPOINT_INVALID & 0x3F)), 0},
3
};
}
}
std::pair<std::array<char16_t, 2>, size_t> StringUtils::codepointToUTF16(char32_t codepoint)
{
if (codepoint <= 0x0000'D7FF || (codepoint >= 0x0000'E000 && codepoint < 0x0001'0000))
{
return {
{(u16)codepoint, 0},
1
};
}
// Current maximum codepoint is defined to be U+10FFFF
else if (codepoint >= 0x0001'0000 && codepoint < 0x0011'0000)
{
codepoint -= 0x10000; // Make it fit in 20 bits
return {
{(u16)(0xD800 | ((codepoint >> 10) & 0x3FF)), (u16)(0xDC00 | (codepoint & 0x03FF))},
2
};
}
else
{
return {
{CODEPOINT_INVALID, 0},
1
};
}
}
u16 StringUtils::codepointToUCS2(char32_t codepoint)
{
if (codepoint <= 0x0000'D7FF || (codepoint >= 0x0000'E000 && codepoint < 0x0001'0000))
{
return codepoint;
}
else
{
return CODEPOINT_INVALID;
}
}
std::pair<char32_t, size_t> StringUtils::UTF8toCodepoint(const char* src, size_t maxSize)
{
char32_t codepoint = CODEPOINT_INVALID;
size_t size = 1;
if ((src[0] & 0xF8) == 0xF0 && 3 < maxSize && (src[1] & 0xC0) == 0x80 &&
(src[2] & 0xC0) == 0x80 && (src[3] & 0xC0) == 0x80)
{
codepoint = src[0] & 0x07;
codepoint = codepoint << 6 | (src[1] & 0x3F);
codepoint = codepoint << 6 | (src[2] & 0x3F);
codepoint = codepoint << 6 | (src[3] & 0x3F);
size = 4;
}
else if ((src[0] & 0xF0) == 0xE0 && 2 < maxSize && (src[1] & 0xC0) == 0x80 &&
(src[2] & 0xC0) == 0x80)
{
codepoint = src[0] & 0x0F;
codepoint = codepoint << 6 | (src[1] & 0x3F);
codepoint = codepoint << 6 | (src[2] & 0x3F);
size = 3;
}
else if ((src[0] & 0xE0) == 0xC0 && 1 < maxSize && (src[1] & 0xC0) == 0x80)
{
codepoint = src[0] & 0x1F;
codepoint = codepoint << 6 | (src[1] & 0x3F);
size = 2;
}
else if (!(src[0] & 0x80))
{
codepoint = src[0];
}
return {codepoint, size};
}
std::pair<char32_t, size_t> StringUtils::UTF16toCodepoint(const char16_t* src, size_t maxSize)
{
char32_t codepoint = CODEPOINT_INVALID;
size_t size = 1;
if (src[0] <= 0xD7FF || src[0] >= 0xE000)
{
codepoint = src[0];
}
else if (((src[0] & 0xFC00) == 0xD800) && 1 < maxSize && ((src[1] & 0xFC00) == 0xDC00))
{
codepoint = (char32_t(src[0] & 0x03FF) << 10) | (src[1] & 0x03FF);
codepoint += 0x10000; // 20->21 bits
size = 2;
}
return {codepoint, size};
}
std::u32string StringUtils::getU32String(const u8* data, int ofs, int len, char16_t term)
{
std::u32string ret;
ret.reserve(len);
for (int i = 0; i < len; i++)
{
char32_t chr = LittleEndian::convertTo<char16_t>(data + ofs + i * 2);
if (chr == term)
{
return ret;
}
ret.push_back(chr);
}
return ret;
}
std::u16string StringUtils::getUCS2String(const u8* data, int ofs, int len, char16_t term)
{
std::u16string ret;
ret.reserve(len);
for (int i = 0; i < len; i++)
{
char16_t chr = LittleEndian::convertTo<char16_t>(data + ofs + i * 2);
if (chr == term)
{
return ret;
}
ret.push_back(chr);
}
return ret;
}
std::string StringUtils::getString(const u8* data, int ofs, int len, char16_t term)
{
std::string ret;
ret.reserve(len);
for (int i = 0; i < len; i++)
{
char16_t codeunit = LittleEndian::convertTo<char16_t>(data + ofs + i * 2);
if (codeunit == term)
{
break;
}
auto [data, size] = codepointToUTF8((char32_t)codeunit);
ret.append(data.data(), size);
}
return ret;
}
void StringUtils::setString(
u8* data, const std::u32string_view& v, int ofs, int len, char16_t terminator, char16_t padding)
{
int i = 0;
for (; i < std::min(len - 1, (int)v.size()); i++)
{
LittleEndian::convertFrom<char16_t>(data + ofs + i * 2, codepointToUCS2(v[i]));
}
LittleEndian::convertFrom<char16_t>(data + ofs + i++ * 2, terminator); // Set terminator
for (; i < len; i++)
{
LittleEndian::convertFrom<char16_t>(data + ofs + i * 2, padding); // Set final padding bytes
}
}
void StringUtils::setString(
u8* data, const std::u16string_view& v, int ofs, int len, char16_t terminator, char16_t padding)
{
size_t i = 0;
int outOfs = 0;
while (outOfs < len - 1 && i < v.size())
{
auto [codepoint, size] = UTF16toCodepoint(v.data() + i, v.size() - i);
LittleEndian::convertFrom<char16_t>(data + ofs + outOfs++ * 2, codepointToUCS2(codepoint));
i += size;
}
LittleEndian::convertFrom<char16_t>(data + ofs + outOfs++ * 2, terminator); // Set terminator
for (; outOfs < len; outOfs++)
{
LittleEndian::convertFrom<char16_t>(
data + ofs + outOfs * 2, padding); // Set final padding bytes
}
}
void StringUtils::setString(
u8* data, const std::string_view& v, int ofs, int len, char16_t terminator, char16_t padding)
{
int outOfs = 0;
size_t i = 0;
while (i < v.size() && outOfs < len - 1)
{
auto [codepoint, size] = UTF8toCodepoint(v.data() + i, v.size() - i);
LittleEndian::convertFrom<char16_t>(data + ofs + outOfs++ * 2, codepointToUCS2(codepoint));
i += size;
}
LittleEndian::convertFrom<char16_t>(data + ofs + (outOfs++ * 2), terminator); // Set terminator
for (; outOfs < len; outOfs++)
{
LittleEndian::convertFrom<char16_t>(data + ofs + (outOfs * 2),
padding); // Set final padding bytes
}
}
std::string StringUtils::getString4(const u8* data, int ofs, int len)
{
std::string output;
len *= 2;
for (u8 i = 0; i < len; i += 2)
{
u16 temp = LittleEndian::convertTo<u16>(data + ofs + i);
if (temp == 0xFFFF)
{
break;
}
auto found =
std::find(pksm::internal::G4Values.begin(), pksm::internal::G4Values.end(), temp);
// Treat an invalid value as a terminator
if (found == pksm::internal::G4Values.end())
{
break;
}
u16 codepoint =
pksm::internal::G4Chars[std::distance(pksm::internal::G4Values.begin(), found)];
if (codepoint == 0xFFFF)
{
break;
}
auto [data, size] = codepointToUTF8((char32_t)codepoint);
output.append(data.data(), size);
}
return output;
}
std::vector<u16> StringUtils::stringToG4(const std::string_view& v)
{
std::vector<u16> ret;
size_t charIndex = 0;
while (charIndex < v.length())
{
auto [codepoint, size] = UTF8toCodepoint(v.data() + charIndex, v.length() - charIndex);
auto found =
std::find(pksm::internal::G4Chars.begin(), pksm::internal::G4Chars.end(), codepoint);
ret.push_back(
found != pksm::internal::G4Chars.end()
? pksm::internal::G4Values[std::distance(pksm::internal::G4Chars.begin(), found)]
: 0x0000);
charIndex += size;
}
if (ret.back() != 0xFFFF)
{
ret.push_back(0xFFFF);
}
return ret;
}
void StringUtils::setString4(u8* data, const std::string_view& v, int ofs, int len)
{
u16 outIndex = 0, charIndex = 0;
while (outIndex < len - 1 && charIndex < v.length())
{
auto [codepoint, size] = UTF8toCodepoint(v.data() + charIndex, v.length() - charIndex);
auto found =
std::find(pksm::internal::G4Chars.begin(), pksm::internal::G4Chars.end(), codepoint);
LittleEndian::convertFrom<u16>(data + ofs + outIndex++ * 2,
found != pksm::internal::G4Chars.end()
? pksm::internal::G4Values[std::distance(pksm::internal::G4Chars.begin(), found)]
: 0x0000);
charIndex += size;
}
LittleEndian::convertFrom<u16>(data + ofs + outIndex * 2, 0xFFFF);
}
std::string& StringUtils::toUpper(std::string& in)
{
std::transform(in.begin(), in.end(), in.begin(), ::toupper);
// Just saying, I have NO clue why two outer braces levels are necessary
static constexpr std::array<std::pair<std::string_view, std::string_view>, 12> transStrings = {
{{"í", "Í"}, {"ó", "Ó"}, {"ú", "Ú"}, {"é", "É"}, {"á", "Á"}, {"ì", "Ì"}, {"ò", "Ò"},
{"ù", "Ù"}, {"è", "È"}, {"à", "À"}, {"ñ", "Ñ"}, {"æ", "Æ"}}
};
for (const auto& str : transStrings)
{
size_t found;
while ((found = in.find(str.first)) != std::string::npos)
{
in.replace(found, str.first.size(), str.second);
}
}
return in;
}
std::string StringUtils::toUpper(const std::string_view& in)
{
std::string ret = std::string(in);
return toUpper(ret);
}
std::string& StringUtils::toLower(std::string& in)
{
std::transform(in.begin(), in.end(), in.begin(), ::tolower);
// Just saying, I have NO clue why two outer braces levels are necessary
static constexpr std::array<std::pair<std::string_view, std::string_view>, 12> transStrings = {
{{"Í", "í"}, {"Ó", "ó"}, {"Ú", "ú"}, {"É", "é"}, {"Á", "á"}, {"Ì", "ì"}, {"Ò", "ò"},
{"Ù", "ù"}, {"È", "è"}, {"À", "à"}, {"Ñ", "ñ"}, {"Æ", "æ"}}
};
for (const auto& str : transStrings)
{
size_t found;
while ((found = in.find(str.first)) != std::string::npos)
{
in.replace(found, str.first.size(), str.second);
}
}
return in;
}
std::string StringUtils::toLower(const std::string_view& in)
{
std::string ret = std::string(in);
return toLower(ret);
}
std::u16string& StringUtils::toFullWidth(std::u16string& in)
{
std::transform(in.begin(), in.end(), in.begin(), tofullwidth);
return in;
}
std::string StringUtils::transString45(const std::string_view& str)
{
return UTF16toUTF8(transString45(UTF8toUTF16(str)));
}
std::u16string StringUtils::transString45(const std::u16string_view& str)
{
std::u16string ret = std::u16string(str);
std::transform(str.begin(), str.end(), ret.begin(),
[](const char16_t& chr) { return (char16_t)swapCodepoints45(chr); });
return ret;
}
std::string StringUtils::transString67(const std::string_view& str)
{
return UTF16toUTF8(transString67(UTF8toUTF16(str)));
}
std::u16string StringUtils::transString67(const std::u16string_view& str)
{
std::u16string ret = std::u16string(str);
std::transform(str.begin(), str.end(), ret.begin(),
[](const char16_t& chr) { return (char16_t)swapCodepoints67(chr); });
return ret;
}
std::string StringUtils::getString3(const u8* data, int ofs, int len, bool jp)
{
auto& characters = jp ? pksm::internal::G3_JP : pksm::internal::G3_EN;
std::u16string outString;
for (int i = 0; i < len; i++)
{
if (data[ofs + i] < characters.size())
{
outString += characters[data[ofs + i]];
}
else
{
break;
}
}
return StringUtils::UTF16toUTF8(outString);
}
void StringUtils::setString3(
u8* data, const std::string_view& v, int ofs, int len, bool jp, int padTo, u8 padWith)
{
auto& characters = jp ? pksm::internal::G3_JP : pksm::internal::G3_EN;
std::u16string str = StringUtils::UTF8toUTF16(v);
if (jp)
{
str = StringUtils::toFullWidth(str);
}
size_t outPos;
for (outPos = 0; outPos < std::min((size_t)len, str.size()); outPos++)
{
auto it = std::find(characters.begin(), characters.end(), str[outPos]);
if (it != characters.end())
{
data[ofs + outPos] = (u8)std::distance(characters.begin(), it);
}
else
{
break;
}
}
if (outPos < (size_t)len)
{
data[ofs + outPos] = 0xFF;
}
while (outPos < (size_t)padTo)
{
data[ofs + outPos] = padWith;
outPos++;
}
}
// The only guessable languages are German, Japanese, and Korean, and German is guessable only if an
// umlaut is found. Japanese and Korean should already be filtered out by this point, so this is
// essentially "German or not". "not" is returned as English.
pksm::Language StringUtils::guessLanguage12(const std::string_view& v)
{
std::u16string str = StringUtils::UTF8toUTF16(v);
for (u32 i = 0; i < str.size(); i++)
{
switch (str[i])
{
case u'Ä':
case u'Ö':
case u'Ü':
case u'ä':
case u'ö':
case u'ü':
return pksm::Language::GER;
}
}
return pksm::Language::ENG;
}
std::string StringUtils::fixJapaneseNameTransporter(const std::string_view& v)
{
std::u16string str = StringUtils::UTF8toUTF16(v);
std::u16string outStr;
for (u32 i = 0; i < str.size(); i++)
{
switch (str[i])
{
case u'ベ':
outStr += u'べ';
break;
case u'ペ':
outStr += u'ぺ';
break;
case u'ヘ':
outStr += u'へ';
break;
case u'リ':
outStr += u'り';
break;
default:
outStr += str[i];
}
}
return StringUtils::UTF16toUTF8(outStr);
}
std::string StringUtils::getTradeOT(pksm::Language lang)
{
switch (lang)
{
case pksm::Language::JPN:
return "トレーナー";
case pksm::Language::ENG:
return "Trainer";
case pksm::Language::FRE:
return "Dresseur";
case pksm::Language::ITA:
return "Allenatore";
case pksm::Language::GER:
return "Trainer";
case pksm::Language::SPA:
return "Entrenador";
case pksm::Language::KOR:
return "트레이너";
default:
return "";
}
}
void StringUtils::gbStringFailsafe(u8* data, int ofs, int len)
{
if (data[ofs + len - 1] != 0x50)
{
if (std::find(&data[ofs], &data[ofs + len], 0x50) == &data[ofs + len])
{
data[ofs + len - 1] = 0x50;
}
else if (data[ofs + len - 1] != 0)
{
data[ofs + len - 1] = 0;
}
}
}
std::string StringUtils::getString1(
const u8* data, int ofs, int len, pksm::Language lang, bool transporter)
{
if (data[ofs] == 0x5D)
{
return transporter ? getTradeOT(lang) : StringUtils::toUpper(getTradeOT(lang));
}
std::string ret;
ret.reserve(len);
if (lang == pksm::Language::JPN)
{
for (int i = 0; i < len; i++)
{
auto found = std::find(
pksm::internal::G1JPVals.begin(), pksm::internal::G1JPVals.end(), data[i + ofs]);
if (found == pksm::internal::G1JPVals.end())
{
break; // treat invalid character as terminator
}
char16_t codepoint =
pksm::internal::G1JPChars[std::distance(pksm::internal::G1JPVals.begin(), found)];
if (codepoint == u'\0')
{
break;
}
if (codepoint == pksm::internal::tradeOTChar)
{
continue;
}
if (transporter)
{
switch (codepoint)
{
case u'?':
case u'!':
codepoint = u' ';
}
}
auto [data, size] = codepointToUTF8(codepoint);
ret.append(data.data(), size);
}
}
else
{
for (int i = 0; i < len; i++)
{
auto found = std::find(
pksm::internal::G1ENVals.begin(), pksm::internal::G1ENVals.end(), data[i + ofs]);
if (found == pksm::internal::G1ENVals.end())
{
break; // treat invalid character as terminator
}
char16_t codepoint =
pksm::internal::G1ENChars[std::distance(pksm::internal::G1ENVals.begin(), found)];
if (codepoint == u'\0')
{
break;
}
if (codepoint == pksm::internal::tradeOTChar)
{
continue;
}
if (transporter)
{
switch (codepoint)
{
case u'[':
codepoint = u'(';
break;
case u']':
codepoint = u')';
break;
case u'×':
codepoint = u'x';
}
}
auto [data, size] = codepointToUTF8(codepoint);
ret.append(data.data(), size);
}
}
return ret;
}
void StringUtils::setString1(u8* data, const std::string_view& v, int ofs, int len,
pksm::Language lang, int padTo, u8 padWith)
{
int outPos = 0;
size_t inPos = 0;
if (lang == pksm::Language::JPN)
{
while (outPos < len && inPos < v.size())
{
auto [codepoint, advance] = UTF8toCodepoint(v.data() + inPos, v.size() - inPos);
codepoint = tofullwidth(codepointToUCS2(codepoint));
auto found = std::find(
pksm::internal::G1JPChars.begin(), pksm::internal::G1JPChars.end(), codepoint);
if (found == pksm::internal::G1JPChars.end())
{
break;
}
data[ofs + outPos++] =
pksm::internal::G1JPVals[std::distance(pksm::internal::G1JPChars.begin(), found)];
inPos += advance;
}
}
else
{
while (outPos < len && inPos < v.size())
{
auto [codepoint, advance] = UTF8toCodepoint(v.data() + inPos, v.size() - inPos);
auto found = std::find(pksm::internal::G1ENChars.begin(),
pksm::internal::G1ENChars.end(), codepointToUCS2(codepoint));
if (found == pksm::internal::G1ENChars.end())
{
break;
}
data[ofs + outPos++] =
pksm::internal::G1ENVals[std::distance(pksm::internal::G1ENChars.begin(), found)];
inPos += advance;
}
}
if (outPos < len)
{
data[ofs + outPos] = 0x50;
outPos++;
}
while (outPos < padTo)
{
data[ofs + outPos] = padWith;
outPos++;
}
StringUtils::gbStringFailsafe(data, ofs, len);
}
std::string StringUtils::getString2(
const u8* data, int ofs, int len, pksm::Language lang, bool transporter)
{
// every language other than KOR is the same as last gen, and as well the case of the trade ot
// char is handled there
if (lang != pksm::Language::KOR || data[ofs] == 0x5D)
{
return getString1(data, ofs, len, lang, transporter);
}
std::string ret;
ret.reserve(len);
int inPos = 0;
while (inPos < len)
{
if (data[ofs + inPos] <= 0xB)
{
auto found = std::find(pksm::internal::G2KORVals.begin(),
pksm::internal::G2KORVals.end(), BigEndian::convertTo<u16>(data + ofs + inPos));
if (found == pksm::internal::G2KORVals.end())
{
break; // treat invalid value as terminator
}
inPos += 2;
auto [data, size] = codepointToUTF8(pksm::internal::G2KORChars[std::distance(
pksm::internal::G2KORVals.begin(), found)]);
ret.append(data.data(), size);
}
else
{
auto found = std::find(pksm::internal::G1ENVals.begin(), pksm::internal::G1ENVals.end(),
data[ofs + inPos]);
if (found == pksm::internal::G1ENVals.end())
{
break; // treat invalid value as terminator
}
inPos++;
char16_t codepoint =
pksm::internal::G1ENChars[std::distance(pksm::internal::G1ENVals.begin(), found)];
if (codepoint == u'\0')
{
break;
}
else if (codepoint == pksm::internal::tradeOTChar)
{
continue;
}
auto [data, size] = codepointToUTF8(codepoint);
ret.append(data.data(), size);
}
}
return ret;
}
void StringUtils::setString2(u8* data, const std::string_view& v, int ofs, int len,
pksm::Language lang, int padTo, u8 padWith)
{
if (lang != pksm::Language::KOR)
{
setString1(data, v, ofs, len, lang, padTo, padWith);
return;
}
size_t inPos = 0;
int outPos = 0;
while (outPos < len && inPos < v.size())
{
auto [codepoint, advance] = UTF8toCodepoint(v.data() + inPos, v.size() - inPos);
codepoint = tofullwidth(codepointToUCS2(codepoint));
auto found = std::find(
pksm::internal::G2KORChars.begin(), pksm::internal::G2KORChars.end(), codepoint);
if (found == pksm::internal::G2KORChars.end())
{
auto found = std::find(
pksm::internal::G1ENChars.begin(), pksm::internal::G1ENChars.end(), codepoint);
if (found == pksm::internal::G1ENChars.end())
{
break; // treat invalid character as terminator
}
data[ofs + outPos++] =
pksm::internal::G1ENVals[std::distance(pksm::internal::G1ENChars.begin(), found)];
}
else
{
u16 val =
pksm::internal::G2KORVals[std::distance(pksm::internal::G2KORChars.begin(), found)];
BigEndian::convertFrom<u16>(data + outPos, val);
outPos += 2; // needs to be incremented twice, not just once
}
inPos += advance;
}
if (outPos < len)
{
data[ofs + outPos] = 0x50;
outPos++;
}
while (outPos < padTo)
{
data[ofs + outPos] = padWith;
outPos++;
}
StringUtils::gbStringFailsafe(data, ofs, len);
}
| 37,103
|
C++
|
.cpp
| 1,184
| 21.876689
| 100
| 0.504212
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,263
|
PGT.cpp
|
FlagBrew_PKSM-Core/source/wcx/PGT.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/PGT.hpp"
#include "enums/Language.hpp"
#include "pkx/PK4.hpp"
#include "utils/endian.hpp"
namespace pksm
{
PGT::PGT(u8* pgt)
{
std::copy(pgt, pgt + length, data);
pokemonData = PKX::getPKM<Generation::FOUR>(pgt + 0x8, PK4::PARTY_LENGTH);
if (type() == 7)
{
pokemonData->species(Species::Manaphy);
pokemonData->alternativeForm(0);
pokemonData->egg(true);
pokemonData->shiny(false);
pokemonData->gender(Gender::Genderless);
pokemonData->level(1);
pokemonData->setAbility(0);
pokemonData->move(0, Move::TailGlow);
pokemonData->move(1, Move::Bubble);
pokemonData->move(2, Move::WaterSport);
pokemonData->move(3, Move::None);
pokemonData->heldItem(0);
pokemonData->fatefulEncounter(true);
pokemonData->ball(Ball::Poke);
pokemonData->version(GameVersion::D); // Diamond
pokemonData->language(Language::ENG);
pokemonData->nickname("MANAPHY");
pokemonData->nicknamed(false);
pokemonData->eggLocation(1);
}
pokemonData->refreshChecksum();
pokemonData->encrypt();
std::ranges::copy(pokemonData->rawData().subspan(0, PK4::PARTY_LENGTH), data + 0x8);
pokemonData->decrypt(); // encrypt Pokemon data if it isn't already
}
u16 PGT::ID(void) const
{
return 0;
}
std::string PGT::title(void) const
{
return "Wondercard";
}
bool PGT::power(void) const
{
return false;
}
Generation PGT::generation(void) const
{
return Generation::FOUR;
}
u8 PGT::type(void) const
{
return data[0];
}
bool PGT::bean(void) const
{
return false;
}
bool PGT::BP(void) const
{
return false;
}
bool PGT::item(void) const
{
return type() == 3 || type() == 8 || type() == 9 || type() == 10 || type() == 12;
}
// Pokemon, egg, or Manaphy egg
bool PGT::pokemon(void) const
{
return type() == 1 || type() == 2 || type() == 7;
}
u16 PGT::object(void) const
{
if (type() == 8)
{
return 454;
}
else if (type() == 9)
{
return 452;
}
else if (type() == 10)
{
return 455;
}
else if (type() == 12)
{
return 467;
}
return LittleEndian::convertTo<u16>(data + 0x4);
}
u8 PGT::flags(void) const
{
return data[3];
}
bool PGT::multiObtainable(void) const
{
return false;
}
int PGT::year(void) const
{
return (pokemonData->egg() ? pokemonData->eggDate() : pokemonData->metDate()).year();
}
int PGT::month(void) const
{
return (pokemonData->egg() ? pokemonData->eggDate() : pokemonData->metDate()).month();
}
int PGT::day(void) const
{
return (pokemonData->egg() ? pokemonData->eggDate() : pokemonData->metDate()).day();
}
void PGT::year(int v)
{
Date newDate = date();
newDate.year(v);
pokemonData->egg() ? pokemonData->eggDate(newDate) : pokemonData->metDate(newDate);
pokemonData->refreshChecksum();
pokemonData->encrypt();
std::ranges::copy(pokemonData->rawData().subspan(0, PK4::PARTY_LENGTH),
data + 0x8); // Actually set the data
pokemonData->decrypt();
}
void PGT::month(int v)
{
Date newDate = date();
newDate.month(v);
pokemonData->egg() ? pokemonData->eggDate(newDate) : pokemonData->metDate(newDate);
pokemonData->refreshChecksum();
pokemonData->encrypt();
std::ranges::copy(pokemonData->rawData().subspan(0, PK4::PARTY_LENGTH),
data + 0x8); // Actually set the data
pokemonData->decrypt();
}
void PGT::day(int v)
{
Date newDate = date();
newDate.day(v);
pokemonData->egg() ? pokemonData->eggDate(newDate) : pokemonData->metDate(newDate);
pokemonData->refreshChecksum();
pokemonData->encrypt();
std::ranges::copy(pokemonData->rawData().subspan(0, PK4::PARTY_LENGTH),
data + 0x8); // Actually set the data
pokemonData->decrypt();
}
u8 PGT::cardLocation(void) const
{
return 0;
}
bool PGT::used(void) const
{
return false;
}
Ball PGT::ball(void) const
{
return pokemonData->ball();
}
u16 PGT::heldItem(void) const
{
return pokemonData->heldItem();
}
bool PGT::shiny(void) const
{
return pokemonData->shiny();
}
u8 PGT::PIDType(void) const
{
return pokemonData->shiny() ? 2 : 0;
}
u16 PGT::TID(void) const
{
return pokemonData->TID();
}
u16 PGT::SID(void) const
{
return pokemonData->SID();
}
Move PGT::move(u8 index) const
{
return pokemonData->move(index);
}
Species PGT::species(void) const
{
return pokemonData->species();
}
Gender PGT::gender(void) const
{
return pokemonData->gender();
}
std::string PGT::otName(void) const
{
return !(flags() == 0 && type() != 1) ? pokemonData->otName() : "";
}
u8 PGT::level(void) const
{
return pokemonData->level();
}
u32 PGT::PID(void) const
{
return pokemonData->PID();
}
bool PGT::hasRibbon(Ribbon rib) const
{
return pokemonData->hasRibbon(rib);
}
bool PGT::ribbon(Ribbon rib) const
{
return pokemonData->ribbon(rib);
}
u8 PGT::alternativeForm(void) const
{
return pokemonData->alternativeForm();
}
Language PGT::language(void) const
{
return pokemonData->language();
}
std::string PGT::nickname(void) const
{
return pokemonData->nickname();
}
Nature PGT::nature(void) const
{
return pokemonData->nature();
}
u8 PGT::abilityType(void) const
{
return pokemonData->abilityNumber();
}
Ability PGT::ability(void) const
{
return pokemonData->ability();
}
u16 PGT::eggLocation(void) const
{
return pokemonData->eggLocation();
}
u16 PGT::metLocation(void) const
{
return pokemonData->metLocation();
}
u8 PGT::metLevel(void) const
{
return pokemonData->metLevel();
}
u8 PGT::contest(u8 index) const
{
return pokemonData->contest(index);
}
u8 PGT::iv(Stat index) const
{
return pokemonData->iv(index);
}
bool PGT::egg(void) const
{
return pokemonData->egg();
}
u16 PGT::formSpecies(void) const
{
return pokemonData->formSpecies();
}
}
| 8,235
|
C++
|
.cpp
| 289
| 21.775087
| 94
| 0.590351
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,264
|
WC8.cpp
|
FlagBrew_PKSM-Core/source/wcx/WC8.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WC8.hpp"
#include "personal/personal.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
int langIndex(pksm::Language lang)
{
if (lang > pksm::Language::UNUSED)
{
return u8(lang) - 2;
}
else if (lang == pksm::Language::UNUSED)
{
return 2 - 1; // English
}
else
{
return u8(lang) - 1;
}
}
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionKalos:
return {0x24C, 0};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x24C, 1};
case pksm::Ribbon::ChampionSinnoh:
return {0x24C, 2};
case pksm::Ribbon::BestFriends:
return {0x24C, 3};
case pksm::Ribbon::Training:
return {0x24C, 4};
case pksm::Ribbon::BattlerSkillful:
return {0x24C, 5};
case pksm::Ribbon::BattlerExpert:
return {0x24C, 6};
case pksm::Ribbon::Effort:
return {0x24C, 7};
case pksm::Ribbon::Alert:
return {0x24D, 0};
case pksm::Ribbon::Shock:
return {0x24D, 1};
case pksm::Ribbon::Downcast:
return {0x24D, 2};
case pksm::Ribbon::Careless:
return {0x24D, 3};
case pksm::Ribbon::Relax:
return {0x24D, 4};
case pksm::Ribbon::Snooze:
return {0x24D, 5};
case pksm::Ribbon::Smile:
return {0x24D, 6};
case pksm::Ribbon::Gorgeous:
return {0x24D, 7};
case pksm::Ribbon::Royal:
return {0x24E, 0};
case pksm::Ribbon::GorgeousRoyal:
return {0x24E, 1};
case pksm::Ribbon::Artist:
return {0x24E, 2};
case pksm::Ribbon::Footprint:
return {0x24E, 3};
case pksm::Ribbon::Record:
return {0x24E, 4};
case pksm::Ribbon::Legend:
return {0x24E, 5};
case pksm::Ribbon::Country:
return {0x24E, 6};
case pksm::Ribbon::National:
return {0x24E, 7};
case pksm::Ribbon::Earth:
return {0x24F, 0};
case pksm::Ribbon::World:
return {0x24F, 1};
case pksm::Ribbon::Classic:
return {0x24F, 2};
case pksm::Ribbon::Premier:
return {0x24F, 3};
case pksm::Ribbon::Event:
return {0x24F, 4};
case pksm::Ribbon::Birthday:
return {0x24F, 5};
case pksm::Ribbon::Special:
return {0x24F, 6};
case pksm::Ribbon::Souvenir:
return {0x24F, 7};
case pksm::Ribbon::Wishing:
return {0x250, 0};
case pksm::Ribbon::ChampionBattle:
return {0x250, 1};
case pksm::Ribbon::ChampionRegional:
return {0x250, 2};
case pksm::Ribbon::ChampionNational:
return {0x250, 3};
case pksm::Ribbon::ChampionWorld:
return {0x250, 4};
case pksm::Ribbon::MemoryContest:
return {0x250, 5};
case pksm::Ribbon::MemoryBattle:
return {0x250, 6};
case pksm::Ribbon::ChampionG6Hoenn:
return {0x250, 7};
case pksm::Ribbon::ContestStar:
return {0x251, 0};
case pksm::Ribbon::MasterCoolness:
return {0x251, 1};
case pksm::Ribbon::MasterBeauty:
return {0x251, 2};
case pksm::Ribbon::MasterCuteness:
return {0x251, 3};
case pksm::Ribbon::MasterCleverness:
return {0x251, 4};
case pksm::Ribbon::MasterToughness:
return {0x251, 5};
case pksm::Ribbon::ChampionAlola:
return {0x251, 6};
case pksm::Ribbon::BattleRoyale:
return {0x251, 7};
case pksm::Ribbon::BattleTreeGreat:
return {0x252, 0};
case pksm::Ribbon::BattleTreeMaster:
return {0x252, 1};
case pksm::Ribbon::ChampionGalar:
return {0x252, 2};
case pksm::Ribbon::TowerMaster:
return {0x252, 3};
case pksm::Ribbon::MasterRank:
return {0x252, 4};
case pksm::Ribbon::MarkLunchtime:
return {0x252, 5};
case pksm::Ribbon::MarkSleepyTime:
return {0x252, 6};
case pksm::Ribbon::MarkDusk:
return {0x252, 7};
case pksm::Ribbon::MarkDawn:
return {0x253, 0};
case pksm::Ribbon::MarkCloudy:
return {0x253, 1};
case pksm::Ribbon::MarkRainy:
return {0x253, 2};
case pksm::Ribbon::MarkStormy:
return {0x253, 3};
case pksm::Ribbon::MarkSnowy:
return {0x253, 4};
case pksm::Ribbon::MarkBlizzard:
return {0x253, 5};
case pksm::Ribbon::MarkDry:
return {0x253, 6};
case pksm::Ribbon::MarkSandstorm:
return {0x253, 7};
case pksm::Ribbon::MarkMisty:
return {0x258, 0};
case pksm::Ribbon::MarkDestiny:
return {0x258, 1};
case pksm::Ribbon::MarkFishing:
return {0x258, 2};
case pksm::Ribbon::MarkCurry:
return {0x258, 3};
case pksm::Ribbon::MarkUncommon:
return {0x258, 4};
case pksm::Ribbon::MarkRare:
return {0x258, 5};
case pksm::Ribbon::MarkRowdy:
return {0x258, 6};
case pksm::Ribbon::MarkAbsentMinded:
return {0x258, 7};
case pksm::Ribbon::MarkJittery:
return {0x259, 0};
case pksm::Ribbon::MarkExcited:
return {0x259, 1};
case pksm::Ribbon::MarkCharismatic:
return {0x259, 2};
case pksm::Ribbon::MarkCalmness:
return {0x259, 3};
case pksm::Ribbon::MarkIntense:
return {0x259, 4};
case pksm::Ribbon::MarkZonedOut:
return {0x259, 5};
case pksm::Ribbon::MarkJoyful:
return {0x259, 6};
case pksm::Ribbon::MarkAngry:
return {0x259, 7};
case pksm::Ribbon::MarkSmiley:
return {0x25A, 0};
case pksm::Ribbon::MarkTeary:
return {0x25A, 1};
case pksm::Ribbon::MarkUpbeat:
return {0x25A, 2};
case pksm::Ribbon::MarkPeeved:
return {0x25A, 3};
case pksm::Ribbon::MarkIntellectual:
return {0x25A, 4};
case pksm::Ribbon::MarkFerocious:
return {0x25A, 5};
case pksm::Ribbon::MarkCrafty:
return {0x25A, 6};
case pksm::Ribbon::MarkScowling:
return {0x25A, 7};
case pksm::Ribbon::MarkKindly:
return {0x25B, 0};
case pksm::Ribbon::MarkFlustered:
return {0x25B, 1};
case pksm::Ribbon::MarkPumpedUp:
return {0x25B, 2};
case pksm::Ribbon::MarkZeroEnergy:
return {0x25B, 3};
case pksm::Ribbon::MarkPrideful:
return {0x25B, 4};
case pksm::Ribbon::MarkUnsure:
return {0x25B, 5};
case pksm::Ribbon::MarkHumble:
return {0x25B, 6};
case pksm::Ribbon::MarkThorny:
return {0x25B, 7};
case pksm::Ribbon::MarkVigor:
return {0x25C, 0};
case pksm::Ribbon::MarkSlump:
return {0x25C, 1};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
WC8::WC8(u8* dt)
{
std::copy(dt, dt + length, data);
for (int i = 0; i < 6; i++)
{
if (object(i) != 0)
{
numItems++;
}
else
{
break;
}
}
}
Generation WC8::generation() const
{
return Generation::EIGHT;
}
u16 WC8::ID() const
{
return LittleEndian::convertTo<u16>(data + 8);
}
std::string WC8::title() const
{
return title(titleIndex());
}
std::string WC8::title(Language lang) const
{
// TODO: use titleIndex to get offset, then get string from offset
(void)lang;
return "Wonder Card";
}
Language WC8::titleIndex() const
{
return Language(data[0x15]);
}
u8 WC8::type() const
{
return data[0x11];
}
u8 WC8::flags() const
{
return data[0x10];
}
bool WC8::multiObtainable() const
{
return (flags() & 1) == 1;
}
bool WC8::BP(void) const
{
return type() == 3;
}
bool WC8::item(void) const
{
return type() == 2;
}
bool WC8::pokemon(void) const
{
return type() == 1;
}
bool WC8::clothing(void) const
{
return type() == 4;
}
u16 WC8::object(void) const
{
return object(0);
}
u16 WC8::object(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x20 + index * 4);
}
int WC8::items(void) const
{
return numItems;
}
u16 WC8::objectQuantity(void) const
{
return objectQuantity(0);
}
u16 WC8::objectQuantity(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x22 + index * 4);
}
u8 WC8::PIDType(void) const
{
return data[0x248];
}
bool WC8::shiny(void) const
{
return PIDType() == 2 || PIDType() == 3;
}
u16 WC8::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x20);
}
u16 WC8::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x22);
}
GameVersion WC8::version(void) const
{
return GameVersion(LittleEndian::convertTo<u32>(data + 0x24));
}
u32 WC8::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data + 0x28);
}
u32 WC8::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x2C);
}
Ball WC8::ball(void) const
{
return Ball{data[0x22C]};
}
u16 WC8::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x22E);
}
Move WC8::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x230 + m * 2)};
}
Move WC8::relearnMove(u8 index) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x238 + index * 2)};
}
Species WC8::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x240)};
}
u8 WC8::alternativeForm(void) const
{
return data[0x242];
}
Gender WC8::gender(void) const
{
return Gender{data[0x243]};
}
u8 WC8::level(void) const
{
return data[0x244];
}
bool WC8::egg(void) const
{
return data[0x245] == 1;
}
Nature WC8::nature(void) const
{
return Nature{data[0x246]};
}
u8 WC8::abilityType(void) const
{
return data[0x247];
}
Ability WC8::ability(void) const
{
u8 abilitynum, type = abilityType();
if (type == 2)
{
abilitynum = 2;
}
else if (type == 4)
{
abilitynum = 2;
}
else
{
abilitynum = 0;
}
return PersonalSWSH::ability(u16(species()), abilitynum);
}
u8 WC8::metLevel(void) const
{
return data[0x249];
}
u8 WC8::dynamaxLevel(void) const
{
return data[0x24A];
}
bool WC8::canGigantamax() const
{
return data[0x24B] != 0;
}
u8 WC8::ribbonValue(int index) const
{
return data[0x24C + index];
}
u8 WC8::iv(Stat index) const
{
return data[0x26C + u8(index)];
}
Gender WC8::otGender(void) const
{
return Gender{data[0x272]};
}
u16 WC8::ev(Stat index) const
{
return data[0x273 + u8(index)];
}
u8 WC8::otIntensity(void) const
{
return data[0x279];
}
u8 WC8::otMemory(void) const
{
return data[0x27A];
}
u8 WC8::otFeeling(void) const
{
return data[0x27B];
}
u16 WC8::otTextvar(void) const
{
return LittleEndian::convertTo<u16>(data + 0x27C);
}
u16 WC8::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x228);
}
u16 WC8::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x22A);
}
bool WC8::hasRibbon(Ribbon rib) const
{
return OFFSET_OF(rib).first != RIBBON_ABSENT;
}
bool WC8::ribbon(Ribbon rib) const
{
auto offset = OFFSET_OF(rib);
return offset.first != RIBBON_ABSENT ? FlagUtil::getFlag(data, offset.first, offset.second)
: false;
}
bool WC8::nicknamed(Language lang) const
{
return nickname(lang)[0] != 0;
}
std::string WC8::nickname(Language lang) const
{
return StringUtils::getString(data, 0x30 + langIndex(lang) * 0x1C, 13);
}
Language WC8::nicknameLanguage(Language orig) const
{
return Language(data[0x30 + langIndex(orig) * 0x1C + 0x1A]);
}
std::string WC8::otName(Language lang) const
{
return StringUtils::getString(data, 0x12C + langIndex(lang) * 0x1C, 13);
}
std::string WC8::nickname() const
{
return nickname(Language::ENG);
}
std::string WC8::otName() const
{
return otName(Language::ENG);
}
bool WC8::used() const
{
return false;
}
u16 WC8::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalSWSH::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalSWSH::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
}
| 16,403
|
C++
|
.cpp
| 540
| 20.653704
| 99
| 0.525896
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,265
|
WC7.cpp
|
FlagBrew_PKSM-Core/source/wcx/WC7.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WC7.hpp"
#include "personal/personal.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionBattle:
return {0x74, 0};
case pksm::Ribbon::ChampionRegional:
return {0x74, 1};
case pksm::Ribbon::ChampionNational:
return {0x74, 2};
case pksm::Ribbon::Country:
return {0x74, 3};
case pksm::Ribbon::National:
return {0x74, 4};
case pksm::Ribbon::Earth:
return {0x74, 5};
case pksm::Ribbon::World:
return {0x74, 6};
case pksm::Ribbon::Event:
return {0x74, 7};
case pksm::Ribbon::ChampionWorld:
return {0x75, 0};
case pksm::Ribbon::Birthday:
return {0x75, 1};
case pksm::Ribbon::Special:
return {0x75, 2};
case pksm::Ribbon::Souvenir:
return {0x75, 3};
case pksm::Ribbon::Wishing:
return {0x75, 4};
case pksm::Ribbon::Classic:
return {0x75, 5};
case pksm::Ribbon::Premier:
return {0x75, 6};
default:
break;
}
return {RIBBON_ABSENT, 0};
}
}
namespace pksm
{
WC7::WC7(u8* dt, bool full)
{
const u16 ofs = full ? 0x208 : 0;
std::copy(dt + ofs, dt + ofs + length, data);
for (int i = 0; i < 6; i++)
{
if (object(i) != 0)
{
numItems++;
}
else
{
break;
}
}
}
Generation WC7::generation(void) const
{
return Generation::SEVEN;
}
u16 WC7::ID(void) const
{
return LittleEndian::convertTo<u16>(data);
}
std::string WC7::title(void) const
{
return StringUtils::getString(data, 0x2, 36);
}
u32 WC7::rawDate(void) const
{
return LittleEndian::convertTo<u32>(data + 0x4C);
}
void WC7::rawDate(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x4C, v);
}
int WC7::year(void) const
{
return rawDate() / 10000 + 2000;
}
int WC7::month(void) const
{
return rawDate() % 10000 / 100;
}
int WC7::day(void) const
{
return rawDate() % 100;
}
void WC7::year(int v)
{
u32 newVal = std::max(0, v - 2000);
newVal *= 10000;
newVal += rawDate() % 10000;
rawDate(newVal);
}
void WC7::month(int v)
{
u32 newVal = rawDate() / 10000;
newVal *= 100;
newVal += v;
newVal *= 100;
newVal += rawDate() % 100;
rawDate(newVal);
}
void WC7::day(int v)
{
u32 newVal = rawDate() / 100;
newVal *= 100;
newVal += v;
rawDate(newVal);
}
u8 WC7::type(void) const
{
return data[0x51];
}
u8 WC7::flags(void) const
{
return data[0x52];
}
bool WC7::multiObtainable(void) const
{
return data[0x53] == 1;
}
bool WC7::BP(void) const
{
return type() == 3;
}
bool WC7::bean(void) const
{
return type() == 2;
}
bool WC7::item(void) const
{
return type() == 1;
}
bool WC7::power(void) const
{
return false;
}
u16 WC7::object(void) const
{
return object(0);
}
u16 WC7::object(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x68 + index * 4);
}
int WC7::items(void) const
{
return numItems;
}
u16 WC7::objectQuantity(void) const
{
return objectQuantity(0);
}
u16 WC7::objectQuantity(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x6A + index * 4);
}
bool WC7::pokemon(void) const
{
return type() == 0;
}
u8 WC7::PIDType(void) const
{
return data[0xA3];
}
bool WC7::shiny(void) const
{
return PIDType() == 2;
}
u16 WC7::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x68);
}
u16 WC7::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x6A);
}
GameVersion WC7::version(void) const
{
return GameVersion(data[0x6C]);
}
u32 WC7::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data + 0x70);
}
Ball WC7::ball(void) const
{
return Ball{data[0x76]};
}
u16 WC7::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x78);
}
Move WC7::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x7A + m * 2)};
}
Species WC7::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x82)};
}
u8 WC7::alternativeForm(void) const
{
return data[0x84];
}
Language WC7::language(void) const
{
return Language(data[0x85]);
}
std::string WC7::nickname(void) const
{
return LittleEndian::convertTo<u16>(data + 0x86) != 0
? StringUtils::getString(data, 0x86, 12)
: "Pokemon Name";
} // Localization::speciesName(species()); }
Nature WC7::nature(void) const
{
return Nature{data[0xA0]};
}
Gender WC7::gender(void) const
{
return Gender{data[0xA1]};
}
Ability WC7::ability(void) const
{
u8 abilitynum, type = abilityType();
if (type == 2)
{
abilitynum = 2;
}
else if (type == 4)
{
abilitynum = 2;
}
else
{
abilitynum = 0;
}
return PersonalSMUSUM::ability(u16(species()), abilitynum);
}
u8 WC7::abilityType(void) const
{
return data[0xA2];
}
u8 WC7::metLevel(void) const
{
return data[0xA8];
}
std::string WC7::otName(void) const
{
return StringUtils::getString(data, 0xB6, 12);
}
u8 WC7::level(void) const
{
return data[0xD0];
}
bool WC7::egg(void) const
{
return data[0xD1] == 1;
}
u16 WC7::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA4);
}
u16 WC7::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA6);
}
u8 WC7::contest(u8 index) const
{
return data[0xA9 + index];
}
u8 WC7::iv(Stat index) const
{
return data[0xAF + u8(index)];
}
Gender WC7::otGender(void) const
{
return Gender{data[0xB5]};
}
u16 WC7::additionalItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD2);
}
u32 WC7::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0xD4);
}
Move WC7::relearnMove(u8 index) const
{
return Move{LittleEndian::convertTo<u16>(data + 0xD8 + index * 2)};
}
u8 WC7::otIntensity(void) const
{
return data[0xE0];
}
u8 WC7::otMemory(void) const
{
return data[0xE1];
}
u16 WC7::otTextvar(void) const
{
return data[0xE2];
}
u8 WC7::otFeeling(void) const
{
return data[0xE4];
}
u16 WC7::ev(Stat index) const
{
return data[0xE5 + u8(index)];
}
bool WC7::hasRibbon(Ribbon rib) const
{
return OFFSET_OF(rib).first != RIBBON_ABSENT;
}
bool WC7::ribbon(Ribbon rib) const
{
auto offset = OFFSET_OF(rib);
return offset.first != RIBBON_ABSENT ? FlagUtil::getFlag(data, offset.first, offset.second)
: false;
}
u8 WC7::cardLocation(void) const
{
return data[0x50];
}
bool WC7::repeatable(void) const
{
return (flags() & 1) == 1;
}
bool WC7::used(void) const
{
return (flags() & 2) == 2;
}
bool WC7::oncePerDay(void) const
{
return (flags() & 4) == 4;
}
u16 WC7::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalSMUSUM::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalSMUSUM::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
}
| 10,300
|
C++
|
.cpp
| 396
| 18.664141
| 99
| 0.548932
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,266
|
PCD.cpp
|
FlagBrew_PKSM-Core/source/wcx/PCD.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/PCD.hpp"
#include "utils/endian.hpp"
#include <array>
pksm::PCD::PCD(u8* pcd) : PGT(pcd), name(StringUtils::getString4(pcd, 0x104, 0x24))
{
id = LittleEndian::convertTo<u16>(data + 0x150);
}
| 1,481
|
C++
|
.cpp
| 32
| 44.34375
| 83
| 0.725639
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,267
|
WC6.cpp
|
FlagBrew_PKSM-Core/source/wcx/WC6.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WC6.hpp"
#include "personal/personal.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionBattle:
return {0x74, 0};
case pksm::Ribbon::ChampionRegional:
return {0x74, 1};
case pksm::Ribbon::ChampionNational:
return {0x74, 2};
case pksm::Ribbon::Country:
return {0x74, 3};
case pksm::Ribbon::National:
return {0x74, 4};
case pksm::Ribbon::Earth:
return {0x74, 5};
case pksm::Ribbon::World:
return {0x74, 6};
case pksm::Ribbon::Event:
return {0x74, 7};
case pksm::Ribbon::ChampionWorld:
return {0x75, 0};
case pksm::Ribbon::Birthday:
return {0x75, 1};
case pksm::Ribbon::Special:
return {0x75, 2};
case pksm::Ribbon::Souvenir:
return {0x75, 3};
case pksm::Ribbon::Wishing:
return {0x75, 4};
case pksm::Ribbon::Classic:
return {0x75, 5};
case pksm::Ribbon::Premier:
return {0x75, 6};
default:
break;
}
return {RIBBON_ABSENT, 0};
}
}
namespace pksm
{
WC6::WC6(u8* dt, bool full)
{
const u16 ofs = full ? 0x208 : 0;
std::copy(dt + ofs, dt + ofs + length, data);
}
Generation WC6::generation(void) const
{
return Generation::SIX;
}
u16 WC6::ID(void) const
{
return LittleEndian::convertTo<u16>(data);
}
std::string WC6::title(void) const
{
return StringUtils::getString(data, 0x2, 36);
}
u32 WC6::rawDate(void) const
{
return LittleEndian::convertTo<u32>(data + 0x4C);
}
void WC6::rawDate(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x4C, v);
}
int WC6::year(void) const
{
return rawDate() / 10000 + 2000;
}
int WC6::month(void) const
{
return rawDate() % 10000 / 100;
}
int WC6::day(void) const
{
return rawDate() % 100;
}
void WC6::year(int v)
{
u32 newVal = std::max(0, v - 2000);
newVal *= 10000;
newVal += rawDate() % 10000;
rawDate(newVal);
}
void WC6::month(int v)
{
u32 newVal = rawDate() / 10000;
newVal *= 100;
newVal += v;
newVal *= 100;
newVal += rawDate() % 100;
rawDate(newVal);
}
void WC6::day(int v)
{
u32 newVal = rawDate() / 100;
newVal *= 100;
newVal += v;
rawDate(newVal);
}
u8 WC6::type(void) const
{
return data[0x51];
}
u8 WC6::flags(void) const
{
return data[0x52];
}
bool WC6::multiObtainable(void) const
{
return data[0x53] == 1;
}
bool WC6::BP(void) const
{
return false;
} // WC6 only has Pokemon and Item cards
bool WC6::bean(void) const
{
return false;
} // WC6 only has Pokemon and Item cards
bool WC6::item(void) const
{
return type() == 1;
}
bool WC6::power(void) const
{
return false;
}
u16 WC6::object(void) const
{
return LittleEndian::convertTo<u16>(data + 0x68);
}
u16 WC6::objectQuantity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x70);
}
bool WC6::pokemon(void) const
{
return type() == 0;
}
u8 WC6::PIDType(void) const
{
return data[0xA3];
}
bool WC6::shiny(void) const
{
return PIDType() == 2;
}
u16 WC6::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x68);
}
u16 WC6::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x6A);
}
GameVersion WC6::version(void) const
{
return GameVersion(data[0x6C]);
}
u32 WC6::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data + 0x70);
}
Ball WC6::ball(void) const
{
return Ball{data[0x76]};
}
u16 WC6::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x78);
}
Move WC6::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x7A + m * 2)};
}
Species WC6::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x82)};
}
u8 WC6::alternativeForm(void) const
{
return data[0x84];
}
Language WC6::language(void) const
{
return Language(data[0x85]);
}
std::string WC6::nickname(void) const
{
return LittleEndian::convertTo<u16>(data + 0x86) != 0
? StringUtils::getString(data, 0x86, 12)
: "Pokemon Name";
} // Localization::speciesName(species()); }
Nature WC6::nature(void) const
{
return Nature{data[0xA0]};
}
Gender WC6::gender(void) const
{
return Gender{data[0xA1]};
}
Ability WC6::ability(void) const
{
u8 abilitynum, type = abilityType();
if (type == 2)
{
abilitynum = 2;
}
else if (type == 4)
{
abilitynum = 2;
}
else
{
abilitynum = 0;
}
return PersonalXYORAS::ability(u16(species()), abilitynum);
}
u8 WC6::abilityType(void) const
{
return data[0xA2];
}
u8 WC6::metLevel(void) const
{
return data[0xA8];
}
std::string WC6::otName(void) const
{
return StringUtils::getString(data, 0xB6, 12);
}
u8 WC6::level(void) const
{
return data[0xD0];
}
bool WC6::egg(void) const
{
return data[0xD1] == 1;
}
u16 WC6::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA4);
}
u16 WC6::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA6);
}
u8 WC6::contest(u8 index) const
{
return data[0xA9 + index];
}
u8 WC6::iv(Stat index) const
{
return data[0xAF + u8(index)];
}
Gender WC6::otGender(void) const
{
return Gender{data[0xB5]};
}
u16 WC6::additionalItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD2);
}
u32 WC6::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0xD4);
}
Move WC6::relearnMove(u8 index) const
{
return Move{LittleEndian::convertTo<u16>(data + 0xD8 + index * 2)};
}
u8 WC6::otIntensity(void) const
{
return data[0xE0];
}
u8 WC6::otMemory(void) const
{
return data[0xE1];
}
u16 WC6::otTextvar(void) const
{
return data[0xE2];
}
u8 WC6::otFeeling(void) const
{
return data[0xE4];
}
u16 WC6::ev(Stat index) const
{
return data[0xE5 + u8(index)];
}
bool WC6::hasRibbon(Ribbon rib) const
{
return OFFSET_OF(rib).first != RIBBON_ABSENT;
}
bool WC6::ribbon(Ribbon rib) const
{
auto offset = OFFSET_OF(rib);
return offset.first != RIBBON_ABSENT ? FlagUtil::getFlag(data, offset.first, offset.second)
: false;
}
u8 WC6::cardLocation(void) const
{
return data[0x50];
}
bool WC6::used(void) const
{
return (flags() & 2) == 2;
}
bool WC6::oncePerDay(void) const
{
return (flags() & 4) == 4;
}
u16 WC6::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalXYORAS::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalXYORAS::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
}
| 9,806
|
C++
|
.cpp
| 369
| 19.338753
| 99
| 0.55909
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,268
|
PGF.cpp
|
FlagBrew_PKSM-Core/source/wcx/PGF.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/PGF.hpp"
#include "personal/personal.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::Country:
return {0xC, 0};
case pksm::Ribbon::National:
return {0xC, 1};
case pksm::Ribbon::Earth:
return {0xC, 2};
case pksm::Ribbon::World:
return {0xC, 3};
case pksm::Ribbon::Classic:
return {0xC, 4};
case pksm::Ribbon::Premier:
return {0xC, 5};
case pksm::Ribbon::Event:
return {0xC, 6};
case pksm::Ribbon::Birthday:
return {0xC, 7};
case pksm::Ribbon::Special:
return {0xD, 0};
case pksm::Ribbon::Souvenir:
return {0xD, 1};
case pksm::Ribbon::Wishing:
return {0xD, 2};
case pksm::Ribbon::ChampionBattle:
return {0xD, 3};
case pksm::Ribbon::ChampionRegional:
return {0xD, 4};
case pksm::Ribbon::ChampionNational:
return {0xD, 5};
case pksm::Ribbon::ChampionWorld:
return {0xD, 6};
default:
break;
}
return {RIBBON_ABSENT, 0};
}
}
namespace pksm
{
PGF::PGF(u8* dt)
{
std::copy(dt, dt + length, data);
}
Generation PGF::generation(void) const
{
return Generation::FIVE;
}
u16 PGF::ID(void) const
{
return LittleEndian::convertTo<u16>(data + 0xB0);
}
std::string PGF::title(void) const
{
return StringUtils::transString45(StringUtils::getString(data, 0x60, 37, u'\uFFFF'));
}
u8 PGF::type(void) const
{
return data[0xB3];
}
int PGF::year(void) const
{
return LittleEndian::convertTo<u16>(data + 0xAE);
}
int PGF::month(void) const
{
return data[0xAD];
}
int PGF::day(void) const
{
return data[0xAC];
}
void PGF::year(int v)
{
LittleEndian::convertFrom<u16>(data + 0xAE, v);
}
void PGF::month(int v)
{
data[0xAD] = static_cast<u8>(v);
}
void PGF::day(int v)
{
data[0xAC] = static_cast<u8>(v);
}
bool PGF::item(void) const
{
return type() == 2;
}
u16 PGF::object(void) const
{
return LittleEndian::convertTo<u16>(data);
}
bool PGF::pokemon(void) const
{
return type() == 1;
}
bool PGF::power(void) const
{
return type() == 3;
}
bool PGF::bean(void) const
{
return false;
}
bool PGF::BP(void) const
{
return false;
}
u8 PGF::cardLocation(void) const
{
return data[0xB2];
}
u8 PGF::flags(void) const
{
return data[0xB4];
}
bool PGF::used(void) const
{
return (flags() >> 1) > 0;
}
bool PGF::multiObtainable(void) const
{
return flags() == 1;
}
Ball PGF::ball(void) const
{
return Ball{data[0x0E]};
}
u16 PGF::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x10);
}
bool PGF::shiny(void) const
{
return PIDType() == 2;
}
u8 PGF::PIDType(void) const
{
return data[0x37];
}
u16 PGF::TID(void) const
{
return LittleEndian::convertTo<u16>(data);
}
u16 PGF::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x02);
}
Move PGF::move(u8 index) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x12 + index * 2)};
}
Species PGF::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x1A)};
}
Gender PGF::gender(void) const
{
return Gender{data[0x35]};
}
std::string PGF::otName(void) const
{
return StringUtils::getString(data, 0x4A, 8, u'\uFFFF');
}
u8 PGF::level(void) const
{
return data[0x5B];
}
u32 PGF::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x08);
}
bool PGF::hasRibbon(Ribbon rib) const
{
return OFFSET_OF(rib).first != RIBBON_ABSENT;
}
bool PGF::ribbon(Ribbon rib) const
{
auto offset = OFFSET_OF(rib);
return offset.first != RIBBON_ABSENT ? FlagUtil::getFlag(data, offset.first, offset.second)
: false;
}
u8 PGF::alternativeForm(void) const
{
return data[0x1C];
}
Language PGF::language(void) const
{
return Language(data[0x1D]);
}
std::string PGF::nickname(void) const
{
char16_t firstChar = LittleEndian::convertTo<char16_t>(data + 0x1E);
return firstChar != 0xFFFF ? StringUtils::getString(data, 0x1E, 11, u'\uFFFF')
: "Pokemon Name";
}
Nature PGF::nature(void) const
{
return Nature{data[0x34]};
}
u8 PGF::abilityType(void) const
{
return data[0x36];
}
Ability PGF::ability(void) const
{
u8 abilitynum, type = abilityType();
if (type == 2)
{
abilitynum = 2;
}
else if (type == 4)
{
abilitynum = 2;
}
else
{
abilitynum = 0;
}
return PersonalBWB2W2::ability(u16(species()), abilitynum);
}
u16 PGF::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x38);
}
u16 PGF::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x3A);
}
u8 PGF::metLevel(void) const
{
return data[0x3C];
}
u8 PGF::contest(u8 index) const
{
return data[0x3D + index];
}
u8 PGF::iv(Stat index) const
{
return data[0x43 + u8(index)];
}
bool PGF::egg(void) const
{
return data[0x5C] == 1;
}
u16 PGF::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalBWB2W2::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalBWB2W2::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
}
| 8,104
|
C++
|
.cpp
| 301
| 19.54485
| 99
| 0.560991
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,269
|
WC4.cpp
|
FlagBrew_PKSM-Core/source/wcx/WC4.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WC4.hpp"
#include "utils/endian.hpp"
#include <array>
pksm::WC4::WC4(u8* data) : PGT(data), name(StringUtils::getString4(data, 0x104, 0x24))
{
id = LittleEndian::convertTo<u16>(data + 0x150);
}
| 1,484
|
C++
|
.cpp
| 32
| 44.4375
| 86
| 0.726207
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,270
|
WCX.cpp
|
FlagBrew_PKSM-Core/source/wcx/WCX.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WCX.hpp"
namespace pksm
{
u32 WCX::formatTID() const
{
switch (generation())
{
case Generation::ONE:
case Generation::TWO:
case Generation::THREE:
case Generation::FOUR:
case Generation::FIVE:
case Generation::SIX:
return TID();
case Generation::SEVEN:
case Generation::LGPE:
case Generation::EIGHT:
return u32(SID() << 16 | TID()) % 1000000;
case Generation::UNUSED:
return 0;
}
return 0;
}
u32 WCX::formatSID() const
{
switch (generation())
{
case Generation::THREE:
case Generation::FOUR:
case Generation::FIVE:
case Generation::SIX:
return SID();
case Generation::SEVEN:
case Generation::LGPE:
case Generation::EIGHT:
return u32(SID() << 16 | TID()) / 1000000;
case Generation::UNUSED:
case Generation::ONE:
case Generation::TWO:
return 0;
}
return 0;
}
}
| 2,471
|
C++
|
.cpp
| 69
| 28.275362
| 76
| 0.611505
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,271
|
WB7.cpp
|
FlagBrew_PKSM-Core/source/wcx/WB7.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "wcx/WB7.hpp"
#include "personal/personal.hpp"
#include "utils/endian.hpp"
#include "utils/utils.hpp"
namespace
{
int langIndex(pksm::Language lang)
{
if (lang > pksm::Language::UNUSED)
{
return u8(lang) - 2;
}
else if (lang == pksm::Language::UNUSED)
{
return 2 - 1; // English
}
else
{
return u8(lang) - 1;
}
}
}
namespace pksm
{
WB7::WB7(u8* dt, bool full)
{
u16 ofs = full ? 0x208 : 0;
std::copy(dt + ofs, dt + ofs + length, data);
for (int i = 0; i < 6; i++)
{
if (object(i) != 0)
{
numItems++;
}
else
{
break;
}
}
}
Generation WB7::generation() const
{
return Generation::LGPE;
}
u16 WB7::ID() const
{
return LittleEndian::convertTo<u16>(data);
}
std::string WB7::title() const
{
return StringUtils::getString(data, 2, 36);
}
u32 WB7::rawDate() const
{
return LittleEndian::convertTo<u32>(data + 0x4C);
}
void WB7::rawDate(u32 date)
{
LittleEndian::convertFrom<u32>(data + 0x4C, date);
}
int WB7::year() const
{
return rawDate() / 10000 + 2000;
}
int WB7::month() const
{
return rawDate() % 10000 / 100;
}
int WB7::day() const
{
return rawDate() % 100;
}
void WB7::year(int v)
{
u32 newVal = std::max(0, v - 2000);
newVal *= 10000;
newVal += rawDate() % 10000;
rawDate(newVal);
}
void WB7::month(int v)
{
u32 newVal = rawDate() / 10000;
newVal *= 100;
newVal += v;
newVal *= 100;
newVal += rawDate() % 100;
rawDate(newVal);
}
void WB7::day(int v)
{
u32 newVal = rawDate() / 100;
newVal *= 100;
newVal += v;
rawDate(newVal);
}
u8 WB7::cardLocation() const
{
return data[0x50];
}
u8 WB7::type() const
{
return data[0x51];
}
u8 WB7::flags() const
{
return data[0x52];
}
bool WB7::multiObtainable() const
{
return data[0x53] == 1;
}
bool WB7::BP(void) const
{
return type() == 3;
}
bool WB7::bean(void) const
{
return type() == 2;
}
bool WB7::item(void) const
{
return type() == 1;
}
bool WB7::power(void) const
{
return false;
}
u16 WB7::object(void) const
{
return object(0);
}
u16 WB7::object(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x68 + index * 4);
}
int WB7::items(void) const
{
return numItems;
}
u16 WB7::objectQuantity(void) const
{
return objectQuantity(0);
}
u16 WB7::objectQuantity(int index) const
{
return LittleEndian::convertTo<u16>(data + 0x6A + index * 4);
}
bool WB7::pokemon(void) const
{
return type() == 0;
}
u8 WB7::PIDType(void) const
{
return data[0xA3];
}
bool WB7::shiny(void) const
{
return PIDType() == 2;
}
u16 WB7::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x68);
}
u16 WB7::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x6A);
}
GameVersion WB7::version(void) const
{
return GameVersion(data[0x6C]);
}
u32 WB7::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data + 0x70);
}
Ball WB7::ball(void) const
{
return Ball{data[0x76]};
}
u16 WB7::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x78);
}
Move WB7::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x7A + m * 2)};
}
Species WB7::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x82)};
}
u8 WB7::alternativeForm(void) const
{
return data[0x84];
}
Nature WB7::nature(void) const
{
return Nature{data[0xA0]};
}
Gender WB7::gender(void) const
{
return Gender{data[0xA1]};
}
Ability WB7::ability(void) const
{
u8 abilitynum, type = abilityType();
if (type == 2)
{
abilitynum = 2;
}
else if (type == 4)
{
abilitynum = 2;
}
else
{
abilitynum = 0;
}
return PersonalLGPE::ability(u16(species()), abilitynum);
}
u8 WB7::abilityType(void) const
{
return data[0xA2];
}
u8 WB7::metLevel(void) const
{
return data[0xA8];
}
u8 WB7::level(void) const
{
return data[0xD0];
}
bool WB7::egg(void) const
{
return data[0xD1] == 1;
}
u16 WB7::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA4);
}
u16 WB7::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA6);
}
u8 WB7::awakened(Stat index) const
{
return data[0xA9 + u8(index)];
}
u8 WB7::iv(Stat index) const
{
return data[0xAF + u8(index)];
}
Gender WB7::otGender(void) const
{
return Gender{data[0xB5]};
}
u16 WB7::additionalItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD2);
}
u32 WB7::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0xD4);
}
Move WB7::relearnMove(u8 index) const
{
return Move{LittleEndian::convertTo<u16>(data + 0xD8 + index * 2)};
}
u8 WB7::otIntensity(void) const
{
return data[0xE0];
}
u8 WB7::otMemory(void) const
{
return data[0xE1];
}
u16 WB7::otTextvar(void) const
{
return data[0xE2];
}
u8 WB7::otFeeling(void) const
{
return data[0xE4];
}
u16 WB7::ev(Stat index) const
{
return data[0xE5 + u8(index)];
}
std::string WB7::nickname(Language lang) const
{
return StringUtils::getString(data, 0x4 + langIndex(lang) * 0x1A, 13);
}
std::string WB7::otName(Language lang) const
{
return StringUtils::getString(data, 0xEE + langIndex(lang) * 0x1A, 13);
}
std::string WB7::nickname() const
{
return nickname(Language::ENG);
}
std::string WB7::otName() const
{
return otName(Language::ENG);
}
bool WB7::used() const
{
return (flags() & 2) == 2;
}
bool WB7::oncePerDay(void) const
{
return (flags() & 4) == 4;
}
u16 WB7::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalLGPE::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalLGPE::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
}
| 8,751
|
C++
|
.cpp
| 358
| 17.829609
| 79
| 0.555929
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,272
|
PKX.cpp
|
FlagBrew_PKSM-Core/source/pkx/PKX.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PKX.hpp"
#include "pkx/PB7.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "pkx/PKFilter.hpp"
#include "utils/endian.hpp"
#include "utils/random.hpp"
#include "utils/VersionTables.hpp"
namespace pksm
{
Gender PKX::genderFromRatio(u32 pid, u8 gt)
{
switch (gt)
{
case 0xFF:
return Gender::Genderless;
case 0xFE:
return Gender::Female;
case 0:
return Gender::Male;
default:
return (pid & 0xFF) < gt ? Gender::Female : Gender::Male;
}
}
PKX::PKX(u8* data, size_t length, bool directAccess)
: directAccess(directAccess), length(length)
{
if (data)
{
if (directAccess)
{
this->data = data;
}
else
{
this->data = new u8[length];
std::copy(data, data + length, this->data);
}
}
else
{
this->data = new u8[length];
std::fill_n(this->data, length, 0);
this->directAccess = false;
}
}
PKX::PKX(const PKX& pk)
{
directAccess = false;
data = new u8[length = pk.getLength()];
std::copy(pk.data, pk.data + length, data);
}
PKX::PKX(PKX&& pk)
{
data = pk.data;
length = pk.length;
directAccess = pk.directAccess;
pk.data = nullptr;
}
PKX& PKX::operator=(const PKX& pk)
{
if (&pk == this)
{
return *this;
}
if (!directAccess && data)
{
delete[] data;
}
directAccess = false;
data = new u8[length = pk.getLength()];
std::copy(pk.data, pk.data + length, data);
return *this;
}
PKX& PKX::operator=(PKX&& pk)
{
if (&pk == this)
{
return *this;
}
if (!directAccess && data)
{
delete[] data;
}
data = pk.data;
length = pk.length;
directAccess = pk.directAccess;
pk.data = nullptr;
return *this;
}
PKX::~PKX()
{
if (!directAccess && data)
{
delete[] data;
}
}
u32 PKX::expTable(u8 row, u8 col) const
{
static constexpr u32 table[100][6] = {
{0, 0, 0, 0, 0, 0 },
{8, 15, 4, 9, 6, 10 },
{27, 52, 13, 57, 21, 33 },
{64, 122, 32, 96, 51, 80 },
{125, 237, 65, 135, 100, 156 },
{216, 406, 112, 179, 172, 270 },
{343, 637, 178, 236, 274, 428 },
{512, 942, 276, 314, 409, 640 },
{729, 1326, 393, 419, 583, 911 },
{1000, 1800, 540, 560, 800, 1250 },
{1331, 2369, 745, 742, 1064, 1663 },
{1728, 3041, 967, 973, 1382, 2160 },
{2197, 3822, 1230, 1261, 1757, 2746 },
{2744, 4719, 1591, 1612, 2195, 3430 },
{3375, 5737, 1957, 2035, 2700, 4218 },
{4096, 6881, 2457, 2535, 3276, 5120 },
{4913, 8155, 3046, 3120, 3930, 6141 },
{5832, 9564, 3732, 3798, 4665, 7290 },
{6859, 11111, 4526, 4575, 5487, 8573 },
{8000, 12800, 5440, 5460, 6400, 10000 },
{9261, 14632, 6482, 6458, 7408, 11576 },
{10648, 16610, 7666, 7577, 8518, 13310 },
{12167, 18737, 9003, 8825, 9733, 15208 },
{13824, 21012, 10506, 10208, 11059, 17280 },
{15625, 23437, 12187, 11735, 12500, 19531 },
{17576, 26012, 14060, 13411, 14060, 21970 },
{19683, 28737, 16140, 15244, 15746, 24603 },
{21952, 31610, 18439, 17242, 17561, 27440 },
{24389, 34632, 20974, 19411, 19511, 30486 },
{27000, 37800, 23760, 21760, 21600, 33750 },
{29791, 41111, 26811, 24294, 23832, 37238 },
{32768, 44564, 30146, 27021, 26214, 40960 },
{35937, 48155, 33780, 29949, 28749, 44921 },
{39304, 51881, 37731, 33084, 31443, 49130 },
{42875, 55737, 42017, 36435, 34300, 53593 },
{46656, 59719, 46656, 40007, 37324, 58320 },
{50653, 63822, 50653, 43808, 40522, 63316 },
{54872, 68041, 55969, 47846, 43897, 68590 },
{59319, 72369, 60505, 52127, 47455, 74148 },
{64000, 76800, 66560, 56660, 51200, 80000 },
{68921, 81326, 71677, 61450, 55136, 86151 },
{74088, 85942, 78533, 66505, 59270, 92610 },
{79507, 90637, 84277, 71833, 63605, 99383 },
{85184, 95406, 91998, 77440, 68147, 106480 },
{91125, 100237, 98415, 83335, 72900, 113906 },
{97336, 105122, 107069, 89523, 77868, 121670 },
{103823, 110052, 114205, 96012, 83058, 129778 },
{110592, 115015, 123863, 102810, 88473, 138240 },
{117649, 120001, 131766, 109923, 94119, 147061 },
{125000, 125000, 142500, 117360, 100000, 156250 },
{132651, 131324, 151222, 125126, 106120, 165813 },
{140608, 137795, 163105, 133229, 112486, 175760 },
{148877, 144410, 172697, 141677, 119101, 186096 },
{157464, 151165, 185807, 150476, 125971, 196830 },
{166375, 158056, 196322, 159635, 133100, 207968 },
{175616, 165079, 210739, 169159, 140492, 219520 },
{185193, 172229, 222231, 179056, 148154, 231491 },
{195112, 179503, 238036, 189334, 156089, 243890 },
{205379, 186894, 250562, 199999, 164303, 256723 },
{216000, 194400, 267840, 211060, 172800, 270000 },
{226981, 202013, 281456, 222522, 181584, 283726 },
{238328, 209728, 300293, 234393, 190662, 297910 },
{250047, 217540, 315059, 246681, 200037, 312558 },
{262144, 225443, 335544, 259392, 209715, 327680 },
{274625, 233431, 351520, 272535, 219700, 343281 },
{287496, 241496, 373744, 286115, 229996, 359370 },
{300763, 249633, 390991, 300140, 240610, 375953 },
{314432, 257834, 415050, 314618, 251545, 393040 },
{328509, 267406, 433631, 329555, 262807, 410636 },
{343000, 276458, 459620, 344960, 274400, 428750 },
{357911, 286328, 479600, 360838, 286328, 447388 },
{373248, 296358, 507617, 377197, 298598, 466560 },
{389017, 305767, 529063, 394045, 311213, 486271 },
{405224, 316074, 559209, 411388, 324179, 506530 },
{421875, 326531, 582187, 429235, 337500, 527343 },
{438976, 336255, 614566, 447591, 351180, 548720 },
{456533, 346965, 639146, 466464, 365226, 570666 },
{474552, 357812, 673863, 485862, 379641, 593190 },
{493039, 367807, 700115, 505791, 394431, 616298 },
{512000, 378880, 737280, 526260, 409600, 640000 },
{531441, 390077, 765275, 547274, 425152, 664301 },
{551368, 400293, 804997, 568841, 441094, 689210 },
{571787, 411686, 834809, 590969, 457429, 714733 },
{592704, 423190, 877201, 613664, 474163, 740880 },
{614125, 433572, 908905, 636935, 491300, 767656 },
{636056, 445239, 954084, 660787, 508844, 795070 },
{658503, 457001, 987754, 685228, 526802, 823128 },
{681472, 467489, 1035837, 710266, 545177, 851840 },
{704969, 479378, 1071552, 735907, 563975, 881211 },
{729000, 491346, 1122660, 762160, 583200, 911250 },
{753571, 501878, 1160499, 789030, 602856, 941963 },
{778688, 513934, 1214753, 816525, 622950, 973360 },
{804357, 526049, 1254796, 844653, 643485, 1005446},
{830584, 536557, 1312322, 873420, 664467, 1038230},
{857375, 548720, 1354652, 902835, 685900, 1071718},
{884736, 560922, 1415577, 932903, 707788, 1105920},
{912673, 571333, 1460276, 963632, 730138, 1140841},
{941192, 583539, 1524731, 995030, 752953, 1176490},
{970299, 591882, 1571884, 1027103, 776239, 1212873},
{1000000, 600000, 1640000, 1059860, 800000, 1250000}
};
return table[row][col];
}
void PKX::reorderMoves(void)
{
if (move(3) != Move::None && move(2) == Move::None)
{
move(2, move(3));
PP(2, PP(3));
PPUp(2, PPUp(3));
move(3, Move::None);
}
if (move(2) != Move::None && move(1) == Move::None)
{
move(1, move(2));
PP(1, PP(2));
PPUp(1, PPUp(2));
move(2, Move::None);
reorderMoves();
}
if (move(1) != Move::None && move(0) == Move::None)
{
move(0, move(1));
PP(0, PP(1));
PPUp(0, PPUp(1));
move(1, Move::None);
reorderMoves();
}
if (relearnMove(3) != Move::None && relearnMove(2) == Move::None)
{
relearnMove(2, relearnMove(3));
PP(2, PP(3));
PPUp(2, PPUp(3));
relearnMove(3, Move::None);
}
if (relearnMove(2) != Move::None && relearnMove(1) == Move::None)
{
relearnMove(1, relearnMove(2));
PP(1, PP(2));
PPUp(1, PPUp(2));
relearnMove(2, Move::None);
reorderMoves();
}
if (relearnMove(1) != Move::None && relearnMove(0) == Move::None)
{
relearnMove(0, relearnMove(1));
PP(0, PP(1));
PPUp(0, PPUp(1));
relearnMove(1, Move::None);
reorderMoves();
}
}
bool PKX::originGen7(void) const
{
return (Generation)version() == Generation::SEVEN;
}
bool PKX::originGen6(void) const
{
return (Generation)version() == Generation::SIX;
}
bool PKX::originGen5(void) const
{
return (Generation)version() == Generation::FIVE;
}
bool PKX::originGen4(void) const
{
return (Generation)version() == Generation::FOUR;
}
bool PKX::originGen3(void) const
{
return (Generation)version() == Generation::THREE;
}
bool PKX::originGen2(void) const
{
return (Generation)version() == Generation::TWO;
}
bool PKX::originGen1(void) const
{
return (Generation)version() == Generation::ONE;
}
Generation PKX::originGen(void) const
{
return (Generation)version();
}
void PKX::fixMoves(void)
{
reorderMoves();
if (move(0) == Move::None)
{
move(0, Move::Pound);
}
for (int i = 0; i < 4; i++)
{
if (move(i) == Move::None)
{
PP(i, 0);
PPUp(i, 0);
}
}
}
void PKX::healPP(void)
{
for (int i = 0; i < 4; i++)
{
PP(i, maxPP(i));
}
}
u32 PKX::getRandomPID(Species species, Gender gender, GameVersion originGame, Nature nature,
u8 form, u8 abilityNum, bool shiny, u16 tsv, u32 oldPid, Generation gen)
{
const int psvShift = gen >= Generation::SIX ? 4 : 3;
auto testShiny = [tsv, psvShift](u32 newId)
{
u16 psv = (newId >> 16 ^ (newId & 0xFFFF)) >> psvShift;
return tsv == psv;
};
if (originGame >= GameVersion::X) // Origin game over gen 5
{
u32 retId;
do
{
retId = pksm::randomNumber(0, 0xFFFFFFFF);
}
while (shiny != testShiny(retId));
return retId;
}
u8 (*genderTypeFinder)(u16 species) = nullptr;
switch (gen)
{
case Generation::THREE:
genderTypeFinder = PersonalRSFRLGE::gender;
break;
case Generation::FOUR:
genderTypeFinder = PersonalDPPtHGSS::gender;
break;
case Generation::FIVE:
genderTypeFinder = PersonalBWB2W2::gender;
break;
case Generation::SIX:
genderTypeFinder = PersonalXYORAS::gender;
break;
case Generation::SEVEN:
genderTypeFinder = PersonalSMUSUM::gender;
break;
case Generation::LGPE:
genderTypeFinder = PersonalLGPE::gender;
break;
case Generation::EIGHT:
genderTypeFinder = PersonalSWSH::gender;
break;
case Generation::UNUSED:
case Generation::ONE:
case Generation::TWO:
return 0;
}
if (!genderTypeFinder)
{
return 0;
}
u8 genderType = genderTypeFinder(u16(species));
bool g3unown = (originGame <= GameVersion::LG || gen == Generation::THREE) &&
species == Species::Unown;
u32 abilityBits = oldPid & (abilityNum == 2 ? 0x00010001 : 0);
while (true)
{
u32 possiblePID = pksm::randomNumber(0, 0xFFFFFFFF);
if ((Generation)originGame <= Generation::FOUR && (possiblePID % 25) != size_t(nature))
{
continue;
}
if (g3unown)
{
if (PK3::getUnownForm(possiblePID) != form)
{
continue;
}
}
else if (abilityBits != (possiblePID & 0x00010001))
{
continue;
}
if (testShiny(possiblePID) != shiny)
{
continue;
}
if (genderType == 255 || genderType == 254 || genderType == 0 ||
gender == Gender::Genderless)
{
return possiblePID;
}
if (gender == genderFromRatio(possiblePID, genderType))
{
return possiblePID;
}
}
}
u32 PKX::versionTID() const
{
switch (version())
{
default:
return TID();
case GameVersion::SN:
case GameVersion::MN:
case GameVersion::US:
case GameVersion::UM:
case GameVersion::GP:
case GameVersion::GE:
case GameVersion::SW:
case GameVersion::SH:
return u32(SID() << 16 | TID()) % 1000000;
}
}
u32 PKX::versionSID() const
{
switch (version())
{
default:
return SID();
case GameVersion::SN:
case GameVersion::MN:
case GameVersion::US:
case GameVersion::UM:
case GameVersion::GP:
case GameVersion::GE:
case GameVersion::SW:
case GameVersion::SH:
return u32(SID() << 16 | TID()) / 1000000;
}
}
u32 PKX::formatTID() const
{
switch (generation())
{
case Generation::ONE:
case Generation::TWO:
case Generation::THREE:
case Generation::FOUR:
case Generation::FIVE:
case Generation::SIX:
return TID();
case Generation::SEVEN:
case Generation::LGPE:
case Generation::EIGHT:
return u32(SID() << 16 | TID()) % 1000000;
case Generation::UNUSED:
return 0;
}
return 0;
}
u32 PKX::formatSID() const
{
switch (generation())
{
case Generation::THREE:
case Generation::FOUR:
case Generation::FIVE:
case Generation::SIX:
return SID();
case Generation::SEVEN:
case Generation::LGPE:
case Generation::EIGHT:
return u32(SID() << 16 | TID()) / 1000000;
case Generation::UNUSED:
case Generation::ONE:
case Generation::TWO:
return 0;
}
return 0;
}
std::unique_ptr<PKX> PKX::getPKM(Generation gen, u8* data, size_t length, bool directAccess)
{
switch (gen)
{
case Generation::ONE:
return getPKM<Generation::ONE>(data, length, directAccess);
case Generation::TWO:
return getPKM<Generation::TWO>(data, length, directAccess);
case Generation::THREE:
return getPKM<Generation::THREE>(data, length, directAccess);
case Generation::FOUR:
return getPKM<Generation::FOUR>(data, length, directAccess);
case Generation::FIVE:
return getPKM<Generation::FIVE>(data, length, directAccess);
case Generation::SIX:
return getPKM<Generation::SIX>(data, length, directAccess);
case Generation::SEVEN:
return getPKM<Generation::SEVEN>(data, length, directAccess);
case Generation::LGPE:
return getPKM<Generation::LGPE>(data, length, directAccess);
case Generation::EIGHT:
return getPKM<Generation::EIGHT>(data, length, directAccess);
case Generation::UNUSED:
return nullptr;
}
return nullptr;
}
bool PKX::operator==(const PKFilter& filter) const
{
if (filter.generationEnabled() &&
(filter.generationInversed() != (generation() != filter.generation())))
{
return false;
}
if (filter.speciesEnabled() &&
(filter.speciesInversed() != (species() != filter.species())))
{
return false;
}
if (filter.heldItemEnabled() &&
(filter.heldItemInversed() != (heldItem() != filter.heldItem())))
{
return false;
}
if (filter.levelEnabled() && (filter.levelInversed() != (level() != filter.level())))
{
return false;
}
if (filter.abilityEnabled() &&
(filter.abilityInversed() != (ability() != filter.ability())))
{
return false;
}
if (filter.TSVEnabled() && (filter.TSVInversed() != (TSV() != filter.TSV())))
{
return false;
}
if (filter.natureEnabled() && (filter.natureInversed() != (nature() != filter.nature())))
{
return false;
}
if (filter.genderEnabled() && (filter.genderInversed() != (gender() != filter.gender())))
{
return false;
}
if (filter.ballEnabled() && (filter.ballInversed() != (ball() != filter.ball())))
{
return false;
}
if (filter.languageEnabled() &&
(filter.languageInversed() != (language() != filter.language())))
{
return false;
}
if (filter.eggEnabled() && (filter.eggInversed() != (egg() != filter.egg())))
{
return false;
}
for (int i = 0; i < 4; i++)
{
if (filter.moveEnabled(i) && (filter.moveInversed(i) != (move(i) != filter.move(i))))
{
return false;
}
if (filter.relearnMoveEnabled(i))
{
if (generation() < Generation::SIX)
{
return false;
}
else if (filter.relearnMoveInversed(i) != (filter.relearnMove(i) != relearnMove(i)))
{
return false;
}
}
}
for (int i = 0; i < 6; i++)
{
if (filter.ivEnabled(Stat(i)) &&
(filter.ivInversed(Stat(i)) != (iv(Stat(i)) < filter.iv(Stat(i)))))
{
return false;
}
}
if (filter.shinyEnabled() && (filter.shinyInversed() != (filter.shiny() != shiny())))
{
return false;
}
if (filter.alternativeFormEnabled() &&
(filter.alternativeFormInversed() != (filter.alternativeForm() != alternativeForm())))
{
return false;
}
return true;
}
std::unique_ptr<PK1> PKX::convertToG1(Sav&) const
{
return generation() == Generation::ONE
? std::unique_ptr<PK1>(static_cast<PK1*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK2> PKX::convertToG2(Sav&) const
{
return generation() == Generation::TWO
? std::unique_ptr<PK2>(static_cast<PK2*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK3> PKX::convertToG3(Sav&) const
{
return generation() == Generation::THREE
? std::unique_ptr<PK3>(static_cast<PK3*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK4> PKX::convertToG4(Sav&) const
{
return generation() == Generation::FOUR
? std::unique_ptr<PK4>(static_cast<PK4*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK5> PKX::convertToG5(Sav&) const
{
return generation() == Generation::FIVE
? std::unique_ptr<PK5>(static_cast<PK5*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK6> PKX::convertToG6(Sav&) const
{
return generation() == Generation::SIX
? std::unique_ptr<PK6>(static_cast<PK6*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK7> PKX::convertToG7(Sav&) const
{
return generation() == Generation::SEVEN
? std::unique_ptr<PK7>(static_cast<PK7*>(clone().release()))
: nullptr;
}
std::unique_ptr<PB7> PKX::convertToLGPE(Sav&) const
{
return generation() == Generation::LGPE
? std::unique_ptr<PB7>(static_cast<PB7*>(clone().release()))
: nullptr;
}
std::unique_ptr<PK8> PKX::convertToG8(Sav&) const
{
return generation() == Generation::EIGHT
? std::unique_ptr<PK8>(static_cast<PK8*>(clone().release()))
: nullptr;
}
std::unique_ptr<PKX> PKX::partyClone() const
{
if (isParty())
{
auto ret = clone();
return ret;
}
else
{
size_t partylen;
switch (generation())
{
case Generation::ONE:
partylen = (language() == Language::JPN ? PK1::JP_LENGTH_WITH_NAMES
: PK1::INT_LENGTH_WITH_NAMES);
break;
case Generation::TWO:
partylen = (language() == Language::JPN ? PK2::JP_LENGTH_WITH_NAMES
: PK2::INT_LENGTH_WITH_NAMES);
break;
case Generation::THREE:
partylen = PK3::PARTY_LENGTH;
break;
case Generation::FOUR:
partylen = PK4::PARTY_LENGTH;
break;
case Generation::FIVE:
partylen = PK5::PARTY_LENGTH;
break;
case Generation::SIX:
partylen = PK6::PARTY_LENGTH;
break;
case Generation::SEVEN:
partylen = PK7::PARTY_LENGTH;
break;
case Generation::LGPE:
partylen = PB7::PARTY_LENGTH;
break;
case Generation::EIGHT:
partylen = PK8::PARTY_LENGTH;
break;
default:
partylen = 0;
}
auto ret = PKX::getPKM(generation(), nullptr, partylen);
std::copy(data, data + getLength(), ret->rawData().data());
ret->updatePartyData();
return ret;
}
}
u8 PKX::maxPP(u8 which) const
{
return VersionTables::movePP(generation(), move(which), PPUp(which));
}
}
| 26,582
|
C++
|
.cpp
| 725
| 25.566897
| 100
| 0.491185
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,273
|
PK1.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK1.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/i18n.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#include "utils/ValueConverter.hpp"
#include <algorithm>
namespace pksm
{
PK1::PK1(PrivateConstructor, u8* dt, bool japanese, bool directAccess)
: PKX(dt, japanese ? JP_LENGTH_WITH_NAMES : INT_LENGTH_WITH_NAMES, directAccess)
{
this->japanese = japanese;
lang = japanese ? Language::JPN : Language::ENG;
shiftedData = data + 3;
}
std::unique_ptr<PK2> PK1::convertToG2(Sav&) const
{
auto pk2 = PKX::getPKM<Generation::TWO>(
nullptr, japanese ? PK2::JP_LENGTH_WITH_NAMES : PK2::INT_LENGTH_WITH_NAMES);
pk2->species(species());
pk2->TID(TID());
pk2->experience(experience());
pk2->egg(false);
pk2->otFriendship(pk2->baseFriendship());
pk2->language(language());
pk2->ev(Stat::HP, ev(Stat::HP));
pk2->ev(Stat::ATK, ev(Stat::ATK));
pk2->ev(Stat::DEF, ev(Stat::DEF));
pk2->ev(Stat::SPD, ev(Stat::SPD));
pk2->ev(Stat::SPATK, ev(Stat::SPATK));
pk2->move(0, move(0));
pk2->move(1, move(1));
pk2->move(2, move(2));
pk2->move(3, move(3));
pk2->PPUp(0, PPUp(0));
pk2->PPUp(1, PPUp(1));
pk2->PPUp(2, PPUp(2));
pk2->PPUp(3, PPUp(3));
pk2->PP(0, PP(0));
pk2->PP(1, PP(1));
pk2->PP(2, PP(2));
pk2->PP(3, PP(3));
pk2->iv(Stat::ATK, iv(Stat::ATK));
pk2->iv(Stat::DEF, iv(Stat::DEF));
pk2->iv(Stat::SPD, iv(Stat::SPD));
pk2->iv(Stat::SPATK, iv(Stat::SPATK));
pk2->otName(otName());
pk2->nickname(nickname());
pk2->heldItem2(heldItem2());
pk2->fixMoves();
return pk2;
}
std::unique_ptr<PK3> PK1::convertToG3(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
return pk4->convertToG3(save);
}
}
}
}
return nullptr;
}
std::unique_ptr<PK4> PK1::convertToG4(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
return pk5->convertToG4(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK5> PK1::convertToG5(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
return pk6->convertToG5(save);
}
}
return nullptr;
}
std::unique_ptr<PK6> PK1::convertToG6(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
return pk7->convertToG6(save);
}
return nullptr;
}
std::unique_ptr<PK7> PK1::convertToG7(Sav& save) const
{
auto pk7 = PKX::getPKM<Generation::SEVEN>(nullptr, PK7::BOX_LENGTH);
pk7->encryptionConstant(randomNumber(0, 0xFFFFFFFF));
pk7->PID(randomNumber(0, 0xFFFFFFFF));
pk7->species(species());
pk7->TID(TID());
pk7->level(level());
pk7->metLevel(level());
pk7->nature(nature());
pk7->ball(ball());
pk7->metDate(Date::today());
pk7->version(version());
pk7->move(0, move(0));
pk7->move(1, move(1));
pk7->move(2, move(2));
pk7->move(3, move(3));
pk7->PPUp(0, PPUp(0));
pk7->PPUp(1, PPUp(1));
pk7->PPUp(2, PPUp(2));
pk7->PPUp(3, PPUp(3));
pk7->metLocation(0x753D);
pk7->gender(gender());
pk7->nicknamed(false);
pk7->otName(japanese ? StringUtils::fixJapaneseNameTransporter(transferOT(save.language()))
: transferOT(save.language()));
pk7->currentHandler(PKXHandler::NonOT);
pk7->htName(save.otName());
pk7->htGender(save.gender());
pk7->consoleRegion(save.consoleRegion());
pk7->country(save.country());
pk7->region(save.subRegion());
pk7->geoCountry(0, save.country());
pk7->geoRegion(0, save.subRegion());
pk7->healPP();
pk7->language(save.language());
pk7->nickname(species().localize(pk7->language()));
pk7->otFriendship(PersonalSMUSUM::baseFriendship(u16(species())));
pk7->htFriendship(pk7->otFriendship());
std::array<Stat, 6> stats = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
std::shuffle(stats.begin(), stats.end(), UniformRandomBitGenerator{});
u8 perfectStats = 3;
if (species() == Species::Mew)
{
perfectStats = 5;
}
for (const auto& s : stats | std::views::take(perfectStats))
{
pk7->iv(s, 31);
}
for (const auto& s : stats | std::views::drop(perfectStats))
{
pk7->iv(s, randomNumber(0, 31));
}
if (pk7->shiny() && !shiny())
{
pk7->PID(pk7->PID() ^ 0x10000000);
}
else if (!pk7->shiny() && shiny())
{
pk7->PID(u32(((pk7->TID() ^ (pk7->PID() & 0xFFFF)) << 16) | (pk7->PID() & 0xFFFF)));
}
// always has hidden ability unless it doesn't exist
switch (species())
{
case Species::Gastly:
case Species::Haunter:
case Species::Gengar:
case Species::Koffing:
case Species::Weezing:
case Species::Mew:
pk7->setAbility(0);
break;
default:
pk7->setAbility(2);
}
if (species() == Species::Mew)
{
pk7->fatefulEncounter(true);
}
else if (nicknamed())
{
pk7->nicknamed(true);
pk7->nickname(japanese ? StringUtils::fixJapaneseNameTransporter(nicknameTransporter())
: nicknameTransporter());
}
pk7->htMemory(4);
pk7->htTextVar(0);
pk7->htIntensity(1);
pk7->htFeeling(randomNumber(0, 9));
pk7->fixMoves();
pk7->refreshChecksum();
return pk7;
}
std::unique_ptr<PK8> PK1::convertToG8(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
return pk7->convertToG8(save);
}
return nullptr;
}
std::unique_ptr<PKX> PK1::clone() const
{
return PKX::getPKM<Generation::ONE>(
data, japanese ? JP_LENGTH_WITH_NAMES : INT_LENGTH_WITH_NAMES);
}
u16 PK1::TID() const
{
return BigEndian::convertTo<u16>(shiftedData + 12);
}
void PK1::TID(u16 v)
{
BigEndian::convertFrom<u16>(shiftedData + 12, v);
}
std::string PK1::nickname() const
{
return StringUtils::getString1(
shiftedData, 44 + (japanese ? 6 : 11), japanese ? 6 : 11, lang);
}
std::string PK1::nicknameTransporter() const
{
return StringUtils::getString1(
shiftedData, 44 + (japanese ? 6 : 11), japanese ? 6 : 11, lang, true);
}
void PK1::nickname(const std::string_view& v)
{
StringUtils::setString1(
shiftedData, v, 44 + (japanese ? 6 : 11), japanese ? 6 : 11, lang, japanese ? 6 : 11);
}
Language PK1::language() const
{
return lang;
}
void PK1::language(Language v)
{
// data is too different to allow converting anything between japanese and another language
if (lang != Language::JPN && v != Language::JPN)
{
lang = v;
}
}
std::string PK1::otName() const
{
return StringUtils::getString1(shiftedData, 44, japanese ? 6 : 11, lang);
}
void PK1::otName(const std::string_view& v)
{
StringUtils::setString1(shiftedData, v, 44, japanese ? 6 : 11, lang, japanese ? 6 : 11);
}
std::string PK1::transferOT(Language newLang) const
{
return StringUtils::getString1(
shiftedData, 44, japanese ? 6 : 11, shiftedData[44] == 0x5D ? newLang : lang, true);
}
u8 PK1::speciesID1() const
{
return shiftedData[0];
}
void PK1::speciesID1(u8 v)
{
data[1] = v;
shiftedData[0] = v;
writeG1Types();
// do this now rather than never
data[0] = 1;
data[2] = 0xFF;
}
Species PK1::species() const
{
return SpeciesConverter::g1ToNational(speciesID1());
}
void PK1::species(Species v)
{
speciesID1(SpeciesConverter::nationalToG1(v));
}
// yes, Gen I pokemon data stores catch rate, and yes it's actually important for Gen II
// importing
u8 PK1::catchRate() const
{
return shiftedData[7];
}
void PK1::catchRate(u8 v)
{
shiftedData[7] = v;
}
// experience is actually 3 bytes
u32 PK1::experience() const
{
return BigEndian::convertTo<u32>(shiftedData + 14) >> 8;
}
void PK1::experience(u32 v)
{
shiftedData[14] = v >> 16;
shiftedData[15] = (v >> 8) & 0x00FF;
shiftedData[16] = v & 0x0000FF;
}
u16 PK1::ev(Stat ev) const
{
if (ev == Stat::SPDEF)
{
ev = Stat::SPATK;
}
return BigEndian::convertTo<u16>(shiftedData + 17 + 2 * u8(ev));
}
void PK1::ev(Stat ev, u16 v)
{
if (ev == Stat::SPDEF)
{
ev = Stat::SPATK;
}
BigEndian::convertFrom<u16>(shiftedData + 17 + 2 * u8(ev), v);
}
Move PK1::move(u8 move) const
{
return Move{shiftedData[8 + move]};
}
void PK1::move(u8 move, Move v)
{
shiftedData[8 + move] = u8(v);
}
u8 PK1::PP(u8 move) const
{
return u8(shiftedData[29 + move] & 0x3F);
}
void PK1::PP(u8 move, u8 v)
{
shiftedData[29 + move] = u8((shiftedData[29 + move] & 0xC0) | (v & 0x3F));
}
u8 PK1::PPUp(u8 move) const
{
return shiftedData[29 + move] >> 6;
}
void PK1::PPUp(u8 move, u8 v)
{
shiftedData[29 + move] = u8((v & 0xC0) | (shiftedData[29 + move] & 0x3F));
}
u8 PK1::iv(Stat iv) const
{
switch (iv)
{
case Stat::HP:
return ((PK1::iv(Stat::ATK) & 0x01) << 3) | ((PK1::iv(Stat::DEF) & 0x01) << 2) |
((PK1::iv(Stat::SPD) & 0x01) << 1) | (PK1::iv(Stat::SPATK) & 0x01);
case Stat::ATK:
return (shiftedData[0x1B] & 0xF0) >> 4;
case Stat::DEF:
return shiftedData[0x1B] & 0x0F;
case Stat::SPD:
return (shiftedData[0x1C] & 0xF0) >> 4;
case Stat::SPATK:
case Stat::SPDEF:
return shiftedData[0x1C] & 0x0F;
default:
return 0;
}
}
void PK1::iv(Stat iv, u8 v)
{
if (v > 15)
{
v = 15;
}
switch (iv)
{
case Stat::ATK:
shiftedData[0x1B] = ((v & 0x0F) << 4) | (shiftedData[0x1B] & 0x0F);
break;
case Stat::DEF:
shiftedData[0x1B] = (shiftedData[0x1B] & 0xF0) | (v & 0x0F);
break;
case Stat::SPD:
shiftedData[0x1C] = ((v & 0x0F) << 4) | (shiftedData[0x1C] & 0x0F);
break;
case Stat::SPATK:
case Stat::SPDEF:
shiftedData[0x1C] = (shiftedData[0x1C] & 0xF0) | (v & 0x0F);
break;
case Stat::HP:
default:
return;
}
}
bool PK1::nicknamed() const
{
if (japanese)
{
std::string target = species().localize(language());
return nickname() != StringUtils::toUpper(target);
}
else
{
for (u8 i = u8(Language::ENG); i <= u8(Language::SPA); i++)
{
if (i != u8(Language::UNUSED))
{
std::string target = species().localize(Language{i});
if (nickname() == StringUtils::toUpper(target))
{
return false;
}
}
}
}
return true;
}
Gender PK1::gender() const
{
switch (genderType())
{
case 255:
return Gender::Genderless;
case 254:
return Gender::Female;
case 0:
return Gender::Male;
default:
return iv(Stat::ATK) > (genderType() >> 4) ? Gender::Male : Gender::Female;
}
}
void PK1::gender(Gender g)
{
switch (genderType())
{
case 255:
case 254:
case 0:
return;
default:
iv(Stat::ATK,
(g == Gender::Female) ? (genderType() >> 4) : ((genderType() >> 4) + 1));
}
}
Nature PK1::nature() const
{
return Nature{u8(experience() % 25)};
}
void PK1::nature(Nature v)
{
experience(experience() - (experience() % 25) + u8(v));
}
Type PK1::hpType() const
{
return Type{u8((((iv(Stat::ATK) & 0x3) << 2) | (iv(Stat::DEF) & 0x3)) + 1)};
}
void PK1::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
u8 noNormal = u8(v) - 1;
noNormal %= 16; // just in case
iv(Stat::ATK, (iv(Stat::ATK) & 0xC) | (noNormal >> 2));
iv(Stat::DEF, (iv(Stat::DEF) & 0xC) | (noNormal & 0x3));
}
u8 PK1::level() const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK1::level(u8 v)
{
experience(expTable(v - 1, expType()));
boxLevel(v);
}
// shininess doesn't exist until Gen II, but the GUI is probably gonna use colored sprites, so
// why not
bool PK1::shiny() const
{
return (iv(Stat::DEF) == 10) && (iv(Stat::SPD) == 10) && (iv(Stat::SPATK) == 10) &&
(((iv(Stat::ATK) & 0x02) >> 1) == 1);
}
void PK1::shiny(bool v)
{
if (v)
{
iv(Stat::DEF, 10);
iv(Stat::SPD, 10);
iv(Stat::SPATK, 10);
}
iv(Stat::ATK, v ? 7 : 8);
}
u16 PK1::formSpecies() const
{
return u16(species());
}
u16 PK1::statImpl(Stat stat) const
{
u16 base;
switch (stat)
{
case Stat::HP:
base = baseHP();
break;
case Stat::ATK:
base = baseAtk();
break;
case Stat::DEF:
base = baseDef();
break;
// WHO NAMED THE STAT SPD AND THE METHOD SPE?!
case Stat::SPD:
base = baseSpe();
break;
case Stat::SPATK:
case Stat::SPDEF:
base = baseSpa();
break;
default:
base = 0;
}
u16 EV = u16(std::min(255, int(std::ceil(std::sqrt(ev(stat))))) >> 2);
u16 mid = u16(((2 * (base + iv(stat)) + EV) * level() / 100) + 5);
if (stat == Stat::HP)
{
return mid + 5 + level();
}
return mid;
}
int PK1::partyCurrHP() const
{
return isParty() ? BigEndian::convertTo<u16>(shiftedData + 1) : -1;
}
void PK1::partyCurrHP(u16 v)
{
if (isParty())
{
BigEndian::convertFrom<u16>(shiftedData + 1, v);
}
}
int PK1::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
if (stat == Stat::SPDEF)
{
stat = Stat::SPATK;
}
return BigEndian::convertTo<u16>(shiftedData + 34 + 2 * u8(stat));
}
void PK1::partyStat(Stat stat, u16 v)
{
if (isParty())
{
if (stat == Stat::SPDEF)
{
stat = Stat::SPATK;
}
BigEndian::convertFrom<u16>(shiftedData + 34 + 2 * u8(stat), v);
}
}
int PK1::partyLevel() const
{
return isParty() ? shiftedData[33] : -1;
}
void PK1::partyLevel(u8 v)
{
if (isParty())
{
shiftedData[33] = v;
}
}
int PK1::boxLevel() const
{
return shiftedData[3];
}
void PK1::boxLevel(u8 v)
{
shiftedData[3] = v;
}
void PK1::updatePartyData()
{
partyLevel(level());
for (u8 pstat = u8(Stat::HP); pstat != u8(Stat::SPDEF); pstat++)
{
partyStat(static_cast<Stat>(pstat), stat(static_cast<Stat>(pstat)));
}
partyCurrHP(stat(Stat::HP));
}
void PK1::writeG1Types()
{
static constexpr auto convType = [](Type t) -> u8
{
switch (t)
{
case Type::Normal:
case Type::Fighting:
case Type::Flying:
case Type::Poison:
case Type::Ground:
case Type::Rock:
return u8(t);
case Type::Bug:
case Type::Ghost:
case Type::Steel:
return u8(t) + 1;
default:
return u8(t) + 11;
}
};
shiftedData[5] = convType(type1());
shiftedData[6] = convType(type2());
}
// gen 2 stuff because this is a gen 2 construct
u8 PK1::heldItem2() const
{
switch (catchRate())
{
case 0x19: // Teru-sama
return 0x92; // Leftovers
case 0x2D: // Teru-sama
return 0x53; // Bitter Berry
case 0x32: // Teru-sama
return 0xAE; // Gold Berry
case 0x5A: // Teru-sama
case 0x64: // Teru-sama
case 0x78: // Teru-sama
case 0x7F: // Card Key
case 0xBE: // Teru-sama
case 0xFF: // Cancel
return 0xAD; // Berry
default:
return catchRate();
}
}
void PK1::heldItem2(u8 v)
{
catchRate(v);
}
u16 PK1::heldItem() const
{
return ItemConverter::g2ToNational(heldItem2());
}
void PK1::heldItem(u16 v)
{
catchRate(ItemConverter::nationalToG2(v));
}
void PK1::heldItem(const Item& item)
{
if (item.generation() == Generation::TWO)
{
heldItem2((static_cast<const Item2&>(item)).id2());
}
else
{
heldItem(item.id());
}
}
}
| 20,922
|
C++
|
.cpp
| 696
| 20.938218
| 99
| 0.502904
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,274
|
PB7.cpp
|
FlagBrew_PKSM-Core/source/pkx/PB7.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PB7.hpp"
#include "pkx/PK8.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/utils.hpp"
namespace pksm
{
void PB7::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
}
}
void PB7::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PB7::isEncrypted() const
{
return LittleEndian::convertTo<u16>(data + 0xC8) != 0 &&
LittleEndian::convertTo<u16>(data + 0x58) != 0;
}
PB7::PB7(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PB7::clone(void) const
{
return PKX::getPKM<Generation::LGPE>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PB7::generation(void) const
{
return Generation::LGPE;
}
u32 PB7::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PB7::encryptionConstant(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PB7::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PB7::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PB7::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PB7::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PB7::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PB7::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PB7::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PB7::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PB7::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PB7::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PB7::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PB7::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PB7::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PB7::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
Ability PB7::ability(void) const
{
return Ability{data[0x14]};
}
void PB7::ability(Ability v)
{
data[0x14] = u8(v);
}
void PB7::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else if (v == 1)
{
abilitynum = 2;
}
else
{
abilitynum = 4;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u8 PB7::abilityNumber(void) const
{
return data[0x15];
}
void PB7::abilityNumber(u8 v)
{
data[0x15] = v;
}
u16 PB7::markValue(void) const
{
return LittleEndian::convertTo<u16>(data + 0x16);
}
void PB7::markValue(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x16, v);
}
u32 PB7::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x18);
}
void PB7::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x18, v);
}
Nature PB7::nature(void) const
{
return Nature{data[0x1C]};
}
void PB7::nature(Nature v)
{
data[0x1C] = u8(v);
}
bool PB7::fatefulEncounter(void) const
{
return (data[0x1D] & 1) == 1;
}
void PB7::fatefulEncounter(bool v)
{
data[0x1D] = (data[0x1D] & ~0x01) | (v ? 1 : 0);
}
Gender PB7::gender(void) const
{
return Gender{u8((data[0x1D] >> 1) & 0x3)};
}
void PB7::gender(Gender v)
{
data[0x1D] = (data[0x1D] & ~0x06) | (u8(v) << 1);
}
u16 PB7::alternativeForm(void) const
{
return data[0x1D] >> 3;
}
void PB7::alternativeForm(u16 v)
{
data[0x1D] = (data[0x1D] & 0x07) | (v << 3);
}
u16 PB7::ev(Stat ev) const
{
return data[0x1E + u8(ev)];
}
void PB7::ev(Stat ev, u16 v)
{
data[0x1E + u8(ev)] = v;
}
u8 PB7::awakened(Stat stat) const
{
return data[0x24 + u8(stat)];
}
void PB7::awakened(Stat stat, u8 v)
{
data[0x24 + u8(stat)] = v;
}
u8 PB7::pelagoEventStatus(void) const
{
return data[0x2A];
}
void PB7::pelagoEventStatus(u8 v)
{
data[0x2A] = v;
}
u8 PB7::pkrs(void) const
{
return data[0x2B];
}
void PB7::pkrs(u8 v)
{
data[0x2B] = v;
}
u8 PB7::pkrsDays(void) const
{
return data[0x2B] & 0xF;
};
void PB7::pkrsDays(u8 v)
{
data[0x2B] = (data[0x2B] & ~0xF) | v;
}
u8 PB7::pkrsStrain(void) const
{
return data[0x2B] >> 4;
};
void PB7::pkrsStrain(u8 v)
{
data[0x2B] = (data[0x2B] & 0xF) | (v << 4);
}
std::string PB7::nickname(void) const
{
return StringUtils::getString(data, 0x40, 12);
}
void PB7::nickname(const std::string_view& v)
{
StringUtils::setString(data, v, 0x40, 12);
}
Move PB7::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x5A + m * 2)};
}
void PB7::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x5A + m * 2, u16(v));
}
u8 PB7::PP(u8 m) const
{
return data[0x62 + m];
}
void PB7::PP(u8 m, u8 v)
{
data[0x62 + m] = v;
}
u8 PB7::PPUp(u8 m) const
{
return data[0x66 + m];
}
void PB7::PPUp(u8 m, u8 v)
{
data[0x66 + m] = v;
}
Move PB7::relearnMove(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x6A + m * 2)};
}
void PB7::relearnMove(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x6A + m * 2, u16(v));
}
u8 PB7::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
return u8((buffer >> 5 * u8(stat)) & 0x1F);
}
void PB7::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x74, buffer);
}
bool PB7::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 30) & 0x1) == 1;
}
void PB7::egg(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x74,
(LittleEndian::convertTo<u32>(data + 0x74) & ~0x40000000u) | (v ? 0x40000000u : 0u));
}
bool PB7::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 31) & 0x1) == 1;
}
void PB7::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x74,
(LittleEndian::convertTo<u32>(data + 0x74) & 0x7FFFFFFFu) | (v ? 0x80000000u : 0u));
}
std::string PB7::htName(void) const
{
return StringUtils::getString(data, 0x78, 12);
}
void PB7::htName(const std::string_view& v)
{
StringUtils::setString(data, v, 0x78, 12);
}
Gender PB7::htGender(void) const
{
return Gender{data[0x92]};
}
void PB7::htGender(Gender v)
{
data[0x92] = u8(v);
}
PKXHandler PB7::currentHandler(void) const
{
return data[0x93] == 0 ? PKXHandler::OT : PKXHandler::NonOT;
}
void PB7::currentHandler(PKXHandler v)
{
data[0x93] = v == PKXHandler::OT ? 0 : 1;
}
u8 PB7::htFriendship(void) const
{
return data[0xA2];
}
void PB7::htFriendship(u8 v)
{
data[0xA2] = v;
}
u8 PB7::htIntensity(void) const
{
return data[0xA4];
}
void PB7::htIntensity(u8 v)
{
data[0xA4] = v;
}
u8 PB7::htMemory(void) const
{
return data[0xA5];
}
void PB7::htMemory(u8 v)
{
data[0xA5] = v;
}
u8 PB7::htFeeling(void) const
{
return data[0xA6];
}
void PB7::htFeeling(u8 v)
{
data[0xA6] = v;
}
u16 PB7::htTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA8);
}
void PB7::htTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xA8, v);
}
u8 PB7::fullness(void) const
{
return data[0xAE];
}
void PB7::fullness(u8 v)
{
data[0xAE] = v;
}
u8 PB7::enjoyment(void) const
{
return data[0xAF];
}
void PB7::enjoyment(u8 v)
{
data[0xAF] = v;
}
std::string PB7::otName(void) const
{
return StringUtils::getString(data, 0xB0, 12);
}
void PB7::otName(const std::string_view& v)
{
StringUtils::setString(data, v, 0xB0, 12);
}
u8 PB7::otFriendship(void) const
{
return data[0xCA];
}
void PB7::otFriendship(u8 v)
{
data[0xCA] = v;
}
int PB7::eggYear(void) const
{
return 2000 + data[0xD1];
}
void PB7::eggYear(int v)
{
data[0xD1] = v - 2000;
}
int PB7::eggMonth(void) const
{
return data[0xD2];
}
void PB7::eggMonth(int v)
{
data[0xD2] = v;
}
int PB7::eggDay(void) const
{
return data[0xD3];
}
void PB7::eggDay(int v)
{
data[0xD3] = v;
}
int PB7::metYear(void) const
{
return 2000 + data[0xD4];
}
void PB7::metYear(int v)
{
data[0xD4] = v - 2000;
}
int PB7::metMonth(void) const
{
return data[0xD5];
}
void PB7::metMonth(int v)
{
data[0xD5] = v;
}
int PB7::metDay(void) const
{
return data[0xD6];
}
void PB7::metDay(int v)
{
data[0xD6] = v;
}
u16 PB7::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD8);
}
void PB7::eggLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xD8, v);
}
u16 PB7::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xDA);
}
void PB7::metLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xDA, v);
}
Ball PB7::ball(void) const
{
return Ball{data[0xDC]};
}
void PB7::ball(Ball v)
{
data[0xDC] = u8(v);
}
u8 PB7::metLevel(void) const
{
return data[0xDD] & ~0x80;
}
void PB7::metLevel(u8 v)
{
data[0xDD] = (data[0xDD] & 0x80) | v;
}
Gender PB7::otGender(void) const
{
return Gender{u8(data[0xDD] >> 7)};
}
void PB7::otGender(Gender v)
{
data[0xDD] = (data[0xDD] & ~0x80) | (u8(v) << 7);
}
bool PB7::hyperTrain(Stat stat) const
{
return (data[0xDE] & (1 << hyperTrainLookup[size_t(stat)])) ==
1 << hyperTrainLookup[size_t(stat)];
}
void PB7::hyperTrain(Stat stat, bool v)
{
data[0xDE] = (data[0xDE] & ~(1 << hyperTrainLookup[size_t(stat)])) |
(v ? 1 << hyperTrainLookup[size_t(stat)] : 0);
}
GameVersion PB7::version(void) const
{
return GameVersion(data[0xDF]);
}
void PB7::version(GameVersion v)
{
data[0xDF] = u8(v);
}
Language PB7::language(void) const
{
return Language(data[0xE3]);
}
void PB7::language(Language v)
{
data[0xE3] = u8(v);
}
void PB7::refreshChecksum(void)
{
u16 chk = 0;
for (u8 i = 8; i < 232; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PB7::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PB7::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PB7::TSV(void) const
{
return (TID() ^ SID()) >> 4;
}
u16 PB7::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 4;
}
u8 PB7::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PB7::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PB7::shiny(void) const
{
return TSV() == PSV();
}
void PB7::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PB7::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalLGPE::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalLGPE::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PB7::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc =
10 + ((2 * basestat) +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4 + 100) *
level() / 100;
}
else
{
calc =
5 + (2 * basestat +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4) *
level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10 + awakened(stat);
}
int PB7::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF0);
}
void PB7::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF0, v);
}
}
int PB7::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF2 + u8(stat) * 2);
}
void PB7::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF2 + u8(stat) * 2, v);
}
}
int PB7::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0xEC);
}
void PB7::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0xEC) = v;
}
}
u16 PB7::partyCP() const
{
if (!isParty())
{
return 0;
}
return LittleEndian::convertTo<u16>(data + 0xFE);
}
void PB7::partyCP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xFE, v);
}
}
u16 PB7::CP() const
{
int base = stat(Stat::HP) + 10 + level(); // HP
int mult = ((currentFriendship() / 255.0f / 10.0f) + 1.0f) * 100.0f;
int awake = awakened(Stat::HP);
for (int i = 1; i < 6; i++)
{
base += stat(Stat(i)) * mult / 100;
awake += awakened(Stat(i));
}
base = u16((float)(base * 6 * level()) / 100.0f);
double modifier = level() / 100.0 + 2.0;
awake = u16(modifier) * awake;
return std::min(10000, base + awake);
}
u8 PB7::height(void) const
{
return data[0x3A];
}
void PB7::height(u8 v)
{
data[0x3A] = v;
}
u8 PB7::weight(void) const
{
return data[0x3B];
}
void PB7::weight(u8 v)
{
data[0x3B] = v;
}
void PB7::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
partyCP(CP());
}
std::unique_ptr<PK8> PB7::convertToG8(Sav& save) const
{
auto pk8 = PKX::getPKM<Generation::EIGHT>(nullptr, PK8::BOX_LENGTH);
// Note: Locale stuff does not transfer
pk8->encryptionConstant(encryptionConstant());
pk8->species(species());
pk8->TID(TID());
pk8->SID(SID());
pk8->experience(experience());
pk8->PID(PID());
if (ability() == PersonalLGPE::ability(formSpecies(), abilityNumber() >> 1))
{
pk8->setAbility(abilityNumber() >> 1);
}
else
{
pk8->ability(ability());
pk8->abilityNumber(abilityNumber());
}
pk8->language(language());
for (Stat stat : {Stat::HP, Stat::ATK, Stat::DEF, Stat::SPATK, Stat::SPDEF, Stat::SPD})
{
pk8->ev(stat, ev(stat));
pk8->iv(stat, iv(stat));
pk8->hyperTrain(stat, hyperTrain(stat));
}
for (size_t i = 0; i < 4; i++)
{
pk8->move(i, move(i));
pk8->PPUp(i, PPUp(i));
pk8->PP(i, PP(i));
pk8->relearnMove(i, move(i));
}
pk8->nicknamed(nicknamed());
pk8->fatefulEncounter(fatefulEncounter());
pk8->gender(gender());
pk8->alternativeForm(alternativeForm());
pk8->nature(nature());
pk8->nickname(nickname());
pk8->version(version());
pk8->otName(otName());
pk8->metDate(metDate());
pk8->otGender(otGender());
pk8->metLocation(metLocation());
pk8->ball(ball());
pk8->metLevel(metLevel());
pk8->pkrsStrain(pkrsStrain());
pk8->pkrsDays(pkrsDays());
pk8->otFriendship(otFriendship());
pk8->origNature(nature());
pk8->height(height());
pk8->weight(weight());
pk8->refreshChecksum();
return pk8;
}
}
| 22,959
|
C++
|
.cpp
| 867
| 18.727797
| 100
| 0.508983
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,275
|
PK6.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK6.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK6.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionKalos:
return {0x30, 0};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x30, 1};
case pksm::Ribbon::ChampionSinnoh:
return {0x30, 2};
case pksm::Ribbon::BestFriends:
return {0x30, 3};
case pksm::Ribbon::Training:
return {0x30, 4};
case pksm::Ribbon::BattlerSkillful:
return {0x30, 5};
case pksm::Ribbon::BattlerExpert:
return {0x30, 6};
case pksm::Ribbon::Effort:
return {0x30, 7};
case pksm::Ribbon::Alert:
return {0x31, 0};
case pksm::Ribbon::Shock:
return {0x31, 1};
case pksm::Ribbon::Downcast:
return {0x31, 2};
case pksm::Ribbon::Careless:
return {0x31, 3};
case pksm::Ribbon::Relax:
return {0x31, 4};
case pksm::Ribbon::Snooze:
return {0x31, 5};
case pksm::Ribbon::Smile:
return {0x31, 6};
case pksm::Ribbon::Gorgeous:
return {0x31, 7};
case pksm::Ribbon::Royal:
return {0x32, 0};
case pksm::Ribbon::GorgeousRoyal:
return {0x32, 1};
case pksm::Ribbon::Artist:
return {0x32, 2};
case pksm::Ribbon::Footprint:
return {0x32, 3};
case pksm::Ribbon::Record:
return {0x32, 4};
case pksm::Ribbon::Legend:
return {0x32, 5};
case pksm::Ribbon::Country:
return {0x32, 6};
case pksm::Ribbon::National:
return {0x32, 7};
case pksm::Ribbon::Earth:
return {0x33, 0};
case pksm::Ribbon::World:
return {0x33, 1};
case pksm::Ribbon::Classic:
return {0x33, 2};
case pksm::Ribbon::Premier:
return {0x33, 3};
case pksm::Ribbon::Event:
return {0x33, 4};
case pksm::Ribbon::Birthday:
return {0x33, 5};
case pksm::Ribbon::Special:
return {0x33, 6};
case pksm::Ribbon::Souvenir:
return {0x33, 7};
case pksm::Ribbon::Wishing:
return {0x34, 0};
case pksm::Ribbon::ChampionBattle:
return {0x34, 1};
case pksm::Ribbon::ChampionRegional:
return {0x34, 2};
case pksm::Ribbon::ChampionNational:
return {0x34, 3};
case pksm::Ribbon::ChampionWorld:
return {0x34, 4};
case pksm::Ribbon::MemoryContest:
return {0x34, 5};
case pksm::Ribbon::MemoryBattle:
return {0x34, 6};
case pksm::Ribbon::ChampionG6Hoenn:
return {0x34, 7};
case pksm::Ribbon::ContestStar:
return {0x35, 0};
case pksm::Ribbon::MasterCoolness:
return {0x35, 1};
case pksm::Ribbon::MasterBeauty:
return {0x35, 2};
case pksm::Ribbon::MasterCuteness:
return {0x35, 3};
case pksm::Ribbon::MasterCleverness:
return {0x35, 4};
case pksm::Ribbon::MasterToughness:
return {0x35, 5};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
// void PK6::shuffleArray(u8 sv)
// {
// static constexpr int blockLength = 56;
// u8 index = sv * 4;
// u8 cdata[length];
// std::copy(data, data + length, cdata);
// for (u8 block = 0; block < 4; block++)
// {
// u8 ofs = blockPosition(index + block);
// std::copy(cdata + 8 + blockLength * ofs, cdata + 8 + blockLength * ofs + blockLength,
// data + 8 + blockLength * block);
// }
// }
// void PK6::crypt(void)
// {
// u32 seed = encryptionConstant();
// for (size_t i = 0x08; i < BOX_LENGTH; i += 2)
// {
// u16 temp = LittleEndian::convertTo<u16>(data + i);
// seed = seedStep(seed);
// temp ^= (seed >> 16);
// LittleEndian::convertFrom<u16>(data + i, temp);
// }
// seed = encryptionConstant();
// for (u32 i = BOX_LENGTH; i < length; i += 2)
// {
// u16 temp = LittleEndian::convertTo<u16>(data + i);
// seed = seedStep(seed);
// temp ^= (seed >> 16);
// LittleEndian::convertFrom<u16>(data + i, temp);
// }
// }
void PK6::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
}
}
void PK6::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PK6::isEncrypted() const
{
return LittleEndian::convertTo<u16>(data + 0xC8) != 0 &&
LittleEndian::convertTo<u16>(data + 0x58) != 0;
}
PK6::PK6(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK6::clone(void) const
{
return PKX::getPKM<Generation::SIX>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PK6::generation(void) const
{
return Generation::SIX;
}
bool PK6::untraded(void) const
{
return data[0x78] == 0 && data[0x79] == 0 && originGen() == Generation::SIX;
}
bool PK6::untradedEvent(void) const
{
return geoCountry(0) == 0 && geoRegion(0) == 0 && (metLocation() / 10000 == 4) &&
originGen6();
}
u32 PK6::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK6::encryptionConstant(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK6::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK6::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK6::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK6::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PK6::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PK6::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PK6::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PK6::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PK6::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PK6::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PK6::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PK6::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PK6::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PK6::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
Ability PK6::ability(void) const
{
return Ability{data[0x14]};
}
void PK6::ability(Ability v)
{
data[0x14] = u8(v);
}
void PK6::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else if (v == 1)
{
abilitynum = 2;
}
else
{
abilitynum = 4;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u8 PK6::abilityNumber(void) const
{
return data[0x15];
}
void PK6::abilityNumber(u8 v)
{
data[0x15] = v;
}
u8 PK6::trainingBagHits(void) const
{
return data[0x16];
}
void PK6::trainingBagHits(u8 v)
{
data[0x16] = v;
}
u8 PK6::trainingBag(void) const
{
return data[0x17];
}
void PK6::trainingBag(u8 v)
{
data[0x17] = v;
}
u32 PK6::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x18);
}
void PK6::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x18, v);
}
Nature PK6::nature(void) const
{
return Nature{data[0x1C]};
}
void PK6::nature(Nature v)
{
data[0x1C] = u8(v);
}
bool PK6::fatefulEncounter(void) const
{
return (data[0x1D] & 1) == 1;
}
void PK6::fatefulEncounter(bool v)
{
data[0x1D] = (u8)((data[0x1D] & ~0x01) | (v ? 1 : 0));
}
Gender PK6::gender(void) const
{
return Gender{u8((data[0x1D] >> 1) & 0x3)};
}
void PK6::gender(Gender v)
{
data[0x1D] = (data[0x1D] & ~0x06) | (u8(v) << 1);
}
u16 PK6::alternativeForm(void) const
{
return data[0x1D] >> 3;
}
void PK6::alternativeForm(u16 v)
{
data[0x1D] = (data[0x1D] & 0x07) | (v << 3);
}
u16 PK6::ev(Stat ev) const
{
return data[0x1E + u8(ev)];
}
void PK6::ev(Stat ev, u16 v)
{
data[0x1E + u8(ev)] = v;
}
u8 PK6::contest(u8 contest) const
{
return data[0x24 + contest];
}
void PK6::contest(u8 contest, u8 v)
{
data[0x24 + contest] = v;
}
u16 PK6::markValue(void) const
{
return data[0x2A];
}
void PK6::markValue(u16 v)
{
data[0x2A] = v;
}
u8 PK6::pkrs(void) const
{
return data[0x2B];
}
void PK6::pkrs(u8 v)
{
data[0x2B] = v;
}
u8 PK6::pkrsDays(void) const
{
return data[0x2B] & 0xF;
};
void PK6::pkrsDays(u8 v)
{
data[0x2B] = (u8)((data[0x2B] & ~0xF) | v);
}
u8 PK6::pkrsStrain(void) const
{
return data[0x2B] >> 4;
};
void PK6::pkrsStrain(u8 v)
{
data[0x2B] = (u8)((data[0x2B] & 0xF) | v << 4);
}
bool PK6::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK6::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK6::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
u8 PK6::ribbonContestCount(void) const
{
return data[0x38];
}
void PK6::ribbonContestCount(u8 v)
{
data[0x38] = v;
}
u8 PK6::ribbonBattleCount(void) const
{
return data[0x39];
}
void PK6::ribbonBattleCount(u8 v)
{
data[0x39] = v;
}
std::string PK6::nickname(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0x40, 13));
}
void PK6::nickname(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0x40, 13);
}
Move PK6::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x5A + m * 2)};
}
void PK6::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x5A + m * 2, u16(v));
}
u8 PK6::PP(u8 m) const
{
return data[0x62 + m];
}
void PK6::PP(u8 m, u8 v)
{
data[0x62 + m] = v;
}
u8 PK6::PPUp(u8 m) const
{
return data[0x66 + m];
}
void PK6::PPUp(u8 m, u8 v)
{
data[0x66 + m] = v;
}
Move PK6::relearnMove(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x6A + m * 2)};
}
void PK6::relearnMove(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x6A + m * 2, u16(v));
}
bool PK6::secretSuperTrainingUnlocked(void) const
{
return (data[0x72] & 1) == 1;
}
void PK6::secretSuperTrainingUnlocked(bool v)
{
data[0x72] = (data[0x72] & ~1) | (v ? 1 : 0);
}
bool PK6::secretSuperTrainingComplete(void) const
{
return (data[0x72] & 2) == 2;
}
void PK6::secretSuperTrainingComplete(bool v)
{
data[0x72] = (data[0x72] & ~2) | (v ? 2 : 0);
}
u8 PK6::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
return (u8)((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK6::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x74, buffer);
}
bool PK6::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 30) & 0x1) == 1;
}
void PK6::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x74, (u32)((LittleEndian::convertTo<u32>(data + 0x74) & ~0x40000000) |
(u32)(v ? 0x40000000 : 0)));
}
bool PK6::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 31) & 0x1) == 1;
}
void PK6::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x74,
(LittleEndian::convertTo<u32>(data + 0x74) & 0x7FFFFFFF) | (v ? 0x80000000 : 0));
}
std::string PK6::htName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0x78, 13));
}
void PK6::htName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0x78, 13);
}
Gender PK6::htGender(void) const
{
return Gender{data[0x92]};
}
void PK6::htGender(Gender v)
{
data[0x92] = u8(v);
}
PKXHandler PK6::currentHandler(void) const
{
return data[0x93] == 0 ? PKXHandler::OT : PKXHandler::NonOT;
}
void PK6::currentHandler(PKXHandler v)
{
data[0x93] = v == PKXHandler::OT ? 0 : 1;
}
u8 PK6::geoRegion(u8 region) const
{
return data[0x94 + region * 2];
}
void PK6::geoRegion(u8 region, u8 v)
{
data[0x94 + region * 2] = v;
}
u8 PK6::geoCountry(u8 country) const
{
return data[0x95 + country * 2];
}
void PK6::geoCountry(u8 country, u8 v)
{
data[0x95 + country * 2] = v;
}
u8 PK6::htFriendship(void) const
{
return data[0xA2];
}
void PK6::htFriendship(u8 v)
{
data[0xA2] = v;
}
u8 PK6::htAffection(void) const
{
return data[0xA3];
}
void PK6::htAffection(u8 v)
{
data[0xA3] = v;
}
u8 PK6::htIntensity(void) const
{
return data[0xA4];
}
void PK6::htIntensity(u8 v)
{
data[0xA4] = v;
}
u8 PK6::htMemory(void) const
{
return data[0xA5];
}
void PK6::htMemory(u8 v)
{
data[0xA5] = v;
}
u8 PK6::htFeeling(void) const
{
return data[0xA6];
}
void PK6::htFeeling(u8 v)
{
data[0xA6] = v;
}
u16 PK6::htTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA8);
}
void PK6::htTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xA8, v);
}
u8 PK6::fullness(void) const
{
return data[0xAE];
}
void PK6::fullness(u8 v)
{
data[0xAE] = v;
}
u8 PK6::enjoyment(void) const
{
return data[0xAF];
}
void PK6::enjoyment(u8 v)
{
data[0xAF] = v;
}
std::string PK6::otName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0xB0, 13));
}
void PK6::otName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0xB0, 13);
}
u8 PK6::otFriendship(void) const
{
return data[0xCA];
}
void PK6::otFriendship(u8 v)
{
data[0xCA] = v;
}
u8 PK6::otAffection(void) const
{
return data[0xCB];
}
void PK6::otAffection(u8 v)
{
data[0xCB] = v;
}
u8 PK6::otIntensity(void) const
{
return data[0xCC];
}
void PK6::otIntensity(u8 v)
{
data[0xCC] = v;
}
u8 PK6::otMemory(void) const
{
return data[0xCD];
}
void PK6::otMemory(u8 v)
{
data[0xCD] = v;
}
u16 PK6::otTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xCE);
}
void PK6::otTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xCE, v);
}
u8 PK6::otFeeling(void) const
{
return data[0xD0];
}
void PK6::otFeeling(u8 v)
{
data[0xD0] = v;
}
int PK6::eggYear(void) const
{
return 2000 + data[0xD1];
}
void PK6::eggYear(int v)
{
data[0xD1] = v - 2000;
}
int PK6::eggMonth(void) const
{
return data[0xD2];
}
void PK6::eggMonth(int v)
{
data[0xD2] = v;
}
int PK6::eggDay(void) const
{
return data[0xD3];
}
void PK6::eggDay(int v)
{
data[0xD3] = v;
}
int PK6::metYear(void) const
{
return 2000 + data[0xD4];
}
void PK6::metYear(int v)
{
data[0xD4] = v - 2000;
}
int PK6::metMonth(void) const
{
return data[0xD5];
}
void PK6::metMonth(int v)
{
data[0xD5] = v;
}
int PK6::metDay(void) const
{
return data[0xD6];
}
void PK6::metDay(int v)
{
data[0xD6] = v;
}
u16 PK6::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD8);
}
void PK6::eggLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xD8, v);
}
u16 PK6::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xDA);
}
void PK6::metLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xDA, v);
}
Ball PK6::ball(void) const
{
return Ball{data[0xDC]};
}
void PK6::ball(Ball v)
{
data[0xDC] = u8(v);
}
u8 PK6::metLevel(void) const
{
return data[0xDD] & ~0x80;
}
void PK6::metLevel(u8 v)
{
data[0xDD] = (data[0xDD] & 0x80) | v;
}
Gender PK6::otGender(void) const
{
return Gender{u8(data[0xDD] >> 7)};
}
void PK6::otGender(Gender v)
{
data[0xDD] = (data[0xDD] & ~0x80) | (u8(v) << 7);
}
u8 PK6::encounterType(void) const
{
return data[0xDE];
}
void PK6::encounterType(u8 v)
{
data[0xDE] = v;
}
GameVersion PK6::version(void) const
{
return GameVersion(data[0xDF]);
}
void PK6::version(GameVersion v)
{
data[0xDF] = u8(v);
}
u8 PK6::country(void) const
{
return data[0xE0];
}
void PK6::country(u8 v)
{
data[0xE0] = v;
}
u8 PK6::region(void) const
{
return data[0xE1];
}
void PK6::region(u8 v)
{
data[0xE1] = v;
}
u8 PK6::consoleRegion(void) const
{
return data[0xE2];
}
void PK6::consoleRegion(u8 v)
{
data[0xE2] = v;
}
Language PK6::language(void) const
{
return Language(data[0xE3]);
}
void PK6::language(Language v)
{
data[0xE3] = u8(v);
}
void PK6::refreshChecksum(void)
{
u16 chk = 0;
for (u8 i = 8; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PK6::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK6::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1e) + hpivs[u8(v) - 1][i]);
}
}
u16 PK6::TSV(void) const
{
return (TID() ^ SID()) >> 4;
}
u16 PK6::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 4;
}
u8 PK6::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK6::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK6::shiny(void) const
{
return TSV() == PSV();
}
void PK6::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK6::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalXYORAS::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalXYORAS::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PK6::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc = 10 + (2 * basestat + iv(stat) + ev(stat) / 4 + 100) * level() / 100;
}
else
{
calc = 5 + (2 * basestat + iv(stat) + ev(stat) / 4) * level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
int PK6::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF0);
}
void PK6::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF0, v);
}
}
int PK6::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF2 + u8(stat) * 2);
}
void PK6::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF2 + u8(stat) * 2, v);
}
}
int PK6::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0xEC);
}
void PK6::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0xEC) = v;
}
}
std::unique_ptr<PK1> PK6::convertToG1(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
if (auto pk2 = pk3->convertToG2(save))
{
return pk2->convertToG1(save);
}
}
}
}
return nullptr;
}
std::unique_ptr<PK2> PK6::convertToG2(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
return pk3->convertToG2(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK3> PK6::convertToG3(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
return pk4->convertToG3(save);
}
}
return nullptr;
}
std::unique_ptr<PK4> PK6::convertToG4(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
return pk5->convertToG4(save);
}
return nullptr;
}
std::unique_ptr<PK5> PK6::convertToG5(Sav& save) const
{
auto pk5 = PKX::getPKM<Generation::FIVE>(nullptr, PK5::BOX_LENGTH);
pk5->species(species());
pk5->TID(TID());
pk5->SID(SID());
pk5->experience(experience());
pk5->PID(PID());
pk5->ability(ability());
pk5->markValue(markValue());
pk5->language(language());
for (int i = 0; i < 6; i++)
{
// EV Cap
pk5->ev(Stat(i), ev(Stat(i)) > 252 ? 252 : ev(Stat(i)));
pk5->iv(Stat(i), iv(Stat(i)));
pk5->contest(i, contest(i));
}
for (int i = 0; i < 4; i++)
{
pk5->move(i, move(i));
pk5->PPUp(i, PPUp(i));
pk5->PP(i, PP(i));
}
pk5->egg(egg());
pk5->nicknamed(nicknamed());
pk5->fatefulEncounter(fatefulEncounter());
pk5->gender(gender());
pk5->alternativeForm(alternativeForm());
pk5->nature(nature());
pk5->version(version());
pk5->nickname(nickname());
pk5->otName(otName());
pk5->metDate(metDate());
pk5->eggDate(eggDate());
pk5->metLocation(metLocation());
pk5->eggLocation(eggLocation());
pk5->pkrsStrain(pkrsStrain());
pk5->pkrsDays(pkrsDays());
pk5->ball(ball());
pk5->metLevel(metLevel());
pk5->otGender(otGender());
pk5->encounterType(encounterType());
pk5->ribbon(Ribbon::ChampionG6Hoenn, ribbon(Ribbon::ChampionG6Hoenn));
pk5->ribbon(Ribbon::ChampionSinnoh, ribbon(Ribbon::ChampionSinnoh));
pk5->ribbon(Ribbon::Effort, ribbon(Ribbon::Effort));
pk5->ribbon(Ribbon::Alert, ribbon(Ribbon::Alert));
pk5->ribbon(Ribbon::Shock, ribbon(Ribbon::Shock));
pk5->ribbon(Ribbon::Downcast, ribbon(Ribbon::Downcast));
pk5->ribbon(Ribbon::Careless, ribbon(Ribbon::Careless));
pk5->ribbon(Ribbon::Relax, ribbon(Ribbon::Relax));
pk5->ribbon(Ribbon::Snooze, ribbon(Ribbon::Snooze));
pk5->ribbon(Ribbon::Smile, ribbon(Ribbon::Smile));
pk5->ribbon(Ribbon::Gorgeous, ribbon(Ribbon::Gorgeous));
pk5->ribbon(Ribbon::Royal, ribbon(Ribbon::Royal));
pk5->ribbon(Ribbon::GorgeousRoyal, ribbon(Ribbon::GorgeousRoyal));
pk5->ribbon(Ribbon::Artist, ribbon(Ribbon::Artist));
pk5->ribbon(Ribbon::Footprint, ribbon(Ribbon::Footprint));
pk5->ribbon(Ribbon::Record, ribbon(Ribbon::Record));
pk5->ribbon(Ribbon::Legend, ribbon(Ribbon::Legend));
pk5->ribbon(Ribbon::Country, ribbon(Ribbon::Country));
pk5->ribbon(Ribbon::National, ribbon(Ribbon::National));
pk5->ribbon(Ribbon::Earth, ribbon(Ribbon::Earth));
pk5->ribbon(Ribbon::World, ribbon(Ribbon::World));
pk5->ribbon(Ribbon::Classic, ribbon(Ribbon::Classic));
pk5->ribbon(Ribbon::Premier, ribbon(Ribbon::Premier));
pk5->ribbon(Ribbon::Event, ribbon(Ribbon::Event));
pk5->ribbon(Ribbon::Birthday, ribbon(Ribbon::Birthday));
pk5->ribbon(Ribbon::Special, ribbon(Ribbon::Special));
pk5->ribbon(Ribbon::Souvenir, ribbon(Ribbon::Souvenir));
pk5->ribbon(Ribbon::Wishing, ribbon(Ribbon::Wishing));
pk5->ribbon(Ribbon::ChampionBattle, ribbon(Ribbon::ChampionBattle));
pk5->ribbon(Ribbon::ChampionRegional, ribbon(Ribbon::ChampionRegional));
pk5->ribbon(Ribbon::ChampionNational, ribbon(Ribbon::ChampionNational));
pk5->ribbon(Ribbon::ChampionWorld, ribbon(Ribbon::ChampionWorld));
pk5->otFriendship(pk5->baseFriendship());
// Check if shiny pid needs to be modified
u16 val = TID() ^ SID() ^ (PID() >> 16) ^ (PID() & 0xFFFF);
if (shiny() && (val > 7) && (val < 16))
{
pk5->PID(PID() ^ 0x80000000);
}
for (int i = 0; i < 4; i++)
{
if (pk5->move(i) > save.maxMove())
{
pk5->move(i, Move::None);
}
}
pk5->refreshChecksum();
return pk5;
}
std::unique_ptr<PK7> PK6::convertToG7(Sav& save) const
{
auto pk7 = PKX::getPKM<Generation::SEVEN>(data, PK7::BOX_LENGTH);
// markvalue field moved, clear old gen 6 data
pk7->rawData()[0x2A] = 0;
// Bank Data clearing
for (int i = 0x94; i < 0x9E; i++)
{
pk7->rawData()[i] = 0; // Geolocations
}
for (int i = 0xAA; i < 0xB0; i++)
{
pk7->rawData()[i] = 0; // Amie fullness/enjoyment
}
for (int i = 0xE4; i < 0xE8; i++)
{
pk7->rawData()[i] = 0; // unused
}
pk7->rawData()[0x72] &= 0xFC; // low 2 bits of super training
pk7->rawData()[0xDE] = 0; // gen 4 encounter type
// marks get expanded from one bit to two.
u8 oldMarks = markValue();
u16 newMarks = 0;
for (int i = 0; i < 6; i++)
{
newMarks |= ((oldMarks >> i) & 1) << (i << 1);
}
pk7->markValue(newMarks);
switch (abilityNumber())
{
case 1:
case 2:
case 4:
u8 index = abilityNumber() >> 1;
if (abilities(index) == ability())
{
pk7->ability(pk7->abilities(index));
}
}
pk7->htMemory(4);
pk7->htTextVar(0);
pk7->htIntensity(1);
pk7->htFeeling(pksm::randomNumber(0, 9));
pk7->geoCountry(0, save.country());
pk7->geoRegion(0, save.subRegion());
pk7->currentHandler(PKXHandler::NonOT);
pk7->refreshChecksum();
return pk7;
}
std::unique_ptr<PK8> PK6::convertToG8(Sav& save) const
{
auto pk7 = convertToG7(save);
if (pk7)
{
return pk7->convertToG8(save);
}
return nullptr;
}
void PK6::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 35,529
|
C++
|
.cpp
| 1,259
| 20.01112
| 100
| 0.514451
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,276
|
PK4.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK4.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK4.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/i18n.hpp"
#include "utils/utils.hpp"
#include <algorithm>
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionSinnoh:
return {0x24, 0};
case pksm::Ribbon::Ability:
return {0x24, 1};
case pksm::Ribbon::AbilityGreat:
return {0x24, 2};
case pksm::Ribbon::AbilityDouble:
return {0x24, 3};
case pksm::Ribbon::AbilityMulti:
return {0x24, 4};
case pksm::Ribbon::AbilityPair:
return {0x24, 5};
case pksm::Ribbon::AbilityWorld:
return {0x24, 6};
case pksm::Ribbon::Alert:
return {0x24, 7};
case pksm::Ribbon::Shock:
return {0x25, 0};
case pksm::Ribbon::Downcast:
return {0x25, 1};
case pksm::Ribbon::Careless:
return {0x25, 2};
case pksm::Ribbon::Relax:
return {0x25, 3};
case pksm::Ribbon::Snooze:
return {0x25, 4};
case pksm::Ribbon::Smile:
return {0x25, 5};
case pksm::Ribbon::Gorgeous:
return {0x25, 6};
case pksm::Ribbon::Royal:
return {0x25, 7};
case pksm::Ribbon::GorgeousRoyal:
return {0x26, 0};
case pksm::Ribbon::Footprint:
return {0x26, 1};
case pksm::Ribbon::Record:
return {0x26, 2};
case pksm::Ribbon::Event:
return {0x26, 3};
case pksm::Ribbon::Legend:
return {0x26, 4};
case pksm::Ribbon::ChampionWorld:
return {0x26, 5};
case pksm::Ribbon::Birthday:
return {0x26, 6};
case pksm::Ribbon::Special:
return {0x26, 7};
case pksm::Ribbon::Souvenir:
return {0x27, 0};
case pksm::Ribbon::Wishing:
return {0x27, 1};
case pksm::Ribbon::Classic:
return {0x27, 2};
case pksm::Ribbon::Premier:
return {0x27, 3};
case pksm::Ribbon::G3Cool:
return {0x3C, 0};
case pksm::Ribbon::G3CoolSuper:
return {0x3C, 1};
case pksm::Ribbon::G3CoolHyper:
return {0x3C, 2};
case pksm::Ribbon::G3CoolMaster:
return {0x3C, 3};
case pksm::Ribbon::G3Beauty:
return {0x3C, 4};
case pksm::Ribbon::G3BeautySuper:
return {0x3C, 5};
case pksm::Ribbon::G3BeautyHyper:
return {0x3C, 6};
case pksm::Ribbon::G3BeautyMaster:
return {0x3C, 7};
case pksm::Ribbon::G3Cute:
return {0x3D, 0};
case pksm::Ribbon::G3CuteSuper:
return {0x3D, 1};
case pksm::Ribbon::G3CuteHyper:
return {0x3D, 2};
case pksm::Ribbon::G3CuteMaster:
return {0x3D, 3};
case pksm::Ribbon::G3Smart:
return {0x3D, 4};
case pksm::Ribbon::G3SmartSuper:
return {0x3D, 5};
case pksm::Ribbon::G3SmartHyper:
return {0x3D, 6};
case pksm::Ribbon::G3SmartMaster:
return {0x3D, 7};
case pksm::Ribbon::G3Tough:
return {0x3E, 0};
case pksm::Ribbon::G3ToughSuper:
return {0x3E, 1};
case pksm::Ribbon::G3ToughHyper:
return {0x3E, 2};
case pksm::Ribbon::G3ToughMaster:
return {0x3E, 3};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x3E, 4};
case pksm::Ribbon::Winning:
return {0x3E, 5};
case pksm::Ribbon::Victory:
return {0x3E, 6};
case pksm::Ribbon::Artist:
return {0x3E, 7};
case pksm::Ribbon::Effort:
return {0x3F, 0};
case pksm::Ribbon::ChampionBattle:
return {0x3F, 1};
case pksm::Ribbon::ChampionRegional:
return {0x3F, 2};
case pksm::Ribbon::ChampionNational:
return {0x3F, 3};
case pksm::Ribbon::Country:
return {0x3F, 4};
case pksm::Ribbon::National:
return {0x3F, 5};
case pksm::Ribbon::Earth:
return {0x3F, 6};
case pksm::Ribbon::World:
return {0x3F, 7};
case pksm::Ribbon::G4Cool:
return {0x60, 0};
case pksm::Ribbon::G4CoolGreat:
return {0x60, 1};
case pksm::Ribbon::G4CoolUltra:
return {0x60, 2};
case pksm::Ribbon::G4CoolMaster:
return {0x60, 3};
case pksm::Ribbon::G4Beauty:
return {0x60, 4};
case pksm::Ribbon::G4BeautyGreat:
return {0x60, 5};
case pksm::Ribbon::G4BeautyUltra:
return {0x60, 6};
case pksm::Ribbon::G4BeautyMaster:
return {0x60, 7};
case pksm::Ribbon::G4Cute:
return {0x61, 0};
case pksm::Ribbon::G4CuteGreat:
return {0x61, 1};
case pksm::Ribbon::G4CuteUltra:
return {0x61, 2};
case pksm::Ribbon::G4CuteMaster:
return {0x61, 3};
case pksm::Ribbon::G4Smart:
return {0x61, 4};
case pksm::Ribbon::G4SmartGreat:
return {0x61, 5};
case pksm::Ribbon::G4SmartUltra:
return {0x61, 6};
case pksm::Ribbon::G4SmartMaster:
return {0x61, 7};
case pksm::Ribbon::G4Tough:
return {0x62, 0};
case pksm::Ribbon::G4ToughGreat:
return {0x62, 1};
case pksm::Ribbon::G4ToughUltra:
return {0x62, 2};
case pksm::Ribbon::G4ToughMaster:
return {0x62, 3};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
void PK4::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, checksum());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(data + BOX_LENGTH, PID());
}
}
}
void PK4::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, checksum());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(data + BOX_LENGTH, PID());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PK4::isEncrypted() const
{
return LittleEndian::convertTo<u32>(data + 0x64) != 0;
}
PK4::PK4(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK4::clone(void) const
{
return PKX::getPKM<Generation::FOUR>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PK4::generation(void) const
{
return Generation::FOUR;
}
u32 PK4::encryptionConstant(void) const
{
return PID();
}
void PK4::encryptionConstant(u32) {}
u8 PK4::abilityNumber(void) const
{
return 1 << (PID() & 1);
}
void PK4::abilityNumber(u8 v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(), v,
shiny(), TSV(), PID(), generation()));
}
u32 PK4::PID(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK4::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK4::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK4::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK4::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK4::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PK4::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PK4::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PK4::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PK4::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PK4::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PK4::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PK4::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PK4::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PK4::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PK4::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
u8 PK4::otFriendship(void) const
{
return data[0x14];
}
void PK4::otFriendship(u8 v)
{
data[0x14] = v;
}
Ability PK4::ability(void) const
{
return Ability{data[0x15]};
}
void PK4::ability(Ability v)
{
data[0x15] = u8(v);
}
void PK4::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else
{
abilitynum = 2;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u16 PK4::markValue(void) const
{
return data[0x16];
}
void PK4::markValue(u16 v)
{
data[0x16] = v;
}
Language PK4::language(void) const
{
return Language(data[0x17]);
}
void PK4::language(Language v)
{
data[0x17] = u8(v);
}
u16 PK4::ev(Stat ev) const
{
return data[0x18 + u8(ev)];
}
void PK4::ev(Stat ev, u16 v)
{
data[0x18 + u8(ev)] = v;
}
u8 PK4::contest(u8 contest) const
{
return data[0x1E + contest];
}
void PK4::contest(u8 contest, u8 v)
{
data[0x1E + contest] = v;
}
bool PK4::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK4::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK4::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
Move PK4::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x28 + m * 2)};
}
void PK4::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x28 + m * 2, u16(v));
}
u8 PK4::PP(u8 m) const
{
return data[0x30 + m];
}
void PK4::PP(u8 m, u8 v)
{
data[0x30 + m] = v;
}
u8 PK4::PPUp(u8 m) const
{
return data[0x34 + m];
}
void PK4::PPUp(u8 m, u8 v)
{
data[0x34 + m] = v;
}
u8 PK4::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x38);
return u8((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK4::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x38);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x38, buffer);
}
bool PK4::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x38) >> 30) & 0x1) == 1;
}
void PK4::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x38, u32((LittleEndian::convertTo<u32>(data + 0x38) & ~0x40000000u) |
(v ? 0x40000000u : 0)));
}
bool PK4::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x38) >> 31) & 0x1) == 1;
}
void PK4::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x38,
(LittleEndian::convertTo<u32>(data + 0x38) & 0x7FFFFFFF) | (v ? 0x80000000 : 0));
}
bool PK4::fatefulEncounter(void) const
{
return (data[0x40] & 1) == 1;
}
void PK4::fatefulEncounter(bool v)
{
data[0x40] = (data[0x40] & ~0x01) | (v ? 1 : 0);
}
Gender PK4::gender(void) const
{
return Gender{u8((data[0x40] >> 1) & 0x3)};
}
void PK4::gender(Gender g)
{
data[0x40] = (data[0x40] & ~0x06) | (u8(g) << 1);
PID(PKX::getRandomPID(species(), g, version(), nature(), alternativeForm(), abilityNumber(),
shiny(), TSV(), PID(), generation()));
}
u16 PK4::alternativeForm(void) const
{
return data[0x40] >> 3;
}
void PK4::alternativeForm(u16 v)
{
data[0x40] = (data[0x40] & 0x07) | (v << 3);
}
Nature PK4::nature(void) const
{
return Nature{u8(PID() % 25)};
}
void PK4::nature(Nature v)
{
PID(PKX::getRandomPID(species(), gender(), version(), v, alternativeForm(), abilityNumber(),
shiny(), TSV(), PID(), generation()));
}
u8 PK4::shinyLeaf(void) const
{
return data[0x41];
}
void PK4::shinyLeaf(u8 v)
{
data[0x41] = v;
}
std::string PK4::nickname(void) const
{
return StringUtils::transString45(StringUtils::getString4(data, 0x48, 11));
}
void PK4::nickname(const std::string_view& v)
{
StringUtils::setString4(data, StringUtils::transString45(v), 0x48, 11);
}
GameVersion PK4::version(void) const
{
return GameVersion(data[0x5F]);
}
void PK4::version(GameVersion v)
{
data[0x5F] = u8(v);
}
std::string PK4::otName(void) const
{
return StringUtils::transString45(StringUtils::getString4(data, 0x68, 8));
}
void PK4::otName(const std::string_view& v)
{
StringUtils::setString4(data, StringUtils::transString45(v), 0x68, 8);
}
int PK4::eggYear(void) const
{
return 2000 + data[0x78];
}
void PK4::eggYear(int v)
{
data[0x78] = v - 2000;
}
int PK4::eggMonth(void) const
{
return data[0x79];
}
void PK4::eggMonth(int v)
{
data[0x79] = v;
}
int PK4::eggDay(void) const
{
return data[0x7A];
}
void PK4::eggDay(int v)
{
data[0x7A] = v;
}
int PK4::metYear(void) const
{
return 2000 + data[0x7B];
}
void PK4::metYear(int v)
{
data[0x7B] = v - 2000;
}
int PK4::metMonth(void) const
{
return data[0x7C];
}
void PK4::metMonth(int v)
{
data[0x7C] = v;
}
int PK4::metDay(void) const
{
return data[0x7D];
}
void PK4::metDay(int v)
{
data[0x7D] = v;
}
u16 PK4::eggLocation(void) const
{
u16 hgssLoc = LittleEndian::convertTo<u16>(data + 0x44);
if (hgssLoc != 0)
{
return hgssLoc;
}
return LittleEndian::convertTo<u16>(data + 0x7E);
}
void PK4::eggLocation(u16 v)
{
if (v == 0)
{
LittleEndian::convertFrom<u16>(data + 0x44, v);
LittleEndian::convertFrom<u16>(data + 0x7E, v);
}
else if ((v < 2000 && v > 111) || (v < 3000 && v > 2010))
{
LittleEndian::convertFrom<u16>(data + 0x44, v);
LittleEndian::convertFrom<u16>(data + 0x7E, 0xBBA);
}
else
{
// If this pokemon is from Platinum, HeartGold, or SoulSilver
LittleEndian::convertFrom<u16>(
data + 0x44, (version() == GameVersion::Pt || version() == GameVersion::HG ||
version() == GameVersion::SS)
? v
: 0);
LittleEndian::convertFrom<u16>(data + 0x7E, v);
}
}
u16 PK4::metLocation(void) const
{
u16 hgssLoc = LittleEndian::convertTo<u16>(data + 0x46);
if (hgssLoc != 0)
{
return hgssLoc;
}
return LittleEndian::convertTo<u16>(data + 0x80);
}
void PK4::metLocation(u16 v)
{
if (v == 0)
{
LittleEndian::convertFrom<u16>(data + 0x46, v);
LittleEndian::convertFrom<u16>(data + 0x80, v);
}
else if ((v < 2000 && v > 111) || (v < 3000 && v > 2010))
{
LittleEndian::convertFrom<u16>(data + 0x46, v);
LittleEndian::convertFrom<u16>(data + 0x80, 0xBBA);
}
else
{
// If this pokemon is from Platinum, HeartGold, or SoulSilver
LittleEndian::convertFrom<u16>(
data + 0x46, (version() == GameVersion::Pt || version() == GameVersion::HG ||
version() == GameVersion::SS)
? v
: 0);
LittleEndian::convertFrom<u16>(data + 0x80, v);
}
}
u8 PK4::pkrs(void) const
{
return data[0x82];
}
void PK4::pkrs(u8 v)
{
data[0x82] = v;
}
u8 PK4::pkrsDays(void) const
{
return data[0x82] & 0xF;
};
void PK4::pkrsDays(u8 v)
{
data[0x82] = (u8)((data[0x82] & ~0xF) | v);
}
u8 PK4::pkrsStrain(void) const
{
return data[0x82] >> 4;
};
void PK4::pkrsStrain(u8 v)
{
data[0x82] = (u8)((data[0x82] & 0xF) | v << 4);
}
Ball PK4::ball(void) const
{
return data[0x83] > data[0x86] ? Ball{data[0x83]} : Ball{data[0x86]};
}
void PK4::ball(Ball v)
{
data[0x83] = u8(v <= Ball::Cherish ? v : Ball::Poke);
if (v > Ball::Cherish ||
((version() == GameVersion::HG || version() == GameVersion::SS) && !fatefulEncounter()))
{
data[0x86] = u8(v <= Ball::Sport ? v : Ball::Poke);
}
else
{
data[0x86] = 0;
}
}
u8 PK4::metLevel(void) const
{
return data[0x84] & ~0x80;
}
void PK4::metLevel(u8 v)
{
data[0x84] = (data[0x84] & 0x80) | v;
}
Gender PK4::otGender(void) const
{
return Gender{u8(data[0x84] >> 7)};
}
void PK4::otGender(Gender v)
{
data[0x84] = (data[0x84] & ~0x80) | (u8(v) << 7);
}
u8 PK4::encounterType(void) const
{
return data[0x85];
}
void PK4::encounterType(u8 v)
{
data[0x85] = v;
}
u8 PK4::characteristic(void) const
{
u8 maxIV = 0, pm6stat = 0, pm6 = PID() % 6;
for (int i = 0; i < 6; i++)
{
if (iv(Stat(i)) > maxIV)
{
maxIV = iv(Stat(i));
}
}
for (int i = 0; i < 6; i++)
{
pm6stat = (pm6 + i) % 6;
if (iv(Stat(i)) == maxIV)
{
break;
}
}
return pm6stat * 5 + maxIV % 5;
}
void PK4::refreshChecksum(void)
{
u16 chk = 0;
for (u8 i = 8; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PK4::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK4::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PK4::TSV(void) const
{
return (TID() ^ SID()) >> 3;
}
u16 PK4::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 3;
}
u8 PK4::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK4::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK4::shiny(void) const
{
return TSV() == PSV();
}
void PK4::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK4::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalDPPtHGSS::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalDPPtHGSS::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PK4::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc = 10 + (2 * basestat + iv(stat) + ev(stat) / 4 + 100) * level() / 100;
}
else
{
calc = 5 + (2 * basestat + iv(stat) + ev(stat) / 4) * level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
int PK4::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x8E);
}
void PK4::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x8E, v);
}
}
int PK4::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x90 + u8(stat) * 2);
}
void PK4::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x90 + u8(stat) * 2, v);
}
}
int PK4::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0x8C);
}
void PK4::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0x8C) = v;
}
}
std::unique_ptr<PK1> PK4::convertToG1(Sav& save) const
{
if (auto pk3 = convertToG3(save))
{
if (auto pk2 = pk3->convertToG2(save))
{
return pk2->convertToG1(save);
}
}
return nullptr;
}
std::unique_ptr<PK2> PK4::convertToG2(Sav& save) const
{
if (auto pk3 = convertToG3(save))
{
return pk3->convertToG2(save);
}
return nullptr;
}
std::unique_ptr<PK3> PK4::convertToG3(Sav&) const
{
auto pk3 = PKX::getPKM<Generation::THREE>(nullptr, PK3::BOX_LENGTH);
// This sets gender, nature, alternative form, and shininess as well
pk3->PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), shiny(), TSV(), PID(), Generation::THREE));
pk3->species(species());
pk3->TID(TID());
pk3->SID(SID());
pk3->experience(egg() ? expTable(5, expType()) : experience());
pk3->egg(false);
pk3->otFriendship(70);
pk3->markValue(markValue());
pk3->language(language());
pk3->ev(Stat::HP, ev(Stat::HP));
pk3->ev(Stat::ATK, ev(Stat::ATK));
pk3->ev(Stat::DEF, ev(Stat::DEF));
pk3->ev(Stat::SPD, ev(Stat::SPD));
pk3->ev(Stat::SPATK, ev(Stat::SPATK));
pk3->ev(Stat::SPDEF, ev(Stat::SPDEF));
pk3->contest(0, contest(0));
pk3->contest(1, contest(1));
pk3->contest(2, contest(2));
pk3->contest(3, contest(3));
pk3->contest(4, contest(4));
pk3->contest(5, contest(5));
pk3->move(0, move(0));
pk3->move(1, move(1));
pk3->move(2, move(2));
pk3->move(3, move(3));
pk3->PPUp(0, PPUp(0));
pk3->PPUp(1, PPUp(1));
pk3->PPUp(2, PPUp(2));
pk3->PPUp(3, PPUp(3));
pk3->PP(0, PP(0));
pk3->PP(1, PP(1));
pk3->PP(2, PP(2));
pk3->PP(3, PP(3));
pk3->iv(Stat::HP, iv(Stat::HP));
pk3->iv(Stat::ATK, iv(Stat::ATK));
pk3->iv(Stat::DEF, iv(Stat::DEF));
pk3->iv(Stat::SPD, iv(Stat::SPD));
pk3->iv(Stat::SPATK, iv(Stat::SPATK));
pk3->iv(Stat::SPDEF, iv(Stat::SPDEF));
pk3->ability(ability());
pk3->version(version());
pk3->ball(ball());
pk3->pkrsStrain(pkrsStrain());
pk3->pkrsDays(pkrsDays());
pk3->otGender(otGender());
// met date isn't a thing in PK3
pk3->metLevel(level());
pk3->metLocation(
0xFD); // (gift egg) // Not sure if this is the best, it seemed the most generic
pk3->fatefulEncounter(fatefulEncounter());
pk3->ribbon(Ribbon::ChampionG3Hoenn, ribbon(Ribbon::ChampionG3Hoenn));
pk3->ribbon(Ribbon::Winning, ribbon(Ribbon::Winning));
pk3->ribbon(Ribbon::Victory, ribbon(Ribbon::Victory));
pk3->ribbon(Ribbon::Artist, ribbon(Ribbon::Artist));
pk3->ribbon(Ribbon::Effort, ribbon(Ribbon::Effort));
pk3->ribbon(Ribbon::ChampionBattle, ribbon(Ribbon::ChampionBattle));
pk3->ribbon(Ribbon::ChampionRegional, ribbon(Ribbon::ChampionRegional));
pk3->ribbon(Ribbon::ChampionNational, ribbon(Ribbon::ChampionNational));
pk3->ribbon(Ribbon::Country, ribbon(Ribbon::Country));
pk3->ribbon(Ribbon::National, ribbon(Ribbon::National));
pk3->ribbon(Ribbon::Earth, ribbon(Ribbon::Earth));
pk3->ribbon(Ribbon::World, ribbon(Ribbon::World));
// Contest ribbons
static constexpr std::array<Ribbon, 20> contestRibbons = {Ribbon::G3Cool,
Ribbon::G3CoolSuper, Ribbon::G3CoolHyper, Ribbon::G3CoolMaster, Ribbon::G3Beauty,
Ribbon::G3BeautySuper, Ribbon::G3BeautyHyper, Ribbon::G3BeautyMaster, Ribbon::G3Cute,
Ribbon::G3CuteSuper, Ribbon::G3CuteHyper, Ribbon::G3CuteMaster, Ribbon::G3Smart,
Ribbon::G3SmartSuper, Ribbon::G3SmartHyper, Ribbon::G3SmartMaster, Ribbon::G3Tough,
Ribbon::G3ToughSuper, Ribbon::G3ToughHyper, Ribbon::G3ToughMaster};
for (size_t i = 0; i < contestRibbons.size(); i++)
{
if (ribbon(contestRibbons[i]))
{
pk3->contestRibbonCount(i / 4, pk3->contestRibbonCount(i / 4) + 1);
}
}
std::string name = species().localize(language());
pk3->nickname((egg() || !nicknamed()) ? StringUtils::toUpper(name) : nickname());
pk3->otName(otName());
pk3->heldItem(heldItem());
// Remove HM
Move moves[4] = {move(0), move(1), move(2), move(3)};
for (int i = 0; i < 4; i++)
{
if (std::find(std::begin(banned), std::end(banned), moves[i]) != std::end(banned))
{
moves[i] = Move::None;
}
pk3->move(i, moves[i]);
}
pk3->fixMoves();
pk3->refreshChecksum();
return pk3;
}
std::unique_ptr<PK5> PK4::convertToG5(Sav&) const
{
auto pk5 = PKX::getPKM<Generation::FIVE>(data, PK5::BOX_LENGTH);
// Clear HGSS data
LittleEndian::convertFrom<u16>(data + 0x86, 0);
// Clear PtHGSS met data
LittleEndian::convertFrom<u32>(data + 0x44, 0);
pk5->otFriendship(70);
pk5->metDate(Date::today());
// Force normal Arceus form
if (pk5->species() == Species::Arceus)
{
pk5->alternativeForm(0);
}
pk5->heldItem(0);
pk5->nature(nature());
// Check met location
pk5->metLocation(pk5->originGen4() && pk5->fatefulEncounter() &&
std::find(beasts, beasts + 4, pk5->species()) != beasts + 4
? (pk5->species() == Species::Celebi ? 30010 : 30012) // Celebi : Beast
: 30001); // Pokétransfer (not Crown)
pk5->ball(ball());
pk5->nickname(nickname());
pk5->otName(otName());
// Check level
pk5->metLevel(pk5->level());
// Remove HM
Move moves[4] = {move(0), move(1), move(2), move(3)};
for (int i = 0; i < 4; i++)
{
if (std::find(banned, banned + 8, moves[i]) != banned + 8)
{
moves[i] = Move::None;
}
pk5->move(i, moves[i]);
}
pk5->fixMoves();
pk5->refreshChecksum();
return pk5;
}
std::unique_ptr<PK6> PK4::convertToG6(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
return pk5->convertToG6(save);
}
return nullptr;
}
std::unique_ptr<PK7> PK4::convertToG7(Sav& save) const
{
if (auto pk5 = convertToG5(save))
{
if (auto pk6 = pk5->convertToG6(save))
{
return pk6->convertToG7(save);
}
}
return nullptr;
}
std::unique_ptr<PK8> PK4::convertToG8(Sav& save) const
{
auto pk5 = convertToG5(save);
if (pk5)
{
auto pk6 = pk5->convertToG6(save);
if (pk6)
{
auto pk7 = pk6->convertToG7(save);
if (pk7)
{
return pk7->convertToG8(save);
}
}
}
return nullptr;
}
void PK4::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 34,797
|
C++
|
.cpp
| 1,136
| 21.298415
| 100
| 0.504358
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,277
|
PK5.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK5.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK5.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/i18n.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#include <algorithm>
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionSinnoh:
return {0x24, 0};
case pksm::Ribbon::Ability:
return {0x24, 1};
case pksm::Ribbon::AbilityGreat:
return {0x24, 2};
case pksm::Ribbon::AbilityDouble:
return {0x24, 3};
case pksm::Ribbon::AbilityMulti:
return {0x24, 4};
case pksm::Ribbon::AbilityPair:
return {0x24, 5};
case pksm::Ribbon::AbilityWorld:
return {0x24, 6};
case pksm::Ribbon::Alert:
return {0x24, 7};
case pksm::Ribbon::Shock:
return {0x25, 0};
case pksm::Ribbon::Downcast:
return {0x25, 1};
case pksm::Ribbon::Careless:
return {0x25, 2};
case pksm::Ribbon::Relax:
return {0x25, 3};
case pksm::Ribbon::Snooze:
return {0x25, 4};
case pksm::Ribbon::Smile:
return {0x25, 5};
case pksm::Ribbon::Gorgeous:
return {0x25, 6};
case pksm::Ribbon::Royal:
return {0x25, 7};
case pksm::Ribbon::GorgeousRoyal:
return {0x26, 0};
case pksm::Ribbon::Footprint:
return {0x26, 1};
case pksm::Ribbon::Record:
return {0x26, 2};
case pksm::Ribbon::Event:
return {0x26, 3};
case pksm::Ribbon::Legend:
return {0x26, 4};
case pksm::Ribbon::ChampionWorld:
return {0x26, 5};
case pksm::Ribbon::Birthday:
return {0x26, 6};
case pksm::Ribbon::Special:
return {0x26, 7};
case pksm::Ribbon::Souvenir:
return {0x27, 0};
case pksm::Ribbon::Wishing:
return {0x27, 1};
case pksm::Ribbon::Classic:
return {0x27, 2};
case pksm::Ribbon::Premier:
return {0x27, 3};
case pksm::Ribbon::G3Cool:
return {0X3C, 0};
case pksm::Ribbon::G3CoolSuper:
return {0X3C, 1};
case pksm::Ribbon::G3CoolHyper:
return {0X3C, 2};
case pksm::Ribbon::G3CoolMaster:
return {0X3C, 3};
case pksm::Ribbon::G3Beauty:
return {0X3C, 4};
case pksm::Ribbon::G3BeautySuper:
return {0X3C, 5};
case pksm::Ribbon::G3BeautyHyper:
return {0X3C, 6};
case pksm::Ribbon::G3BeautyMaster:
return {0X3C, 7};
case pksm::Ribbon::G3Cute:
return {0x3D, 0};
case pksm::Ribbon::G3CuteSuper:
return {0x3D, 1};
case pksm::Ribbon::G3CuteHyper:
return {0x3D, 2};
case pksm::Ribbon::G3CuteMaster:
return {0x3D, 3};
case pksm::Ribbon::G3Smart:
return {0x3D, 4};
case pksm::Ribbon::G3SmartSuper:
return {0x3D, 5};
case pksm::Ribbon::G3SmartHyper:
return {0x3D, 6};
case pksm::Ribbon::G3SmartMaster:
return {0x3D, 7};
case pksm::Ribbon::G3Tough:
return {0x3E, 0};
case pksm::Ribbon::G3ToughSuper:
return {0x3E, 1};
case pksm::Ribbon::G3ToughHyper:
return {0x3E, 2};
case pksm::Ribbon::G3ToughMaster:
return {0x3E, 3};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x3E, 4};
case pksm::Ribbon::Winning:
return {0x3E, 5};
case pksm::Ribbon::Victory:
return {0x3E, 6};
case pksm::Ribbon::Artist:
return {0x3E, 7};
case pksm::Ribbon::Effort:
return {0x3F, 0};
case pksm::Ribbon::ChampionBattle:
return {0x3F, 1};
case pksm::Ribbon::ChampionRegional:
return {0x3F, 2};
case pksm::Ribbon::ChampionNational:
return {0x3F, 3};
case pksm::Ribbon::Country:
return {0x3F, 4};
case pksm::Ribbon::National:
return {0x3F, 5};
case pksm::Ribbon::Earth:
return {0x3F, 6};
case pksm::Ribbon::World:
return {0x3F, 7};
case pksm::Ribbon::G4Cool:
return {0x60, 0};
case pksm::Ribbon::G4CoolGreat:
return {0x60, 1};
case pksm::Ribbon::G4CoolUltra:
return {0x60, 2};
case pksm::Ribbon::G4CoolMaster:
return {0x60, 3};
case pksm::Ribbon::G4Beauty:
return {0x60, 4};
case pksm::Ribbon::G4BeautyGreat:
return {0x60, 5};
case pksm::Ribbon::G4BeautyUltra:
return {0x60, 6};
case pksm::Ribbon::G4BeautyMaster:
return {0x60, 7};
case pksm::Ribbon::G4Cute:
return {0x61, 0};
case pksm::Ribbon::G4CuteGreat:
return {0x61, 1};
case pksm::Ribbon::G4CuteUltra:
return {0x61, 2};
case pksm::Ribbon::G4CuteMaster:
return {0x61, 3};
case pksm::Ribbon::G4Smart:
return {0x61, 4};
case pksm::Ribbon::G4SmartGreat:
return {0x61, 5};
case pksm::Ribbon::G4SmartUltra:
return {0x61, 6};
case pksm::Ribbon::G4SmartMaster:
return {0x61, 7};
case pksm::Ribbon::G4Tough:
return {0x62, 0};
case pksm::Ribbon::G4ToughGreat:
return {0x62, 1};
case pksm::Ribbon::G4ToughUltra:
return {0x62, 2};
case pksm::Ribbon::G4ToughMaster:
return {0x62, 3};
default:
return {RIBBON_ABSENT, 0};
}
}
void fixString(std::u16string& fixString)
{
for (size_t i = 0; i < fixString.size(); i++)
{
if (fixString[i] == u'\u2467')
{
fixString[i] = u'\u00d7';
}
else if (fixString[i] == u'\u2468')
{
fixString[i] = u'\u00f7';
}
else if (fixString[i] == u'\u246c')
{
fixString[i] = u'\u2026';
}
else if (fixString[i] == u'\u246d')
{
fixString[i] = u'\uE08E';
}
else if (fixString[i] == u'\u246e')
{
fixString[i] = u'\uE08F';
}
else if (fixString[i] == u'\u246f')
{
fixString[i] = u'\uE090';
}
else if (fixString[i] == u'\u2470')
{
fixString[i] = u'\uE091';
}
else if (fixString[i] == u'\u2471')
{
fixString[i] = u'\uE092';
}
else if (fixString[i] == u'\u2472')
{
fixString[i] = u'\uE093';
}
else if (fixString[i] == u'\u2473')
{
fixString[i] = u'\uE094';
}
else if (fixString[i] == u'\u2474')
{
fixString[i] = u'\uE095';
}
else if (fixString[i] == u'\u2475')
{
fixString[i] = u'\uE096';
}
else if (fixString[i] == u'\u2476')
{
fixString[i] = u'\uE097';
}
else if (fixString[i] == u'\u2477')
{
fixString[i] = u'\uE098';
}
else if (fixString[i] == u'\u2478')
{
fixString[i] = u'\uE099';
}
else if (fixString[i] == u'\u2479')
{
fixString[i] = u'\uE09A';
}
else if (fixString[i] == u'\u247a')
{
fixString[i] = u'\uE09B';
}
else if (fixString[i] == u'\u247b')
{
fixString[i] = u'\uE09C';
}
else if (fixString[i] == u'\u247d')
{
fixString[i] = u'\uE09D';
}
}
}
}
namespace pksm
{
void PK5::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, checksum());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(data + BOX_LENGTH, PID());
}
}
}
void PK5::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, checksum());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(data + BOX_LENGTH, PID());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PK5::isEncrypted() const
{
return LittleEndian::convertTo<u32>(data + 0x64) != 0;
}
PK5::PK5(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK5::clone(void) const
{
return PKX::getPKM<Generation::FIVE>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PK5::generation(void) const
{
return Generation::FIVE;
}
u32 PK5::encryptionConstant(void) const
{
return PID();
}
void PK5::encryptionConstant(u32) {}
u8 PK5::abilityNumber(void) const
{
return hiddenAbility() ? 4 : 1 << ((PID() >> 16) & 1);
}
void PK5::abilityNumber(u8 v)
{
if (v == 1 || v == 2)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(), v,
shiny(), TSV(), PID(), generation()));
hiddenAbility(false);
}
else // Hidden ability
{
hiddenAbility(true);
}
}
u32 PK5::PID(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK5::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK5::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK5::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK5::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK5::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PK5::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PK5::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PK5::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PK5::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PK5::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PK5::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PK5::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PK5::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PK5::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PK5::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
u8 PK5::otFriendship(void) const
{
return data[0x14];
}
void PK5::otFriendship(u8 v)
{
data[0x14] = v;
}
Ability PK5::ability(void) const
{
return Ability{data[0x15]};
}
void PK5::ability(Ability v)
{
data[0x15] = u8(v);
}
void PK5::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else if (v == 1)
{
abilitynum = 2;
}
else
{
abilitynum = 4;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u16 PK5::markValue(void) const
{
return data[0x16];
}
void PK5::markValue(u16 v)
{
data[0x16] = v;
}
Language PK5::language(void) const
{
return Language(data[0x17]);
}
void PK5::language(Language v)
{
data[0x17] = u8(v);
}
u16 PK5::ev(Stat ev) const
{
return data[0x18 + u8(ev)];
}
void PK5::ev(Stat ev, u16 v)
{
data[0x18 + u8(ev)] = v;
}
u8 PK5::contest(u8 contest) const
{
return data[0x1E + contest];
}
void PK5::contest(u8 contest, u8 v)
{
data[0x1E + contest] = v;
}
bool PK5::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK5::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK5::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
Move PK5::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x28 + m * 2)};
}
void PK5::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x28 + m * 2, u16(v));
}
u8 PK5::PP(u8 m) const
{
return data[0x30 + m];
}
void PK5::PP(u8 m, u8 v)
{
data[0x30 + m] = v;
}
u8 PK5::PPUp(u8 m) const
{
return data[0x34 + m];
}
void PK5::PPUp(u8 m, u8 v)
{
data[0x34 + m] = v;
}
u8 PK5::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x38);
return (u8)((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK5::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x38);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x38, buffer);
}
bool PK5::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x38) >> 30) & 0x1) == 1;
}
void PK5::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x38, (u32)((LittleEndian::convertTo<u32>(data + 0x38) & ~0x40000000) |
(u32)(v ? 0x40000000 : 0)));
}
bool PK5::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x38) >> 31) & 0x1) == 1;
}
void PK5::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x38,
(LittleEndian::convertTo<u32>(data + 0x38) & 0x7FFFFFFF) | (v ? 0x80000000 : 0));
}
bool PK5::fatefulEncounter(void) const
{
return (data[0x40] & 1) == 1;
}
void PK5::fatefulEncounter(bool v)
{
data[0x40] = (u8)((data[0x40] & ~0x01) | (v ? 1 : 0));
}
Gender PK5::gender(void) const
{
return Gender{u8((data[0x40] >> 1) & 0x3)};
}
void PK5::gender(Gender g)
{
data[0x40] = (data[0x40] & ~0x06) | (u8(g) << 1);
PID(PKX::getRandomPID(species(), g, version(), nature(), alternativeForm(), abilityNumber(),
shiny(), TSV(), PID(), generation()));
}
u16 PK5::alternativeForm(void) const
{
return data[0x40] >> 3;
}
void PK5::alternativeForm(u16 v)
{
data[0x40] = (data[0x40] & 0x07) | (v << 3);
}
Nature PK5::nature(void) const
{
return Nature{data[0x41]};
}
void PK5::nature(Nature v)
{
data[0x41] = u8(v);
}
bool PK5::hiddenAbility(void) const
{
return (data[0x42] & 1) == 1;
}
void PK5::hiddenAbility(bool v)
{
data[0x42] = (u8)((data[0x42] & ~0x01) | (v ? 1 : 0));
}
bool PK5::nPokemon(void) const
{
return (data[0x42] & 2) == 2;
}
void PK5::nPokemon(bool v)
{
data[0x42] = (u8)((data[0x42] & ~0x02) | (v ? 2 : 0));
}
std::string PK5::nickname(void) const
{
return StringUtils::transString45(StringUtils::getString(data, 0x48, 11, u'\uFFFF'));
}
void PK5::nickname(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString45(v), 0x48, 11, u'\uFFFF', 0);
}
GameVersion PK5::version(void) const
{
return GameVersion(data[0x5F]);
}
void PK5::version(GameVersion v)
{
data[0x5F] = u8(v);
}
std::string PK5::otName(void) const
{
return StringUtils::transString45(StringUtils::getString(data, 0x68, 8, u'\uFFFF'));
}
void PK5::otName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString45(v), 0x68, 8, u'\uFFFF', 0);
}
int PK5::eggYear(void) const
{
return 2000 + data[0x78];
}
void PK5::eggYear(int v)
{
data[0x78] = v - 2000;
}
int PK5::eggMonth(void) const
{
return data[0x79];
}
void PK5::eggMonth(int v)
{
data[0x79] = v;
}
int PK5::eggDay(void) const
{
return data[0x7A];
}
void PK5::eggDay(int v)
{
data[0x7A] = v;
}
int PK5::metYear(void) const
{
return 2000 + data[0x7B];
}
void PK5::metYear(int v)
{
data[0x7B] = v - 2000;
}
int PK5::metMonth(void) const
{
return data[0x7C];
}
void PK5::metMonth(int v)
{
data[0x7C] = v;
}
int PK5::metDay(void) const
{
return data[0x7D];
}
void PK5::metDay(int v)
{
data[0x7D] = v;
}
u16 PK5::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x7E);
}
void PK5::eggLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x7E, v);
}
u16 PK5::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x80);
}
void PK5::metLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x80, v);
}
u8 PK5::pkrs(void) const
{
return data[0x82];
}
void PK5::pkrs(u8 v)
{
data[0x82] = v;
}
u8 PK5::pkrsDays(void) const
{
return data[0x82] & 0xF;
};
void PK5::pkrsDays(u8 v)
{
data[0x82] = (u8)((data[0x82] & ~0xF) | v);
}
u8 PK5::pkrsStrain(void) const
{
return data[0x82] >> 4;
};
void PK5::pkrsStrain(u8 v)
{
data[0x82] = (u8)((data[0x82] & 0xF) | v << 4);
}
Ball PK5::ball(void) const
{
return Ball{data[0x83]};
}
void PK5::ball(Ball v)
{
data[0x83] = u8(v);
}
u8 PK5::metLevel(void) const
{
return data[0x84] & ~0x80;
}
void PK5::metLevel(u8 v)
{
data[0x84] = (data[0x84] & 0x80) | v;
}
Gender PK5::otGender(void) const
{
return Gender{u8(data[0x84] >> 7)};
}
void PK5::otGender(Gender v)
{
data[0x84] = (data[0x84] & ~0x80) | (u8(v) << 7);
}
u8 PK5::encounterType(void) const
{
return data[0x85];
}
void PK5::encounterType(u8 v)
{
data[0x85] = v;
}
void PK5::refreshChecksum(void)
{
u16 chk = 0;
for (u8 i = 8; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PK5::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK5::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PK5::TSV(void) const
{
return (TID() ^ SID()) >> 3;
}
u16 PK5::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 3;
}
u8 PK5::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK5::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK5::shiny(void) const
{
return TSV() == PSV();
}
void PK5::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK5::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalBWB2W2::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalBWB2W2::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PK5::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc = 10 + (2 * basestat + iv(stat) + ev(stat) / 4 + 100) * level() / 100;
}
else
{
calc = 5 + (2 * basestat + iv(stat) + ev(stat) / 4) * level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
int PK5::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x8E);
}
void PK5::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x8E, v);
}
}
int PK5::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x90 + u8(stat) * 2);
}
void PK5::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x90 + u8(stat) * 2, v);
}
}
int PK5::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0x8C);
}
void PK5::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0x8C) = v;
}
}
std::unique_ptr<PK1> PK5::convertToG1(Sav& save) const
{
if (auto pk4 = convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
if (auto pk2 = pk3->convertToG2(save))
{
return pk2->convertToG1(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK2> PK5::convertToG2(Sav& save) const
{
if (auto pk4 = convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
return pk3->convertToG2(save);
}
}
return nullptr;
}
std::unique_ptr<PK4> PK5::convertToG4(Sav& save) const
{
auto pk4 = PKX::getPKM<Generation::FOUR>(data, PK4::BOX_LENGTH);
// Clear nature field
pk4->rawData()[0x41] = 0;
pk4->nature(nature());
// Force normal Arceus form
if (pk4->species() == Species::Arceus)
{
pk4->alternativeForm(0);
}
pk4->nickname(nickname());
pk4->otName(otName());
pk4->heldItem(0);
pk4->otFriendship(70);
pk4->ball(ball());
// met location ???
for (int i = 0; i < 4; i++)
{
if (pk4->move(i) > save.maxMove())
{
pk4->move(i, Move::None);
}
}
pk4->fixMoves();
pk4->refreshChecksum();
return pk4;
}
std::unique_ptr<PK6> PK5::convertToG6(Sav& save) const
{
auto pk6 = PKX::getPKM<Generation::SIX>(nullptr, PK6::BOX_LENGTH);
pk6->encryptionConstant(PID());
pk6->species(species());
pk6->TID(TID());
pk6->SID(SID());
pk6->experience(experience());
pk6->PID(PID());
pk6->ability(ability());
Ability pkmAbilities[3] = {abilities(0), abilities(1), abilities(2)};
u8 abilVal =
std::distance(pkmAbilities, std::find(pkmAbilities, pkmAbilities + 3, ability()));
if (abilVal < 3 && pkmAbilities[abilVal] == pkmAbilities[2] && hiddenAbility())
{
abilVal = 2; // HA shared by normal ability
}
if (abilVal < 3)
{
pk6->abilityNumber(1 << abilVal);
}
else // Shouldn't happen
{
if (hiddenAbility())
{
pk6->abilityNumber(4);
}
else
{
pk6->abilityNumber(originGen5() ? ((PID() >> 16) & 1) : 1 << (PID() & 1));
}
}
pk6->markValue(markValue());
pk6->language(language());
for (int i = 0; i < 6; i++)
{
// EV Cap
pk6->ev(Stat(i), ev(Stat(i)) > 252 ? 252 : ev(Stat(i)));
pk6->iv(Stat(i), iv(Stat(i)));
pk6->contest(i, contest(i));
}
for (int i = 0; i < 4; i++)
{
pk6->move(i, move(i));
pk6->PPUp(i, PPUp(i));
pk6->PP(i, PP(i));
}
pk6->egg(egg());
pk6->nicknamed(nicknamed());
pk6->fatefulEncounter(fatefulEncounter());
pk6->gender(gender());
pk6->alternativeForm(alternativeForm());
pk6->nature(nature());
pk6->nickname(pk6->species().localize(pk6->language()));
if (nicknamed())
{
pk6->nickname(nickname());
}
pk6->version(version());
pk6->otName(otName());
pk6->metDate(metDate());
pk6->eggDate(eggDate());
pk6->metLocation(metLocation());
pk6->eggLocation(eggLocation());
pk6->pkrsStrain(pkrsStrain());
pk6->pkrsDays(pkrsDays());
pk6->ball(ball());
pk6->metLevel(metLevel());
pk6->otGender(otGender());
pk6->encounterType(encounterType());
// Ribbon
u8 contestRibbon = 0;
u8 battleRibbon = 0;
for (int i = 0; i < 8; i++) // Sinnoh 3, Hoenn 1
{
if (((data[0x60] >> i) & 1) == 1)
{
contestRibbon++;
}
if (((data[0x61] >> i) & 1) == 1)
{
contestRibbon++;
}
if (((data[0x3C] >> i) & 1) == 1)
{
contestRibbon++;
}
if (((data[0x3D] >> i) & 1) == 1)
{
contestRibbon++;
}
}
for (int i = 0; i < 4; i++) // Sinnoh 4, Hoenn 2
{
if (((data[0x62] >> i) & 1) == 1)
{
contestRibbon++;
}
if (((data[0x3E] >> i) & 1) == 1)
{
contestRibbon++;
}
}
// Winning Ribbon
if (((data[0x3E] & 0x20) >> 5) == 1)
{
battleRibbon++;
}
// Victory Ribbon
if (((data[0x3E] & 0x40) >> 6) == 1)
{
battleRibbon++;
}
for (int i = 1; i < 7; i++)
{ // Sinnoh Battle Ribbons
if (((data[0x24] >> i) & 1) == 1)
{
battleRibbon++;
}
}
pk6->ribbonContestCount(contestRibbon);
pk6->ribbonBattleCount(battleRibbon);
pk6->ribbon(Ribbon::ChampionG3Hoenn, ribbon(Ribbon::ChampionG3Hoenn));
pk6->ribbon(Ribbon::ChampionSinnoh, ribbon(Ribbon::ChampionSinnoh));
pk6->ribbon(Ribbon::Effort, ribbon(Ribbon::Effort));
pk6->ribbon(Ribbon::Alert, ribbon(Ribbon::Alert));
pk6->ribbon(Ribbon::Shock, ribbon(Ribbon::Shock));
pk6->ribbon(Ribbon::Downcast, ribbon(Ribbon::Downcast));
pk6->ribbon(Ribbon::Careless, ribbon(Ribbon::Careless));
pk6->ribbon(Ribbon::Relax, ribbon(Ribbon::Relax));
pk6->ribbon(Ribbon::Snooze, ribbon(Ribbon::Snooze));
pk6->ribbon(Ribbon::Smile, ribbon(Ribbon::Smile));
pk6->ribbon(Ribbon::Gorgeous, ribbon(Ribbon::Gorgeous));
pk6->ribbon(Ribbon::Royal, ribbon(Ribbon::Royal));
pk6->ribbon(Ribbon::GorgeousRoyal, ribbon(Ribbon::GorgeousRoyal));
pk6->ribbon(Ribbon::Artist, ribbon(Ribbon::Artist));
pk6->ribbon(Ribbon::Footprint, ribbon(Ribbon::Footprint));
pk6->ribbon(Ribbon::Record, ribbon(Ribbon::Record));
pk6->ribbon(Ribbon::Legend, ribbon(Ribbon::Legend));
pk6->ribbon(Ribbon::Country, ribbon(Ribbon::Country));
pk6->ribbon(Ribbon::National, ribbon(Ribbon::National));
pk6->ribbon(Ribbon::Earth, ribbon(Ribbon::Earth));
pk6->ribbon(Ribbon::World, ribbon(Ribbon::World));
pk6->ribbon(Ribbon::Classic, ribbon(Ribbon::Classic));
pk6->ribbon(Ribbon::Premier, ribbon(Ribbon::Premier));
pk6->ribbon(Ribbon::Event, ribbon(Ribbon::Event));
pk6->ribbon(Ribbon::Birthday, ribbon(Ribbon::Birthday));
pk6->ribbon(Ribbon::Special, ribbon(Ribbon::Special));
pk6->ribbon(Ribbon::Souvenir, ribbon(Ribbon::Souvenir));
pk6->ribbon(Ribbon::Wishing, ribbon(Ribbon::Wishing));
pk6->ribbon(Ribbon::ChampionBattle, ribbon(Ribbon::ChampionBattle));
pk6->ribbon(Ribbon::ChampionRegional, ribbon(Ribbon::ChampionRegional));
pk6->ribbon(Ribbon::ChampionNational, ribbon(Ribbon::ChampionNational));
pk6->ribbon(Ribbon::ChampionWorld, ribbon(Ribbon::ChampionWorld));
pk6->region(save.subRegion());
pk6->country(save.country());
pk6->consoleRegion(save.consoleRegion());
pk6->currentHandler(PKXHandler::NonOT);
pk6->htName(save.otName());
pk6->htGender(save.gender());
pk6->geoRegion(0, save.subRegion());
pk6->geoCountry(0, save.country());
pk6->htIntensity(1);
pk6->htMemory(4);
pk6->htFeeling(pksm::randomNumber(0, 9));
pk6->otFriendship(pk6->baseFriendship());
pk6->htFriendship(pk6->baseFriendship());
u32 shiny = 0;
shiny = (PID() >> 16) ^ (PID() & 0xFFFF) ^ TID() ^ SID();
if (shiny >= 8 && shiny < 16)
{ // Illegal shiny transfer
pk6->PID(pk6->PID() ^ 0x80000000);
}
pk6->fixMoves();
std::u16string toFix = StringUtils::UTF8toUCS2(pk6->otName());
fixString(toFix);
pk6->otName(StringUtils::UCS2toUTF8(toFix));
toFix = StringUtils::UTF8toUCS2(pk6->nickname());
fixString(toFix);
pk6->nickname(StringUtils::UCS2toUTF8(toFix));
pk6->refreshChecksum();
return pk6;
}
std::unique_ptr<PK3> PK5::convertToG3(Sav& save) const
{
if (auto pk4 = convertToG4(save))
{
return pk4->convertToG3(save);
}
return nullptr;
}
std::unique_ptr<PK7> PK5::convertToG7(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
return pk6->convertToG7(save);
}
return nullptr;
}
std::unique_ptr<PK8> PK5::convertToG8(Sav& save) const
{
auto pk6 = convertToG6(save);
if (pk6)
{
auto pk7 = pk6->convertToG7(save);
if (pk7)
{
return pk7->convertToG8(save);
}
}
return nullptr;
}
void PK5::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 36,852
|
C++
|
.cpp
| 1,232
| 20.461039
| 100
| 0.494809
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,278
|
PK2.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK2.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK2.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/i18n.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#include "utils/ValueConverter.hpp"
#include <algorithm>
namespace pksm
{
PK2::PK2(PrivateConstructor, u8* dt, bool japanese, bool directAccess)
: PKX(dt, japanese ? JP_LENGTH_WITH_NAMES : INT_LENGTH_WITH_NAMES, directAccess)
{
this->japanese = japanese;
lang = japanese ? Language::JPN : Language::ENG;
shiftedData = data + 3;
}
std::unique_ptr<PK1> PK2::convertToG1(Sav& save) const
{
auto pk1 = PKX::getPKM<Generation::ONE>(
nullptr, japanese ? PK1::JP_LENGTH_WITH_NAMES : PK1::INT_LENGTH_WITH_NAMES);
pk1->species(species());
pk1->TID(TID());
pk1->experience(experience());
pk1->egg(false);
pk1->otFriendship(70);
pk1->language(language());
pk1->ev(Stat::HP, ev(Stat::HP));
pk1->ev(Stat::ATK, ev(Stat::ATK));
pk1->ev(Stat::DEF, ev(Stat::DEF));
pk1->ev(Stat::SPD, ev(Stat::SPD));
pk1->ev(Stat::SPATK, ev(Stat::SPATK));
for (int i = 0; i < 4; i++)
{
if (move(i) > save.maxMove())
{
pk1->move(i, Move::None);
}
else
{
pk1->move(i, move(i));
pk1->PPUp(i, PPUp(i));
pk1->PP(i, PP(i));
}
}
pk1->iv(Stat::ATK, iv(Stat::ATK));
pk1->iv(Stat::DEF, iv(Stat::DEF));
pk1->iv(Stat::SPD, iv(Stat::SPD));
pk1->iv(Stat::SPATK, iv(Stat::SPATK));
pk1->otName(otName());
pk1->nickname(nickname());
pk1->catchRate(heldItem2());
pk1->fixMoves();
return pk1;
}
std::unique_ptr<PK3> PK2::convertToG3(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
return pk4->convertToG3(save);
}
}
}
}
return nullptr;
}
std::unique_ptr<PK4> PK2::convertToG4(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
return pk5->convertToG4(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK5> PK2::convertToG5(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
if (auto pk6 = pk7->convertToG6(save))
{
return pk6->convertToG5(save);
}
}
return nullptr;
}
std::unique_ptr<PK6> PK2::convertToG6(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
return pk7->convertToG6(save);
}
return nullptr;
}
std::unique_ptr<PK7> PK2::convertToG7(Sav& save) const
{
auto pk7 = PKX::getPKM<Generation::SEVEN>(nullptr, PK7::BOX_LENGTH);
pk7->encryptionConstant(randomNumber(0, 0xFFFFFFFF));
pk7->PID(randomNumber(0, 0xFFFFFFFF));
pk7->species(species());
pk7->TID(TID());
pk7->level(level());
pk7->metLevel(level());
pk7->nature(nature());
pk7->ball(ball());
pk7->metDate(Date::today());
pk7->version(version());
// cannot transfer Dizzy Punch
pk7->move(0, move(0) == Move::DizzyPunch ? Move::None : move(0));
pk7->move(1, move(1) == Move::DizzyPunch ? Move::None : move(1));
pk7->move(2, move(2) == Move::DizzyPunch ? Move::None : move(2));
pk7->move(3, move(3) == Move::DizzyPunch ? Move::None : move(3));
pk7->PPUp(0, PPUp(0));
pk7->PPUp(1, PPUp(1));
pk7->PPUp(2, PPUp(2));
pk7->PPUp(3, PPUp(3));
pk7->metLocation(0x7541);
pk7->gender(gender());
pk7->nicknamed(false);
pk7->alternativeForm(alternativeForm());
pk7->currentHandler(PKXHandler::NonOT);
pk7->htName(save.otName());
pk7->htGender(save.gender());
pk7->consoleRegion(save.consoleRegion());
pk7->country(save.country());
pk7->region(save.subRegion());
pk7->geoCountry(0, save.country());
pk7->geoRegion(0, save.subRegion());
pk7->healPP();
pk7->language(save.language());
pk7->nickname(species().localize(pk7->language()));
pk7->otFriendship(PersonalSMUSUM::baseFriendship(u16(species())));
pk7->htFriendship(pk7->otFriendship());
std::array<Stat, 6> stats = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
std::shuffle(stats.begin(), stats.end(), UniformRandomBitGenerator{});
u8 perfectStats = 3;
if (species() == Species::Mew || species() == Species::Celebi)
{
perfectStats = 5;
}
for (const auto& s : stats | std::views::take(perfectStats))
{
pk7->iv(s, 31);
}
for (const auto& s : stats | std::views::drop(perfectStats))
{
pk7->iv(s, randomNumber(0, 31));
}
if (pk7->shiny() && !shiny())
{
pk7->PID(pk7->PID() ^ 0x10000000);
}
else if (!pk7->shiny() && shiny())
{
pk7->PID(u32(((pk7->TID() ^ (pk7->PID() & 0xFFFF)) << 16) | (pk7->PID() & 0xFFFF)));
}
// always has hidden ability unless it doesn't exist
switch (species())
{
case Species::Gastly:
case Species::Haunter:
case Species::Gengar:
case Species::Koffing:
case Species::Weezing:
case Species::Mew:
case Species::Misdreavus:
case Species::Unown:
case Species::Celebi:
pk7->setAbility(0);
break;
default:
pk7->setAbility(2);
}
if (species() == Species::Mew || species() == Species::Celebi)
{
pk7->fatefulEncounter(true);
}
if (nicknamed())
{
pk7->nicknamed(true);
pk7->nickname(japanese ? StringUtils::fixJapaneseNameTransporter(nicknameTransporter())
: nicknameTransporter());
}
pk7->otName(japanese ? StringUtils::fixJapaneseNameTransporter(transferOT(save.language()))
: transferOT(save.language()));
pk7->otGender(otGender());
pk7->htMemory(4);
pk7->htTextVar(0);
pk7->htIntensity(1);
pk7->htFeeling(randomNumber(0, 9));
pk7->fixMoves();
pk7->refreshChecksum();
return pk7;
}
std::unique_ptr<PK8> PK2::convertToG8(Sav& save) const
{
if (auto pk7 = convertToG7(save))
{
return pk7->convertToG8(save);
}
return nullptr;
}
GameVersion PK2::version() const
{
return catchData() == 0 ? versionOfGame : GameVersion::C;
}
void PK2::version(GameVersion v)
{
if ((version() == GameVersion::C) ^ (v != GameVersion::C))
{
versionOfGame = v;
}
}
std::unique_ptr<PKX> PK2::clone() const
{
return PKX::getPKM<Generation::TWO>(
data, japanese ? JP_LENGTH_WITH_NAMES : INT_LENGTH_WITH_NAMES);
}
u16 PK2::TID() const
{
return BigEndian::convertTo<u16>(shiftedData + 6);
}
void PK2::TID(u16 v)
{
BigEndian::convertFrom<u16>(shiftedData + 6, v);
}
std::string PK2::nickname() const
{
return StringUtils::getString2(
shiftedData, 48 + (japanese ? 6 : 11), japanese ? 6 : 11, lang);
}
std::string PK2::nicknameTransporter() const
{
return StringUtils::getString2(
shiftedData, 48 + (japanese ? 6 : 11), japanese ? 6 : 11, lang, true);
}
void PK2::nickname(const std::string_view& v)
{
StringUtils::setString2(
shiftedData, v, 48 + (japanese ? 6 : 11), japanese ? 6 : 11, lang, japanese ? 6 : 11);
}
Language PK2::language() const
{
return lang;
}
void PK2::language(Language v)
{
// korean has a page for INT characters
if (((lang == Language::JPN) == (v == Language::JPN)) && (lang != Language::KOR))
{
korean = v == Language::KOR;
lang = v;
}
}
// do not use, only for use when building a PK2
void PK2::languageOverrideLimits(Language v)
{
japanese = v == Language::JPN;
korean = v == Language::KOR;
lang = v;
}
std::string PK2::otName() const
{
return StringUtils::getString2(shiftedData, 48, japanese ? 6 : 11, lang);
}
void PK2::otName(const std::string_view& v)
{
StringUtils::setString2(shiftedData, v, 48, japanese ? 6 : 11, lang, japanese ? 6 : 11, 0);
}
std::string PK2::transferOT(Language newLang) const
{
return StringUtils::getString2(
shiftedData, 48, japanese ? 6 : 11, shiftedData[48] == 0x5D ? newLang : lang, true);
}
Species PK2::species() const
{
return Species{shiftedData[0]};
}
void PK2::species(Species v)
{
shiftedData[0] = u8(v);
if (!egg())
{
data[1] = u8(v);
}
// do this now rather than never
data[0] = 1;
data[2] = 0xFF;
}
u8 PK2::heldItem2() const
{
return shiftedData[1];
}
void PK2::heldItem2(u8 v)
{
shiftedData[1] = v;
}
u16 PK2::heldItem() const
{
return ItemConverter::g2ToNational(shiftedData[1]);
}
void PK2::heldItem(u16 v)
{
shiftedData[1] = ItemConverter::nationalToG2(v);
}
void PK2::heldItem(const Item& item)
{
if (item.generation() == Generation::TWO)
{
heldItem2((static_cast<const Item2&>(item)).id2());
}
else
{
heldItem(item.id());
}
}
u32 PK2::experience() const
{
return BigEndian::convertTo<u32>(shiftedData + 8) >> 8;
}
void PK2::experience(u32 v)
{
shiftedData[8] = v >> 16;
shiftedData[9] = (v >> 8) & 0x00FF;
shiftedData[10] = v & 0x0000FF;
shiftedData[31] = level();
}
u8 PK2::otFriendship() const
{
return shiftedData[27];
}
void PK2::otFriendship(u8 v)
{
shiftedData[27] = v;
}
u16 PK2::ev(Stat ev) const
{
if (ev == Stat::SPDEF)
{
ev = Stat::SPATK;
}
return BigEndian::convertTo<u16>(shiftedData + 11 + 2 * u8(ev));
}
void PK2::ev(Stat ev, u16 v)
{
if (ev == Stat::SPDEF)
{
ev = Stat::SPATK;
}
BigEndian::convertFrom<u16>(shiftedData + 11 + 2 * u8(ev), v);
}
Move PK2::move(u8 move) const
{
return Move{shiftedData[2 + move]};
}
void PK2::move(u8 move, Move v)
{
shiftedData[2 + move] = u8(v);
}
u8 PK2::PP(u8 move) const
{
return u8(shiftedData[23 + move] & 0x3F);
}
void PK2::PP(u8 move, u8 v)
{
shiftedData[23 + move] = u8((shiftedData[23 + move] & 0xC0) | (v & 0x3F));
}
u8 PK2::PPUp(u8 move) const
{
return shiftedData[23 + move] >> 6;
}
void PK2::PPUp(u8 move, u8 v)
{
shiftedData[23 + move] = u8((v & 0xC0) | (shiftedData[23 + move] & 0x3F));
}
u8 PK2::iv(Stat iv) const
{
switch (iv)
{
case Stat::HP:
return ((PK2::iv(Stat::ATK) & 0x01) << 3) | ((PK2::iv(Stat::DEF) & 0x01) << 2) |
((PK2::iv(Stat::SPD) & 0x01) << 1) | (PK2::iv(Stat::SPATK) & 0x01);
case Stat::ATK:
return (shiftedData[0x15] & 0xF0) >> 4;
case Stat::DEF:
return shiftedData[0x15] & 0x0F;
case Stat::SPD:
return (shiftedData[0x16] & 0xF0) >> 4;
case Stat::SPATK:
case Stat::SPDEF:
return shiftedData[0x16] & 0x0F;
default:
return 0;
}
}
void PK2::iv(Stat iv, u8 v)
{
if (v > 15)
{
v = 15;
}
switch (iv)
{
case Stat::ATK:
shiftedData[0x15] = ((v & 0x0F) << 4) | (shiftedData[0x15] & 0x0F);
break;
case Stat::DEF:
shiftedData[0x15] = (shiftedData[0x15] & 0xF0) | (v & 0x0F);
break;
case Stat::SPD:
shiftedData[0x16] = ((v & 0x0F) << 4) | (shiftedData[0x16] & 0x0F);
break;
case Stat::SPATK:
case Stat::SPDEF:
shiftedData[0x16] = (shiftedData[0x16] & 0xF0) | (v & 0x0F);
break;
case Stat::HP:
default:
return;
}
}
bool PK2::egg() const
{
return data[1] == 0xFD;
}
void PK2::egg(bool v)
{
data[1] = v ? 0xFD : u8(species());
}
bool PK2::nicknamed() const
{
if (japanese || korean)
{
std::string target = species().localize(language());
return nickname() != StringUtils::toUpper(target);
}
else
{
for (u8 i = u8(Language::ENG); i <= u8(Language::SPA); i++)
{
if (i != u8(Language::UNUSED))
{
std::string target = species().localize(Language{i});
if (nickname() == StringUtils::toUpper(target))
{
return false;
}
}
}
}
return true;
}
Gender PK2::gender() const
{
switch (genderType())
{
case 255:
return Gender::Genderless;
case 254:
return Gender::Female;
case 0:
return Gender::Male;
default:
return iv(Stat::ATK) > (genderType() >> 4) ? Gender::Male : Gender::Female;
}
}
void PK2::gender(Gender g)
{
switch (genderType())
{
case 255:
case 254:
case 0:
return;
default:
iv(Stat::ATK,
(g == Gender::Female) ? (genderType() >> 4) : ((genderType() >> 4) + 1));
}
}
u16 PK2::alternativeForm() const
{
if (species() == Species::Unown)
{
return ((((iv(Stat::ATK) >> 1) & 0x03) << 6) | (((iv(Stat::DEF) >> 1) & 0x03) << 4) |
(((iv(Stat::SPD) >> 1) & 0x03) << 2) | ((iv(Stat::SPATK) >> 1) & 0x03)) /
10;
}
return 0;
}
void PK2::alternativeForm(u16 v)
{
if (species() == Species::Unown)
{
v %= 26;
v *= 10;
iv(Stat::ATK, (iv(Stat::ATK) & 0x9) | ((v & 0xC0) >> 5));
iv(Stat::DEF, (iv(Stat::DEF) & 0x9) | ((v & 0x30) >> 3));
iv(Stat::SPD, (iv(Stat::SPD) & 0x9) | ((v & 0x0C) >> 1));
iv(Stat::SPATK, (iv(Stat::SPATK) & 0x9) | ((v & 0x03) << 1));
}
}
Nature PK2::nature() const
{
return Nature{u8(experience() % 25)};
}
void PK2::nature(Nature v)
{
experience(experience() - (experience() % 25) + u8(v));
}
// this data is generated in Crystal, preserved in Gold and Silver
u16 PK2::catchData() const
{
return BigEndian::convertTo<u16>(shiftedData + 29);
}
void PK2::catchData(u16 v)
{
BigEndian::convertFrom<u16>(shiftedData + 29, v);
}
u16 PK2::metLocation() const
{
return catchData() & 0x7F;
}
void PK2::metLocation(u16 v)
{
catchData((catchData() & 0xFF80) | (v & 0x7F));
}
u8 PK2::pkrs() const
{
return shiftedData[28];
}
void PK2::pkrs(u8 v)
{
shiftedData[28] = v;
}
u8 PK2::pkrsDays() const
{
return shiftedData[28] & 0xF;
}
void PK2::pkrsDays(u8 v)
{
shiftedData[28] = (shiftedData[28] & 0xF0) | v;
}
u8 PK2::pkrsStrain() const
{
return shiftedData[28] >> 4;
}
void PK2::pkrsStrain(u8 v)
{
shiftedData[28] = (v << 4) | (shiftedData[28] & 0x0F);
}
u8 PK2::metLevel() const
{
return (catchData() >> 8) & 0x3F;
}
void PK2::metLevel(u8 v)
{
catchData((catchData() & 0xC0FF) | ((v & 0x3F) << 8));
}
Gender PK2::otGender() const
{
return Gender{u8((catchData() & 0x80) >> 7)};
}
void PK2::otGender(Gender v)
{
if (u8(v) > 1)
{
v = Gender::Male;
}
catchData((catchData() & 0xFF7F) | (u8(v) << 7));
}
// 1 is morning, 2 is day, 3 is night, 0 is for PK2s not generated in Crystal
u8 PK2::metTime() const
{
return catchData() >> 14;
}
void PK2::metTime(u8 v)
{
catchData((catchData() & 0x3FFF) | ((v & 0x03) << 14));
}
Type PK2::hpType() const
{
return Type{u8((((iv(Stat::ATK) & 0x3) << 2) | (iv(Stat::DEF) & 0x3)) + 1)};
}
void PK2::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
u8 noNormal = u8(v) - 1;
noNormal %= 16; // just in case
iv(Stat::ATK, (iv(Stat::ATK) & 0xC) | (noNormal >> 2));
iv(Stat::DEF, (iv(Stat::DEF) & 0xC) | (noNormal & 0x3));
}
u8 PK2::level() const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK2::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK2::shiny() const
{
return (iv(Stat::DEF) == 10) && (iv(Stat::SPD) == 10) && (iv(Stat::SPATK) == 10) &&
(((iv(Stat::ATK) & 0x02) >> 1) == 1);
}
void PK2::shiny(bool v)
{
if (v)
{
iv(Stat::DEF, 10);
iv(Stat::SPD, 10);
iv(Stat::SPATK, 10);
}
iv(Stat::ATK, v ? 7 : 8);
}
u16 PK2::formSpecies() const
{
return u16(species());
}
u16 PK2::statImpl(Stat stat) const
{
u16 base;
switch (stat)
{
case Stat::HP:
base = baseHP();
break;
case Stat::ATK:
base = baseAtk();
break;
case Stat::DEF:
base = baseDef();
break;
case Stat::SPD:
base = baseSpe();
break;
case Stat::SPATK:
base = baseSpa();
break;
case Stat::SPDEF:
base = baseSpd();
break;
default:
base = 0;
}
u16 EV = u16(std::min(255, int(std::ceil(std::sqrt(ev(stat))))) >> 2);
u16 mid = u16(((2 * (base + iv(stat)) + EV) * level() / 100) + 5);
if (stat == Stat::HP)
{
return mid + 5 + level();
}
return mid;
}
int PK2::partyCurrHP() const
{
return isParty() ? BigEndian::convertTo<u16>(shiftedData + 34) : -1;
}
void PK2::partyCurrHP(u16 v)
{
if (isParty())
{
BigEndian::convertFrom<u16>(shiftedData + 34, v);
}
}
int PK2::partyStat(Stat stat) const
{
return isParty() ? BigEndian::convertTo<u16>(shiftedData + 36 + 2 * u8(stat)) : -1;
}
void PK2::partyStat(Stat stat, u16 v)
{
if (isParty())
{
BigEndian::convertFrom<u16>(shiftedData + 36 + 2 * u8(stat), v);
}
}
int PK2::partyLevel() const
{
return isParty() ? shiftedData[31] : -1;
}
void PK2::partyLevel(u8 v)
{
if (isParty())
{
shiftedData[31] = v;
}
}
void PK2::updatePartyData()
{
partyLevel(level());
for (u8 pstat = u8(Stat::HP); pstat <= u8(Stat::SPDEF); pstat++)
{
partyStat(static_cast<Stat>(pstat), stat(static_cast<Stat>(pstat)));
}
partyCurrHP(stat(Stat::HP));
}
}
| 22,349
|
C++
|
.cpp
| 750
| 21.04
| 99
| 0.50335
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,279
|
PK3.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK3.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK3.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK7.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/i18n.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#include "utils/ValueConverter.hpp"
#include <algorithm>
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionG3Hoenn:
return {0x4D, 7};
case pksm::Ribbon::Winning:
return {0x4E, 0};
case pksm::Ribbon::Victory:
return {0x4E, 1};
case pksm::Ribbon::Artist:
return {0x4E, 2};
case pksm::Ribbon::Effort:
return {0x4E, 3};
case pksm::Ribbon::ChampionBattle:
return {0x4E, 4};
case pksm::Ribbon::ChampionRegional:
return {0x4E, 5};
case pksm::Ribbon::ChampionNational:
return {0x4E, 6};
case pksm::Ribbon::Country:
return {0x4E, 7};
case pksm::Ribbon::National:
return {0x4F, 0};
case pksm::Ribbon::Earth:
return {0x4F, 1};
case pksm::Ribbon::World:
return {0x4F, 2};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
u8 PK3::getUnownForm(u32 pid)
{
u32 val =
(pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | (pid & 0x3);
return val % 28;
}
void PK3::encrypt()
{
if (!isEncrypted())
{
u8 sv = PID() % 24;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BlockDataLength>(
data + BlockShuffleStart, pksm::crypto::pkm::InvertedBlockPositions[sv]);
crypt();
}
}
void PK3::decrypt()
{
if (isEncrypted())
{
u8 sv = PID() % 24;
crypt();
pksm::crypto::pkm::blockShuffle<BlockDataLength>(data + BlockShuffleStart, sv);
}
}
void PK3::crypt(void)
{
u32 seed = LittleEndian::convertTo<u32>(data) ^ LittleEndian::convertTo<u32>(data + 4);
auto xorkey = LittleEndian::convertFrom<u32>(seed);
for (size_t i = 32; i < BOX_LENGTH; i++)
{
data[i] ^= xorkey[i % xorkey.size()];
}
}
int PK3::swapBits(int value, int p1, int p2)
{
int bit1 = (value >> p1) & 1;
int bit2 = (value >> p2) & 1;
int x = bit1 ^ bit2;
x = (x << p1) | (x << p2);
return value ^ x;
}
bool PK3::japanese(void) const
{
return flagIsEgg() || language() == Language::JPN;
}
u16 PK3::calcChecksum() const
{
u16 chk = 0;
for (size_t i = 0x20; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
return chk;
}
void PK3::refreshChecksum()
{
checksum(calcChecksum());
}
bool PK3::isEncrypted() const
{
return calcChecksum() != checksum();
}
PK3::PK3(PrivateConstructor, u8* dt, bool party, bool directAccess)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, directAccess)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK3::clone(void) const
{
// Can't use normal data constructor because of checksum encryption checks
std::unique_ptr<PK3> ret =
PKX::getPKM<Generation::THREE>(nullptr, isParty() ? PARTY_LENGTH : BOX_LENGTH);
std::copy(data, data + getLength(), ret->rawData().begin());
return ret;
}
Generation PK3::generation(void) const
{
return Generation::THREE;
}
u32 PK3::encryptionConstant(void) const
{
return PID();
}
void PK3::encryptionConstant(u32) {}
u8 PK3::abilityNumber(void) const
{
return abilityBit() ? 2 : 1;
}
void PK3::abilityNumber(u8 v)
{
abilityBit(v > 1);
}
u32 PK3::PID(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK3::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK3::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK3::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK3::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK3::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
std::string PK3::nickname(void) const
{
return StringUtils::getString3(data, 0x08, 10, japanese());
}
void PK3::nickname(const std::string_view& v)
{
StringUtils::setString3(data, v, 0x08, 10, japanese());
}
Language PK3::language(void) const
{
return Language(data[0x12]);
}
void PK3::language(Language v)
{
data[0x12] = u8(v);
}
bool PK3::flagIsBadEgg(void) const
{
return (data[0x13] & 1) == 1;
}
void PK3::flagIsBadEgg(bool v)
{
data[0x13] = (data[0x13] & ~1) | (v ? 1 : 0);
}
bool PK3::flagHasSpecies(void) const
{
return (data[0x13] & 2) == 2;
}
void PK3::flagHasSpecies(bool v)
{
data[0x13] = (data[0x13] & ~2) | (v ? 2 : 0);
}
bool PK3::flagIsEgg(void) const
{
return (data[0x13] & 4) == 4;
}
void PK3::flagIsEgg(bool v)
{
data[0x13] = (data[0x13] & ~4) | (v ? 4 : 0);
}
std::string PK3::otName(void) const
{
return StringUtils::getString3(data, 0x14, 7, japanese());
}
void PK3::otName(const std::string_view& v)
{
StringUtils::setString3(data, v, 0x14, 7, japanese());
}
u16 PK3::markValue(void) const
{
return swapBits(data[0x1B], 1, 2);
}
void PK3::markValue(u16 v)
{
data[0x1B] = swapBits(v, 1, 2);
}
u16 PK3::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x1C);
}
void PK3::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x1C, v);
}
u16 PK3::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x1E);
}
void PK3::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x1E, v);
}
u16 PK3::speciesID3(void) const
{
return LittleEndian::convertTo<u16>(data + 0x20);
}
void PK3::speciesID3(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x20, v);
}
Species PK3::species(void) const
{
return SpeciesConverter::g3ToNational(speciesID3());
}
void PK3::species(Species v)
{
speciesID3(SpeciesConverter::nationalToG3(v));
flagHasSpecies(species() != Species::None);
}
u16 PK3::heldItem3(void) const
{
return LittleEndian::convertTo<u16>(data + 0x22);
}
void PK3::heldItem3(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x22, v);
}
u16 PK3::heldItem(void) const
{
return ItemConverter::g3ToNational(heldItem3());
}
void PK3::heldItem(u16 v)
{
heldItem3(ItemConverter::nationalToG3(v));
}
void PK3::heldItem(const Item& item)
{
if (item.generation() == Generation::THREE)
{
heldItem3((static_cast<const Item3&>(item)).id3());
}
else
{
heldItem(item.id());
}
}
u32 PK3::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x24);
}
void PK3::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x24, v);
}
u8 PK3::PPUp(u8 move) const
{
return (data[0x28] >> (move * 2) & 3);
}
void PK3::PPUp(u8 move, u8 v)
{
data[0x28] = (data[0x28] & ~(3 << (move * 2))) | ((v & 3) << (move * 2));
}
u8 PK3::otFriendship(void) const
{
return data[0x29];
}
void PK3::otFriendship(u8 v)
{
data[0x29] = v;
}
Move PK3::move(u8 move) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x2C + move * 2)};
}
void PK3::move(u8 move, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x2C + move * 2, u16(v));
}
u8 PK3::PP(u8 move) const
{
return data[0x34 + move];
}
void PK3::PP(u8 move, u8 v)
{
data[0x34 + move] = v;
}
u16 PK3::ev(Stat ev) const
{
return data[0x38 + u8(ev)];
}
void PK3::ev(Stat ev, u16 v)
{
data[0x38 + u8(ev)] = v;
}
u8 PK3::contest(u8 contest) const
{
return data[0x3E + contest];
}
void PK3::contest(u8 contest, u8 v)
{
data[0x3E + contest] = v;
}
u8 PK3::pkrs(void) const
{
return data[0x44];
}
void PK3::pkrs(u8 v)
{
data[0x44] = v;
}
u8 PK3::pkrsDays(void) const
{
return data[0x44] & 0xF;
}
void PK3::pkrsDays(u8 v)
{
data[0x44] = (data[0x44] & ~0xF) | v;
}
u8 PK3::pkrsStrain(void) const
{
return data[0x44] >> 4;
}
void PK3::pkrsStrain(u8 v)
{
data[0x44] = (data[0x44] & 0xF) | (v << 4);
}
u16 PK3::metLocation(void) const
{
return data[0x45];
}
void PK3::metLocation(u16 v)
{
data[0x45] = u8(v);
}
u8 PK3::metLevel(void) const
{
return LittleEndian::convertTo<u16>(data + 0x46) & 0x7F;
}
void PK3::metLevel(u8 v)
{
LittleEndian::convertFrom<u16>(
data + 0x46, u16((LittleEndian::convertTo<u16>(data + 0x46) & ~0x7F) | v));
}
GameVersion PK3::version(void) const
{
return GameVersion((LittleEndian::convertTo<u16>(data + 0x46) >> 7) & 0xF);
}
void PK3::version(GameVersion v)
{
LittleEndian::convertFrom<u16>(data + 0x46,
u16((LittleEndian::convertTo<u16>(data + 0x46) & ~0x780) | ((u8(v) & 0xF) << 7)));
}
Ball PK3::ball(void) const
{
return Ball{u8((LittleEndian::convertTo<u16>(data + 0x46) >> 11) & 0xF)};
}
void PK3::ball(Ball v)
{
LittleEndian::convertFrom<u16>(data + 0x46,
u16((LittleEndian::convertTo<u16>(data + 0x46) & ~0x7800) | ((u16(v) & 0xF) << 11)));
}
Gender PK3::otGender(void) const
{
return Gender{u8((LittleEndian::convertTo<u16>(data + 0x46) >> 15) & 1)};
}
void PK3::otGender(Gender v)
{
LittleEndian::convertFrom<u16>(data + 0x46,
u16((LittleEndian::convertTo<u16>(data + 0x46) & ~(1 << 15)) | ((u8(v) & 1) << 15)));
}
u8 PK3::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x48);
return u8((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK3::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x48);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x48, buffer);
}
bool PK3::egg() const
{
return ((LittleEndian::convertTo<u32>(data + 0x48) >> 30) & 1) == 1;
}
void PK3::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x48, u32((LittleEndian::convertTo<u32>(data + 0x48) & ~0x40000000) |
(u32)(v ? 0x40000000 : 0)));
flagIsEgg(v);
if (v)
{
nickname("タマゴ");
language(Language::JPN);
}
}
bool PK3::abilityBit(void) const
{
return (LittleEndian::convertTo<u32>(data + 0x48) >> 31) == 1;
}
void PK3::abilityBit(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x48,
(LittleEndian::convertTo<u32>(data + 0x48) & 0x7FFFFFFF) | (v ? 1u << 31 : 0u));
}
bool PK3::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK3::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK3::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
u8 PK3::contestRibbonCount(u8 contest) const
{
u16 rawVal = LittleEndian::convertTo<u16>(data + 0x4C);
return (rawVal >> (contest * 3)) & 7;
}
void PK3::contestRibbonCount(u8 contest, u8 count)
{
u16 rawVal = LittleEndian::convertTo<u16>(data + 0x4C);
rawVal &= 0xFFFF ^ (0x7 << (contest * 3));
rawVal |= (count & 0x7) << (contest * 3);
LittleEndian::convertFrom<u16>(data + 0x4C, rawVal);
}
bool PK3::fatefulEncounter(void) const
{
return (LittleEndian::convertTo<u32>(data + 0x4C) >> 31) == 1;
}
void PK3::fatefulEncounter(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x4C,
(LittleEndian::convertTo<u32>(data + 0x4C) & ~(1u << 31)) | (v ? 1u << 31 : 0));
}
int PK3::partyLevel() const
{
if (!isParty())
{
return -1;
}
return data[0x54];
}
void PK3::partyLevel(u8 v)
{
if (isParty())
{
data[0x54] = v;
}
}
int PK3::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x56);
}
void PK3::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x56, v);
}
}
int PK3::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x58 + u8(stat) * 2);
}
void PK3::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x58 + u8(stat) * 2, v);
}
}
std::unique_ptr<PK1> PK3::convertToG1(Sav& save) const
{
if (auto pk2 = convertToG2(save))
{
return pk2->convertToG1(save);
}
return nullptr;
}
std::unique_ptr<PK2> PK3::convertToG2(Sav& save) const
{
auto pk2 = PKX::getPKM<Generation::TWO>(
nullptr, japanese() ? PK1::JP_LENGTH_WITH_NAMES : PK1::INT_LENGTH_WITH_NAMES);
pk2->species(species());
pk2->TID(TID());
pk2->experience(experience());
pk2->egg(false);
pk2->otFriendship(otFriendship());
pk2->language(language());
pk2->heldItem(heldItem() == ItemConverter::ITEM_NOT_CONVERTIBLE ? 0 : heldItem());
// approximate an equivalent stat experience for an ev, by squaring
pk2->ev(Stat::HP, ev(Stat::HP) * ev(Stat::HP));
pk2->ev(Stat::ATK, ev(Stat::ATK) * ev(Stat::ATK));
pk2->ev(Stat::DEF, ev(Stat::DEF) * ev(Stat::DEF));
pk2->ev(Stat::SPD, ev(Stat::SPD) * ev(Stat::SPD));
pk2->ev(Stat::SPATK, ev(Stat::SPATK) * ev(Stat::SPATK));
for (int i = 0; i < 4; i++)
{
if (move(i) > save.maxMove())
{
pk2->move(i, Move::None);
}
else
{
pk2->move(i, move(i));
pk2->PPUp(i, PPUp(i));
}
}
if (shiny())
{
pk2->shiny(true);
}
else
{
// approximate an equivalent dv for an iv, by dividing by two
// unfortunately the hp dv is determined by the other dvs
pk2->iv(Stat::ATK, iv(Stat::ATK) >> 1);
pk2->iv(Stat::DEF, iv(Stat::DEF) >> 1);
pk2->iv(Stat::SPD, iv(Stat::SPD) >> 1);
pk2->iv(Stat::SPATK, iv(Stat::SPATK) >> 1);
}
pk2->otName(otName());
pk2->nickname(nickname());
pk2->fixMoves();
return pk2;
}
std::unique_ptr<PK4> PK3::convertToG4(Sav&) const
{
static constexpr std::array<std::array<u8, 18>, 7> trashBytes = {
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00},
{0x18, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xA1,
0x0C, 0x02, 0xE0, 0xFF},
{0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1,
0x0C, 0x02, 0xE0, 0xFF},
{0x54, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0xA1,
0x0C, 0x02, 0xE0, 0xFF},
{0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1,
0x0C, 0x02, 0xE0, 0xFF},
{}, // Unused
{0x74, 0x20, 0x0D, 0x02, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA1,
0x0C, 0x02, 0xE0, 0xFF},
}
};
auto pk4 = PKX::getPKM<Generation::FOUR>(nullptr, PK4::BOX_LENGTH);
pk4->species(species());
pk4->TID(TID());
pk4->SID(SID());
pk4->experience(egg() ? expTable(5, expType()) : experience());
pk4->gender(gender());
pk4->alternativeForm(alternativeForm());
pk4->nature(nature());
pk4->egg(false);
pk4->otFriendship(70);
pk4->markValue(markValue());
pk4->language(language());
pk4->ev(Stat::HP, ev(Stat::HP));
pk4->ev(Stat::ATK, ev(Stat::ATK));
pk4->ev(Stat::DEF, ev(Stat::DEF));
pk4->ev(Stat::SPD, ev(Stat::SPD));
pk4->ev(Stat::SPATK, ev(Stat::SPATK));
pk4->ev(Stat::SPDEF, ev(Stat::SPDEF));
pk4->contest(0, contest(0));
pk4->contest(1, contest(1));
pk4->contest(2, contest(2));
pk4->contest(3, contest(3));
pk4->contest(4, contest(4));
pk4->contest(5, contest(5));
pk4->move(0, move(0));
pk4->move(1, move(1));
pk4->move(2, move(2));
pk4->move(3, move(3));
pk4->PPUp(0, PPUp(0));
pk4->PPUp(1, PPUp(1));
pk4->PPUp(2, PPUp(2));
pk4->PPUp(3, PPUp(3));
pk4->iv(Stat::HP, iv(Stat::HP));
pk4->iv(Stat::ATK, iv(Stat::ATK));
pk4->iv(Stat::DEF, iv(Stat::DEF));
pk4->iv(Stat::SPD, iv(Stat::SPD));
pk4->iv(Stat::SPATK, iv(Stat::SPATK));
pk4->iv(Stat::SPDEF, iv(Stat::SPDEF));
if (ability() == PersonalRSFRLGE::ability(formSpecies(), abilityNumber() >> 1))
{
pk4->setAbility(abilityNumber() >> 1);
}
else
{
pk4->ability(ability());
}
pk4->PID(PID());
pk4->version(version());
pk4->ball(ball());
pk4->pkrsStrain(pkrsStrain());
pk4->pkrsDays(pkrsDays());
pk4->otGender(otGender());
pk4->metDate(Date::today());
pk4->metLevel(level());
pk4->metLocation(0x37); // Pal Park
pk4->fatefulEncounter(fatefulEncounter());
pk4->ribbon(Ribbon::ChampionG3Hoenn, ribbon(Ribbon::ChampionG3Hoenn));
pk4->ribbon(Ribbon::Winning, ribbon(Ribbon::Winning));
pk4->ribbon(Ribbon::Victory, ribbon(Ribbon::Victory));
pk4->ribbon(Ribbon::Artist, ribbon(Ribbon::Artist));
pk4->ribbon(Ribbon::Effort, ribbon(Ribbon::Effort));
pk4->ribbon(Ribbon::ChampionBattle, ribbon(Ribbon::ChampionBattle));
pk4->ribbon(Ribbon::ChampionRegional, ribbon(Ribbon::ChampionRegional));
pk4->ribbon(Ribbon::ChampionNational, ribbon(Ribbon::ChampionNational));
pk4->ribbon(Ribbon::Country, ribbon(Ribbon::Country));
pk4->ribbon(Ribbon::National, ribbon(Ribbon::National));
pk4->ribbon(Ribbon::Earth, ribbon(Ribbon::Earth));
pk4->ribbon(Ribbon::World, ribbon(Ribbon::World));
// Contest ribbons
pk4->ribbon(Ribbon::G3Cool, contestRibbonCount(0) > 0);
pk4->ribbon(Ribbon::G3CoolSuper, contestRibbonCount(0) > 1);
pk4->ribbon(Ribbon::G3CoolHyper, contestRibbonCount(0) > 2);
pk4->ribbon(Ribbon::G3CoolMaster, contestRibbonCount(0) > 3);
pk4->ribbon(Ribbon::G3Beauty, contestRibbonCount(1) > 0);
pk4->ribbon(Ribbon::G3BeautySuper, contestRibbonCount(1) > 1);
pk4->ribbon(Ribbon::G3BeautyHyper, contestRibbonCount(1) > 2);
pk4->ribbon(Ribbon::G3BeautyMaster, contestRibbonCount(1) > 3);
pk4->ribbon(Ribbon::G3Cute, contestRibbonCount(2) > 0);
pk4->ribbon(Ribbon::G3CuteSuper, contestRibbonCount(2) > 1);
pk4->ribbon(Ribbon::G3CuteHyper, contestRibbonCount(2) > 2);
pk4->ribbon(Ribbon::G3CuteMaster, contestRibbonCount(2) > 3);
pk4->ribbon(Ribbon::G3Smart, contestRibbonCount(3) > 0);
pk4->ribbon(Ribbon::G3SmartSuper, contestRibbonCount(3) > 1);
pk4->ribbon(Ribbon::G3SmartHyper, contestRibbonCount(3) > 2);
pk4->ribbon(Ribbon::G3SmartMaster, contestRibbonCount(3) > 3);
pk4->ribbon(Ribbon::G3Tough, contestRibbonCount(4) > 0);
pk4->ribbon(Ribbon::G3ToughSuper, contestRibbonCount(4) > 1);
pk4->ribbon(Ribbon::G3ToughHyper, contestRibbonCount(4) > 2);
pk4->ribbon(Ribbon::G3ToughMaster, contestRibbonCount(4) > 3);
// Yay trash bytes
if ((size_t)(u8(language()) - 1) < trashBytes.size())
{
auto& trash = trashBytes[u8(language()) - 1];
std::copy(trash.begin(), trash.end(), pk4->rawData().begin() + 0x48 + 4);
}
std::string name = species().localize(language());
pk4->nickname(egg() ? StringUtils::toUpper(name) : nickname());
pk4->nicknamed(!egg() && nicknamed());
// Copy nickname trash into OT name
std::ranges::copy(pk4->rawData().subspan(0x48, 0x10), pk4->rawData().begin() + 0x68);
pk4->otName(otName());
// I use 0 for invalid items
pk4->heldItem(heldItem() == ItemConverter::ITEM_NOT_CONVERTIBLE ? 0 : heldItem());
// Remove HM moves
for (int i = 0; i < 4; i++)
{
static constexpr std::array<Move, 8> hms = {Move::Cut, Move::Fly, Move::Surf,
Move::Strength, Move::Flash, Move::RockSmash, Move::Waterfall, Move::Dive};
if (std::find(hms.begin(), hms.end(), pk4->move(i)) != hms.end())
{
pk4->move(i, Move::None);
}
else
{
pk4->move(i, move(i));
}
}
pk4->fixMoves();
pk4->refreshChecksum();
return pk4;
}
std::unique_ptr<PK5> PK3::convertToG5(Sav& save) const
{
auto pk4 = convertToG4(save);
if (pk4)
{
return pk4->convertToG5(save);
}
return nullptr;
}
std::unique_ptr<PK6> PK3::convertToG6(Sav& save) const
{
auto pk4 = convertToG4(save);
if (pk4)
{
auto pk5 = pk4->convertToG5(save);
if (pk5)
{
return pk5->convertToG6(save);
}
}
return nullptr;
}
std::unique_ptr<PK7> PK3::convertToG7(Sav& save) const
{
auto pk4 = convertToG4(save);
if (pk4)
{
auto pk5 = pk4->convertToG5(save);
if (pk5)
{
auto pk6 = pk5->convertToG6(save);
if (pk6)
{
return pk6->convertToG7(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK8> PK3::convertToG8(Sav& save) const
{
auto pk4 = convertToG4(save);
if (pk4)
{
auto pk5 = pk4->convertToG5(save);
if (pk5)
{
auto pk6 = pk5->convertToG6(save);
if (pk6)
{
auto pk7 = pk6->convertToG7(save);
if (pk7)
{
return pk7->convertToG8(save);
}
}
}
}
return nullptr;
}
u8 PK3::level() const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK3::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
Ability PK3::ability() const
{
return abilityBit() ? abilities(1) : abilities(0);
}
void PK3::ability(Ability v)
{
if (v == abilities(0))
{
abilityBit(false);
}
else if (v == abilities(1))
{
abilityBit(true);
}
}
void PK3::setAbility(u8 num)
{
if (num < 2)
{
ability(abilities(num));
}
}
Nature PK3::nature() const
{
return Nature{u8(PID() % 25)};
}
void PK3::nature(Nature v)
{
PID(PKX::getRandomPID(species(), gender(), version(), v, alternativeForm(), abilityNumber(),
shiny(), TSV(), PID(), Generation::THREE));
}
Gender PK3::gender() const
{
switch (genderType())
{
case 0:
return Gender::Male;
case 254:
return Gender::Female;
case 255:
return Gender::Genderless;
default:
return (PID() & 0xFF) < genderType() ? Gender::Female : Gender::Male;
}
}
void PK3::gender(Gender v)
{
PID(PKX::getRandomPID(species(), v, version(), nature(), alternativeForm(), abilityNumber(),
shiny(), TSV(), PID(), Generation::THREE));
}
u16 PK3::alternativeForm() const
{
if (species() == Species::Unown)
{
return getUnownForm(PID());
}
return 0;
}
void PK3::alternativeForm(u16 v)
{
if (species() == Species::Unown)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), v, abilityNumber(),
shiny(), TSV(), PID(), Generation::THREE));
}
}
bool PK3::nicknamed() const
{
std::string target = species().localize(language());
return nickname() != StringUtils::toUpper(target);
}
void PK3::nicknamed(bool) {}
Type PK3::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK3::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PK3::TSV() const
{
return (TID() ^ SID()) >> 3;
}
u16 PK3::PSV() const
{
return (PID() >> 16 ^ (PID() & 0xFFFF)) >> 3;
}
bool PK3::shiny(void) const
{
return TSV() == PSV();
}
void PK3::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK3::formSpecies() const
{
return u16(species());
}
u16 PK3::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc = 10 + (2 * basestat + iv(stat) + ev(stat) / 4 + 100) * level() / 100;
}
else
{
calc = 5 + (2 * basestat + iv(stat) + ev(stat) / 4) * level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
void PK3::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 31,580
|
C++
|
.cpp
| 1,020
| 22.493137
| 100
| 0.522268
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,280
|
PK8.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK8.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK8.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionKalos:
return {0x34, 0};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x34, 1};
case pksm::Ribbon::ChampionSinnoh:
return {0x34, 2};
case pksm::Ribbon::BestFriends:
return {0x34, 3};
case pksm::Ribbon::Training:
return {0x34, 4};
case pksm::Ribbon::BattlerSkillful:
return {0x34, 5};
case pksm::Ribbon::BattlerExpert:
return {0x34, 6};
case pksm::Ribbon::Effort:
return {0x34, 7};
case pksm::Ribbon::Alert:
return {0x35, 0};
case pksm::Ribbon::Shock:
return {0x35, 1};
case pksm::Ribbon::Downcast:
return {0x35, 2};
case pksm::Ribbon::Careless:
return {0x35, 3};
case pksm::Ribbon::Relax:
return {0x35, 4};
case pksm::Ribbon::Snooze:
return {0x35, 5};
case pksm::Ribbon::Smile:
return {0x35, 6};
case pksm::Ribbon::Gorgeous:
return {0x35, 7};
case pksm::Ribbon::Royal:
return {0x36, 0};
case pksm::Ribbon::GorgeousRoyal:
return {0x36, 1};
case pksm::Ribbon::Artist:
return {0x36, 2};
case pksm::Ribbon::Footprint:
return {0x36, 3};
case pksm::Ribbon::Record:
return {0x36, 4};
case pksm::Ribbon::Legend:
return {0x36, 5};
case pksm::Ribbon::Country:
return {0x36, 6};
case pksm::Ribbon::National:
return {0x36, 7};
case pksm::Ribbon::Earth:
return {0x37, 0};
case pksm::Ribbon::World:
return {0x37, 1};
case pksm::Ribbon::Classic:
return {0x37, 2};
case pksm::Ribbon::Premier:
return {0x37, 3};
case pksm::Ribbon::Event:
return {0x37, 4};
case pksm::Ribbon::Birthday:
return {0x37, 5};
case pksm::Ribbon::Special:
return {0x37, 6};
case pksm::Ribbon::Souvenir:
return {0x37, 7};
case pksm::Ribbon::Wishing:
return {0x38, 0};
case pksm::Ribbon::ChampionBattle:
return {0x38, 1};
case pksm::Ribbon::ChampionRegional:
return {0x38, 2};
case pksm::Ribbon::ChampionNational:
return {0x38, 3};
case pksm::Ribbon::ChampionWorld:
return {0x38, 4};
case pksm::Ribbon::MemoryContest:
return {0x38, 5};
case pksm::Ribbon::MemoryBattle:
return {0x38, 6};
case pksm::Ribbon::ChampionG6Hoenn:
return {0x38, 7};
case pksm::Ribbon::ContestStar:
return {0x39, 0};
case pksm::Ribbon::MasterCoolness:
return {0x39, 1};
case pksm::Ribbon::MasterBeauty:
return {0x39, 2};
case pksm::Ribbon::MasterCuteness:
return {0x39, 3};
case pksm::Ribbon::MasterCleverness:
return {0x39, 4};
case pksm::Ribbon::MasterToughness:
return {0x39, 5};
case pksm::Ribbon::ChampionAlola:
return {0x39, 6};
case pksm::Ribbon::BattleRoyale:
return {0x39, 7};
case pksm::Ribbon::BattleTreeGreat:
return {0x3A, 0};
case pksm::Ribbon::BattleTreeMaster:
return {0x3A, 1};
case pksm::Ribbon::ChampionGalar:
return {0x3A, 2};
case pksm::Ribbon::TowerMaster:
return {0x3A, 3};
case pksm::Ribbon::MasterRank:
return {0x3A, 4};
case pksm::Ribbon::MarkLunchtime:
return {0x3A, 5};
case pksm::Ribbon::MarkSleepyTime:
return {0x3A, 6};
case pksm::Ribbon::MarkDusk:
return {0x3A, 7};
case pksm::Ribbon::MarkDawn:
return {0x3B, 0};
case pksm::Ribbon::MarkCloudy:
return {0x3B, 1};
case pksm::Ribbon::MarkRainy:
return {0x3B, 2};
case pksm::Ribbon::MarkStormy:
return {0x3B, 3};
case pksm::Ribbon::MarkSnowy:
return {0x3B, 4};
case pksm::Ribbon::MarkBlizzard:
return {0x3B, 5};
case pksm::Ribbon::MarkDry:
return {0x3B, 6};
case pksm::Ribbon::MarkSandstorm:
return {0x3B, 7};
case pksm::Ribbon::MarkMisty:
return {0x40, 0};
case pksm::Ribbon::MarkDestiny:
return {0x40, 1};
case pksm::Ribbon::MarkFishing:
return {0x40, 2};
case pksm::Ribbon::MarkCurry:
return {0x40, 3};
case pksm::Ribbon::MarkUncommon:
return {0x40, 4};
case pksm::Ribbon::MarkRare:
return {0x40, 5};
case pksm::Ribbon::MarkRowdy:
return {0x40, 6};
case pksm::Ribbon::MarkAbsentMinded:
return {0x40, 7};
case pksm::Ribbon::MarkJittery:
return {0x41, 0};
case pksm::Ribbon::MarkExcited:
return {0x41, 1};
case pksm::Ribbon::MarkCharismatic:
return {0x41, 2};
case pksm::Ribbon::MarkCalmness:
return {0x41, 3};
case pksm::Ribbon::MarkIntense:
return {0x41, 4};
case pksm::Ribbon::MarkZonedOut:
return {0x41, 5};
case pksm::Ribbon::MarkJoyful:
return {0x41, 6};
case pksm::Ribbon::MarkAngry:
return {0x41, 7};
case pksm::Ribbon::MarkSmiley:
return {0x42, 0};
case pksm::Ribbon::MarkTeary:
return {0x42, 1};
case pksm::Ribbon::MarkUpbeat:
return {0x42, 2};
case pksm::Ribbon::MarkPeeved:
return {0x42, 3};
case pksm::Ribbon::MarkIntellectual:
return {0x42, 4};
case pksm::Ribbon::MarkFerocious:
return {0x42, 5};
case pksm::Ribbon::MarkCrafty:
return {0x42, 6};
case pksm::Ribbon::MarkScowling:
return {0x42, 7};
case pksm::Ribbon::MarkKindly:
return {0x43, 0};
case pksm::Ribbon::MarkFlustered:
return {0x43, 1};
case pksm::Ribbon::MarkPumpedUp:
return {0x43, 2};
case pksm::Ribbon::MarkZeroEnergy:
return {0x43, 3};
case pksm::Ribbon::MarkPrideful:
return {0x43, 4};
case pksm::Ribbon::MarkUnsure:
return {0x43, 5};
case pksm::Ribbon::MarkHumble:
return {0x43, 6};
case pksm::Ribbon::MarkThorny:
return {0x43, 7};
case pksm::Ribbon::MarkVigor:
return {0x44, 0};
case pksm::Ribbon::MarkSlump:
return {0x44, 1};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
void PK8::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
}
}
void PK8::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PK8::isEncrypted() const
{
return LittleEndian::convertTo<u16>(data + 0x70) != 0 &&
LittleEndian::convertTo<u16>(data + 0xC0) != 0;
}
PK8::PK8(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK8::clone(void) const
{
return PKX::getPKM<Generation::EIGHT>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PK8::generation(void) const
{
return Generation::EIGHT;
}
u32 PK8::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK8::encryptionConstant(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK8::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK8::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK8::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK8::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PK8::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PK8::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PK8::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PK8::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PK8::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PK8::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PK8::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PK8::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PK8::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PK8::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
Ability PK8::ability(void) const
{
return Ability{LittleEndian::convertTo<u16>(data + 0x14)};
}
void PK8::ability(Ability v)
{
LittleEndian::convertFrom<u16>(data + 0x14, u16(v));
}
void PK8::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else if (v == 1)
{
abilitynum = 2;
}
else
{
abilitynum = 4;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u8 PK8::abilityNumber(void) const
{
return data[0x16] & 0x7;
}
void PK8::abilityNumber(u8 v)
{
data[0x16] = (data[0x16] & ~7) | (v & 7);
}
bool PK8::favorite(void) const
{
return (data[0x16] & 8) != 0;
}
void PK8::favorite(bool v) const
{
data[0x16] = (data[0x16] & ~8) | (v ? 8 : 0);
}
bool PK8::canGiga(void) const
{
return (data[0x16] & 16) != 0;
}
void PK8::canGiga(bool v) const
{
data[0x16] = (data[0x16] & ~16) | (v ? 16 : 0);
}
u16 PK8::markValue(void) const
{
return LittleEndian::convertTo<u16>(data + 0x18);
}
void PK8::markValue(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x18, v);
}
u32 PK8::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x1C);
}
void PK8::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x1C, v);
}
Nature PK8::origNature(void) const
{
return Nature{data[0x20]};
}
void PK8::origNature(Nature v)
{
data[0x20] = u8(v);
}
Nature PK8::nature(void) const
{
return Nature{data[0x21]};
}
void PK8::nature(Nature v)
{
data[0x21] = u8(v);
}
bool PK8::fatefulEncounter(void) const
{
return (data[0x22] & 1) == 1;
}
void PK8::fatefulEncounter(bool v)
{
data[0x22] = (u8)((data[0x22] & ~0x01) | (v ? 1 : 0));
}
/*
bool PK8::data22flag2(void) const
{
return (data[0x22] & 2) == 1;
}
void PK8::data22flag2(bool v)
{
data[0x22] = (data[0x22] & ~2) | (v ? 2 : 0);
}
*/
Gender PK8::gender(void) const
{
return Gender{u8((data[0x22] >> 2) & 0x3)};
}
void PK8::gender(Gender v)
{
data[0x22] = (data[0x22] & ~12) | ((u8(v) & 3) << 2);
}
u16 PK8::alternativeForm(void) const
{
return LittleEndian::convertTo<u16>(data + 0x24);
}
void PK8::alternativeForm(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x24, v);
}
u16 PK8::ev(Stat ev) const
{
return data[0x26 + u8(ev)];
}
void PK8::ev(Stat ev, u16 v)
{
data[0x26 + u8(ev)] = v;
}
u8 PK8::contest(u8 contest) const
{
return data[0x2C + contest];
}
void PK8::contest(u8 contest, u8 v)
{
data[0x2C + contest] = v;
}
u8 PK8::pkrs(void) const
{
return data[0x32];
}
void PK8::pkrs(u8 v)
{
data[0x32] = v;
}
u8 PK8::pkrsDays(void) const
{
return data[0x32] & 0xF;
}
void PK8::pkrsDays(u8 v)
{
data[0x32] = (data[0x32] & ~0xF) | (v & 0xF);
}
u8 PK8::pkrsStrain(void) const
{
return data[0x32] >> 4;
}
void PK8::pkrsStrain(u8 v)
{
data[0x32] = (data[0x2B] & 0xF) | (v << 4);
}
bool PK8::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK8::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK8::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
u8 PK8::ribbonContestCount(void) const
{
return data[0x3C];
}
void PK8::ribbonContestCount(u8 v)
{
data[0x3C] = v;
if (v)
{
// Bitflag for having at least one
ribbon(Ribbon::MemoryContest, 1);
}
else
{
// Bitflag for having at least one
ribbon(Ribbon::MemoryContest, 0);
}
}
u8 PK8::ribbonBattleCount(void) const
{
return data[0x3D];
}
void PK8::ribbonBattleCount(u8 v)
{
data[0x3D] = v;
if (v)
{
// Bitflag for having at least one
ribbon(Ribbon::MemoryBattle, 1);
}
else
{
// Bitflag for having at least one
ribbon(Ribbon::MemoryBattle, 0);
}
}
u8 PK8::height(void) const
{
return data[0x50];
}
void PK8::height(u8 v)
{
data[0x50] = v;
}
u8 PK8::weight(void) const
{
return data[0x51];
}
void PK8::weight(u8 v)
{
data[0x51] = v;
}
std::string PK8::nickname(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0x58, 13));
}
void PK8::nickname(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0x58, 13);
}
Move PK8::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x72 + m * 2)};
}
void PK8::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x72 + m * 2, u16(v));
}
u8 PK8::PP(u8 m) const
{
return data[0x7A + m];
}
void PK8::PP(u8 m, u8 v)
{
data[0x7A + m] = v;
}
u8 PK8::PPUp(u8 m) const
{
return data[0x7E + m];
}
void PK8::PPUp(u8 m, u8 v)
{
data[0x7E + m] = v;
}
Move PK8::relearnMove(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x82 + m * 2)};
}
void PK8::relearnMove(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x82 + m * 2, u16(v));
}
int PK8::partyCurrHP(void) const
{
return LittleEndian::convertTo<u16>(data + 0x8A);
}
void PK8::partyCurrHP(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x8A, v);
}
u8 PK8::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x8C);
return (u8)((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK8::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x8C);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x8C, buffer);
}
bool PK8::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x8C) >> 30) & 0x1) == 1;
}
void PK8::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x8C, (u32)((LittleEndian::convertTo<u32>(data + 0x8C) & ~0x40000000) |
(u32)(v ? 0x40000000 : 0)));
}
bool PK8::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x8C) >> 31) & 0x1) == 1;
}
void PK8::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x8C,
(LittleEndian::convertTo<u32>(data + 0x8C) & 0x7FFFFFFF) | (v ? 0x80000000 : 0));
}
u8 PK8::dynamaxLevel(void) const
{
return data[0x90];
}
void PK8::dynamaxLevel(u8 v)
{
data[0x90] = v;
}
std::string PK8::htName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0xA8, 13));
}
void PK8::htName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0xA8, 13);
}
Gender PK8::htGender(void) const
{
return Gender{data[0xC2]};
}
void PK8::htGender(Gender v)
{
data[0xC2] = u8(v);
}
Language PK8::htLanguage(void) const
{
return Language(data[0xC3]);
}
void PK8::htLanguage(Language lang)
{
data[0xC3] = u8(lang);
}
PKXHandler PK8::currentHandler(void) const
{
return data[0xC4] == 0 ? PKXHandler::OT : PKXHandler::NonOT;
}
void PK8::currentHandler(PKXHandler v)
{
data[0xC4] = v == PKXHandler::OT ? 0 : 1;
}
u16 PK8::htID(void) const
{
return LittleEndian::convertTo<u16>(data + 0xC6);
}
void PK8::htID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xC6, v);
}
u8 PK8::htFriendship(void) const
{
return data[0xC8];
}
void PK8::htFriendship(u8 v)
{
data[0xC8] = v;
}
u8 PK8::htIntensity(void) const
{
return data[0xC9];
}
void PK8::htIntensity(u8 v)
{
data[0xC9] = v;
}
u8 PK8::htMemory(void) const
{
return data[0xCA];
}
void PK8::htMemory(u8 v)
{
data[0xCA] = v;
}
u8 PK8::htFeeling(void) const
{
return data[0xCB];
}
void PK8::htFeeling(u8 v)
{
data[0xCB] = v;
}
u16 PK8::htTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xCC);
}
void PK8::htTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xCC, v);
}
u8 PK8::fullness(void) const
{
return data[0xDC];
}
void PK8::fullness(u8 v)
{
data[0xDC] = v;
}
u8 PK8::enjoyment(void) const
{
return data[0xDD];
}
void PK8::enjoyment(u8 v)
{
data[0xDD] = v;
}
GameVersion PK8::version(void) const
{
return GameVersion(data[0xDE]);
}
void PK8::version(GameVersion v)
{
data[0xDE] = u8(v);
}
u8 PK8::battleVersion(void) const
{
return data[0xDF];
}
void PK8::battleVersion(u8 v)
{
data[0xDF] = v;
}
Language PK8::language(void) const
{
return Language(data[0xE2]);
}
void PK8::language(Language v)
{
data[0xE2] = u8(v);
}
u32 PK8::formDuration(void) const
{
return LittleEndian::convertTo<u32>(data + 0xE4);
}
void PK8::formDuration(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0xE4, v);
}
s8 PK8::favRibbon(void) const
{
return data[0xE8];
}
void PK8::favRibbon(s8 v)
{
data[0xE8] = v;
}
std::string PK8::otName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0xF8, 13));
}
void PK8::otName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0xF8, 13);
}
u8 PK8::otFriendship(void) const
{
return data[0x112];
}
void PK8::otFriendship(u8 v)
{
data[0x112] = v;
}
u8 PK8::otIntensity(void) const
{
return data[0x113];
}
void PK8::otIntensity(u8 v)
{
data[0x113] = v;
}
u8 PK8::otMemory(void) const
{
return data[0x114];
}
void PK8::otMemory(u8 v)
{
data[0x114] = v;
}
u16 PK8::otTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0x116);
}
void PK8::otTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x116, v);
}
u8 PK8::otFeeling(void) const
{
return data[0x118];
}
void PK8::otFeeling(u8 v)
{
data[0x118] = v;
}
int PK8::eggYear(void) const
{
return 2000 + data[0x119];
}
void PK8::eggYear(int v)
{
data[0x119] = v - 2000;
}
int PK8::eggMonth(void) const
{
return data[0x11A];
}
void PK8::eggMonth(int v)
{
data[0x11A] = v;
}
int PK8::eggDay(void) const
{
return data[0x11B];
}
void PK8::eggDay(int v)
{
data[0x11B] = v;
}
int PK8::metYear(void) const
{
return 2000 + data[0x11C];
}
void PK8::metYear(int v)
{
data[0x11C] = v - 2000;
}
int PK8::metMonth(void) const
{
return data[0x11D];
}
void PK8::metMonth(int v)
{
data[0x11D] = v;
}
int PK8::metDay(void) const
{
return data[0x11E];
}
void PK8::metDay(int v)
{
data[0x11E] = v;
}
u16 PK8::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x120);
}
void PK8::eggLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x120, v);
}
u16 PK8::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0x122);
}
void PK8::metLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x122, v);
}
Ball PK8::ball(void) const
{
return Ball{data[0x124]};
}
void PK8::ball(Ball v)
{
data[0x124] = u8(v);
}
u8 PK8::metLevel(void) const
{
return data[0x125] & ~0x80;
}
void PK8::metLevel(u8 v)
{
data[0x125] = (data[0x125] & 0x80) | v;
}
Gender PK8::otGender(void) const
{
return Gender{u8(data[0x125] >> 7)};
}
void PK8::otGender(Gender v)
{
data[0x125] = (data[0x125] & ~0x80) | (u8(v) << 7);
}
bool PK8::hyperTrain(Stat stat) const
{
return (data[0x126] & (1 << hyperTrainLookup[size_t(stat)])) ==
1 << hyperTrainLookup[size_t(stat)];
}
void PK8::hyperTrain(Stat stat, bool v)
{
data[0x126] = (u8)((data[0x126] & ~(1 << hyperTrainLookup[size_t(stat)])) |
(v ? 1 << hyperTrainLookup[size_t(stat)] : 0));
}
bool PK8::moveRecordFlag(u8 index) const
{
return (*(data + (index >> 3)) & (index & 7)) == 1;
}
void PK8::moveRecordFlag(u8 index, bool v)
{
*(data + (index >> 3)) =
(*(data + (index >> 3)) & ~(index & 7)) | ((v ? 1 : 0) << (index & 7));
}
u64 PK8::homeTracker(void) const
{
return LittleEndian::convertTo<u64>(data + 0x135);
}
void PK8::homeTracker(u64 v)
{
LittleEndian::convertFrom<u64>(data + 0x135, v);
}
int PK8::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0x14A + u8(stat) * 2);
}
void PK8::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x14A + u8(stat) * 2, v);
}
}
int PK8::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0x148);
}
void PK8::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0x148) = v;
}
}
u16 PK8::dynamaxType(void) const
{
if (!isParty())
{
return 0;
}
return LittleEndian::convertTo<u16>(data + 0x156);
}
void PK8::dynamaxType(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0x156, v);
}
}
void PK8::refreshChecksum(void)
{
u16 chk = 0;
for (size_t i = 8; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PK8::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK8::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PK8::TSV(void) const
{
return (TID() ^ SID()) >> 4;
}
u16 PK8::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 4;
}
u8 PK8::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK8::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK8::shiny(void) const
{
return TSV() == PSV();
}
void PK8::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK8::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalSWSH::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalSWSH::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PK8::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc =
10 + ((2 * basestat) +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4 + 100) *
level() / 100;
}
else
{
calc =
5 + (2 * basestat +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4) *
level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
void PK8::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 32,765
|
C++
|
.cpp
| 1,178
| 19.085739
| 100
| 0.505622
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,281
|
PK7.cpp
|
FlagBrew_PKSM-Core/source/pkx/PK7.cpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "pkx/PK7.hpp"
#include "pkx/PK1.hpp"
#include "pkx/PK2.hpp"
#include "pkx/PK3.hpp"
#include "pkx/PK4.hpp"
#include "pkx/PK5.hpp"
#include "pkx/PK6.hpp"
#include "pkx/PK8.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
#include "utils/endian.hpp"
#include "utils/flagUtil.hpp"
#include "utils/random.hpp"
#include "utils/utils.hpp"
#define RIBBON_ABSENT 0xFFFFFFFF
namespace
{
std::pair<size_t, size_t> OFFSET_OF(pksm::Ribbon rib)
{
switch (rib)
{
case pksm::Ribbon::ChampionKalos:
return {0x30, 0};
case pksm::Ribbon::ChampionG3Hoenn:
return {0x30, 1};
case pksm::Ribbon::ChampionSinnoh:
return {0x30, 2};
case pksm::Ribbon::BestFriends:
return {0x30, 3};
case pksm::Ribbon::Training:
return {0x30, 4};
case pksm::Ribbon::BattlerSkillful:
return {0x30, 5};
case pksm::Ribbon::BattlerExpert:
return {0x30, 6};
case pksm::Ribbon::Effort:
return {0x30, 7};
case pksm::Ribbon::Alert:
return {0x31, 0};
case pksm::Ribbon::Shock:
return {0x31, 1};
case pksm::Ribbon::Downcast:
return {0x31, 2};
case pksm::Ribbon::Careless:
return {0x31, 3};
case pksm::Ribbon::Relax:
return {0x31, 4};
case pksm::Ribbon::Snooze:
return {0x31, 5};
case pksm::Ribbon::Smile:
return {0x31, 6};
case pksm::Ribbon::Gorgeous:
return {0x31, 7};
case pksm::Ribbon::Royal:
return {0x32, 0};
case pksm::Ribbon::GorgeousRoyal:
return {0x32, 1};
case pksm::Ribbon::Artist:
return {0x32, 2};
case pksm::Ribbon::Footprint:
return {0x32, 3};
case pksm::Ribbon::Record:
return {0x32, 4};
case pksm::Ribbon::Legend:
return {0x32, 5};
case pksm::Ribbon::Country:
return {0x32, 6};
case pksm::Ribbon::National:
return {0x32, 7};
case pksm::Ribbon::Earth:
return {0x33, 0};
case pksm::Ribbon::World:
return {0x33, 1};
case pksm::Ribbon::Classic:
return {0x33, 2};
case pksm::Ribbon::Premier:
return {0x33, 3};
case pksm::Ribbon::Event:
return {0x33, 4};
case pksm::Ribbon::Birthday:
return {0x33, 5};
case pksm::Ribbon::Special:
return {0x33, 6};
case pksm::Ribbon::Souvenir:
return {0x33, 7};
case pksm::Ribbon::Wishing:
return {0x34, 0};
case pksm::Ribbon::ChampionBattle:
return {0x34, 1};
case pksm::Ribbon::ChampionRegional:
return {0x34, 2};
case pksm::Ribbon::ChampionNational:
return {0x34, 3};
case pksm::Ribbon::ChampionWorld:
return {0x34, 4};
case pksm::Ribbon::MemoryContest:
return {0x34, 5};
case pksm::Ribbon::MemoryBattle:
return {0x34, 6};
case pksm::Ribbon::ChampionG6Hoenn:
return {0x34, 7};
case pksm::Ribbon::ContestStar:
return {0x35, 0};
case pksm::Ribbon::MasterCoolness:
return {0x35, 1};
case pksm::Ribbon::MasterBeauty:
return {0x35, 2};
case pksm::Ribbon::MasterCuteness:
return {0x35, 3};
case pksm::Ribbon::MasterCleverness:
return {0x35, 4};
case pksm::Ribbon::MasterToughness:
return {0x35, 5};
case pksm::Ribbon::ChampionAlola:
return {0x35, 6};
case pksm::Ribbon::BattleRoyale:
return {0x35, 7};
case pksm::Ribbon::BattleTreeGreat:
return {0x36, 0};
case pksm::Ribbon::BattleTreeMaster:
return {0x36, 1};
default:
return {RIBBON_ABSENT, 0};
}
}
}
namespace pksm
{
void PK7::encrypt(void)
{
if (!isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
refreshChecksum();
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(
data + ENCRYPTION_START, pksm::crypto::pkm::InvertedBlockPositions[sv]);
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
}
}
void PK7::decrypt(void)
{
if (isEncrypted())
{
u8 sv = (encryptionConstant() >> 13) & 31;
pksm::crypto::pkm::crypt<BOX_LENGTH - ENCRYPTION_START>(
data + ENCRYPTION_START, encryptionConstant());
if (isParty())
{
pksm::crypto::pkm::crypt<PARTY_LENGTH - BOX_LENGTH>(
data + BOX_LENGTH, encryptionConstant());
}
pksm::crypto::pkm::blockShuffle<BLOCK_LENGTH>(data + ENCRYPTION_START, sv);
}
}
bool PK7::isEncrypted() const
{
return LittleEndian::convertTo<u16>(data + 0xC8) != 0 &&
LittleEndian::convertTo<u16>(data + 0x58) != 0;
}
PK7::PK7(PrivateConstructor, u8* dt, bool party, bool direct)
: PKX(dt, party ? PARTY_LENGTH : BOX_LENGTH, direct)
{
if (isEncrypted())
{
decrypt();
}
}
std::unique_ptr<PKX> PK7::clone(void) const
{
return PKX::getPKM<Generation::SEVEN>(data, isParty() ? PARTY_LENGTH : BOX_LENGTH);
}
Generation PK7::generation(void) const
{
return Generation::SEVEN;
}
u32 PK7::encryptionConstant(void) const
{
return LittleEndian::convertTo<u32>(data);
}
void PK7::encryptionConstant(u32 v)
{
LittleEndian::convertFrom<u32>(data, v);
}
u16 PK7::sanity(void) const
{
return LittleEndian::convertTo<u16>(data + 0x04);
}
void PK7::sanity(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x04, v);
}
u16 PK7::checksum(void) const
{
return LittleEndian::convertTo<u16>(data + 0x06);
}
void PK7::checksum(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x06, v);
}
Species PK7::species(void) const
{
return Species{LittleEndian::convertTo<u16>(data + 0x08)};
}
void PK7::species(Species v)
{
LittleEndian::convertFrom<u16>(data + 0x08, u16(v));
}
u16 PK7::heldItem(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0A);
}
void PK7::heldItem(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0A, v);
}
u16 PK7::TID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0C);
}
void PK7::TID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0C, v);
}
u16 PK7::SID(void) const
{
return LittleEndian::convertTo<u16>(data + 0x0E);
}
void PK7::SID(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x0E, v);
}
u32 PK7::experience(void) const
{
return LittleEndian::convertTo<u32>(data + 0x10);
}
void PK7::experience(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x10, v);
}
Ability PK7::ability(void) const
{
return Ability{data[0x14]};
}
void PK7::ability(Ability v)
{
data[0x14] = u8(v);
}
void PK7::setAbility(u8 v)
{
u8 abilitynum;
if (v == 0)
{
abilitynum = 1;
}
else if (v == 1)
{
abilitynum = 2;
}
else
{
abilitynum = 4;
}
abilityNumber(abilitynum);
ability(abilities(v));
}
u8 PK7::abilityNumber(void) const
{
return data[0x15];
}
void PK7::abilityNumber(u8 v)
{
data[0x15] = v;
}
u16 PK7::markValue(void) const
{
return LittleEndian::convertTo<u16>(data + 0x16);
}
void PK7::markValue(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0x16, v);
}
u32 PK7::PID(void) const
{
return LittleEndian::convertTo<u32>(data + 0x18);
}
void PK7::PID(u32 v)
{
LittleEndian::convertFrom<u32>(data + 0x18, v);
}
Nature PK7::nature(void) const
{
return Nature{data[0x1C]};
}
void PK7::nature(Nature v)
{
data[0x1C] = u8(v);
}
bool PK7::fatefulEncounter(void) const
{
return (data[0x1D] & 1) == 1;
}
void PK7::fatefulEncounter(bool v)
{
data[0x1D] = (u8)((data[0x1D] & ~0x01) | (v ? 1 : 0));
}
Gender PK7::gender(void) const
{
return Gender{u8((data[0x1D] >> 1) & 0x3)};
}
void PK7::gender(Gender v)
{
data[0x1D] = (data[0x1D] & ~0x06) | (u8(v) << 1);
}
u16 PK7::alternativeForm(void) const
{
return data[0x1D] >> 3;
}
void PK7::alternativeForm(u16 v)
{
data[0x1D] = (data[0x1D] & 0x07) | (v << 3);
}
u16 PK7::ev(Stat ev) const
{
return data[0x1E + u8(ev)];
}
void PK7::ev(Stat ev, u16 v)
{
data[0x1E + u8(ev)] = v;
}
u8 PK7::contest(u8 contest) const
{
return data[0x24 + contest];
}
void PK7::contest(u8 contest, u8 v)
{
data[0x24 + contest] = v;
}
u8 PK7::pelagoEventStatus(void) const
{
return data[0x2A];
}
void PK7::pelagoEventStatus(u8 v)
{
data[0x2A] = v;
}
u8 PK7::pkrs(void) const
{
return data[0x2B];
}
void PK7::pkrs(u8 v)
{
data[0x2B] = v;
}
u8 PK7::pkrsDays(void) const
{
return data[0x2B] & 0xF;
};
void PK7::pkrsDays(u8 v)
{
data[0x2B] = (u8)((data[0x2B] & ~0xF) | v);
}
u8 PK7::pkrsStrain(void) const
{
return data[0x2B] >> 4;
};
void PK7::pkrsStrain(u8 v)
{
data[0x2B] = (u8)((data[0x2B] & 0xF) | v << 4);
}
bool PK7::hasRibbon(Ribbon ribbon) const
{
return OFFSET_OF(ribbon).first != RIBBON_ABSENT;
}
bool PK7::ribbon(Ribbon ribbon) const
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
return FlagUtil::getFlag(data, offset.first, offset.second);
}
return false;
}
void PK7::ribbon(Ribbon ribbon, bool v)
{
auto offset = OFFSET_OF(ribbon);
if (offset.first != RIBBON_ABSENT)
{
FlagUtil::setFlag(data, offset.first, offset.second, v);
}
}
u8 PK7::ribbonContestCount(void) const
{
return data[0x38];
}
void PK7::ribbonContestCount(u8 v)
{
data[0x38] = v;
}
u8 PK7::ribbonBattleCount(void) const
{
return data[0x39];
}
void PK7::ribbonBattleCount(u8 v)
{
data[0x39] = v;
}
std::string PK7::nickname(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0x40, 13));
}
void PK7::nickname(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0x40, 13);
}
Move PK7::move(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x5A + m * 2)};
}
void PK7::move(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x5A + m * 2, u16(v));
}
u8 PK7::PP(u8 m) const
{
return data[0x62 + m];
}
void PK7::PP(u8 m, u8 v)
{
data[0x62 + m] = v;
}
u8 PK7::PPUp(u8 m) const
{
return data[0x66 + m];
}
void PK7::PPUp(u8 m, u8 v)
{
data[0x66 + m] = v;
}
Move PK7::relearnMove(u8 m) const
{
return Move{LittleEndian::convertTo<u16>(data + 0x6A + m * 2)};
}
void PK7::relearnMove(u8 m, Move v)
{
LittleEndian::convertFrom<u16>(data + 0x6A + m * 2, u16(v));
}
u8 PK7::iv(Stat stat) const
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
return (u8)((buffer >> 5 * u8(stat)) & 0x1F);
}
void PK7::iv(Stat stat, u8 v)
{
u32 buffer = LittleEndian::convertTo<u32>(data + 0x74);
buffer &= ~(0x1F << 5 * u8(stat));
buffer |= v << (5 * u8(stat));
LittleEndian::convertFrom<u32>(data + 0x74, buffer);
}
bool PK7::egg(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 30) & 0x1) == 1;
}
void PK7::egg(bool v)
{
LittleEndian::convertFrom<u32>(
data + 0x74, (u32)((LittleEndian::convertTo<u32>(data + 0x74) & ~0x40000000) |
(u32)(v ? 0x40000000 : 0)));
}
bool PK7::nicknamed(void) const
{
return ((LittleEndian::convertTo<u32>(data + 0x74) >> 31) & 0x1) == 1;
}
void PK7::nicknamed(bool v)
{
LittleEndian::convertFrom<u32>(data + 0x74,
(LittleEndian::convertTo<u32>(data + 0x74) & 0x7FFFFFFF) | (v ? 0x80000000 : 0));
}
std::string PK7::htName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0x78, 13));
}
void PK7::htName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0x78, 13);
}
Gender PK7::htGender(void) const
{
return Gender{data[0x92]};
}
void PK7::htGender(Gender v)
{
data[0x92] = u8(v);
}
PKXHandler PK7::currentHandler(void) const
{
return data[0x93] == 0 ? PKXHandler::OT : PKXHandler::NonOT;
}
void PK7::currentHandler(PKXHandler v)
{
data[0x93] = v == PKXHandler::OT ? 0 : 1;
}
u8 PK7::geoRegion(u8 region) const
{
return data[0x94 + region * 2];
}
void PK7::geoRegion(u8 region, u8 v)
{
data[0x94 + region * 2] = v;
}
u8 PK7::geoCountry(u8 country) const
{
return data[0x95 + country * 2];
}
void PK7::geoCountry(u8 country, u8 v)
{
data[0x95 + country * 2] = v;
}
u8 PK7::htFriendship(void) const
{
return data[0xA2];
}
void PK7::htFriendship(u8 v)
{
data[0xA2] = v;
}
u8 PK7::htAffection(void) const
{
return data[0xA3];
}
void PK7::htAffection(u8 v)
{
data[0xA3] = v;
}
u8 PK7::htIntensity(void) const
{
return data[0xA4];
}
void PK7::htIntensity(u8 v)
{
data[0xA4] = v;
}
u8 PK7::htMemory(void) const
{
return data[0xA5];
}
void PK7::htMemory(u8 v)
{
data[0xA5] = v;
}
u8 PK7::htFeeling(void) const
{
return data[0xA6];
}
void PK7::htFeeling(u8 v)
{
data[0xA6] = v;
}
u16 PK7::htTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xA8);
}
void PK7::htTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xA8, v);
}
u8 PK7::fullness(void) const
{
return data[0xAE];
}
void PK7::fullness(u8 v)
{
data[0xAE] = v;
}
u8 PK7::enjoyment(void) const
{
return data[0xAF];
}
void PK7::enjoyment(u8 v)
{
data[0xAF] = v;
}
std::string PK7::otName(void) const
{
return StringUtils::transString67(StringUtils::getString(data, 0xB0, 13));
}
void PK7::otName(const std::string_view& v)
{
StringUtils::setString(data, StringUtils::transString67(v), 0xB0, 13);
}
u8 PK7::otFriendship(void) const
{
return data[0xCA];
}
void PK7::otFriendship(u8 v)
{
data[0xCA] = v;
}
u8 PK7::otAffection(void) const
{
return data[0xCB];
}
void PK7::otAffection(u8 v)
{
data[0xCB] = v;
}
u8 PK7::otIntensity(void) const
{
return data[0xCC];
}
void PK7::otIntensity(u8 v)
{
data[0xCC] = v;
}
u8 PK7::otMemory(void) const
{
return data[0xCD];
}
void PK7::otMemory(u8 v)
{
data[0xCD] = v;
}
u16 PK7::otTextVar(void) const
{
return LittleEndian::convertTo<u16>(data + 0xCE);
}
void PK7::otTextVar(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xCE, v);
}
u8 PK7::otFeeling(void) const
{
return data[0xD0];
}
void PK7::otFeeling(u8 v)
{
data[0xD0] = v;
}
int PK7::eggYear(void) const
{
return 2000 + data[0xD1];
}
void PK7::eggYear(int v)
{
data[0xD1] = v - 2000;
}
int PK7::eggMonth(void) const
{
return data[0xD2];
}
void PK7::eggMonth(int v)
{
data[0xD2] = v;
}
int PK7::eggDay(void) const
{
return data[0xD3];
}
void PK7::eggDay(int v)
{
data[0xD3] = v;
}
int PK7::metYear(void) const
{
return 2000 + data[0xD4];
}
void PK7::metYear(int v)
{
data[0xD4] = v - 2000;
}
int PK7::metMonth(void) const
{
return data[0xD5];
}
void PK7::metMonth(int v)
{
data[0xD5] = v;
}
int PK7::metDay(void) const
{
return data[0xD6];
}
void PK7::metDay(int v)
{
data[0xD6] = v;
}
u16 PK7::eggLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xD8);
}
void PK7::eggLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xD8, v);
}
u16 PK7::metLocation(void) const
{
return LittleEndian::convertTo<u16>(data + 0xDA);
}
void PK7::metLocation(u16 v)
{
LittleEndian::convertFrom<u16>(data + 0xDA, v);
}
Ball PK7::ball(void) const
{
return Ball{data[0xDC]};
}
void PK7::ball(Ball v)
{
data[0xDC] = u8(v);
}
u8 PK7::metLevel(void) const
{
return data[0xDD] & ~0x80;
}
void PK7::metLevel(u8 v)
{
data[0xDD] = (data[0xDD] & 0x80) | v;
}
Gender PK7::otGender(void) const
{
return Gender{u8(data[0xDD] >> 7)};
}
void PK7::otGender(Gender v)
{
data[0xDD] = (data[0xDD] & ~0x80) | (u8(v) << 7);
}
bool PK7::hyperTrain(Stat stat) const
{
return (data[0xDE] & (1 << hyperTrainLookup[size_t(stat)])) ==
1 << hyperTrainLookup[size_t(stat)];
}
void PK7::hyperTrain(Stat stat, bool v)
{
data[0xDE] = (u8)((data[0xDE] & ~(1 << hyperTrainLookup[size_t(stat)])) |
(v ? 1 << hyperTrainLookup[size_t(stat)] : 0));
}
GameVersion PK7::version(void) const
{
return GameVersion(data[0xDF]);
}
void PK7::version(GameVersion v)
{
data[0xDF] = u8(v);
}
u8 PK7::country(void) const
{
return data[0xE0];
}
void PK7::country(u8 v)
{
data[0xE0] = v;
}
u8 PK7::region(void) const
{
return data[0xE1];
}
void PK7::region(u8 v)
{
data[0xE1] = v;
}
u8 PK7::consoleRegion(void) const
{
return data[0xE2];
}
void PK7::consoleRegion(u8 v)
{
data[0xE2] = v;
}
Language PK7::language(void) const
{
return Language(data[0xE3]);
}
void PK7::language(Language v)
{
data[0xE3] = u8(v);
}
void PK7::refreshChecksum(void)
{
u16 chk = 0;
for (u8 i = 8; i < BOX_LENGTH; i += 2)
{
chk += LittleEndian::convertTo<u16>(data + i);
}
checksum(chk);
}
Type PK7::hpType(void) const
{
return Type{u8((15 *
((iv(Stat::HP) & 1) + 2 * (iv(Stat::ATK) & 1) + 4 * (iv(Stat::DEF) & 1) +
8 * (iv(Stat::SPD) & 1) + 16 * (iv(Stat::SPATK) & 1) +
32 * (iv(Stat::SPDEF) & 1)) /
63) +
1)};
}
void PK7::hpType(Type v)
{
if (v <= Type::Normal || v >= Type::Fairy)
{
return;
}
static constexpr u16 hpivs[16][6] = {
{1, 1, 0, 0, 0, 0}, // Fighting
{0, 0, 0, 1, 0, 0}, // Flying
{1, 1, 0, 1, 0, 0}, // Poison
{1, 1, 1, 1, 0, 0}, // Ground
{1, 1, 0, 0, 1, 0}, // Rock
{1, 0, 0, 1, 1, 0}, // Bug
{1, 0, 1, 1, 1, 0}, // Ghost
{1, 1, 1, 1, 1, 0}, // Steel
{1, 0, 1, 0, 0, 1}, // Fire
{1, 0, 0, 1, 0, 1}, // Water
{1, 0, 1, 1, 0, 1}, // Grass
{1, 1, 1, 1, 0, 1}, // Electric
{1, 0, 1, 0, 1, 1}, // Psychic
{1, 0, 0, 1, 1, 1}, // Ice
{1, 0, 1, 1, 1, 1}, // Dragon
{1, 1, 1, 1, 1, 1}, // Dark
};
for (u8 i = 0; i < 6; i++)
{
iv(Stat(i), (iv(Stat(i)) & 0x1E) + hpivs[u8(v) - 1][i]);
}
}
u16 PK7::TSV(void) const
{
return (TID() ^ SID()) >> 4;
}
u16 PK7::PSV(void) const
{
return ((PID() >> 16) ^ (PID() & 0xFFFF)) >> 4;
}
u8 PK7::level(void) const
{
u8 i = 1;
u8 xpType = expType();
while (experience() >= expTable(i, xpType) && ++i < 100)
{
;
}
return i;
}
void PK7::level(u8 v)
{
experience(expTable(v - 1, expType()));
}
bool PK7::shiny(void) const
{
return TSV() == PSV();
}
void PK7::shiny(bool v)
{
PID(PKX::getRandomPID(species(), gender(), version(), nature(), alternativeForm(),
abilityNumber(), v, TSV(), PID(), generation()));
}
u16 PK7::formSpecies(void) const
{
u16 tmpSpecies = u16(species());
u8 form = alternativeForm();
u8 formcount = PersonalSMUSUM::formCount(tmpSpecies);
if (form && form < formcount)
{
u16 backSpecies = tmpSpecies;
tmpSpecies = PersonalSMUSUM::formStatIndex(tmpSpecies);
if (!tmpSpecies)
{
tmpSpecies = backSpecies;
}
else
{
tmpSpecies += form - 1;
}
}
return tmpSpecies;
}
u16 PK7::statImpl(Stat stat) const
{
u16 calc;
u8 mult = 10, basestat = 0;
switch (stat)
{
case Stat::HP:
basestat = baseHP();
break;
case Stat::ATK:
basestat = baseAtk();
break;
case Stat::DEF:
basestat = baseDef();
break;
case Stat::SPD:
basestat = baseSpe();
break;
case Stat::SPATK:
basestat = baseSpa();
break;
case Stat::SPDEF:
basestat = baseSpd();
break;
}
if (stat == Stat::HP)
{
calc =
10 + ((2 * basestat) +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4 + 100) *
level() / 100;
}
else
{
calc =
5 + (2 * basestat +
((((data[0xDE] >> hyperTrainLookup[u8(stat)]) & 1) == 1) ? 31 : iv(stat)) +
ev(stat) / 4) *
level() / 100;
}
if (u8(nature()) / 5 + 1 == u8(stat))
{
mult++;
}
if (u8(nature()) % 5 + 1 == u8(stat))
{
mult--;
}
return calc * mult / 10;
}
std::unique_ptr<PK1> PK7::convertToG1(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
if (auto pk2 = pk3->convertToG2(save))
{
return pk2->convertToG1(save);
}
}
}
}
}
return nullptr;
}
std::unique_ptr<PK2> PK7::convertToG2(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
if (auto pk3 = pk4->convertToG3(save))
{
return pk3->convertToG2(save);
}
}
}
}
return nullptr;
}
std::unique_ptr<PK3> PK7::convertToG3(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
if (auto pk4 = pk5->convertToG4(save))
{
return pk4->convertToG3(save);
}
}
}
return nullptr;
}
std::unique_ptr<PK4> PK7::convertToG4(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
if (auto pk5 = pk6->convertToG5(save))
{
return pk5->convertToG4(save);
}
}
return nullptr;
}
std::unique_ptr<PK5> PK7::convertToG5(Sav& save) const
{
if (auto pk6 = convertToG6(save))
{
return pk6->convertToG5(save);
}
return nullptr;
}
std::unique_ptr<PK6> PK7::convertToG6(Sav& save) const
{
auto pk6 = PKX::getPKM<Generation::SIX>(data, PK6::BOX_LENGTH);
// markvalue field moved, clear old gen 7 data
LittleEndian::convertFrom<u16>(data + 0x16, 0);
// marks get un-expanded from two bits to one.
u16 oldMarks = markValue();
u8 newMarks = 0;
for (int i = 0; i < 6; i++)
{
// if any bits of old mark are on (including both, which is illegal), turn on new mark
newMarks |= (((oldMarks >> (i << 1)) & 3) ? 1 : 0) << i;
}
pk6->markValue(newMarks);
switch (abilityNumber())
{
case 1:
case 2:
case 4:
u8 index = abilityNumber() >> 1;
if (abilities(index) == ability())
{
pk6->ability(pk6->abilities(index));
}
}
pk6->htMemory(4);
pk6->htTextVar(0);
pk6->htIntensity(1);
pk6->htFeeling(pksm::randomNumber(0, 9));
pk6->geoCountry(0, save.country());
pk6->geoRegion(0, save.subRegion());
for (int i = 0; i < 4; i++)
{
if (pk6->move(i) > save.maxMove())
{
pk6->move(i, Move::None);
}
if (pk6->relearnMove(i) > save.maxMove())
{
pk6->relearnMove(i, Move::None);
}
}
pk6->fixMoves();
pk6->refreshChecksum();
return pk6;
}
std::unique_ptr<PK8> PK7::convertToG8(Sav& save) const
{
auto pk8 = PKX::getPKM<Generation::EIGHT>(nullptr, PK8::BOX_LENGTH);
// Note: Locale stuff does not transfer
pk8->encryptionConstant(encryptionConstant());
pk8->species(species());
pk8->TID(TID());
pk8->SID(SID());
pk8->experience(experience());
pk8->PID(PID());
if (ability() == PersonalSMUSUM::ability(formSpecies(), abilityNumber() >> 1))
{
pk8->setAbility(abilityNumber() >> 1);
}
else
{
pk8->ability(ability());
pk8->abilityNumber(abilityNumber());
}
pk8->language(language());
for (Stat stat : {Stat::HP, Stat::ATK, Stat::DEF, Stat::SPATK, Stat::SPDEF, Stat::SPD})
{
pk8->ev(stat, ev(stat));
pk8->iv(stat, iv(stat));
pk8->hyperTrain(stat, hyperTrain(stat));
}
for (size_t i = 0; i < 4; i++)
{
pk8->move(i, move(i));
pk8->PPUp(i, PPUp(i));
pk8->PP(i, PP(i));
pk8->relearnMove(i, relearnMove(i));
}
pk8->egg(egg());
pk8->nicknamed(nicknamed());
pk8->nickname(nickname());
pk8->fatefulEncounter(fatefulEncounter());
pk8->gender(gender());
pk8->otGender(otGender());
pk8->alternativeForm(alternativeForm());
pk8->nature(nature());
pk8->version(version());
pk8->otName(otName());
pk8->metDate(metDate());
pk8->eggDate(eggDate());
pk8->metLocation(metLocation());
pk8->eggLocation(eggLocation());
pk8->ball(ball());
pk8->metLevel(metLevel());
// TODO from PKHeX: set proper memories
pk8->otMemory(otMemory());
pk8->otTextVar(otTextVar());
pk8->otFeeling(otFeeling());
pk8->otIntensity(otIntensity());
pk8->pkrsStrain(pkrsStrain());
pk8->pkrsDays(pkrsDays());
for (size_t i = 0; i < 6; i++)
{
pk8->contest(i, contest(i));
}
pk8->ribbon(Ribbon::ChampionG3Hoenn, ribbon(Ribbon::ChampionG3Hoenn));
pk8->ribbon(Ribbon::ChampionSinnoh, ribbon(Ribbon::ChampionSinnoh));
pk8->ribbon(Ribbon::Effort, ribbon(Ribbon::Effort));
pk8->ribbon(Ribbon::Alert, ribbon(Ribbon::Alert));
pk8->ribbon(Ribbon::Shock, ribbon(Ribbon::Shock));
pk8->ribbon(Ribbon::Downcast, ribbon(Ribbon::Downcast));
pk8->ribbon(Ribbon::Careless, ribbon(Ribbon::Careless));
pk8->ribbon(Ribbon::Relax, ribbon(Ribbon::Relax));
pk8->ribbon(Ribbon::Snooze, ribbon(Ribbon::Snooze));
pk8->ribbon(Ribbon::Smile, ribbon(Ribbon::Smile));
pk8->ribbon(Ribbon::Gorgeous, ribbon(Ribbon::Gorgeous));
pk8->ribbon(Ribbon::Royal, ribbon(Ribbon::Royal));
pk8->ribbon(Ribbon::GorgeousRoyal, ribbon(Ribbon::GorgeousRoyal));
pk8->ribbon(Ribbon::Artist, ribbon(Ribbon::Artist));
pk8->ribbon(Ribbon::Footprint, ribbon(Ribbon::Footprint));
pk8->ribbon(Ribbon::Record, ribbon(Ribbon::Record));
pk8->ribbon(Ribbon::Legend, ribbon(Ribbon::Legend));
pk8->ribbon(Ribbon::Country, ribbon(Ribbon::Country));
pk8->ribbon(Ribbon::National, ribbon(Ribbon::National));
pk8->ribbon(Ribbon::Earth, ribbon(Ribbon::Earth));
pk8->ribbon(Ribbon::World, ribbon(Ribbon::World));
pk8->ribbon(Ribbon::Classic, ribbon(Ribbon::Classic));
pk8->ribbon(Ribbon::Premier, ribbon(Ribbon::Premier));
pk8->ribbon(Ribbon::Event, ribbon(Ribbon::Event));
pk8->ribbon(Ribbon::Birthday, ribbon(Ribbon::Birthday));
pk8->ribbon(Ribbon::Special, ribbon(Ribbon::Special));
pk8->ribbon(Ribbon::Souvenir, ribbon(Ribbon::Souvenir));
pk8->ribbon(Ribbon::Wishing, ribbon(Ribbon::Wishing));
pk8->ribbon(Ribbon::ChampionBattle, ribbon(Ribbon::ChampionBattle));
pk8->ribbon(Ribbon::ChampionRegional, ribbon(Ribbon::ChampionRegional));
pk8->ribbon(Ribbon::ChampionNational, ribbon(Ribbon::ChampionNational));
pk8->ribbon(Ribbon::ChampionWorld, ribbon(Ribbon::ChampionWorld));
pk8->ribbon(Ribbon::ChampionKalos, ribbon(Ribbon::ChampionKalos));
pk8->ribbon(Ribbon::ChampionG6Hoenn, ribbon(Ribbon::ChampionG6Hoenn));
pk8->ribbon(Ribbon::BestFriends, ribbon(Ribbon::BestFriends));
pk8->ribbon(Ribbon::Training, ribbon(Ribbon::Training));
pk8->ribbon(Ribbon::BattlerSkillful, ribbon(Ribbon::BattlerSkillful));
pk8->ribbon(Ribbon::BattlerExpert, ribbon(Ribbon::BattlerExpert));
pk8->ribbon(Ribbon::ContestStar, ribbon(Ribbon::ContestStar));
pk8->ribbon(Ribbon::MasterCoolness, ribbon(Ribbon::MasterCoolness));
pk8->ribbon(Ribbon::MasterBeauty, ribbon(Ribbon::MasterBeauty));
pk8->ribbon(Ribbon::MasterCuteness, ribbon(Ribbon::MasterCuteness));
pk8->ribbon(Ribbon::MasterCleverness, ribbon(Ribbon::MasterCleverness));
pk8->ribbon(Ribbon::MasterToughness, ribbon(Ribbon::MasterToughness));
pk8->ribbon(Ribbon::ChampionAlola, ribbon(Ribbon::ChampionAlola));
pk8->ribbon(Ribbon::BattleRoyale, ribbon(Ribbon::BattleRoyale));
pk8->ribbon(Ribbon::BattleTreeGreat, ribbon(Ribbon::BattleTreeGreat));
pk8->ribbon(Ribbon::BattleTreeMaster, ribbon(Ribbon::BattleTreeMaster));
pk8->ribbonContestCount(ribbonContestCount());
pk8->ribbonBattleCount(ribbonBattleCount());
pk8->otFriendship(otFriendship());
pk8->origNature(nature());
// TODO: remove totem forms
pk8->refreshChecksum();
return pk8;
}
int PK7::partyCurrHP(void) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF0);
}
void PK7::partyCurrHP(u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF0, v);
}
}
int PK7::partyStat(Stat stat) const
{
if (!isParty())
{
return -1;
}
return LittleEndian::convertTo<u16>(data + 0xF2 + u8(stat) * 2);
}
void PK7::partyStat(Stat stat, u16 v)
{
if (isParty())
{
LittleEndian::convertFrom<u16>(data + 0xF2 + u8(stat) * 2, v);
}
}
int PK7::partyLevel() const
{
if (!isParty())
{
return -1;
}
return *(data + 0xEC);
}
void PK7::partyLevel(u8 v)
{
if (isParty())
{
*(data + 0xEC) = v;
}
}
void PK7::updatePartyData()
{
static constexpr Stat stats[] = {
Stat::HP, Stat::ATK, Stat::DEF, Stat::SPD, Stat::SPATK, Stat::SPDEF};
for (size_t i = 0; i < 6; i++)
{
partyStat(stats[i], stat(stats[i]));
}
partyLevel(level());
partyCurrHP(stat(Stat::HP));
}
}
| 36,241
|
C++
|
.cpp
| 1,244
| 20.498392
| 100
| 0.521625
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,282
|
SavFRLG.hpp
|
FlagBrew_PKSM-Core/include/sav/SavFRLG.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVFRLG_HPP
#define SAVFRLG_HPP
#include "sav/Sav3.hpp"
namespace pksm
{
class SavFRLG : public Sav3
{
public:
explicit SavFRLG(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems3(
void) const override;
};
}
#endif
| 1,736
|
C++
|
.h
| 41
| 39.073171
| 90
| 0.707692
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,283
|
SavSUMO.hpp
|
FlagBrew_PKSM-Core/include/sav/SavSUMO.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVSUMO_HPP
#define SAVSUMO_HPP
#include "sav/Sav7.hpp"
namespace pksm
{
class SavSUMO : public Sav7
{
protected:
static constexpr u32 chkofs[37] = {0x00000, 0x00E00, 0x01000, 0x01200, 0x01400, 0x01C00,
0x02A00, 0x03A00, 0x03E00, 0x04000, 0x04200, 0x04400, 0x04600, 0x04800, 0x04E00,
0x3B400, 0x40C00, 0x40E00, 0x42000, 0x43C00, 0x4A200, 0x50800, 0x54200, 0x54400,
0x54600, 0x64C00, 0x65000, 0x65C00, 0x69C00, 0x6A000, 0x6A800, 0x6AA00, 0x6B200,
0x6B400, 0x6B600, 0x6B800, 0x6BA00};
static constexpr u32 chklen[37] = {0xDE0, 0x07C, 0x014, 0x0C0, 0x61C, 0xE00, 0xF78, 0x228,
0x104, 0x200, 0x020, 0x004, 0x058, 0x5E6, 0x36600, 0x572C, 0x008, 0x1080, 0x1A08,
0x6408, 0x6408, 0x3998, 0x100, 0x100, 0x10528, 0x204, 0xB60, 0x3F50, 0x358, 0x728,
0x200, 0x718, 0x1FC, 0x200, 0x120, 0x1C8, 0x200};
// u16 species, u16 formcount
static constexpr u16 formtable[230] = {0x0003, 0x0002, 0x0006, 0x0003, 0x0009, 0x0002,
0x000F, 0x0002, 0x0012, 0x0002, 0x0013, 0x0002, 0x0014, 0x0003, 0x0019, 0x0007, 0x001A,
0x0002, 0x001B, 0x0002, 0x001C, 0x0002, 0x0025, 0x0002, 0x0026, 0x0002, 0x0032, 0x0002,
0x0033, 0x0002, 0x0034, 0x0002, 0x0035, 0x0002, 0x0041, 0x0002, 0x004A, 0x0002, 0x004B,
0x0002, 0x004C, 0x0002, 0x0050, 0x0002, 0x0058, 0x0002, 0x0059, 0x0002, 0x005E, 0x0002,
0x0067, 0x0002, 0x0069, 0x0002, 0x0073, 0x0002, 0x007F, 0x0002, 0x0082, 0x0002, 0x008E,
0x0002, 0x0096, 0x0003, 0x00B5, 0x0002, 0x00C9, 0x001C, 0x00D0, 0x0002, 0x00D4, 0x0002,
0x00D6, 0x0002, 0x00E5, 0x0002, 0x00F8, 0x0002, 0x00FE, 0x0002, 0x0101, 0x0002, 0x0104,
0x0002, 0x011A, 0x0002, 0x012E, 0x0002, 0x012F, 0x0002, 0x0132, 0x0002, 0x0134, 0x0002,
0x0136, 0x0002, 0x013F, 0x0002, 0x0143, 0x0002, 0x014E, 0x0002, 0x015F, 0x0004, 0x0162,
0x0002, 0x0167, 0x0002, 0x016A, 0x0002, 0x0175, 0x0002, 0x0178, 0x0002, 0x017C, 0x0002,
0x017D, 0x0002, 0x017E, 0x0002, 0x017F, 0x0002, 0x0180, 0x0002, 0x0182, 0x0004, 0x019C,
0x0003, 0x019D, 0x0003, 0x01A5, 0x0002, 0x01A6, 0x0002, 0x01A7, 0x0002, 0x01AC, 0x0002,
0x01BD, 0x0002, 0x01C0, 0x0002, 0x01CC, 0x0002, 0x01DB, 0x0002, 0x01DF, 0x0006, 0x01E7,
0x0002, 0x01EC, 0x0002, 0x01ED, 0x0012, 0x0213, 0x0002, 0x0226, 0x0002, 0x022B, 0x0002,
0x0249, 0x0004, 0x024A, 0x0004, 0x0281, 0x0002, 0x0282, 0x0002, 0x0285, 0x0002, 0x0286,
0x0003, 0x0287, 0x0002, 0x0288, 0x0002, 0x0289, 0x0005, 0x0292, 0x0003, 0x029A, 0x0014,
0x029D, 0x0005, 0x029E, 0x0006, 0x029F, 0x0005, 0x02A4, 0x000A, 0x02A6, 0x0002, 0x02A9,
0x0002, 0x02C6, 0x0004, 0x02C7, 0x0004, 0x02CC, 0x0002, 0x02CE, 0x0005, 0x02CF, 0x0002,
0x02D0, 0x0002, 0x02DF, 0x0002, 0x02E2, 0x0002, 0x02E5, 0x0004, 0x02E9, 0x0002, 0x02EA,
0x0002, 0x02F2, 0x0002, 0x02F6, 0x0002, 0x0305, 0x0012, 0x0306, 0x000E, 0x030A, 0x0004,
0x0310, 0x0002, 0x0321, 0x0002};
int dexFormIndex(int species, int formct, int start) const override;
int dexFormCount(int species) const override;
public:
explicit SavSUMO(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 4,745
|
C++
|
.h
| 75
| 55.946667
| 99
| 0.681974
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,284
|
Sav.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV_HPP
#define SAV_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/GameVersion.hpp"
#include "enums/Gender.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Species.hpp"
#include "pkx/PKX.hpp"
#include "sav/Item.hpp"
#include "utils/coretypes.h"
#include "utils/DateTime.hpp"
#include "utils/SmallVector.hpp"
#include "utils/VersionTables.hpp"
#include "wcx/WCX.hpp"
#include <map>
#include <memory>
#include <set>
#include <type_traits>
#include <vector>
namespace pksm
{
class Sav
{
protected:
enum class Game
{
DP,
Pt,
HGSS,
BW,
B2W2,
XY,
ORAS,
SM,
USUM,
LGPE,
SWSH,
RS,
E,
FRLG,
RGB,
Y,
GS,
C
} game;
int Box, Party, PokeDex, WondercardData, WondercardFlags;
int PouchHeldItem, PouchKeyItem, PouchTMHM, PouchMedicine, PouchBerry;
const std::shared_ptr<u8[]> data;
const u32 length;
u32 fullLength;
[[nodiscard]] static std::unique_ptr<Sav> checkGBType(
const std::shared_ptr<u8[]>& dt, size_t length);
[[nodiscard]] static std::unique_ptr<Sav> checkGBAType(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] static std::unique_ptr<Sav> checkDSType(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] static bool validSequence(const std::shared_ptr<u8[]>& dt, size_t offset);
public:
enum class Pouch
{
NormalItem,
KeyItem,
TM,
Mail,
Medicine,
Berry,
Ball,
Battle,
Candy,
ZCrystals,
Treasure,
Ingredient,
PCItem,
RotomPower,
CatchingItem
};
enum class BadTransferReason
{
OKAY, // Indicates a transfer that should be successful
MOVE,
SPECIES,
FORM,
ABILITY,
ITEM,
BALL
};
virtual ~Sav() = default;
Sav(const std::shared_ptr<u8[]>& data, u32 length) : data(data), length(length) {}
Sav(const Sav& save) = delete;
Sav& operator=(const Sav& save) = delete;
// Readies the save for serialization in signed/encrypted form
virtual void finishEditing(void) = 0;
// Must be called to continue editing after calling finishEditing.
// Not necessary directly after construction
virtual void beginEditing(void) = 0;
[[nodiscard]] BadTransferReason invalidTransferReason(const PKX& pk) const;
[[nodiscard]] std::unique_ptr<PKX> transfer(const PKX& pk);
[[nodiscard]] static bool isValidDSSave(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] static std::unique_ptr<Sav> getSave(
const std::shared_ptr<u8[]>& dt, size_t length);
[[nodiscard]] virtual u16 TID(void) const = 0;
virtual void TID(u16 v) = 0;
[[nodiscard]] virtual u16 SID(void) const = 0;
virtual void SID(u16 v) = 0;
[[nodiscard]] virtual GameVersion version(void) const = 0;
virtual void version(GameVersion v) = 0;
[[nodiscard]] virtual Gender gender(void) const = 0;
virtual void gender(Gender v) = 0;
[[nodiscard]] virtual u8 subRegion(void) const = 0;
virtual void subRegion(u8 v) = 0;
[[nodiscard]] virtual u8 country(void) const = 0;
virtual void country(u8 v) = 0;
[[nodiscard]] virtual u8 consoleRegion(void) const = 0;
virtual void consoleRegion(u8 v) = 0;
[[nodiscard]] virtual Language language(void) const = 0;
virtual void language(Language v) = 0;
[[nodiscard]] virtual std::string otName(void) const = 0;
virtual void otName(const std::string_view& v) = 0;
[[nodiscard]] virtual u32 money(void) const = 0;
virtual void money(u32 v) = 0;
[[nodiscard]] virtual u32 BP(void) const = 0;
virtual void BP(u32 v) = 0;
[[nodiscard]] virtual u8 badges(void) const = 0;
[[nodiscard]] virtual u16 playedHours(void) const = 0;
virtual void playedHours(u16 v) = 0;
[[nodiscard]] virtual u8 playedMinutes(void) const = 0;
virtual void playedMinutes(u8 v) = 0;
[[nodiscard]] virtual u8 playedSeconds(void) const = 0;
virtual void playedSeconds(u8 v) = 0;
[[nodiscard]] u32 displayTID(void) const;
[[nodiscard]] u32 displaySID(void) const;
[[nodiscard]] virtual u8 currentBox(void) const = 0;
virtual void currentBox(u8 v) = 0;
[[nodiscard]] virtual u8 unlockedBoxes(void) const = 0;
virtual void unlockedBoxes(u8 v) = 0;
[[nodiscard]] virtual u8 legendBoxUnlockSize(void) const = 0;
[[nodiscard]] virtual u32 boxOffset(u8 box, u8 slot) const = 0;
[[nodiscard]] virtual u32 partyOffset(u8 slot) const = 0;
[[nodiscard]] virtual std::unique_ptr<PKX> pkm(u8 slot) const = 0;
virtual void pkm(const PKX& pk, u8 slot) = 0;
[[nodiscard]] virtual std::unique_ptr<PKX> pkm(u8 box, u8 slot) const = 0;
virtual void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) = 0;
virtual void trade(PKX& pk,
const Date& date = Date::today()) const = 0; // Look into bank boolean parameter
[[nodiscard]] virtual std::unique_ptr<PKX> emptyPkm() const = 0;
virtual void dex(const PKX& pk) = 0;
[[nodiscard]] virtual int dexSeen(void) const = 0;
[[nodiscard]] virtual int dexCaught(void) const = 0;
[[nodiscard]] virtual int currentGiftAmount(void) const = 0;
[[nodiscard]] virtual std::unique_ptr<WCX> mysteryGift(int pos) const = 0;
virtual void mysteryGift(const WCX& wc, int& pos) = 0;
virtual void cryptBoxData(bool crypted) = 0;
[[nodiscard]] virtual std::string boxName(u8 box) const = 0;
virtual void boxName(u8 box, const std::string_view& name) = 0;
[[nodiscard]] virtual u8 boxWallpaper(u8 box) const = 0;
virtual void boxWallpaper(u8 box, const u8 v) = 0;
[[nodiscard]] virtual u8 partyCount(void) const = 0;
virtual void partyCount(u8 count) = 0;
virtual void fixParty(void); // Has to be overridden by SavLGPE because it works stupidly
[[nodiscard]] virtual int maxSlot(void) const { return maxBoxes() * 30; }
[[nodiscard]] virtual int maxBoxes(void) const = 0;
[[nodiscard]] virtual size_t maxWondercards(void) const = 0;
[[nodiscard]] virtual Generation generation(void) const = 0;
[[nodiscard]] const std::set<int>& availableItems(void) const
{
return VersionTables::availableItems(version());
}
[[nodiscard]] const std::set<Move>& availableMoves(void) const
{
return VersionTables::availableMoves(version());
}
[[nodiscard]] const std::set<Species>& availableSpecies(void) const
{
return VersionTables::availableSpecies(version());
}
[[nodiscard]] const std::set<Ability>& availableAbilities(void) const
{
return VersionTables::availableAbilities(version());
}
[[nodiscard]] const std::set<Ball>& availableBalls(void) const
{
return VersionTables::availableBalls(version());
}
// Not guaranteed to be useful
[[nodiscard]] int maxItem() const { return VersionTables::maxItem(version()); }
[[nodiscard]] Move maxMove() const { return VersionTables::maxMove(version()); }
[[nodiscard]] Species maxSpecies() const { return VersionTables::maxSpecies(version()); }
[[nodiscard]] Ability maxAbility() const { return VersionTables::maxAbility(version()); }
[[nodiscard]] Ball maxBall() const { return VersionTables::maxBall(version()); }
[[nodiscard]] u8 formCount(Species s) const
{
return VersionTables::formCount(version(), s);
}
virtual void item(const Item& item, Pouch pouch, u16 slot) = 0;
[[nodiscard]] virtual std::unique_ptr<Item> item(Pouch pouch, u16 slot) const = 0;
[[nodiscard]] virtual SmallVector<std::pair<Pouch, int>, 15> pouches(void) const = 0;
[[nodiscard]] virtual SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const = 0;
[[nodiscard]] u32 getLength() const { return length; }
[[nodiscard]] u32 getEntireLengthIncludingFooter() const { return fullLength; }
[[nodiscard]] const std::shared_ptr<u8[]>& rawData() const { return data; }
};
}
#endif
| 10,977
|
C++
|
.h
| 229
| 39.646288
| 97
| 0.573122
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,285
|
Sav2.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav2.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV2_HPP
#define SAV2_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
#include <array>
namespace pksm
{
class Sav2 : public Sav
{
protected:
bool japanese;
bool korean;
Language lang;
GameVersion versionOfGame;
u8 maxPkmInBox, originalCurrentBox;
u32 boxSize, OFS_PARTY, OFS_PC_ITEMS, OFS_CURRENT_BOX, OFS_CURRENT_BOX_INDEX, OFS_GENDER,
OFS_BADGES, OFS_POKEDEX_CAUGHT, OFS_POKEDEX_SEEN, OFS_BOX_NAMES, OFS_TM_POUCH,
OFS_ITEMS, OFS_KEY_ITEMS, OFS_BALLS, OFS_CHECKSUM_ONE, OFS_MONEY, OFS_CHECKSUM_TWO,
OFS_CHECKSUM_END, OFS_TIME_PLAYED, OFS_PALETTE, OFS_TID, OFS_NAME;
void fixBoxes(void);
[[nodiscard]] bool getCaught(Species species) const;
void setCaught(Species species, bool caught);
[[nodiscard]] bool getSeen(Species species) const;
void setSeen(Species species, bool seen);
[[nodiscard]] static u16 calculateChecksum(u8* start, const u8* end);
std::span<const int> tmItems2() const;
public:
Sav2(const std::shared_ptr<u8[]>& data, u32 length,
std::tuple<GameVersion, Language, bool> versionAndLanguage);
[[nodiscard]] static std::tuple<GameVersion, Language, bool> getVersion(
const std::shared_ptr<u8[]>& dt);
[[nodiscard]] static bool validList(const std::shared_ptr<u8[]>& dt, size_t ofs, u8 slot);
void finishEditing(void) override;
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override { return 0; }
void SID(u16 v) override {}
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override { return 0; }
void BP(u32 v) override {}
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 boxNicknameOffset(u8 box, u8 slot) const;
[[nodiscard]] u32 boxOtNameOffset(u8 box, u8 slot) const;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] u32 partyNicknameOffset(u8 slot) const;
[[nodiscard]] u32 partyOtNameOffset(u8 slot) const;
[[nodiscard]] u32 boxStart(u8 box, bool obeyCurrentBoxMechanics = true) const;
[[nodiscard]] u32 boxDataStart(u8 box, bool obeyCurrentBoxMechanics = true) const;
[[nodiscard]] u8 nameLength(void) const;
[[nodiscard]] u8 PK2Length(void) const;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
void pkm(const PKX& pk, u8 slot) override;
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void trade(PKX& pk, const Date& date = Date::today()) const override {}
[[nodiscard]] std::unique_ptr<PKX> emptyPkm(void) const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override { return 0; }
void mysteryGift(const WCX&, int&) override {}
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override { return nullptr; }
void cryptBoxData(bool crypted) override {}
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override { return 0; }
void boxWallpaper(u8 box, u8 v) override {}
[[nodiscard]] u8 partyCount(void) const override;
[[nodiscard]] u8 boxCount(u8 box) const;
void partyCount(u8 count) override;
void boxCount(u8 box, u8 count);
void fixBox(u8 box);
void fixParty(void) override;
[[nodiscard]] int maxSlot(void) const override;
[[nodiscard]] int maxBoxes(void) const override;
[[nodiscard]] size_t maxWondercards(void) const override { return 0; }
[[nodiscard]] Generation generation(void) const override { return Generation::TWO; }
void item(const Item& tItem, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
// Gen II Item IDs
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems2(
void) const;
// apparently weird stuff happens if you ignore this
[[nodiscard]] u8 pouchEntryCount(Pouch pouch) const;
void pouchEntryCount(Pouch pouch, u8 v);
void fixItemLists(void);
};
}
#endif
| 7,734
|
C++
|
.h
| 145
| 45.641379
| 98
| 0.667816
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,286
|
SavORAS.hpp
|
FlagBrew_PKSM-Core/include/sav/SavORAS.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVORAS_HPP
#define SAVORAS_HPP
#include "sav/Sav6.hpp"
namespace pksm
{
class SavORAS : public Sav6
{
protected:
static constexpr u32 chkofs[58] = {0x00000, 0x00400, 0x01000, 0x01200, 0x01400, 0x01600,
0x01800, 0x01A00, 0x01C00, 0x01E00, 0x02000, 0x04200, 0x04400, 0x04A00, 0x05000,
0x0A000, 0x0F000, 0x14000, 0x14200, 0x14A00, 0x15000, 0x16200, 0x16A00, 0x16C00,
0x16E00, 0x17400, 0x17600, 0x17A00, 0x18200, 0x18400, 0x18600, 0x18800, 0x18A00,
0x18C00, 0x19400, 0x19A00, 0x19E00, 0x1BA00, 0x1BC00, 0x1C000, 0x1C400, 0x1CC00,
0x1E800, 0x1EC00, 0x1F400, 0x1F800, 0x20200, 0x20600, 0x20E00, 0x21C00, 0x21E00,
0x22000, 0x22E00, 0x23600, 0x23A00, 0x2B600, 0x33000, 0x67C00};
static constexpr u32 chklen[58] = {0x002C8, 0x00B90, 0x0002C, 0x00038, 0x00150, 0x00004,
0x00008, 0x001C0, 0x000BE, 0x00024, 0x02100, 0x00130, 0x00440, 0x00574, 0x04E28,
0x04E28, 0x04E28, 0x00170, 0x0061C, 0x00504, 0x011CC, 0x00644, 0x00104, 0x00004,
0x00420, 0x00064, 0x003F0, 0x0070C, 0x00180, 0x00004, 0x0000C, 0x00048, 0x00054,
0x00644, 0x005C8, 0x002F8, 0x01B40, 0x001F4, 0x003E0, 0x00216, 0x00640, 0x01A90,
0x00400, 0x00618, 0x0025C, 0x00834, 0x00318, 0x007D0, 0x00C48, 0x00078, 0x00200,
0x00C84, 0x00628, 0x00400, 0x07AD0, 0x078B0, 0x34AD0, 0x0E058};
public:
explicit SavORAS(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 2,935
|
C++
|
.h
| 55
| 47.854545
| 96
| 0.699861
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,287
|
Sav5.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav5.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV5_HPP
#define SAV5_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
namespace pksm
{
class Sav5 : public Sav
{
protected:
int PCLayout, Trainer1, Trainer2, BattleSubway, PokeDexLanguageFlags;
private:
[[nodiscard]] int dexFormIndex(int species, int formct) const;
public:
Sav5(const std::shared_ptr<u8[]>& data, u32 length) : Sav(data, length) {}
virtual void resign(void) = 0;
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override;
void unlockedBoxes(u8 v) override;
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override;
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override;
void cryptBoxData(bool crypted) override;
void cryptMysteryGiftData(void);
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, const u8 v) override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxBoxes(void) const override { return 24; }
[[nodiscard]] size_t maxWondercards(void) const override { return 12; }
[[nodiscard]] Generation generation(void) const override { return Generation::FIVE; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 5,654
|
C++
|
.h
| 110
| 44.545455
| 93
| 0.676759
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,288
|
SavXY.hpp
|
FlagBrew_PKSM-Core/include/sav/SavXY.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVXY_HPP
#define SAVXY_HPP
#include "sav/Sav6.hpp"
namespace pksm
{
class SavXY : public Sav6
{
protected:
static constexpr u32 chkofs[55] = {0x00000, 0x00400, 0x01000, 0x01200, 0x01400, 0x01600,
0x01800, 0x01A00, 0x01C00, 0x01E00, 0x02000, 0x04200, 0x04400, 0x04A00, 0x05000,
0x0A000, 0x0F000, 0x14000, 0x14200, 0x14A00, 0x15000, 0x15800, 0x16000, 0x16200,
0x16400, 0x16A00, 0x16C00, 0x17000, 0x17800, 0x17A00, 0x17C00, 0x17E00, 0x18000,
0x18200, 0x18A00, 0x19000, 0x19400, 0x1B000, 0x1B200, 0x1B400, 0x1B800, 0x1BC00,
0x1D800, 0x1DC00, 0x1E400, 0x1E800, 0x1F200, 0x1F600, 0x1FE00, 0x20C00, 0x20E00,
0x21000, 0x21E00, 0x22600, 0x57200};
static constexpr u32 chklen[55] = {0x002C8, 0x00B88, 0x0002C, 0x00038, 0x00150, 0x00004,
0x00008, 0x001C0, 0x000BE, 0x00024, 0x02100, 0x00140, 0x00440, 0x00574, 0x04E28,
0x04E28, 0x04E28, 0x00170, 0x0061C, 0x00504, 0x006A0, 0x00644, 0x00104, 0x00004,
0x00420, 0x00064, 0x003F0, 0x0070C, 0x00180, 0x00004, 0x0000C, 0x00048, 0x00054,
0x00644, 0x005C8, 0x002F8, 0x01B40, 0x001F4, 0x001F0, 0x00216, 0x00390, 0x01A90,
0x00308, 0x00618, 0x0025C, 0x00834, 0x00318, 0x007D0, 0x00C48, 0x00078, 0x00200,
0x00C84, 0x00628, 0x34AD0, 0x0E058};
public:
explicit SavXY(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 2,873
|
C++
|
.h
| 55
| 46.727273
| 96
| 0.697509
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,289
|
SavHGSS.hpp
|
FlagBrew_PKSM-Core/include/sav/SavHGSS.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVHGSS_HPP
#define SAVHGSS_HPP
#include "sav/Sav4.hpp"
namespace pksm
{
class SavHGSS : public Sav4
{
public:
explicit SavHGSS(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Sav::Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 1,701
|
C++
|
.h
| 40
| 39.5
| 95
| 0.711957
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,290
|
SavRS.hpp
|
FlagBrew_PKSM-Core/include/sav/SavRS.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVRS_HPP
#define SAVRS_HPP
#include "sav/Sav3.hpp"
namespace pksm
{
class SavRS : public Sav3
{
public:
explicit SavRS(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems3(
void) const override;
};
}
#endif
| 1,728
|
C++
|
.h
| 41
| 38.878049
| 90
| 0.706302
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,291
|
Item.hpp
|
FlagBrew_PKSM-Core/include/sav/Item.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef ITEM_HPP
#define ITEM_HPP
#include "enums/Generation.hpp"
#include "utils/coretypes.h"
#include "utils/endian.hpp"
#include "utils/SmallVector.hpp"
#include "utils/ValueConverter.hpp"
namespace pksm
{
class Item1;
class Item2;
class Item3;
class Item4;
class Item5;
class Item6;
class Item7;
class Item7b;
class Item8;
class Item
{
public:
virtual ~Item() = default;
[[nodiscard]] virtual Generation generation(void) const = 0;
[[nodiscard]] virtual u16 maxCount(void) const = 0;
[[nodiscard]] virtual u16 id(void) const = 0;
[[nodiscard]] virtual u16 count(void) const = 0;
[[nodiscard]] virtual SmallVector<u8, 4> bytes(void) const = 0;
virtual void id(u16 id) = 0;
virtual void count(u16 id) = 0;
[[nodiscard]] virtual operator Item1(void) const;
[[nodiscard]] virtual operator Item2(void) const;
[[nodiscard]] virtual operator Item3(void) const;
[[nodiscard]] virtual operator Item4(void) const;
[[nodiscard]] virtual operator Item5(void) const;
[[nodiscard]] virtual operator Item6(void) const;
[[nodiscard]] virtual operator Item7(void) const;
[[nodiscard]] virtual operator Item7b(void) const;
[[nodiscard]] virtual operator Item8(void) const;
};
class Item1 : public Item
{
private:
std::array<u8, 2> itemData;
public:
Item1(u8* data = nullptr)
{
if (data)
{
std::copy(data, data + 2, itemData.data());
}
else
{
itemData = {0, 0};
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::ONE; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFF; }
[[nodiscard]] u16 id(void) const override
{
return ItemConverter::g1ToNational(itemData[0]);
}
void id(u16 v) override { itemData[0] = ItemConverter::nationalToG1(v); }
[[nodiscard]] u16 id1(void) const { return itemData[0]; }
void id1(u16 v) { itemData[0] = u8(v); }
[[nodiscard]] u16 count(void) const override { return itemData[1]; }
void count(u16 v) override { itemData[1] = u8(v); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
return {std::span(itemData)};
}
};
class Item2 : public Item
{
private:
std::array<u8, 2> itemData;
public:
Item2(u8* data = nullptr)
{
if (data)
{
std::copy(data, data + 2, itemData.data());
}
else
{
itemData = {0, 0};
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::TWO; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFF; }
[[nodiscard]] u16 id(void) const override
{
return ItemConverter::g2ToNational(itemData[0]);
}
void id(u16 v) override { itemData[0] = ItemConverter::nationalToG2(v); }
[[nodiscard]] u16 id2(void) const { return itemData[0]; }
void id2(u16 v) { itemData[0] = u8(v); }
[[nodiscard]] u16 count(void) const override { return itemData[1]; }
void count(u16 v) override { itemData[1] = u8(v); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
return {std::span(itemData)};
}
};
class Item3 : public Item
{
private:
std::array<u8, 4> itemData;
u16 key;
public:
Item3(u8* data = nullptr, u16 securityKey = 0)
{
if (data)
{
std::copy(data, data + 4, itemData.data());
LittleEndian::convertFrom<u16>(itemData.data() + 2,
LittleEndian::convertTo<u16>(itemData.data() + 2) ^ securityKey);
key = securityKey;
}
else
{
itemData = {0, 0, 0, 0};
key = securityKey;
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::THREE; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFFFF; }
[[nodiscard]] u16 id(void) const override
{
return ItemConverter::g3ToNational(LittleEndian::convertTo<u16>(itemData.data()));
}
void id(u16 v) override
{
LittleEndian::convertFrom<u16>(itemData.data(), ItemConverter::nationalToG3(v));
}
[[nodiscard]] u16 id3(void) const { return LittleEndian::convertTo<u16>(itemData.data()); }
void id3(u16 v) { LittleEndian::convertFrom<u16>(itemData.data(), v); }
[[nodiscard]] u16 count(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data() + 2);
}
void count(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data() + 2, v); }
[[nodiscard]] u16 securityKey(void) const { return key; }
void securityKey(u16 v) { key = v; }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
std::array<u8, 4> data = itemData;
LittleEndian::convertFrom<u16>(
data.data() + 2, LittleEndian::convertTo<u16>(data.data() + 2) ^ key);
return {std::span(data)};
}
};
class Item4 : public Item
{
private:
std::array<u8, 4> itemData;
public:
Item4(u8* data = nullptr)
{
if (data)
{
std::copy(data, data + 4, itemData.data());
}
else
{
itemData = {0, 0, 0, 0};
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::FOUR; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFFFF; }
[[nodiscard]] u16 id(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data());
}
void id(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data(), v); }
[[nodiscard]] u16 count(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data() + 2);
}
void count(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data() + 2, v); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
return {std::span(itemData)};
}
};
class Item5 : public Item
{
private:
std::array<u8, 4> itemData;
public:
Item5(u8* data = nullptr)
{
if (data)
{
std::copy(data, data + 4, itemData.data());
}
else
{
itemData = {0, 0, 0, 0};
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::FIVE; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFFFF; }
[[nodiscard]] u16 id(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data());
}
void id(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data(), v); }
[[nodiscard]] u16 count(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data() + 2);
}
void count(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data() + 2, v); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
return {std::span(itemData)};
}
};
class Item6 : public Item
{
private:
std::array<u8, 4> itemData;
public:
Item6(u8* data = nullptr)
{
if (data)
{
std::copy(data, data + 4, itemData.data());
}
else
{
itemData = {0, 0, 0, 0};
}
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
using Item::operator Item7b;
using Item::operator Item8;
[[nodiscard]] Generation generation(void) const override { return Generation::SIX; }
[[nodiscard]] u16 maxCount(void) const override { return 0xFFFF; }
[[nodiscard]] u16 id(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data());
}
void id(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data(), v); }
[[nodiscard]] u16 count(void) const override
{
return LittleEndian::convertTo<u16>(itemData.data() + 2);
}
void count(u16 v) override { LittleEndian::convertFrom<u16>(itemData.data() + 2, v); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
return {std::span(itemData)};
}
};
class Item7 : public Item
{
private:
// Reference structure
// struct
// {
// unsigned int id : 10;
// unsigned int count : 10;
// unsigned int freeSpace : 10;
// unsigned int newFlag : 1;
// unsigned int reserved : 1;
// };
u32 itemData = 0;
public:
Item7(u8* data = nullptr)
{
if (data)
{
itemData = LittleEndian::convertTo<u32>(data);
}
}
[[nodiscard]] Generation generation(void) const override { return Generation::SEVEN; }
[[nodiscard]] u16 maxCount(void) const override { return 0x3FF; }
[[nodiscard]] u16 id(void) const override { return itemData & 0x3FF; }
void id(u16 v) override { itemData = ((itemData & ~0x3FF) | std::min((u32)v, (u32)0x3FF)); }
[[nodiscard]] u16 count(void) const override { return (itemData >> 10) & 0x3FF; }
void count(u16 v) override
{
itemData = (itemData & ~(0x3FF << 10)) | (std::min((u32)v, (u32)0x3FF) << 10);
}
[[nodiscard]] u16 freeSpaceIndex(void) const { return (itemData >> 20) & 0x3FF; }
void freeSpaceIndex(u16 v)
{
itemData = (itemData & ~(0x3FF << 20)) | (std::min((u32)v, (u32)0x3FF) << 20);
}
[[nodiscard]] bool newFlag(void) const { return (itemData >> 30) & 1; }
void newFlag(bool v) { itemData = (itemData & ~(1 << 30)) | (v ? 1 << 30 : 0); }
[[nodiscard]] bool reserved(void) const { return (itemData >> 31) & 1; }
void reserved(bool v) { itemData = (itemData & ~(1u << 31)) | (v ? 1u << 31 : 0); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
u8 data[4];
LittleEndian::convertFrom<u32>(data, itemData);
return {std::span(data)};
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7;
[[nodiscard]] operator Item7b(void) const override;
[[nodiscard]] operator Item8(void) const override;
};
class Item7b : public Item
{
private:
// Reference structure
// struct
// {
// unsigned int id : 15;
// unsigned int count : 15;
// unsigned int newFlag : 1;
// unsigned int reserved : 1;
// };
u32 itemData = 0;
public:
Item7b(u8* data = nullptr)
{
if (data)
{
itemData = LittleEndian::convertTo<u32>(data);
}
}
[[nodiscard]] Generation generation(void) const override { return Generation::LGPE; }
[[nodiscard]] u16 maxCount(void) const override { return 0x7FFF; }
[[nodiscard]] u16 id(void) const override { return itemData & 0x7FFF; }
void id(u16 v) override
{
itemData = ((itemData & ~0x7FFF) | std::min((u32)v, (u32)0x7FFF));
}
[[nodiscard]] u16 count(void) const override { return (itemData >> 15) & 0x7FFF; }
void count(u16 v) override
{
itemData = (itemData & ~(0x7FFF << 15)) | (std::min((u32)v, (u32)0x7FFF) << 15);
}
[[nodiscard]] bool newFlag(void) const { return (itemData >> 30) & 1; }
void newFlag(bool v) { itemData = (itemData & ~(1 << 30)) | (v ? 1 << 30 : 0); }
[[nodiscard]] bool reserved(void) const { return (itemData >> 31) & 1; }
void reserved(bool v) { itemData = (itemData & ~(1u << 31)) | (v ? 1u << 31 : 0); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
u8 data[4];
LittleEndian::convertFrom<u32>(data, itemData);
return {std::span(data)};
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item7b;
[[nodiscard]] operator Item7(void) const override;
[[nodiscard]] operator Item8(void) const override;
};
class Item8 : public Item
{
private:
// Reference structure
// struct
// {
// unsigned int id : 15;
// unsigned int count : 15;
// unsigned int newFlag : 1;
// unsigned int reserved : 1;
// };
u32 itemData = 0;
public:
Item8(u8* data = nullptr)
{
if (data)
{
itemData = LittleEndian::convertTo<u32>(data);
}
}
[[nodiscard]] Generation generation(void) const override { return Generation::SEVEN; }
[[nodiscard]] u16 maxCount(void) const override { return 0x7FFF; }
[[nodiscard]] u16 id(void) const override { return itemData & 0x7FFF; }
void id(u16 v) override
{
itemData = ((itemData & ~0x7FFF) | std::min((u32)v, (u32)0x7FFF));
}
[[nodiscard]] u16 count(void) const override { return (itemData >> 15) & 0x7FFF; }
void count(u16 v) override
{
itemData = (itemData & ~(0x7FFF << 15)) | (std::min((u32)v, (u32)0x7FFF) << 15);
}
[[nodiscard]] bool newFlag(void) const { return (itemData >> 30) & 1; }
void newFlag(bool v) { itemData = (itemData & ~(1 << 30)) | (v ? 1 << 30 : 0); }
[[nodiscard]] bool reserved(void) const { return (itemData >> 31) & 1; }
void reserved(bool v) { itemData = (itemData & ~(1u << 31)) | (v ? 1u << 31 : 0); }
[[nodiscard]] SmallVector<u8, 4> bytes(void) const override
{
u8 data[4];
LittleEndian::convertFrom<u32>(data, itemData);
return {std::span(data)};
}
using Item::operator Item1;
using Item::operator Item2;
using Item::operator Item3;
using Item::operator Item4;
using Item::operator Item5;
using Item::operator Item6;
using Item::operator Item8;
[[nodiscard]] operator Item7(void) const override;
[[nodiscard]] operator Item7b(void) const override;
};
}
#endif
| 18,687
|
C++
|
.h
| 490
| 28.92449
| 100
| 0.562151
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,292
|
SavBW.hpp
|
FlagBrew_PKSM-Core/include/sav/SavBW.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVBW_HPP
#define SAVBW_HPP
#include "sav/Sav5.hpp"
namespace pksm
{
class SavBW : public Sav5
{
private:
static constexpr u16 lengths[70] = {0x03E0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0,
0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0,
0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x0FF0, 0x09C0, 0x0534, 0x0068, 0x009C,
0x1338, 0x07C4, 0x0D54, 0x002C, 0x0658, 0x0A94, 0x01AC, 0x03EC, 0x005C, 0x01E0, 0x00A8,
0x0460, 0x1400, 0x02A4, 0x02DC, 0x034C, 0x03EC, 0x00F8, 0x02FC, 0x0094, 0x035C, 0x01CC,
0x0168, 0x00EC, 0x01B0, 0x001C, 0x04D4, 0x0034, 0x003C, 0x01AC, 0x0B90, 0x009C, 0x0850,
0x0028, 0x0284, 0x0010, 0x005C, 0x016C, 0x0040, 0x00FC, 0x008C};
static constexpr u32 chkofs[70] = {0x003E2, 0x013F2, 0x023F2, 0x033F2, 0x043F2, 0x053F2,
0x063F2, 0x073F2, 0x083F2, 0x093F2, 0x0A3F2, 0x0B3F2, 0x0C3F2, 0x0D3F2, 0x0E3F2,
0x0F3F2, 0x103F2, 0x113F2, 0x123F2, 0x133F2, 0x143F2, 0x153F2, 0x163F2, 0x173F2,
0x183F2, 0x18DC2, 0x19336, 0x1946A, 0x1959E, 0x1A93A, 0x1B1C6, 0x1BF56, 0x1C02E,
0x1C75A, 0x1D296, 0x1D4AE, 0x1D8EE, 0x1D95E, 0x1DBE2, 0x1DCAA, 0x1E162, 0x1F602,
0x1F9A6, 0x1FCDE, 0x2004E, 0x204EE, 0x205FA, 0x208FE, 0x20996, 0x20D5E, 0x20FCE,
0x2116A, 0x212EE, 0x214B2, 0x2151E, 0x21AD6, 0x21B36, 0x21C3E, 0x21EAE, 0x22A92,
0x22B9E, 0x23452, 0x2352A, 0x23886, 0x23912, 0x23A5E, 0x23C6E, 0x23D42, 0x23EFE,
0x23F9A};
static constexpr u32 blockOfs[70] = {0x00000, 0x00400, 0x01400, 0x02400, 0x03400, 0x04400,
0x05400, 0x06400, 0x07400, 0x08400, 0x09400, 0x0A400, 0x0B400, 0x0C400, 0x0D400,
0x0E400, 0x0F400, 0x10400, 0x11400, 0x12400, 0x13400, 0x14400, 0x15400, 0x16400,
0x17400, 0x18400, 0x18E00, 0x19400, 0x19500, 0x19600, 0x1AA00, 0x1B200, 0x1C000,
0x1C100, 0x1C800, 0x1D300, 0x1D500, 0x1D900, 0x1DA00, 0x1DC00, 0x1DD00, 0x1E200,
0x1F700, 0x1FA00, 0x1FD00, 0x20100, 0x20500, 0x20600, 0x20900, 0x20A00, 0x20E00,
0x21000, 0x21200, 0x21300, 0x21500, 0x21600, 0x21B00, 0x21C00, 0x21D00, 0x21F00,
0x22B00, 0x22C00, 0x23500, 0x23600, 0x23900, 0x23A00, 0x23B00, 0x23D00, 0x23E00,
0x23F00};
static constexpr u32 chkMirror[70] = {0x23F00, 0x23F02, 0x23F04, 0x23F06, 0x23F08, 0x23F0A,
0x23F0C, 0x23F0E, 0x23F10, 0x23F12, 0x23F14, 0x23F16, 0x23F18, 0x23F1A, 0x23F1C,
0x23F1E, 0x23F20, 0x23F22, 0x23F24, 0x23F26, 0x23F28, 0x23F2A, 0x23F2C, 0x23F2E,
0x23F30, 0x23F32, 0x23F34, 0x23F36, 0x23F38, 0x23F3A, 0x23F3C, 0x23F3E, 0x23F40,
0x23F42, 0x23F44, 0x23F46, 0x23F48, 0x23F4A, 0x23F4C, 0x23F4E, 0x23F50, 0x23F52,
0x23F54, 0x23F56, 0x23F58, 0x23F5A, 0x23F5C, 0x23F5E, 0x23F60, 0x23F62, 0x23F64,
0x23F66, 0x23F68, 0x23F6A, 0x23F6C, 0x23F6E, 0x23F70, 0x23F72, 0x23F74, 0x23F76,
0x23F78, 0x23F7A, 0x23F7C, 0x23F7E, 0x23F80, 0x23F82, 0x23F84, 0x23F86, 0x23F88,
0x23F9A};
public:
explicit SavBW(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 4,643
|
C++
|
.h
| 75
| 54.48
| 99
| 0.688021
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,293
|
SavUSUM.hpp
|
FlagBrew_PKSM-Core/include/sav/SavUSUM.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVUSUM_HPP
#define SAVUSUM_HPP
#include "sav/Sav7.hpp"
namespace pksm
{
class SavUSUM : public Sav7
{
protected:
static constexpr u32 chkofs[39] = {0x00000, 0x01000, 0x01200, 0x01400, 0x01600, 0x01E00,
0x02C00, 0x03C00, 0x04000, 0x04400, 0x04600, 0x04800, 0x04A00, 0x04C00, 0x05200,
0x3B800, 0x41000, 0x41200, 0x42600, 0x44200, 0x4A800, 0x50E00, 0x54800, 0x54A00,
0x54C00, 0x65200, 0x65600, 0x66200, 0x6A200, 0x6A600, 0x6AE00, 0x6B000, 0x6B800,
0x6BA00, 0x6BC00, 0x6BE00, 0x6C000, 0x6C200, 0x6C600};
static constexpr u32 chklen[39] = {0xE28, 0x7C, 0x14, 0xC0, 0x61C, 0xE00, 0xF78, 0x228,
0x30C, 0x1FC, 0x4C, 0x4, 0x58, 0x5E6, 0x36600, 0X572C, 0x8, 0x1218, 0x1A08, 0x6408,
0x6408, 0x3998, 0x100, 0x100, 0x10528, 0x204, 0xB60, 0x3F50, 0x358, 0x728, 0x200, 0x718,
0x1FC, 0x200, 0x120, 0x1C8, 0x200, 0x39C, 0x400};
// u16 species, u16 formcount
static constexpr u16 formtable[246] = {0x0003, 0x0002, 0x0006, 0x0003, 0x0009, 0x0002,
0x000F, 0x0002, 0x0012, 0x0002, 0x0013, 0x0002, 0x0014, 0x0003, 0x0019, 0x0008, 0x001A,
0x0002, 0x001B, 0x0002, 0x001C, 0x0002, 0x0025, 0x0002, 0x0026, 0x0002, 0x0032, 0x0002,
0x0033, 0x0002, 0x0034, 0x0002, 0x0035, 0x0002, 0x0041, 0x0002, 0x004A, 0x0002, 0x004B,
0x0002, 0x004C, 0x0002, 0x0050, 0x0002, 0x0058, 0x0002, 0x0059, 0x0002, 0x005E, 0x0002,
0x0067, 0x0002, 0x0069, 0x0003, 0x0073, 0x0002, 0x007F, 0x0002, 0x0082, 0x0002, 0x008E,
0x0002, 0x0096, 0x0003, 0x00B5, 0x0002, 0x00C9, 0x001C, 0x00D0, 0x0002, 0x00D4, 0x0002,
0x00D6, 0x0002, 0x00E5, 0x0002, 0x00F8, 0x0002, 0x00FE, 0x0002, 0x0101, 0x0002, 0x0104,
0x0002, 0x011A, 0x0002, 0x012E, 0x0002, 0x012F, 0x0002, 0x0132, 0x0002, 0x0134, 0x0002,
0x0136, 0x0002, 0x013F, 0x0002, 0x0143, 0x0002, 0x014E, 0x0002, 0x015F, 0x0004, 0x0162,
0x0002, 0x0167, 0x0002, 0x016A, 0x0002, 0x0175, 0x0002, 0x0178, 0x0002, 0x017C, 0x0002,
0x017D, 0x0002, 0x017E, 0x0002, 0x017F, 0x0002, 0x0180, 0x0002, 0x0182, 0x0004, 0x019C,
0x0003, 0x019D, 0x0003, 0x019E, 0x0003, 0x01A5, 0x0002, 0x01A6, 0x0002, 0x01A7, 0x0002,
0x01AC, 0x0002, 0x01BD, 0x0002, 0x01C0, 0x0002, 0x01CC, 0x0002, 0x01DB, 0x0002, 0x01DF,
0x0006, 0x01E7, 0x0002, 0x01EC, 0x0002, 0x01ED, 0x0012, 0x0213, 0x0002, 0x0226, 0x0002,
0x022B, 0x0002, 0x0249, 0x0004, 0x024A, 0x0004, 0x0281, 0x0002, 0x0282, 0x0002, 0x0285,
0x0002, 0x0286, 0x0003, 0x0287, 0x0002, 0x0288, 0x0002, 0x0289, 0x0005, 0x0292, 0x0003,
0x0298, 0x0014, 0x0299, 0x0014, 0x029A, 0x0014, 0x029D, 0x0005, 0x029E, 0x0006, 0x029F,
0x0005, 0x02A4, 0x000A, 0x02A6, 0x0002, 0x02A9, 0x0002, 0x02C6, 0x0004, 0x02C7, 0x0004,
0x02CC, 0x0002, 0x02CE, 0x0005, 0x02CF, 0x0002, 0x02D0, 0x0002, 0x02DF, 0x0002, 0x02E2,
0x0002, 0x02E5, 0x0004, 0x02E7, 0x0002, 0x02E8, 0x0002, 0x02E9, 0x0003, 0x02EA, 0x0002,
0x02F0, 0x0002, 0x02F2, 0x0002, 0x02F6, 0x0002, 0x0305, 0x0012, 0x0306, 0x000E, 0x0309,
0x0002, 0x030A, 0x0004, 0x0310, 0x0002, 0x0320, 0x0004, 0x0321, 0x0002};
int dexFormIndex(int species, int formct, int start) const override;
int dexFormCount(int species) const override;
public:
explicit SavUSUM(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 4,908
|
C++
|
.h
| 76
| 57.184211
| 100
| 0.682082
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,294
|
Sav7.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav7.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV7_HPP
#define SAV7_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
namespace pksm
{
class Sav7 : public Sav
{
protected:
int TrainerCard, Misc, PlayTime, LastViewedBox, PokeDexLanguageFlags, PCLayout;
int PouchZCrystals, BattleItems;
[[nodiscard]] virtual int dexFormIndex(int species, int formct, int start) const = 0;
[[nodiscard]] virtual int dexFormCount(int species) const = 0;
private:
void setDexFlags(int index, int gender, int shiny, int baseSpecies);
[[nodiscard]] int getDexFlags(int index, int baseSpecies) const;
bool sanitizeFormsToIterate(Species species, int& fs, int& fe, int formIn) const;
public:
Sav7(const std::shared_ptr<u8[]>& data, u32 length) : Sav(data, length) {}
virtual void resign(void) = 0;
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override;
void subRegion(u8 v) override;
[[nodiscard]] u8 country(void) const override;
void country(u8 v) override;
[[nodiscard]] u8 consoleRegion(void) const override;
void consoleRegion(u8 v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
// Actually stamps, but whatever
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override;
void unlockedBoxes(u8 v) override;
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 8; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override;
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override;
void cryptBoxData(bool crypted) override;
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, u8 v) override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxBoxes(void) const override { return 32; }
[[nodiscard]] size_t maxWondercards(void) const override { return 48; }
[[nodiscard]] Generation generation(void) const override { return Generation::SEVEN; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 6,012
|
C++
|
.h
| 115
| 45.382609
| 94
| 0.676596
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,295
|
Sav6.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav6.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV6_HPP
#define SAV6_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
namespace pksm
{
class Sav6 : public Sav
{
protected:
int TrainerCard, Trainer2, PlayTime, LastViewedBox, PokeDexLanguageFlags, EncounterCount,
PCLayout;
private:
[[nodiscard]] int dexFormIndex(int species, int formct) const;
public:
Sav6(const std::shared_ptr<u8[]>& data, u32 length) : Sav(data, length) {}
virtual void resign(void) = 0;
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override;
void subRegion(u8 v) override;
[[nodiscard]] u8 country(void) const override;
void country(u8 v) override;
[[nodiscard]] u8 consoleRegion(void) const override;
void consoleRegion(u8 v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override;
void unlockedBoxes(u8 v) override;
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 1; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override;
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override;
void cryptBoxData(bool crypted) override;
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, u8 v) override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxBoxes(void) const override { return 31; }
[[nodiscard]] size_t maxWondercards(void) const override { return 24; }
[[nodiscard]] Generation generation(void) const override { return Generation::SIX; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 5,602
|
C++
|
.h
| 110
| 44.1
| 97
| 0.677573
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,296
|
SavB2W2.hpp
|
FlagBrew_PKSM-Core/include/sav/SavB2W2.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVB2W2_HPP
#define SAVB2W2_HPP
#include "sav/Sav5.hpp"
namespace pksm
{
class SavB2W2 : public Sav5
{
private:
static constexpr u16 lengths[74] = {0x03e0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0,
0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0,
0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x0ff0, 0x09ec, 0x0534, 0x00b0, 0x00a8,
0x1338, 0x07c4, 0x0d54, 0x0094, 0x0658, 0x0a94, 0x01ac, 0x03ec, 0x005c, 0x01e0, 0x00a8,
0x0460, 0x1400, 0x02a4, 0x00e0, 0x034c, 0x04e0, 0x00f8, 0x02fc, 0x0094, 0x035c, 0x01d4,
0x01e0, 0x00f0, 0x01b4, 0x04dc, 0x0034, 0x003c, 0x01ac, 0x0b90, 0x00ac, 0x0850, 0x0284,
0x0010, 0x00a8, 0x016c, 0x0080, 0x00fc, 0x16a8, 0x0498, 0x0060, 0x00fc, 0x03e4, 0x00f0,
0x0094};
static constexpr u32 chkofs[74] = {0x003E2, 0x013F2, 0x023F2, 0x033F2, 0x043F2, 0x053F2,
0x063F2, 0x073F2, 0x083F2, 0x093F2, 0x0A3F2, 0x0B3F2, 0x0C3F2, 0x0D3F2, 0x0E3F2,
0x0F3F2, 0x103F2, 0x113F2, 0x123F2, 0x133F2, 0x143F2, 0x153F2, 0x163F2, 0x173F2,
0x183F2, 0x18DEE, 0x19336, 0x194B2, 0x195AA, 0x1A93A, 0x1B1C6, 0x1BF56, 0x1C096,
0x1C75A, 0x1D296, 0x1D4AE, 0x1D8EE, 0x1D95E, 0x1DBE2, 0x1DCAA, 0x1E162, 0x1F602,
0x1F9A6, 0x1FAE2, 0x1FE4E, 0x203E2, 0x204FA, 0x207FE, 0x20896, 0x20C5E, 0x20ED6,
0x210E2, 0x211F2, 0x213B6, 0x218DE, 0x21936, 0x21A3E, 0x21CAE, 0x22892, 0x229AE,
0x23252, 0x23586, 0x23612, 0x237AA, 0x2396E, 0x23A82, 0x23BFE, 0x252AA, 0x2579A,
0x25862, 0x259FE, 0x25DE6, 0x25EF2, 0x25FA2};
static constexpr u32 blockOfs[74] = {0x00000, 0x00400, 0x01400, 0x02400, 0x03400, 0x04400,
0x05400, 0x06400, 0x07400, 0x08400, 0x09400, 0x0A400, 0x0B400, 0x0C400, 0x0D400,
0x0E400, 0x0F400, 0x10400, 0x11400, 0x12400, 0x13400, 0x14400, 0x15400, 0x16400,
0x17400, 0x18400, 0x18E00, 0x19400, 0x19500, 0x19600, 0x1AA00, 0x1B200, 0x1C000,
0x1C100, 0x1C800, 0x1D300, 0x1D500, 0x1D900, 0x1DA00, 0x1DC00, 0x1DD00, 0x1E200,
0x1F700, 0x1FA00, 0x1FB00, 0x1FF00, 0x20400, 0x20500, 0x20800, 0x20900, 0x20D00,
0x20F00, 0x21100, 0x21200, 0x21400, 0x21900, 0x21A00, 0x21B00, 0x21D00, 0x22900,
0x22A00, 0x23300, 0x23600, 0x23700, 0x23800, 0x23A00, 0x23B00, 0x23C00, 0x25300,
0x25800, 0x25900, 0x25A00, 0x25E00, 0x25F00};
static constexpr u32 chkMirror[74] = {0x25F00, 0x25F02, 0x25F04, 0x25F06, 0x25F08, 0x25F0A,
0x25F0C, 0x25F0E, 0x25F10, 0x25F12, 0x25F14, 0x25F16, 0x25F18, 0x25F1A, 0x25F1C,
0x25F1E, 0x25F20, 0x25F22, 0x25F24, 0x25F26, 0x25F28, 0x25F2A, 0x25F2C, 0x25F2E,
0x25F30, 0x25F32, 0x25F34, 0x25F36, 0x25F38, 0x25F3A, 0x25F3C, 0x25F3E, 0x25F40,
0x25F42, 0x25F44, 0x25F46, 0x25F48, 0x25F4A, 0x25F4C, 0x25F4E, 0x25F50, 0x25F52,
0x25F54, 0x25F56, 0x25F58, 0x25F5A, 0x25F5C, 0x25F5E, 0x25F60, 0x25F62, 0x25F64,
0x25F66, 0x25F68, 0x25F6A, 0x25F6C, 0x25F6E, 0x25F70, 0x25F72, 0x25F74, 0x25F76,
0x25F78, 0x25F7A, 0x25F7C, 0x25F7E, 0x25F80, 0x25F82, 0x25F84, 0x25F86, 0x25F88,
0x25F8A, 0x25F8C, 0x25F8E, 0x25F90, 0x25FA2};
public:
explicit SavB2W2(const std::shared_ptr<u8[]>& dt);
void resign(void) override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 4,803
|
C++
|
.h
| 76
| 55.697368
| 99
| 0.689421
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,297
|
SavLGPE.hpp
|
FlagBrew_PKSM-Core/include/sav/SavLGPE.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVLGPE_HPP
#define SAVLGPE_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
namespace pksm
{
class SavLGPE : public Sav
{
protected:
static constexpr u32 chkofs[21] = {0x00000, 0x00E00, 0x01000, 0x01200, 0x02A00, 0x04C00,
0x05600, 0x05800, 0x05A00, 0x05C00, 0x45400, 0x45600, 0x46600, 0x47800, 0x47A00,
0x4DC00, 0x4DE00, 0x4E000, 0x4E200, 0xB7A00, 0xB7C00};
static constexpr u32 chklen[21] = {0xD90, 0x200, 0x168, 0x1800, 0x20E8, 0x930, 0x004, 0x130,
0x012, 0x3F7A0, 0x008, 0xE90, 0x10A4, 0x0F0, 0x6010, 0x200, 0x098, 0x068, 0x69780,
0x0B0, 0x940};
static constexpr u16 formtable[62] = {3, 2, 6, 3, 9, 2, 15, 2, 18, 2, 19, 2, 20, 2, 26, 2,
27, 2, 28, 2, 37, 2, 38, 2, 50, 2, 51, 2, 52, 2, 53, 2, 65, 2, 74, 2, 75, 2, 76, 2, 80,
2, 88, 2, 89, 2, 94, 2, 103, 2, 105, 2, 115, 2, 127, 2, 130, 2, 142, 2, 150, 3};
int dexFormIndex(int species, int formct, int start) const;
int dexFormCount(int species) const;
int getDexFlags(int index, int baseSpecies) const;
void setDexFlags(int index, int gender, int shiny, int baseSpecies);
bool sanitizeFormsToIterate(Species species, int& fs, int& fe, int formIn) const;
public:
SavLGPE(const std::shared_ptr<u8[]>& dt, size_t length);
void resign(void);
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u16 boxedPkm(void) const;
void boxedPkm(u16 v);
[[nodiscard]] u16 followPkm(void) const;
void followPkm(u16 v);
[[nodiscard]] u16 partyBoxSlot(u8 slot) const;
void partyBoxSlot(u8 slot, u16 v);
void compressBox(void);
void fixParty(void) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override { return 0; }
void BP(u32) override {}
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override { return 0; }
void currentBox(u8) override {}
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8 v) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
// Will never be encrypted: part of normal box stuff
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a pkx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override { return 0; } // Data not stored
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(
int pos) const override; // Always returns null: Data not stored
void cryptBoxData(bool crypted) override;
[[nodiscard]] std::string boxName(u8) const override
{
return "";
} // There are no actual boxes. They are emulated for interface compatibility
void boxName(u8, const std::string_view&) override {}
[[nodiscard]] u8 boxWallpaper(u8) const override { return 0; }
void boxWallpaper(u8, u8) override {}
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxSlot(void) const override { return 1000; }
[[nodiscard]] int maxBoxes(void) const override
{
return 34;
} // ish; stupid 1000-slot list makes this dumb
[[nodiscard]] size_t maxWondercards(void) const override { return 1; } // Data not stored
[[nodiscard]] Generation generation(void) const override { return Generation::LGPE; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
};
}
#endif
| 7,473
|
C++
|
.h
| 139
| 46.028777
| 100
| 0.65679
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,298
|
SavDP.hpp
|
FlagBrew_PKSM-Core/include/sav/SavDP.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVDP_HPP
#define SAVDP_HPP
#include "sav/Sav4.hpp"
namespace pksm
{
class SavDP : public Sav4
{
public:
explicit SavDP(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Sav::Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 1,693
|
C++
|
.h
| 40
| 39.3
| 95
| 0.710558
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,299
|
SavE.hpp
|
FlagBrew_PKSM-Core/include/sav/SavE.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVE_HPP
#define SAVE_HPP
#include "sav/Sav3.hpp"
namespace pksm
{
class SavE : public Sav3
{
public:
explicit SavE(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems3(
void) const override;
};
}
#endif
| 1,724
|
C++
|
.h
| 41
| 38.780488
| 90
| 0.705602
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,300
|
SavSWSH.hpp
|
FlagBrew_PKSM-Core/include/sav/SavSWSH.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVSWSH_HPP
#define SAVSWSH_HPP
#include "sav/Sav8.hpp"
namespace pksm
{
class SavSWSH : public Sav8
{
private:
int ArmorDex, CrownDex;
static constexpr std::array<u16, 25> gigaSpecies = {6, 12, 25, 52, 68, 94, 99, 131, 133,
143, 569, 823, 826, 834, 839, 841, 842, 844, 851, 858, 861, 869, 879, 884, 890};
public:
static constexpr size_t SIZE_G8SWSH = 0x1716B3; // 1.0
static constexpr size_t SIZE_G8SWSH_1 = 0x17195E; // 1.0 -> 1.1
static constexpr size_t SIZE_G8SWSH_2 = 0x180B19; // 1.0 -> 1.1 -> 1.2
static constexpr size_t SIZE_G8SWSH_2B = 0x180AD0; // 1.0 -> 1.2
static constexpr size_t SIZE_G8SWSH_3 = 0x1876B1; // 1.0 -> 1.1 -> 1.2 -> 1.3
static constexpr size_t SIZE_G8SWSH_3A = 0x187693; // 1.0 -> 1.1 -> 1.3
static constexpr size_t SIZE_G8SWSH_3B = 0x187668; // 1.0 -> 1.2 -> 1.3
static constexpr size_t SIZE_G8SWSH_3C = 0x18764A; // 1.0 -> 1.3
SavSWSH(const std::shared_ptr<u8[]>& dt, size_t length);
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string jerseyNum(void) const;
void jerseyNum(const std::string_view& v);
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
// TODO: last saved time
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] u8 subRegion(void) const override { return 0; } // Not applicable
void subRegion(u8) override {} // Not applicable
[[nodiscard]] u8 country(void) const override { return 0; } // Not applicable
void country(u8) override {} // Not applicable
[[nodiscard]] u8 consoleRegion(void) const override { return 0; } // Not applicable
void consoleRegion(u8) override {} // Not applicable
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8) override;
// TODO: CHECK WHERE THIS IS ACTUALLY STORED
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8 v) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void cryptBoxData(bool crypted) override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
// Check whether gifts are stored, or whether some disgusting record system is used
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int) const override;
};
}
#endif
| 6,172
|
C++
|
.h
| 114
| 47.061404
| 96
| 0.66302
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,301
|
Sav4.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav4.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV4_HPP
#define SAV4_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
#include "utils/SmallVector.hpp"
namespace pksm
{
class Sav4 : public Sav
{
protected:
int Trainer1;
int MailItems, PouchBalls, BattleItems;
int GBOOffset, SBOOffset;
int PalPark;
int gbo = -1;
int sbo = -1;
void GBO(void);
void SBO(void);
[[nodiscard]] bool checkInsertForm(SmallVector<u8, 0x20>& forms, u8 formNum);
[[nodiscard]] SmallVector<u8, 0x20> getForms(Species species);
[[nodiscard]] SmallVector<u8, 0x20> getDexFormValues(u32 v, u8 bitsPerForm, u8 readCt);
void setForms(SmallVector<u8, 0x20> forms, Species species);
[[nodiscard]] u32 setDexFormValues(SmallVector<u8, 0x20> forms, u8 bitsPerForm, u8 readCt);
enum class CountType
{
FIRST,
SECOND,
SAME
};
[[nodiscard]] static CountType compareCounters(u32 c1, u32 c2);
public:
Sav4(const std::shared_ptr<u8[]>& data, u32 length) : Sav(data, length) {}
void resign(void);
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8 v) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void pkm(const PKX& pk, u8 slot) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override;
[[nodiscard]] bool giftsMenuActivated(void) const;
void giftsMenuActivated(bool v);
void mysteryGift(const WCX& wc, int& pos) override;
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override;
void cryptBoxData(bool crypted) override;
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, const u8 v) override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxBoxes(void) const override { return 18; }
[[nodiscard]] size_t maxWondercards(void) const override { return 8; }
[[nodiscard]] Generation generation(void) const override { return Generation::FOUR; }
[[nodiscard]] int getGBO(void) const { return gbo; }
[[nodiscard]] int getSBO(void) const { return sbo; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
void palPark(std::span<std::unique_ptr<PK4>, 6> mons);
void palPark(std::span<std::unique_ptr<PK4>, 0> mons);
[[nodiscard]] std::optional<std::array<std::unique_ptr<PK4>, 6>> palPark(void) const;
};
}
#endif
| 6,672
|
C++
|
.h
| 133
| 42.81203
| 99
| 0.664719
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,302
|
Sav1.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav1.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV1_HPP
#define SAV1_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
#include <array>
namespace pksm
{
class Sav1 : public Sav
{
protected:
bool japanese;
Language lang;
GameVersion versionOfGame = GameVersion::RD; // not even PKHeX tries to do better
u8 maxPkmInBox, originalCurrentBox;
u16 boxSize, mainDataLength, bankBoxesSize, OFS_DEX_CAUGHT, OFS_DEX_SEEN, OFS_BAG,
OFS_MONEY, OFS_BADGES, OFS_TID, OFS_PC_ITEMS, OFS_CURRENT_BOX_INDEX, OFS_HOURS,
OFS_PARTY, OFS_CURRENT_BOX, OFS_MAIN_DATA_SUM, OFS_BANK2_BOX_SUMS, OFS_BANK3_BOX_SUMS;
void fixBoxes(void);
[[nodiscard]] bool getCaught(Species species) const;
void setCaught(Species species, bool caught);
[[nodiscard]] bool getSeen(Species species) const;
void setSeen(Species species, bool seen);
public:
Sav1(const std::shared_ptr<u8[]>& data, u32 length);
[[nodiscard]] static Game getVersion(const std::shared_ptr<u8[]>& dt);
void finishEditing(void) override;
void beginEditing(void) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override { return 0; }
void SID(u16 v) override {}
[[nodiscard]] GameVersion version(void) const override { return versionOfGame; }
void version(GameVersion v) override { versionOfGame = v; };
[[nodiscard]] Gender gender(void) const override { return Gender::Male; }
void gender(Gender v) override {}
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override { return 0; }
void BP(u32 v) override {}
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 boxNicknameOffset(u8 box, u8 slot) const;
[[nodiscard]] u32 boxOtNameOffset(u8 box, u8 slot) const;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] u32 partyNicknameOffset(u8 slot) const;
[[nodiscard]] u32 partyOtNameOffset(u8 slot) const;
[[nodiscard]] u32 boxStart(u8 box, bool obeyCurrentBoxMechanics = true) const;
[[nodiscard]] u32 boxDataStart(u8 box, bool obeyCurrentBoxMechanics = true) const;
[[nodiscard]] u8 nameLength(void) const;
[[nodiscard]] u8 PK1Length(void) const;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
void pkm(const PKX& pk, u8 slot) override;
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void trade(PKX& pk, const Date& date = Date::today()) const override {}
[[nodiscard]] std::unique_ptr<PKX> emptyPkm(void) const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override { return 0; }
void mysteryGift(const WCX&, int&) override {}
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override { return nullptr; }
void cryptBoxData(bool crypted) override {}
[[nodiscard]] std::string boxName(u8 box) const override
{
return "Box " + std::to_string(box + 1);
}
void boxName(u8 box, const std::string_view& name) override {}
[[nodiscard]] u8 boxWallpaper(u8 box) const override { return 0; }
void boxWallpaper(u8 box, u8 v) override {}
[[nodiscard]] u8 partyCount(void) const override;
[[nodiscard]] u8 boxCount(u8 box) const;
void partyCount(u8 count) override;
void boxCount(u8 box, u8 count);
void fixBox(u8 box);
void fixParty(void) override;
[[nodiscard]] int maxSlot(void) const override;
[[nodiscard]] int maxBoxes(void) const override;
[[nodiscard]] size_t maxWondercards(void) const override { return 0; }
[[nodiscard]] Generation generation(void) const override { return Generation::ONE; }
void item(const Item& tItem, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
// Gen I Item IDs
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems1(
void) const;
void fixItemLists(void);
};
}
#endif
| 7,317
|
C++
|
.h
| 138
| 45.456522
| 98
| 0.666293
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,303
|
Sav8.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav8.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV8_HPP
#define SAV8_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
#include "utils/crypto.hpp"
namespace pksm
{
class Sav8 : public Sav
{
protected:
std::vector<std::shared_ptr<pksm::crypto::swsh::SCBlock>> blocks;
int Items, BoxLayout, Misc, TrainerCard, PlayTime, Status;
bool encrypted = false;
public:
Sav8(const std::shared_ptr<u8[]>& dt, size_t length);
[[nodiscard]] std::shared_ptr<pksm::crypto::swsh::SCBlock> getBlock(u32 key) const;
void finishEditing(void) override;
void beginEditing(void) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
[[nodiscard]] int maxBoxes(void) const override { return 32; }
[[nodiscard]] size_t maxWondercards(void) const override { return 1; } // Data not stored
[[nodiscard]] int currentGiftAmount(void) const override { return 0; } // Data not stored
[[nodiscard]] Generation generation(void) const override { return Generation::EIGHT; }
};
}
#endif
| 2,418
|
C++
|
.h
| 52
| 42.384615
| 97
| 0.701956
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,304
|
Sav3.hpp
|
FlagBrew_PKSM-Core/include/sav/Sav3.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAV3_HPP
#define SAV3_HPP
#include "personal/personal.hpp"
#include "sav/Sav.hpp"
#include <array>
namespace pksm
{
class Sav3 : public Sav
{
protected:
bool japanese;
int OFS_PCItem, OFS_PouchHeldItem, OFS_PouchKeyItem, OFS_PouchBalls, OFS_PouchTMHM,
OFS_PouchBerry, eventFlag;
void initialize();
[[nodiscard]] static u16 calculateChecksum(std::span<const u8> data);
static constexpr int BLOCK_COUNT = 14;
static constexpr int SIZE_RESERVED =
0x10000; // unpacked box data will start after the save data
static constexpr int SIZE_BLOCK_USED = 0xF80;
std::array<int, BLOCK_COUNT> blockOrder, blockOfs;
SmallVector<int, 3> seenFlagOffsets;
void loadBlocks();
[[nodiscard]] static std::array<int, BLOCK_COUNT> getBlockOrder(
const std::shared_ptr<u8[]>& dt, int ofs);
[[nodiscard]] static int getActiveSaveIndex(const std::shared_ptr<u8[]>& dt,
std::array<int, BLOCK_COUNT>& blockOrder1, std::array<int, BLOCK_COUNT>& blockOrder2);
static constexpr u16 chunkLength[BLOCK_COUNT] = {
0xf2c, // 0 | Small Block (Trainer Info)
0xf80, // 1 | Large Block Part 1
0xf80, // 2 | Large Block Part 2
0xf80, // 3 | Large Block Part 3
0xf08, // 4 | Large Block Part 4
0xf80, // 5 | PC Block 0
0xf80, // 6 | PC Block 1
0xf80, // 7 | PC Block 2
0xf80, // 8 | PC Block 3
0xf80, // 9 | PC Block 4
0xf80, // A | PC Block 5
0xf80, // B | PC Block 6
0xf80, // C | PC Block 7
0x7d0 // D | PC Block 8
};
[[nodiscard]] int ABO() const { return activeSAV * SIZE_BLOCK * BLOCK_COUNT; };
int activeSAV;
[[nodiscard]] u32 securityKey() const;
[[nodiscard]] bool getEventFlag(int flagNumber) const;
void setEventFlag(int flagNumber, bool value);
[[nodiscard]] bool canSetDex(Species species);
[[nodiscard]] u32 dexPIDUnown(void);
void dexPIDUnown(u32 v);
[[nodiscard]] u32 dexPIDSpinda(void);
void dexPIDSpinda(u32 v);
[[nodiscard]] bool getCaught(Species species) const;
void setCaught(Species species, bool caught);
[[nodiscard]] bool getSeen(Species species) const;
void setSeen(Species species, bool seen);
Sav3(const std::shared_ptr<u8[]>& data, SmallVector<int, 3>&& seenFlagOffsets);
public:
static constexpr int SIZE_BLOCK = 0x1000;
[[nodiscard]] static Game getVersion(const std::shared_ptr<u8[]>& dt);
void resign(void);
void finishEditing(void) override { resign(); }
void beginEditing(void) override {}
[[nodiscard]] u8* getBlock(size_t blockNum) { return &data[blockOfs[blockNum]]; }
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender v) override;
[[nodiscard]] u8 subRegion(void) const override { return 0; }
void subRegion(u8) override {}
[[nodiscard]] u8 country(void) const override { return 0; }
void country(u8) override {}
[[nodiscard]] u8 consoleRegion(void) const override { return 0; }
void consoleRegion(u8) override {}
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u32 money(void) const override;
void money(u32 v) override;
[[nodiscard]] u32 BP(void) const override;
void BP(u32 v) override;
[[nodiscard]] u8 badges(void) const override;
[[nodiscard]] u16 playedHours(void) const override;
void playedHours(u16 v) override;
[[nodiscard]] u8 playedMinutes(void) const override;
void playedMinutes(u8 v) override;
[[nodiscard]] u8 playedSeconds(void) const override;
void playedSeconds(u8 v) override;
[[nodiscard]] u8 currentBox(void) const override;
void currentBox(u8 v) override;
[[nodiscard]] u8 unlockedBoxes(void) const override { return maxBoxes(); }
void unlockedBoxes(u8) override {}
[[nodiscard]] u8 legendBoxUnlockSize(void) const override { return 0; }
// Note: a Pokemon may be split up into two pieces! That will happen if RETURNVALUE % 0x1000
// + PK3::BOX_LENGTH > 0xF80 In this case, the first 0xF80 - RETURNVALUE bytes of a Pokemon
// should be written to the returned offset, with the remainder written to offset
// boxOffset(box + (slot + 1) / 30, (slot + 1) % 30) & 0xFFFFF000
[[nodiscard]] u32 boxOffset(u8 box, u8 slot) const override;
[[nodiscard]] u32 partyOffset(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 slot) const override;
[[nodiscard]] std::unique_ptr<PKX> pkm(u8 box, u8 slot) const override;
// NOTICE: this sets a pkx into the savefile, not a ekx
// that's because PKSM works with decrypted boxes and
// crypts them back during resigning
void pkm(const PKX& pk, u8 slot) override;
void pkm(const PKX& pk, u8 box, u8 slot, bool applyTrade) override;
void trade(PKX& pk, const Date& date = Date::today()) const override;
[[nodiscard]] std::unique_ptr<PKX> emptyPkm() const override;
void dex(const PKX& pk) override;
[[nodiscard]] int dexSeen(void) const override;
[[nodiscard]] int dexCaught(void) const override;
[[nodiscard]] int currentGiftAmount(void) const override { return 0; }
void mysteryGift(const WCX&, int&) override {}
[[nodiscard]] std::unique_ptr<WCX> mysteryGift(int pos) const override;
void cryptBoxData(bool crypted) override;
[[nodiscard]] std::string boxName(u8 box) const override;
void boxName(u8 box, const std::string_view& name) override;
[[nodiscard]] u8 boxWallpaper(u8 box) const override;
void boxWallpaper(u8 box, u8 v) override;
[[nodiscard]] u8 partyCount(void) const override;
void partyCount(u8 count) override;
[[nodiscard]] int maxBoxes(void) const override { return 14; }
[[nodiscard]] size_t maxWondercards(void) const override { return 0; }
[[nodiscard]] Generation generation(void) const override { return Generation::THREE; }
void item(const Item& item, Pouch pouch, u16 slot) override;
[[nodiscard]] std::unique_ptr<Item> item(Pouch pouch, u16 slot) const override;
[[nodiscard]] SmallVector<std::pair<Pouch, int>, 15> pouches(void) const override;
// G3 item IDs
[[nodiscard]] virtual SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems3(
void) const = 0;
[[nodiscard]] u16 rtcInitialDay(void) const;
void rtcInitialDay(u16 v);
[[nodiscard]] u8 rtcInitialHour(void) const;
void rtcInitialHour(u8 v);
[[nodiscard]] u8 rtcInitialMinute(void) const;
void rtcInitialMinute(u8 v);
[[nodiscard]] u8 rtcInitialSecond(void) const;
void rtcInitialSecond(u8 v);
[[nodiscard]] u16 rtcElapsedDay(void) const;
void rtcElapsedDay(u16 v);
[[nodiscard]] u8 rtcElapsedHour(void) const;
void rtcElapsedHour(u8 v);
[[nodiscard]] u8 rtcElapsedMinute(void) const;
void rtcElapsedMinute(u8 v);
[[nodiscard]] u8 rtcElapsedSecond(void) const;
void rtcElapsedSecond(u8 v);
};
}
#endif
| 9,236
|
C++
|
.h
| 179
| 43.396648
| 100
| 0.650533
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,305
|
SavPT.hpp
|
FlagBrew_PKSM-Core/include/sav/SavPT.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SAVPT_HPP
#define SAVPT_HPP
#include "sav/Sav4.hpp"
namespace pksm
{
class SavPT : public Sav4
{
public:
explicit SavPT(const std::shared_ptr<u8[]>& dt);
[[nodiscard]] SmallVector<std::pair<Pouch, std::span<const int>>, 15> validItems(
void) const override;
[[nodiscard]] SmallVector<std::pair<Sav::Pouch, int>, 15> pouches(void) const override;
};
}
#endif
| 1,693
|
C++
|
.h
| 40
| 39.3
| 95
| 0.710558
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,306
|
personal.hpp
|
FlagBrew_PKSM-Core/include/personal/personal.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PERSONAL_HPP
#define PERSONAL_HPP
#include "enums/Ability.hpp"
#include "enums/Type.hpp"
#include "utils/coretypes.h"
namespace pksm
{
namespace PersonalLGPE
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalSMUSUM
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalXYORAS
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalBWB2W2
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalDPPtHGSS
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalSWSH
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u16 formStatIndex(u16 formSpecies);
[[nodiscard]] u8 formCount(u16 formSpecies);
[[nodiscard]] u16 pokedexIndex(u16 formSpecies);
[[nodiscard]] u16 armordexIndex(u16 species);
[[nodiscard]] u16 crowndexIndex(u16 species);
[[nodiscard]] bool canLearnTR(u16 formSpecies, u8 trID);
}
namespace PersonalRSFRLGE
{
[[nodiscard]] u8 baseHP(u16 formSpecies);
[[nodiscard]] u8 baseAtk(u16 formSpecies);
[[nodiscard]] u8 baseDef(u16 formSpecies);
[[nodiscard]] u8 baseSpe(u16 formSpecies);
[[nodiscard]] u8 baseSpa(u16 formSpecies);
[[nodiscard]] u8 baseSpd(u16 formSpecies);
[[nodiscard]] Type type1(u16 formSpecies);
[[nodiscard]] Type type2(u16 formSpecies);
[[nodiscard]] u8 gender(u16 formSpecies);
[[nodiscard]] u8 baseFriendship(u16 formSpecies);
[[nodiscard]] u8 expType(u16 formSpecies);
[[nodiscard]] Ability ability(u16 formSpecies, u8 n);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalGSC
{
[[nodiscard]] u8 baseHP(u8 species);
[[nodiscard]] u8 baseAtk(u8 species);
[[nodiscard]] u8 baseDef(u8 species);
[[nodiscard]] u8 baseSpe(u8 species);
[[nodiscard]] u8 baseSpa(u8 species);
[[nodiscard]] u8 baseSpd(u8 species);
[[nodiscard]] Type type1(u8 species);
[[nodiscard]] Type type2(u8 species);
[[nodiscard]] u8 gender(u8 species);
[[nodiscard]] u8 expType(u8 species);
[[nodiscard]] u8 formCount(u16 formSpecies);
}
namespace PersonalRGBY
{
[[nodiscard]] u8 baseHP(u8 species);
[[nodiscard]] u8 baseAtk(u8 species);
[[nodiscard]] u8 baseDef(u8 species);
[[nodiscard]] u8 baseSpe(u8 species);
[[nodiscard]] u8 baseSpad(u8 species);
[[nodiscard]] Type type1(u8 species);
[[nodiscard]] Type type2(u8 species);
[[nodiscard]] u8 catchRate(u8 species);
[[nodiscard]] u8 expType(u8 species);
}
}
#endif
| 8,069
|
C++
|
.h
| 182
| 37.225275
| 76
| 0.656889
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,307
|
SmallVector.hpp
|
FlagBrew_PKSM-Core/include/utils/SmallVector.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SMALLVECTOR_HPP
#define SMALLVECTOR_HPP
#include <algorithm>
#include <compare>
#include <cstdint>
#include <iterator>
#include <memory>
#include <span>
#include <type_traits>
template <typename T, std::size_t Size>
requires std::same_as<T, std::remove_cvref_t<T>> && (Size > 0) && std::is_destructible_v<T>
class SmallVector
{
private:
template <typename U, std::size_t OSize>
requires std::same_as<U, std::remove_cvref_t<U>> && (OSize > 0) && std::is_destructible_v<U>
friend class SmallVector;
// Once again, I really wish anonymous structures were a thing
// This allows the data array to have its lifetime start without its elements' lifetime starting
union SVData
{
struct SubData
{
T data[Size];
std::size_t populated;
} data;
constexpr SVData() { data.populated = 0; }
constexpr ~SVData() {}
} alldata;
constexpr std::size_t& populated() { return alldata.data.populated; }
constexpr std::size_t populated() const { return alldata.data.populated; }
static constexpr bool nothrow_movable =
std::is_nothrow_move_constructible_v<T> &&
(!std::is_move_assignable_v<T> || std::is_nothrow_move_assignable_v<T>);
static constexpr bool nothrow_copyable =
std::is_nothrow_copy_constructible_v<T> &&
(!std::is_copy_assignable_v<T> || std::is_nothrow_copy_assignable_v<T>);
static constexpr void nothrow_migrate(T* dest, T&& src) noexcept(nothrow_movable)
{
if constexpr (std::is_nothrow_move_assignable_v<T> ||
(std::is_move_assignable_v<T> && !std::is_nothrow_move_constructible_v<T>))
{
*dest = std::forward<T&&>(src);
}
else
{
std::destroy_at(dest);
std::construct_at(dest, std::forward<T&&>(src));
}
}
static constexpr void nothrow_migrate(T* dest, const T& src) noexcept(nothrow_copyable)
{
if constexpr (std::is_nothrow_copy_assignable_v<T> ||
(std::is_copy_assignable_v<T> && !std::is_nothrow_copy_constructible_v<T>))
{
*dest = std::forward<const T&>(src);
}
else
{
std::destroy_at(dest);
std::construct_at(dest, std::forward<const T&>(src));
}
}
public:
using value_type = T;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using reference = value_type&;
using const_reference = const value_type&;
using pointer = value_type*;
using const_pointer = const value_type*;
using iterator = T*;
using const_iterator = const T*;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
constexpr SmallVector() = default;
constexpr ~SmallVector() noexcept(std::is_nothrow_destructible_v<T>)
{
std::destroy_n(data(), size());
}
template <std::size_t OSize = Size>
requires (OSize <= Size) && std::is_copy_constructible_v<T>
constexpr SmallVector(const SmallVector<T, OSize>& o) noexcept(noexcept(emplace_back(o[0])))
{
for (std::size_t i = 0; i < o.size(); i++)
{
emplace_back(o[i]);
}
}
template <std::size_t OSize = Size>
requires (OSize <= Size) && std::is_move_constructible_v<T>
constexpr SmallVector(SmallVector<T, OSize>&& o) noexcept(
noexcept(emplace_back(std::move(o[0]))) && std::is_nothrow_destructible_v<T>)
{
for (std::size_t i = 0; i < o.size(); i++)
{
emplace_back(std::move(o[i]));
}
std::destroy_n(o.data(), o.size());
o.populated() = 0;
}
template <std::size_t OSize = Size>
requires (OSize <= Size) && std::is_copy_constructible_v<T>
constexpr SmallVector& operator=(const SmallVector<T, OSize>& o) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), o[0])) &&
std::is_nothrow_destructible_v<T>)
{
std::size_t minsize = std::min(size(), o.size());
std::size_t targetsize = o.size();
std::size_t currentsize = size();
for (std::size_t i = 0; i < minsize; i++)
{
nothrow_migrate(std::addressof(data()[i]), o[i]);
}
for (std::size_t i = minsize; i < targetsize; i++)
{
std::construct_at(std::addressof(data()[i]), o[i]);
}
// not destroy_n to avoid overflow
for (std::size_t i = targetsize; i < currentsize; i++)
{
std::destroy_at(std::addressof(data()[i]));
}
populated() = o.populated();
return *this;
}
template <std::size_t OSize = Size>
requires (OSize <= Size) && std::is_move_constructible_v<T>
constexpr SmallVector& operator=(SmallVector<T, OSize>&& o) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(o[0]))) &&
std::is_nothrow_destructible_v<T>)
{
std::size_t minsize = std::min(size(), o.size());
std::size_t targetsize = o.size();
std::size_t currentsize = size();
for (std::size_t i = 0; i < minsize; i++)
{
nothrow_migrate(std::addressof(data()[i]), std::move(o[i]));
std::destroy_at(std::addressof(o[i]));
}
for (std::size_t i = minsize; i < targetsize; i++)
{
std::construct_at(std::addressof(data()[i]), std::move(o[i]));
std::destroy_at(std::addressof(o[i]));
}
// not destroy_n to avoid overflow
for (std::size_t i = targetsize; i < currentsize; i++)
{
std::destroy_at(std::addressof(data()[i]));
}
populated() = o.populated();
o.populated() = 0;
return *this;
}
template <typename... Args>
requires (std::convertible_to<Args, T> && ...) && (sizeof...(Args) <= Size)
constexpr SmallVector(Args&&... args) noexcept(
(noexcept(emplace_back(std::forward<decltype(args)>(args))) && ...))
{
(emplace_back(std::forward<decltype(args)>(args)) && ...);
}
template <std::size_t SpanSize, typename Contained>
requires std::convertible_to<Contained, T> && (SpanSize <= Size) &&
(SpanSize != std::dynamic_extent)
constexpr explicit(!std::is_same_v<std::remove_cvref_t<Contained>, T>) SmallVector(
const std::span<Contained, SpanSize>& in) noexcept(noexcept(emplace_back(in[0])))
{
for (std::size_t i = 0; i < in.size(); i++)
{
emplace_back(in[i]);
}
}
// Returns true if the value fit, false if it didn't
constexpr bool push_back(const T& value) noexcept(std::is_nothrow_copy_constructible_v<T>)
requires std::is_copy_constructible_v<T>
{
if (size() < capacity())
{
std::construct_at(std::addressof(data()[populated()++]), std::forward<const T&>(value));
return true;
}
return false;
}
constexpr bool push_back(T&& value) noexcept(std::is_nothrow_move_constructible_v<T>)
requires std::is_move_constructible_v<T>
{
if (size() < capacity())
{
std::construct_at(std::addressof(data()[populated()++]), std::forward<T&&>(value));
return true;
}
return false;
}
template <typename... Args>
constexpr bool emplace_back(Args&&... args) noexcept(
std::is_nothrow_constructible_v<T, decltype(args)...>)
requires std::is_constructible_v<T, decltype(args)...>
{
if (size() < capacity())
{
std::construct_at(
std::addressof(data()[populated()++]), std::forward<decltype(args)>(args)...);
return true;
}
return false;
}
constexpr void pop_back() noexcept(std::is_nothrow_destructible_v<T>)
{
if (!empty())
{
std::destroy_at(std::addressof(data()[--populated()]));
}
}
constexpr void clear() noexcept(std::is_nothrow_destructible_v<T>)
{
std::destroy_n(begin(), size());
populated() = 0;
}
constexpr iterator erase(const_iterator pos) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(data()[0]))) &&
std::is_nothrow_destructible_v<T>)
{
iterator movedest = begin() + (pos - begin());
iterator movestart = movedest + 1;
iterator moveend = end();
while (movestart != moveend)
{
nothrow_migrate(std::addressof(*(movedest++)), std::move(*(movestart++)));
}
std::destroy_at(std::addressof(data()[--populated()]));
return begin() + (pos - begin());
}
constexpr iterator erase(const_iterator first, const_iterator last) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(data()[0]))) &&
std::is_nothrow_destructible_v<T>)
{
if (last <= first)
{
return begin() + (last - begin());
}
iterator movedest = begin() + (first - begin());
iterator movestart = begin() + (last - begin());
iterator moveend = end();
while (movestart != moveend)
{
nothrow_migrate(std::addressof(*(movedest++)), std::move(*(movestart++)));
}
std::destroy_n(std::addressof(data()[populated() - (last - first)]), last - first);
populated() -= (last - first);
return begin() + (last - first);
}
constexpr bool insert(const_iterator pos, const T& data) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(data()[0]))) && noexcept(
nothrow_migrate(std::addressof(data()[0]), data()[0])))
requires std::is_copy_constructible_v<T>
{
if (pos == end())
{
return push_back(std::forward<const T&>(data));
}
if (size() < capacity())
{
for (auto i = end() - 1; i >= pos; i--)
{
// Special case to increase size
if (i + 1 == end())
{
emplace_back(std::move(*(end() - 1)));
}
else
{
nothrow_migrate(std::addressof(*(i + 1)), std::move(*i));
}
}
nothrow_migrate(begin() + (pos - begin()), data);
return true;
}
return false;
}
constexpr bool insert(const_iterator pos, T&& data) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(data()[0]))))
requires std::is_move_constructible_v<T>
{
if (pos == end())
{
return push_back(std::forward<T&&>(data));
}
if (size() < capacity())
{
for (auto i = end() - 1; i >= pos; i--)
{
// Special case to increase size
if (i + 1 == end())
{
emplace_back(std::move(*i));
}
else
{
nothrow_migrate(std::addressof(*(i + 1)), std::move(*i));
}
}
nothrow_migrate(begin() + (pos - begin()), std::forward<T&&>(data));
return true;
}
return false;
}
template <typename... Args>
constexpr bool emplace(const_iterator pos, Args&&... args) noexcept(
noexcept(nothrow_migrate(std::addressof(data()[0]), std::move(data()[0]))) &&
std::is_nothrow_constructible_v<T, decltype(args)...>)
requires std::is_constructible_v<T, decltype(args)...>
{
if (pos == end())
{
return emplace_back(std::forward<decltype(args)>(args)...);
}
else if (size() < capacity())
{
for (auto i = end() - 1; i >= pos; i--)
{
// Special case to increase size
if (i + 1 == end())
{
emplace_back(std::move(*i));
}
else
{
nothrow_migrate(std::addressof(*(i + 1)), std::move(*i));
}
}
T data{std::forward<decltype(args)>(args)...};
nothrow_migrate(begin() + (pos - begin()), std::move(data));
return true;
}
return false;
}
constexpr T* data() noexcept { return alldata.data.data; }
constexpr const T* data() const noexcept { return alldata.data.data; }
constexpr const_reference operator[](std::size_t i) const noexcept { return data()[i]; }
constexpr reference operator[](std::size_t i) noexcept { return data()[i]; }
constexpr reference front() noexcept { return *begin(); }
constexpr const_reference front() const noexcept { return *begin(); }
constexpr reference back() noexcept { return *rbegin(); }
constexpr const_reference back() const noexcept { return *rbegin(); }
constexpr size_type size() const noexcept { return populated(); }
constexpr size_type capacity() const noexcept { return Size; }
constexpr size_type max_size() const noexcept { return Size; }
constexpr bool empty() const noexcept { return size() == 0; }
constexpr iterator begin() noexcept { return iterator{data()}; }
constexpr iterator end() noexcept { return iterator{data()} + size(); }
constexpr reverse_iterator rbegin() noexcept { return std::make_reverse_iterator(end()); }
constexpr reverse_iterator rend() noexcept { return std::make_reverse_iterator(begin()); }
constexpr const_iterator begin() const noexcept { return const_iterator{data()}; }
constexpr const_iterator end() const noexcept { return const_iterator{data()} + size(); }
constexpr const_reverse_iterator rbegin() const noexcept
{
return std::make_reverse_iterator(end());
}
constexpr const_reverse_iterator rend() const noexcept
{
return std::make_reverse_iterator(begin());
}
constexpr const_iterator cbegin() const noexcept { return const_iterator{data()}; }
constexpr const_iterator cend() const noexcept { return const_iterator{data()} + size(); }
constexpr const_reverse_iterator crbegin() const noexcept
{
return std::make_reverse_iterator(cend());
}
constexpr const_reverse_iterator crend() const noexcept
{
return std::make_reverse_iterator(cbegin());
}
};
template <typename... Args>
SmallVector(Args...) -> SmallVector<std::common_type_t<Args...>, sizeof...(Args)>;
template <typename T, std::size_t Size>
SmallVector(std::span<T, Size>) -> SmallVector<T, Size>;
#endif
| 16,228
|
C++
|
.h
| 403
| 31.913151
| 100
| 0.573371
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,308
|
i18n.hpp
|
FlagBrew_PKSM-Core/include/utils/i18n.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef I18N_HPP
#define I18N_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/GameVersion.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Move.hpp"
#include "enums/Nature.hpp"
#include "enums/Ribbon.hpp"
#include "enums/Species.hpp"
#include "enums/Type.hpp"
#include "utils/coretypes.h"
#include "utils/SmallVector.hpp"
#include <map>
#include <string>
#include <vector>
namespace i18n
{
using initCallback = void (*)(pksm::Language);
using exitCallback = void (*)(pksm::Language);
void addInitCallback(initCallback callback);
void removeInitCallback(initCallback callback);
void addExitCallback(exitCallback callback);
void removeExitCallback(exitCallback callback);
inline void addCallbacks(initCallback init, exitCallback exit)
{
addInitCallback(init);
addExitCallback(exit);
}
inline void removeCallbacks(initCallback init, exitCallback exit)
{
removeInitCallback(init);
removeExitCallback(exit);
}
// Calls the callbacks that have been registered with addInitCallback in a thread-safe manner
// NOTE: default callbacks include all init functions in this file
void init(pksm::Language lang);
// Calls the callbacks that have been registered with addExitCallback in a thread-safe manner
// for all languages that have been initialized NOTE: default callbacks include all exit
// functions in this file
void exit(void);
[[nodiscard]] const std::string& langString(pksm::Language l);
[[nodiscard]] pksm::Language langFromString(const std::string_view& value);
void initAbility(pksm::Language lang);
void exitAbility(pksm::Language lang);
[[nodiscard]] const std::string& ability(pksm::Language lang, pksm::Ability value);
[[nodiscard]] const std::vector<std::string>& rawAbilities(pksm::Language lang);
void initBall(pksm::Language lang);
void exitBall(pksm::Language lang);
[[nodiscard]] const std::string& ball(pksm::Language lang, pksm::Ball value);
[[nodiscard]] const std::vector<std::string>& rawBalls(pksm::Language lang);
void initForm(pksm::Language lang);
void exitForm(pksm::Language lang);
[[nodiscard]] const std::string& form(
pksm::Language lang, pksm::GameVersion version, pksm::Species species, u8 form);
[[nodiscard]] SmallVector<std::string, 0x20> forms(
pksm::Language lang, pksm::GameVersion version, pksm::Species species);
// No good raw interface for this
void initGame(pksm::Language lang);
void exitGame(pksm::Language lang);
[[nodiscard]] const std::string& game(pksm::Language lang, pksm::GameVersion value);
[[nodiscard]] const std::vector<std::string>& rawGames(pksm::Language lang);
void initItem(pksm::Language lang);
void exitItem(pksm::Language lang);
[[nodiscard]] const std::string& item(pksm::Language lang, u16 value);
[[nodiscard]] const std::vector<std::string>& rawItems(pksm::Language lang);
void initItem1(pksm::Language lang);
void exitItem1(pksm::Language lang);
[[nodiscard]] const std::string& item1(pksm::Language lang, u8 value);
[[nodiscard]] const std::vector<std::string>& rawItems1(pksm::Language lang);
void initItem2(pksm::Language lang);
void exitItem2(pksm::Language lang);
[[nodiscard]] const std::string& item2(pksm::Language lang, u8 value);
[[nodiscard]] const std::vector<std::string>& rawItems2(pksm::Language lang);
void initItem3(pksm::Language lang);
void exitItem3(pksm::Language lang);
[[nodiscard]] const std::string& item3(pksm::Language lang, u16 value);
[[nodiscard]] const std::vector<std::string>& rawItems3(pksm::Language lang);
void initMove(pksm::Language lang);
void exitMove(pksm::Language lang);
[[nodiscard]] const std::string& move(pksm::Language lang, pksm::Move value);
[[nodiscard]] const std::vector<std::string>& rawMoves(pksm::Language lang);
void initNature(pksm::Language lang);
void exitNature(pksm::Language lang);
[[nodiscard]] const std::string& nature(pksm::Language lang, pksm::Nature value);
[[nodiscard]] const std::vector<std::string>& rawNatures(pksm::Language lang);
void initRibbon(pksm::Language lang);
void exitRibbon(pksm::Language lang);
[[nodiscard]] const std::string& ribbon(pksm::Language lang, pksm::Ribbon value);
[[nodiscard]] const std::vector<std::string>& rawRibbons(pksm::Language lang);
// Note: several functions require this to function properly.
// A nonexhaustive list includes PK3::nicknamed, PK4::convertToPK3, PK5::convertToPK6,
// SavLGPE::mysteryGift, and SavSWSH::mysteryGift
void initSpecies(pksm::Language lang);
void exitSpecies(pksm::Language lang);
[[nodiscard]] const std::string& species(pksm::Language lang, pksm::Species value);
[[nodiscard]] const std::vector<std::string>& rawSpecies(pksm::Language lang);
void initType(pksm::Language lang);
void exitType(pksm::Language lang);
[[nodiscard]] const std::string& type(pksm::Language lang, pksm::Type value);
[[nodiscard]] const std::vector<std::string>& rawType(pksm::Language lang);
void initLocation(pksm::Language lang);
void exitLocation(pksm::Language lang);
[[nodiscard]] const std::string& location(
pksm::Language lang, pksm::Generation generation, u16 value);
[[nodiscard]] const std::map<u16, std::string>& rawLocations(
pksm::Language lang, pksm::Generation g);
void initGeo(pksm::Language lang);
void exitGeo(pksm::Language lang);
[[nodiscard]] const std::string& subregion(pksm::Language lang, u8 country, u8 value);
[[nodiscard]] const std::map<u8, std::string>& rawSubregions(pksm::Language lang, u8 country);
[[nodiscard]] const std::string& country(pksm::Language lang, u8 value);
[[nodiscard]] const std::map<u8, std::string>& rawCountries(pksm::Language lang);
};
#endif
| 7,246
|
C++
|
.h
| 141
| 47.134752
| 98
| 0.721689
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,309
|
endian.hpp
|
FlagBrew_PKSM-Core/include/utils/endian.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef ENDIAN_HPP
#define ENDIAN_HPP
#include "utils/coretypes.h"
#include <array>
#include <bit>
#include <cmath>
#include <functional>
#include <ranges>
#include <span>
#include <string.h>
#include <type_traits>
#include <vector>
namespace EndianTraits
{
constexpr bool EasyArch =
(std::endian::big == std::endian::native) || (std::endian::little == std::endian::native);
template <typename T>
struct EndianConvertible_s
{
static constexpr bool value =
std::is_integral_v<T> ||
(std::is_floating_point_v<T> && std::numeric_limits<T>::is_iec559);
};
template <typename T>
concept EndianConvertible = EndianConvertible_s<T>::value;
namespace EndianCommon
{
// DEPENDENT CONVERSIONS
// Converts arithmetic types into big-endian byte representations. Integer types and IEEE
// 754 compliant single and double-precision floating-point types are supported.
template <EndianConvertible T, std::endian TargetEndianness>
constexpr void convertFrom(u8* dest, const T& orig)
{
if constexpr (EasyArch)
{
auto obtained = std::bit_cast<std::array<u8, sizeof(T)>>(orig);
if constexpr (std::endian::native != TargetEndianness)
{
std::copy(obtained.rbegin(), obtained.rend(), dest);
}
else
{
std::copy(obtained.begin(), obtained.end(), dest);
}
}
else if constexpr (std::is_integral_v<T>)
{
auto origVal = std::bit_cast<std::make_unsigned_t<T>>(orig);
if constexpr (TargetEndianness == std::endian::little)
{
for (size_t i = 0; i < sizeof(T); i++)
{
dest[i] = u8(origVal);
origVal >>= 8;
}
}
else
{
for (size_t i = 0; i < sizeof(T); i++)
{
dest[sizeof(T) - i - 1] = u8(origVal);
origVal >>= 8;
}
}
}
else if constexpr (std::is_floating_point_v<T>)
{
bool negative = std::signbit(orig);
int exponent;
T normalized = std::frexp(orig, &exponent); // gets biased exponent
if constexpr (std::is_same_v<T, float>)
{
u32 write = negative ? (1u << 31) : 0;
switch (std::fpclassify(orig))
{
case FP_INFINITE:
write |= u32(0xFF)
<< 23; // should be written as 0x7F800000 or 0xFF800000
break;
case FP_NAN:
write = 0xFFFFFFFF; // might as well just use a constant NaN number
break;
case FP_ZERO:
// do nothing; it should be written as either 0x80000000 or 0x00000000
break;
case FP_NORMAL:
write |= u32(exponent + 127) << 23;
// falls through
case FP_SUBNORMAL:
normalized *= 1 << 23;
write |= u32(normalized);
break;
}
convertFrom<u32, TargetEndianness>(dest, write);
}
else if constexpr (std::is_same_v<T, double>)
{
u64 write = negative ? (u64(1) << 63) : 0;
switch (std::fpclassify(orig))
{
case FP_INFINITE:
write |= u64(0x7FF) << 52; // should be written as 0x7FF0000000000000 or
// 0xFFF0000000000000
break;
case FP_NAN:
write =
0xFFFFFFFFFFFFFFFF; // might as well just use a constant NaN number
break;
case FP_ZERO:
// do nothing; it should be written as either 0x8000000000000000 or
// 0x0000000000000000
break;
case FP_NORMAL:
write |= u64(exponent + 1023) << 52;
// falls through
case FP_SUBNORMAL:
normalized *= u64(1) << 52;
write |= u64(normalized);
break;
}
convertFrom<u64, TargetEndianness>(dest, write);
}
}
}
// Converts big-endian byte representations into arithmetic types. Integer types and IEEE
// 754 compliant single and double-precision floating-point types are supported.
template <EndianTraits::EndianConvertible T, std::endian TargetEndianness>
constexpr T convertTo(const u8* from)
{
if constexpr (EasyArch)
{
std::array<u8, sizeof(T)> data;
if constexpr (std::endian::native != TargetEndianness)
{
std::copy(from, from + sizeof(T), data.rbegin());
}
else
{
std::copy(from, from + sizeof(T), data.begin());
}
return std::bit_cast<T>(data);
}
else if constexpr (std::is_integral_v<T>)
{
std::make_unsigned_t<T> dest = 0;
for (size_t i = 0; i < sizeof(T); i++)
{
dest |= std::make_unsigned_t<T>(from[i]) << ((sizeof(T) - i - 1) * 8);
}
return dest;
}
else if constexpr (std::is_same_v<T, float>)
{
u32 data = convertTo<u32, TargetEndianness>(from);
bool negative = (data & 0x80000000) != 0;
int exponent = (data & 0x7F800000) >> 23;
int fraction = data & ~0xFF800000;
if (exponent == 0 && fraction == 0)
{
return std::copysign(T(0), negative ? -1 : 1);
}
else if (exponent == 0xFF)
{
if (fraction == 0)
{
return negative ? -std::numeric_limits<T>::infinity()
: std::numeric_limits<T>::infinity();
}
else
{
return std::numeric_limits<T>::signaling_NaN(); // Going to ignore the
// difference between quiet
// and signaling NaN
}
}
else
{
// fraction is currently shifted 23 bits from where it should be, so fix that
// and set the proper exponent
T ret = std::ldexp(fraction, -23);
if (exponent == 0) // Denormal number
{
ret = std::ldexp(ret, -126);
}
else
{
// Unbias the exponent & add the one necessary because it's not a denormal
// number
ret = std::ldexp(ret + 1, exponent - 127);
}
return std::copysign(ret, negative ? -1 : 1);
}
}
else if constexpr (std::is_same_v<T, double>)
{
u64 data = convertTo<u64, TargetEndianness>(from);
bool negative = (data & 0x8000000000000000) != 0;
int exponent = (data & 0x7FF0000000000000) >> 52;
int fraction = data & ~0xFFF0000000000000;
if (exponent == 0 && fraction == 0)
{
return std::copysign(T(0), negative ? -1 : 1);
}
else if (exponent == 0x7FF)
{
if (fraction == 0)
{
return negative ? -std::numeric_limits<T>::infinity()
: std::numeric_limits<T>::infinity();
}
else
{
return std::numeric_limits<T>::signaling_NaN(); // Going to ignore the
// difference between quiet
// and signaling NaN
}
}
else
{
// fraction is currently shifted 52 bits from where it should be, so fix that
// and set the proper exponent
T ret = std::ldexp(fraction, -52);
if (exponent == 0) // Denormal number
{
ret = std::ldexp(ret, -1022);
}
else
{
// Unbias the exponent & add the one necessary because it's not a denormal
// number
ret = std::ldexp(ret + 1, exponent - 1023);
}
return std::copysign(ret, negative ? -1 : 1);
}
}
}
// Binary-Coded Decimal (BCD) conversions
template <std::unsigned_integral T, size_t arrayLength, std::endian TargetEndianness>
constexpr T BCDtoUInteger(const u8* src)
{
T out = 0;
T j = 1;
auto [begin, end] = std::invoke(
[&src]
{
if constexpr (TargetEndianness == std::endian::big)
{
return std::make_pair(std::make_reverse_iterator(src + arrayLength - 1),
std::make_reverse_iterator(src - 1));
}
else
{
return std::make_pair(src, src + arrayLength);
}
});
for (; begin != end; ++begin)
{
out += ((*begin & 0x0F) * j) + (((*begin & 0xF0) >> 4) * (j * 10));
}
return out;
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T),
std::endian TargetEndianness>
constexpr void UIntegerToBCD(u8* dest, T src)
{
auto [begin, end] = std::invoke(
[&dest]
{
if constexpr (TargetEndianness == std::endian::big)
{
return std::make_pair(std::make_reverse_iterator(dest + arrayLength - 1),
std::make_reverse_iterator(dest - 1));
}
else
{
return std::make_pair(dest, dest + arrayLength);
}
});
for (; begin != end; ++begin, ++dest, src /= 100)
{
*dest = (((src / 10) % 10) << 4) | (src % 10);
}
}
// NON-DEPENDENT CONVERSIONS
template <std::ranges::range R, std::endian TargetEndianness>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr void convertFrom(u8* dest, R&& range)
{
for (auto it = std::ranges::begin(range); it != std::ranges::end(range); ++it)
{
convertFrom<std::ranges::range_value_t<R>, TargetEndianness>(dest, *it);
dest += sizeof(std::ranges::range_value_t<R>);
}
}
// Same as above, just with automatic handling of data lifetime
template <EndianTraits::EndianConvertible T, std::endian TargetEndianness>
constexpr std::array<u8, sizeof(T)> convertFrom(const T& orig)
{
std::array<u8, sizeof(T)> ret{};
convertFrom<T, TargetEndianness>(ret.data(), orig);
return ret;
}
template <EndianTraits::EndianConvertible T, std::size_t Extent,
std::endian TargetEndianness>
requires (Extent != std::dynamic_extent)
constexpr std::array<u8, sizeof(T) * Extent> convertFrom(std::span<T, Extent> span)
{
std::array<u8, sizeof(T) * Extent> ret{};
for (size_t i = 0; i < Extent; i++)
{
convertFrom<T, TargetEndianness>(ret.data() + i * sizeof(T), span[i]);
}
return ret;
}
template <std::ranges::range R, std::endian TargetEndianness>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr std::vector<u8> convertFrom(R&& range)
{
std::vector<u8> ret = std::invoke(
[&]
{
if constexpr (requires { requires std::ranges::sized_range<R>; })
{
return std::vector<u8>(
std::ranges::size(range) * sizeof(std::ranges::range_value_t<R>));
}
else
{
return std::vector<u8>();
}
});
std::size_t current = 0;
for (auto it = std::ranges::begin(range); it != std::ranges::end(range);
++it, current += sizeof(std::ranges::range_value_t<R>))
{
if constexpr (!requires { requires std::ranges::sized_range<R>; })
{
ret.insert(ret.end(), sizeof(std::ranges::range_value_t<R>), 0);
}
convertFrom<std::ranges::range_value_t<R>, TargetEndianness>(
ret.data() + current, *it);
}
return ret;
}
template <EndianTraits::EndianConvertible T, size_t N, std::endian TargetEndianness>
constexpr std::array<T, N> convertTo(const u8* from)
{
std::array<T, N> ret{};
for (size_t i = 0; i < N; i++)
{
ret[i] = convertTo<T, TargetEndianness>(from + i * sizeof(T));
}
return ret;
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T),
std::endian TargetEndianness>
constexpr std::array<u8, arrayLength> UIntegerToBCD(T src)
{
std::array<u8, arrayLength> out;
UIntegerToBCD<T, arrayLength, TargetEndianness>(out.data(), src);
return out;
}
}
}
namespace BigEndian
{
template <EndianTraits::EndianConvertible T>
constexpr void convertFrom(u8* dest, const T& orig)
{
return EndianTraits::EndianCommon::convertFrom<T, std::endian::big>(dest, orig);
}
template <EndianTraits::EndianConvertible T>
constexpr T convertTo(const u8* from)
{
return EndianTraits::EndianCommon::convertTo<T, std::endian::big>(from);
}
template <std::unsigned_integral T, size_t arrayLength>
constexpr T BCDtoUInteger(const u8* src)
{
return EndianTraits::EndianCommon::BCDtoUInteger<T, arrayLength, std::endian::big>(src);
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T)>
constexpr void UIntegerToBCD(u8* dest, T src)
{
return EndianTraits::EndianCommon::UIntegerToBCD<T, arrayLength, std::endian::big>(
dest, src);
}
template <std::ranges::range R>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr void convertFrom(u8* dest, R&& range)
{
return EndianTraits::EndianCommon::convertFrom<R, std::endian::big>(
dest, std::forward<decltype(range)>(range));
}
template <EndianTraits::EndianConvertible T>
constexpr std::array<u8, sizeof(T)> convertFrom(const T& orig)
{
return EndianTraits::EndianCommon::convertFrom<T, std::endian::big>(orig);
}
template <EndianTraits::EndianConvertible T, std::size_t Extent>
requires (Extent != std::dynamic_extent)
constexpr std::array<u8, sizeof(T) * Extent> convertFrom(std::span<T, Extent> span)
{
return EndianTraits::EndianCommon::convertFrom<T, Extent, std::endian::big>(span);
}
template <std::ranges::range R>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr std::vector<u8> convertFrom(R&& range)
{
return EndianTraits::EndianCommon::convertFrom<R, std::endian::big>(
std::forward<decltype(range)>(range));
}
template <EndianTraits::EndianConvertible T, size_t N>
constexpr std::array<T, N> convertTo(const u8* from)
{
return EndianTraits::EndianCommon::convertTo<T, N, std::endian::big>(from);
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T)>
constexpr std::array<u8, arrayLength> UIntegerToBCD(T src)
{
return EndianTraits::EndianCommon::UIntegerToBCD<T, arrayLength, std::endian::big>(src);
}
}
namespace LittleEndian
{
template <EndianTraits::EndianConvertible T>
constexpr void convertFrom(u8* dest, const T& orig)
{
return EndianTraits::EndianCommon::convertFrom<T, std::endian::little>(dest, orig);
}
template <EndianTraits::EndianConvertible T>
constexpr T convertTo(const u8* from)
{
return EndianTraits::EndianCommon::convertTo<T, std::endian::little>(from);
}
template <std::unsigned_integral T, size_t arrayLength>
constexpr T BCDtoUInteger(const u8* src)
{
return EndianTraits::EndianCommon::BCDtoUInteger<T, arrayLength, std::endian::little>(src);
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T)>
constexpr void UIntegerToBCD(u8* dest, T src)
{
return EndianTraits::EndianCommon::UIntegerToBCD<T, arrayLength, std::endian::little>(
dest, src);
}
template <std::ranges::range R>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr void convertFrom(u8* dest, R&& range)
{
return EndianTraits::EndianCommon::convertFrom<R, std::endian::little>(
dest, std::forward<decltype(range)>(range));
}
template <EndianTraits::EndianConvertible T>
constexpr std::array<u8, sizeof(T)> convertFrom(const T& orig)
{
return EndianTraits::EndianCommon::convertFrom<T, std::endian::little>(orig);
}
template <EndianTraits::EndianConvertible T, std::size_t Extent>
requires (Extent != std::dynamic_extent)
constexpr std::array<u8, sizeof(T) * Extent> convertFrom(std::span<T, Extent> span)
{
return EndianTraits::EndianCommon::convertFrom<T, Extent, std::endian::little>(span);
}
template <std::ranges::range R>
requires EndianTraits::EndianConvertible<std::ranges::range_value_t<R>>
constexpr std::vector<u8> convertFrom(R&& range)
{
return EndianTraits::EndianCommon::convertFrom<R, std::endian::little>(
std::forward<decltype(range)>(range));
}
template <EndianTraits::EndianConvertible T, size_t N>
constexpr std::array<T, N> convertTo(const u8* from)
{
return EndianTraits::EndianCommon::convertTo<T, N, std::endian::little>(from);
}
template <std::unsigned_integral T, size_t arrayLength = sizeof(T)>
constexpr std::array<u8, arrayLength> UIntegerToBCD(T src)
{
return EndianTraits::EndianCommon::UIntegerToBCD<T, arrayLength, std::endian::little>(src);
}
}
#endif
| 21,733
|
C++
|
.h
| 508
| 28.627953
| 100
| 0.504697
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,310
|
_map_macro.hpp
|
FlagBrew_PKSM-Core/include/utils/_map_macro.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef MAP_MACRO_HPP
#define MAP_MACRO_HPP
#define MAP_PARENS ()
#define MAP_EXPAND(...) MAP_EXPAND4(MAP_EXPAND4(MAP_EXPAND4(MAP_EXPAND4(__VA_ARGS__))))
#define MAP_EXPAND4(...) MAP_EXPAND3(MAP_EXPAND3(MAP_EXPAND3(MAP_EXPAND3(__VA_ARGS__))))
#define MAP_EXPAND3(...) MAP_EXPAND2(MAP_EXPAND2(MAP_EXPAND2(MAP_EXPAND2(__VA_ARGS__))))
#define MAP_EXPAND2(...) MAP_EXPAND1(MAP_EXPAND1(MAP_EXPAND1(MAP_EXPAND1(__VA_ARGS__))))
#define MAP_EXPAND1(...) __VA_ARGS__
#define MAP(macro, ...) __VA_OPT__(MAP_EXPAND(MAP_HELPER(macro, __VA_ARGS__)))
#define MAP_HELPER(macro, a1, ...) macro(a1) __VA_OPT__(MAP_AGAIN MAP_PARENS(macro, __VA_ARGS__))
#define MAP_AGAIN() MAP_HELPER
#define MAP_LIST(macro, ...) __VA_OPT__(MAP_EXPAND(MAP_LIST_HELPER(macro, __VA_ARGS__)))
#define MAP_LIST_HELPER(macro, a1, ...) \
macro(a1) __VA_OPT__(, MAP_LIST_AGAIN MAP_PARENS(macro, __VA_ARGS__))
#define MAP_LIST_AGAIN() MAP_LIST_HELPER
#endif
| 2,254
|
C++
|
.h
| 41
| 53.146341
| 100
| 0.689171
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,311
|
crypto.hpp
|
FlagBrew_PKSM-Core/include/utils/crypto.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef CRYPTO_HPP
#define CRYPTO_HPP
#include "utils/coretypes.h"
#include <array>
#include <memory>
#include <span>
#include <string>
#include <vector>
namespace pksm::crypto
{
[[nodiscard]] u16 ccitt16(std::span<const u8> data);
[[nodiscard]] u16 crc16(std::span<const u8> data);
[[nodiscard]] u16 crc16_noinvert(std::span<const u8> data);
[[nodiscard]] u8 diff8(std::span<const u8> data);
[[nodiscard]] u16 bytewiseSum16(std::span<const u8> data);
// Length must be a multiple of 4
[[nodiscard]] u32 sum32(std::span<const u8> data);
// This SHA256 implementation is Brad Conte's. It has been modified to have a C++-style
// interface.
class SHA256
{
private:
u8 data[64];
u32 dataLength;
u64 bitLength;
std::array<u32, 8> state;
void update();
public:
SHA256() { reinitialize(); }
void reinitialize()
{
dataLength = 0;
bitLength = 0;
state = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c,
0x1f83d9ab, 0x5be0cd19};
}
void update(std::span<const u8> buf);
[[nodiscard]] std::array<u8, 32> finish();
};
[[nodiscard]] std::array<u8, 32> sha256(std::span<const u8> data);
class SHA1
{
private:
u8 data[64];
u32 dataLength;
u64 bitLength;
std::array<u32, 5> state;
void update();
public:
SHA1() { reinitialize(); }
void reinitialize()
{
dataLength = 0;
bitLength = 0;
state = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};
}
void update(std::span<const u8> data);
[[nodiscard]] std::array<u8, 20> finish();
};
[[nodiscard]] std::array<u8, 20> sha1(std::span<const u8> data);
namespace swsh
{
class SCBlock
{
friend std::vector<std::shared_ptr<SCBlock>> getBlockList(
std::shared_ptr<u8[]> data, size_t length);
public:
enum class SCBlockType : u8
{
None = 0,
Bool1 = 1, // False?
Bool2 = 2, // True?
Bool3 = 3, // Either? Array bool type
Object = 4,
Array = 5,
U8 = 8,
U16 = 9,
U32 = 10,
U64 = 11,
S8 = 12,
S16 = 13,
S32 = 14,
S64 = 15,
Float = 16,
Double = 17,
};
u32 key() const;
// Nop if in proper state
void encrypt();
void decrypt();
u8* decryptedData()
{
decrypt();
return rawData();
}
private:
SCBlock(std::shared_ptr<u8[]> data, size_t& offset);
SCBlock(const SCBlock&) = delete;
SCBlock& operator=(const SCBlock&) = delete;
// Returns pointer to data at the beginning of the block's data region, skipping block
// identifying information
u8* rawData() const { return data.get() + myOffset + headerSize(type); }
void key(u32 v);
// data.get() + myOffset points to the beginning of the block data: *(u32*)(data.get() +
// myOffset) == key
std::shared_ptr<u8[]> data = nullptr;
size_t myOffset;
size_t dataLength;
SCBlockType type;
SCBlockType subtype;
bool currentlyEncrypted = false;
size_t encryptedDataSize();
static size_t arrayEntrySize(SCBlockType type);
static size_t headerSize(SCBlockType type);
};
void applyXor(std::shared_ptr<u8[]> data, size_t length);
void sign(std::shared_ptr<u8[]> data, size_t length);
[[nodiscard]] bool verify(std::shared_ptr<u8[]> data, size_t length);
[[nodiscard]] std::vector<std::shared_ptr<SCBlock>> getBlockList(
std::shared_ptr<u8[]> data, size_t length);
}
namespace pkm
{
constexpr std::array<u8, 128> BlockPositions = {0, 1, 2, 3, 0, 1, 3, 2, 0, 2, 1, 3, 0, 3, 1,
2, 0, 2, 3, 1, 0, 3, 2, 1, 1, 0, 2, 3, 1, 0, 3, 2, 2, 0, 1, 3, 3, 0, 1, 2, 2, 0, 3, 1,
3, 0, 2, 1, 1, 2, 0, 3, 1, 3, 0, 2, 2, 1, 0, 3, 3, 1, 0, 2, 2, 3, 0, 1, 3, 2, 0, 1, 1,
2, 3, 0, 1, 3, 2, 0, 2, 1, 3, 0, 3, 1, 2, 0, 2, 3, 1, 0, 3, 2, 1, 0,
// duplicates of 0-7 to eliminate modulus
0, 1, 2, 3, 0, 1, 3, 2, 0, 2, 1, 3, 0, 3, 1, 2, 0, 2, 3, 1, 0, 3, 2, 1, 1, 0, 2, 3, 1,
0, 3, 2};
constexpr std::array<u8, 32> InvertedBlockPositions = {
0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23, 0,
1, 2, 4, 3, 5, 6, 7 // duplicates of 0-7 to eliminate
// modulus
};
[[nodiscard]] constexpr u32 seedStep(u32 seed)
{
return seed * 0x41C64E6D + 0x6073;
}
template <size_t BlockLength>
constexpr void blockShuffle(u8* data, u8 sv)
{
u8 temp[BlockLength * 4];
std::copy(data, data + BlockLength * 4, temp);
u8 index = sv * 4;
for (size_t block = 0; block < 4; block++)
{
u8 ofs = BlockPositions[index + block];
std::copy(temp + ofs * BlockLength, temp + (ofs + 1) * BlockLength,
data + block * BlockLength);
}
}
template <size_t Size>
constexpr void crypt(u8* data, u32 key)
{
for (size_t i = 0; i < Size; i += 2)
{
key = seedStep(key);
data[i] ^= (key >> 16);
data[i + 1] ^= (key >> 24);
}
}
[[deprecated("Use the templated version wherever possible")]] constexpr void crypt(
std::span<u8> data, u32 key)
{
for (size_t i = 0; i < data.size(); i += 2)
{
key = seedStep(key);
data[i] ^= (key >> 16);
data[i + 1] ^= (key >> 24);
}
}
}
}
#endif
| 7,696
|
C++
|
.h
| 200
| 28.72
| 100
| 0.524729
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,312
|
utils.hpp
|
FlagBrew_PKSM-Core/include/utils/utils.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef UTILS_HPP
#define UTILS_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <array>
#include <codecvt>
#include <concepts>
#include <locale>
#include <memory>
#include <optional>
#include <stdarg.h>
#include <string.h>
#include <string>
#include <type_traits>
#include <vector>
namespace StringUtils
{
inline constexpr char32_t CODEPOINT_INVALID = 0xFFFD;
// Standard UTF-8/16/32 conversions
[[nodiscard]] std::u16string UTF8toUTF16(const std::string_view& src);
[[nodiscard]] std::string UTF16toUTF8(const std::u16string_view& src);
[[nodiscard]] std::u32string UTF8toUTF32(const std::string_view& src);
[[nodiscard]] std::string UTF32toUTF8(const std::u32string_view& src);
[[nodiscard]] std::u32string UTF16toUTF32(const std::u16string_view& src);
[[nodiscard]] std::u16string UTF32toUTF16(const std::u32string_view& src);
// UCS-2 is UTF-16 without the extended codepage(s). This is the format used in recent Pokémon
// games. It can be seen as the valid UTF-16 codepoints between 0x0000 and 0xFFFF, inclusive.
// Note that passing a UTF-8 string that contains only codepoints in that region to UTF8toUTF16
// will also result in a UCS-2 string.
[[nodiscard]] std::u16string UTF8toUCS2(const std::string_view& src);
[[nodiscard]] std::u16string UTF16toUCS2(const std::u16string_view& src);
[[nodiscard]] std::u16string UTF32toUCS2(const std::u32string_view& src);
[[nodiscard]] inline std::string UCS2toUTF8(const std::u16string_view& src)
{
return UTF16toUTF8(src);
}
[[nodiscard]] inline std::u16string UCS2toUTF16(const std::u16string_view& src)
{
return std::u16string(src);
}
[[nodiscard]] inline std::u32string UCS2toUTF32(const std::u16string_view& src)
{
return UTF16toUTF32(src);
}
[[nodiscard]] std::pair<std::array<char, 4>, size_t> codepointToUTF8(char32_t codepoint);
[[nodiscard]] std::pair<std::array<char16_t, 2>, size_t> codepointToUTF16(char32_t codepoint);
[[nodiscard]] u16 codepointToUCS2(char32_t codepoint);
[[nodiscard]] std::pair<char32_t, size_t> UTF8toCodepoint(const char* data, size_t maxSize);
[[nodiscard]] std::pair<char32_t, size_t> UTF16toCodepoint(
const char16_t* data, size_t maxSize);
[[nodiscard]] inline std::pair<char32_t, size_t> UCS2toCodepoint(const char16_t* data)
{
return UTF16toCodepoint(data, 1);
}
// All of these take a pointer to a buffer with a UCS-2 little-endian char16_t array at data +
// ofs, terminated by term, and turn them into the format indicated by the method name.
[[nodiscard]] std::u32string getU32String(
const u8* data, int ofs, int len, char16_t term = u'\0');
[[nodiscard]] std::u16string getUCS2String(
const u8* data, int ofs, int len, char16_t term = u'\0');
[[nodiscard]] inline std::u16string getU16String(
const u8* data, int ofs, int len, char16_t term = u'\0')
{
return getUCS2String(data, ofs, len, term);
}
[[nodiscard]] std::string getString(const u8* data, int ofs, int len, char16_t term = u'\0');
// All of these take a pointer to a buffer with a UCS-2 char16_t array at data + ofs and write
// the given string to them, replacing unrepresentable codepoints with 0xFFFD, and using
// terminator as the terminator and padding as the characters to set after the terminator.
// Note that any codepoint >= 0x10000 will be converted to 0xFFFD
// Note that the u16string_view overload takes a UTF-16 string
void setString(u8* data, const std::u32string_view& v, int ofs, int len,
char16_t terminator = u'\0', char16_t padding = u'\0');
void setString(u8* data, const std::u16string_view& v, int ofs, int len,
char16_t terminator = u'\0', char16_t padding = u'\0');
void setString(u8* data, const std::string_view& v, int ofs, int len,
char16_t terminator = u'\0', char16_t padding = u'\0');
[[nodiscard]] std::string getString4(const u8* data, int ofs, int len);
void setString4(u8* data, const std::string_view& v, int ofs, int len);
[[nodiscard]] std::string getString3(const u8* data, int ofs, int len, bool jp);
void setString3(u8* data, const std::string_view& v, int ofs, int len, bool jp, int padTo = 0,
u8 padWith = 0xFF);
[[nodiscard]] std::string getString1(
const u8* data, int ofs, int len, pksm::Language lang, bool transporter = false);
void setString1(u8* data, const std::string_view& v, int ofs, int len, pksm::Language lang,
int padTo = 0, u8 padWith = 0x50);
[[nodiscard]] std::string getString2(
const u8* data, int ofs, int len, pksm::Language lang, bool transporter = false);
void setString2(u8* data, const std::string_view& v, int ofs, int len, pksm::Language lang,
int padTo = 0, u8 padWith = 0x50);
void gbStringFailsafe(u8* data, int ofs, int len);
std::string getTradeOT(pksm::Language lang);
pksm::Language guessLanguage12(const std::string_view& v);
std::string fixJapaneseNameTransporter(const std::string_view& v);
[[nodiscard]] std::vector<u16> stringToG4(const std::string_view& v);
std::string& toLower(std::string& in);
[[nodiscard]] std::string toLower(const std::string_view& in);
std::string& toUpper(std::string& in);
[[nodiscard]] std::string toUpper(const std::string_view& in);
std::u16string& toFullWidth(std::u16string& in);
/** Swaps and reswaps Pokemon specific characters, namely:
* 0x2227, 0x2228, 0x2460, 0x2461, 0x2462,
* 0x2463, 0x2464, 0x2465, 0x2466, 0x2469,
* 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
* 0x246F, 0x2470, 0x2471, 0x2472, 0x2473,
* 0x2474, 0x2475, 0x2476, 0x2477, 0x2478,
* 0x2479, 0x247A, 0x247B, 0x247C, 0x247D,
* 0x247E, 0x247F, 0x2480, 0x2481, 0x2482,
* 0x2483, 0x2484, 0x2485, 0x2486, and 0x2487
*/
[[nodiscard]] std::string transString45(const std::string_view& str);
[[nodiscard]] std::u16string transString45(const std::u16string_view& str);
/** Swaps and reswaps Pokemon specific characters, namely:
* 0xE088, 0xE089, 0xE08A, 0xE08B, 0xE08C, 0xE0A6
*/
[[nodiscard]] std::string transString67(const std::string_view& str);
[[nodiscard]] std::u16string transString67(const std::u16string_view& str);
namespace internal
{
template <typename RetType, typename First, typename... Params>
requires (std::same_as<std::string, RetType> || std::same_as<std::u16string, RetType> ||
std::same_as<std::u32string, RetType>) &&
(std::convertible_to<First, std::string_view> ||
std::convertible_to<First, std::u16string_view> ||
std::convertible_to<First, std::u32string_view>) &&
((std::convertible_to<Params, std::string_view> ||
std::convertible_to<Params, std::u16string_view> ||
std::convertible_to<Params, std::u32string_view>) &&
...)
void concatImpl(RetType& ret, First&& f, Params&&... rest)
{
static constexpr auto toGenericView = [](First&& x)
-> std::conditional_t<std::is_convertible_v<First, std::string_view>,
std::string_view,
std::conditional_t<std::is_convertible_v<First, std::u16string_view>,
std::u16string_view, std::u32string_view>> { return x; };
if constexpr (std::is_same_v<RetType, std::string> &&
std::is_convertible_v<First, std::string_view>)
{
std::string_view view{std::forward<decltype(f)>(f)};
ret.append(view.data(), view.size());
}
else if constexpr (std::is_same_v<RetType, std::u16string> &&
std::is_convertible_v<First, std::u16string_view>)
{
std::u16string_view view{std::forward<decltype(f)>(f)};
ret.append(view.data(), view.size());
}
else if constexpr (std::is_same_v<RetType, std::u32string> &&
std::is_convertible_v<First, std::u32string_view>)
{
std::u32string_view view{std::forward<decltype(f)>(f)};
ret.append(view.data(), view.size());
}
else
{
auto view = toGenericView(std::forward<decltype(f)>(f));
size_t i = 0;
while (i < view.size())
{
size_t iMod = 1;
char32_t codepoint;
if constexpr (std::is_same_v<decltype(view), std::string_view>)
{
std::tie(codepoint, iMod) =
UTF8toCodepoint(view.data() + i, view.size() - i);
}
else if constexpr (std::is_same_v<decltype(view), std::u16string_view>)
{
std::tie(codepoint, iMod) =
UTF16toCodepoint(view.data() + i, view.size() - i);
}
else if constexpr (std::is_same_v<decltype(view), std::u32string_view>)
{
codepoint = view[i];
}
if constexpr (std::is_same_v<RetType, std::string>)
{
auto [data, size] = codepointToUTF8(codepoint);
ret.append(data.data(), size);
}
else if constexpr (std::is_same_v<RetType, std::u16string>)
{
auto [data, size] = codepointToUTF16(codepoint);
ret.append(data.data(), size);
}
else if constexpr (std::is_same_v<RetType, std::u32string>)
{
ret += codepoint;
}
i += iMod;
}
}
if constexpr (sizeof...(rest) != 0)
{
concatImpl(ret, std::forward<decltype(rest)>(rest)...);
}
}
template <typename StringType>
requires std::same_as<std::string, StringType> ||
std::same_as<std::u16string, StringType> ||
std::same_as<std::u32string, StringType>
size_t concatMaxSizeInCodeUnits()
{
return 0;
}
template <typename StringType, typename First, typename... Params>
requires (std::same_as<std::string, StringType> ||
std::same_as<std::u16string, StringType> ||
std::same_as<std::u32string, StringType>) &&
(std::convertible_to<First, std::string_view> ||
std::convertible_to<First, std::u16string_view> ||
std::convertible_to<First, std::u32string_view>) &&
((std::convertible_to<Params, std::string_view> ||
std::convertible_to<Params, std::u16string_view> ||
std::convertible_to<Params, std::u32string_view>) &&
...)
size_t concatMaxSizeInCodeUnits(First&& f, Params&&... args)
{
if constexpr (std::is_same_v<StringType, std::string>)
{
if constexpr (std::is_convertible_v<First, std::string_view>)
{
return toView(std::forward<decltype(f)>(f)).size() +
concatMaxSizeInCodeUnits<StringType>(
std::forward<decltype(args)>(args)...);
}
else if constexpr (std::is_convertible_v<First, std::u16string_view>)
{
return toView(std::forward<decltype(f)>(f)).size() * 2 +
concatMaxSizeInCodeUnits<StringType>(
std::forward<decltype(args)>(args)...);
}
else if constexpr (std::is_convertible_v<First, std::u32string_view>)
{
return toView(std::forward<decltype(f)>(f)).size() * 4 +
concatMaxSizeInCodeUnits<StringType>(
std::forward<decltype(args)>(args)...);
}
}
else if constexpr (std::is_same_v<StringType, std::u16string>)
{
if constexpr (std::is_convertible_v<First, std::u32string_view>)
{
return toView(std::forward<decltype(f)>(f)).size() * 2 +
concatMaxSizeInCodeUnits<StringType>(
std::forward<decltype(args)>(args)...);
}
return toView(std::forward<decltype(f)>(f)).size() +
concatMaxSizeInCodeUnits<StringType>(std::forward<decltype(args)>(args)...);
}
else if constexpr (std::is_same_v<StringType, std::u32string>)
{
return toView(std::forward<decltype(f)>(f)).size() +
concatMaxSizeInCodeUnits<StringType>(std::forward<decltype(args)>(args)...);
}
}
}
template <typename EncString, typename OrigString>
requires (std::same_as<std::string, EncString> || std::same_as<std::u16string, EncString> ||
std::same_as<std::u32string, EncString>) &&
(std::convertible_to<OrigString, std::string_view> ||
std::convertible_to<OrigString, std::u16string_view> ||
std::convertible_to<OrigString, std::u32string_view>)
EncString convert(OrigString&& str)
{
if constexpr (std::is_same_v<EncString, std::string>)
{
if constexpr (std::is_convertible_v<OrigString, std::string_view>)
{
return EncString(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u16string_view>)
{
return UTF16toUTF8(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u32string_view>)
{
return UTF32toUTF8(str);
}
}
else if constexpr (std::is_same_v<EncString, std::u16string>)
{
if constexpr (std::is_convertible_v<OrigString, std::string_view>)
{
return UTF8toUTF16(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u16string_view>)
{
return EncString(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u32string_view>)
{
return UTF32toUTF16(str);
}
}
else if constexpr (std::is_same_v<EncString, std::u32string>)
{
if constexpr (std::is_convertible_v<OrigString, std::string_view>)
{
return UTF8toUTF32(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u16string_view>)
{
return UTF16toUTF32(str);
}
else if constexpr (std::is_convertible_v<OrigString, std::u32string_view>)
{
return EncString(str);
}
}
}
template <typename RetType, bool ShrinkAfter = false, typename... Params>
requires (std::same_as<RetType, std::string> || std::same_as<RetType, std::u16string> ||
std::same_as<RetType, std::u32string>) &&
((std::convertible_to<Params, std::string_view> ||
std::convertible_to<Params, std::u16string_view> ||
std::convertible_to<Params, std::u32string_view>) &&
...)
RetType concat(Params&&... rest)
{
if constexpr (sizeof...(rest) == 0)
{
return RetType();
}
RetType ret;
ret.reserve(
internal::concatMaxSizeInCodeUnits<RetType>(std::forward<decltype(rest)>(rest)...));
internal::concatImpl(ret, rest...);
if constexpr (ShrinkAfter)
{
ret.shrink_to_fit();
}
return ret;
}
}
#endif
| 17,817
|
C++
|
.h
| 362
| 37.314917
| 100
| 0.574086
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,313
|
genToPkx.hpp
|
FlagBrew_PKSM-Core/include/utils/genToPkx.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GENTOPKX_HPP
#define GENTOPKX_HPP
#include "enums/Generation.hpp"
namespace pksm
{
class PK1;
class PK2;
class PK3;
class PK4;
class PK5;
class PK6;
class PK7;
class PK8;
class PB7;
template <pksm::Generation::EnumType g>
struct GenToPkx
{
};
template <>
struct GenToPkx<pksm::Generation::ONE>
{
using PKX = pksm::PK1;
};
template <>
struct GenToPkx<pksm::Generation::TWO>
{
using PKX = pksm::PK2;
};
template <>
struct GenToPkx<pksm::Generation::THREE>
{
using PKX = pksm::PK3;
};
template <>
struct GenToPkx<pksm::Generation::FOUR>
{
using PKX = pksm::PK4;
};
template <>
struct GenToPkx<pksm::Generation::FIVE>
{
using PKX = pksm::PK5;
};
template <>
struct GenToPkx<pksm::Generation::SIX>
{
using PKX = pksm::PK6;
};
template <>
struct GenToPkx<pksm::Generation::SEVEN>
{
using PKX = pksm::PK7;
};
template <>
struct GenToPkx<pksm::Generation::EIGHT>
{
using PKX = pksm::PK8;
};
template <>
struct GenToPkx<pksm::Generation::LGPE>
{
using PKX = pksm::PB7;
};
}
#endif
| 2,532
|
C++
|
.h
| 90
| 23.733333
| 76
| 0.657743
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,314
|
flagUtil.hpp
|
FlagBrew_PKSM-Core/include/utils/flagUtil.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef FLAG_UTIL_HPP
#define FLAG_UTIL_HPP
#include "utils/coretypes.h"
namespace pksm::FlagUtil
{
// Gets a bitflag from a byte array
[[nodiscard]] bool getFlag(const u8* data, int offset, int bitIndex);
// Sets a bitflag in a byte array
void setFlag(u8* data, int offset, int bitIndex, bool v);
}
#endif
| 1,604
|
C++
|
.h
| 36
| 42.305556
| 76
| 0.727447
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,315
|
DateTime.hpp
|
FlagBrew_PKSM-Core/include/utils/DateTime.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef DATE_HPP
#define DATE_HPP
#include "utils/coretypes.h"
#include <time.h>
class Date
{
public:
Date(const time_t& time) : Date(*gmtime(&time)) {}
constexpr Date(const struct tm& time) : Date(time.tm_mday, time.tm_mon + 1, time.tm_year + 1900)
{
}
constexpr Date(u8 day, u8 month, u32 year) : mYear(year), mDay(day), mMonth(month) {}
[[nodiscard]] static Date today() { return Date{time(nullptr)}; }
// 1-31
[[nodiscard]] constexpr u8 day() const { return mDay; }
// 1-12
[[nodiscard]] constexpr u8 month() const { return mMonth; }
// full year, ex 2015
[[nodiscard]] constexpr u32 year() const { return mYear; }
constexpr void day(u8 v) { mDay = v; }
constexpr void month(u8 v) { mMonth = v; }
constexpr void year(u32 v) { mYear = v; }
[[nodiscard]] constexpr bool operator==(const Date& other) const
{
return mDay == other.mDay && mMonth == other.mMonth && mYear == other.mYear;
}
[[nodiscard]] constexpr bool operator!=(const Date& other) const { return !(*this == other); }
[[nodiscard]] constexpr bool operator<(const Date& other) const
{
if (mYear < other.mYear)
{
return true;
}
else if (mYear == other.mYear && mMonth < other.mMonth)
{
return true;
}
else if (mYear == other.mYear && mMonth == other.mMonth && mDay < other.mDay)
{
return true;
}
return false;
}
[[nodiscard]] constexpr bool operator<=(const Date& other) const
{
return *this == other || *this < other;
}
[[nodiscard]] constexpr bool operator>(const Date& other) const
{
if (mYear > other.mYear)
{
return true;
}
else if (mYear == other.mYear && mMonth > other.mMonth)
{
return true;
}
else if (mYear == other.mYear && mMonth == other.mMonth && mDay > other.mDay)
{
return true;
}
return false;
}
[[nodiscard]] constexpr bool operator>=(const Date& other) const
{
return *this == other || *this > other;
}
[[nodiscard]] constexpr operator struct tm() const
{
return {0, 0, 0, mDay, mMonth - 1, (int)(mYear - 1900), 0, 0, 0};
}
protected:
u32 mYear;
u8 mDay;
u8 mMonth;
};
class Time
{
public:
Time(const time_t& time) : Time(*gmtime(&time)) {}
constexpr Time(const struct tm& time) : Time(time.tm_hour, time.tm_min, time.tm_sec) {}
constexpr Time(u8 hour, u8 minute, u8 second) : mHour(hour), mMinute(minute), mSecond(second) {}
[[nodiscard]] static Time now() { return Time{time(nullptr)}; }
// 0-23
[[nodiscard]] constexpr u8 hour() const { return mHour; }
// 0-59
[[nodiscard]] constexpr u8 minute() const { return mMinute; }
// 0-60. 60 is possible because of leap seconds (https://en.wikipedia.org/wiki/Leap_second)
[[nodiscard]] constexpr u8 second() const { return mSecond; }
constexpr void hour(u8 v) { mHour = v; }
constexpr void minute(u8 v) { mMinute = v; }
constexpr void second(u8 v) { mSecond = v; }
[[nodiscard]] constexpr bool operator==(const Time& other) const
{
return mSecond == other.mSecond && mMinute == other.mMinute && mHour == other.mHour;
}
[[nodiscard]] constexpr bool operator!=(const Time& other) const { return !(*this == other); }
[[nodiscard]] constexpr bool operator<(const Time& other) const
{
if (mHour < other.mHour)
{
return true;
}
else if (mHour == other.mHour && mMinute < other.mMinute)
{
return true;
}
else if (mHour == other.mHour && mMinute == other.mMinute && mSecond < other.mSecond)
{
return true;
}
return false;
}
[[nodiscard]] constexpr bool operator<=(const Time& other) const
{
return *this == other || *this < other;
}
[[nodiscard]] constexpr bool operator>(const Time& other) const
{
if (mHour > other.mHour)
{
return true;
}
else if (mHour == other.mHour && mMinute > other.mMinute)
{
return true;
}
else if (mHour == other.mHour && mMinute == other.mMinute && mSecond > other.mSecond)
{
return true;
}
return false;
}
[[nodiscard]] constexpr bool operator>=(const Time& other) const
{
return *this == other || *this > other;
}
[[nodiscard]] constexpr operator struct tm() const
{
return {mSecond, mMinute, mHour, 1, 0, 0, 0, 0, 0};
}
protected:
u8 mHour;
u8 mMinute;
u8 mSecond;
};
class DateTime : public Date, public Time
{
public:
DateTime(const time_t& time) : DateTime(*gmtime(&time)) {}
constexpr DateTime(const struct tm& time) : Date(time), Time(time) {}
constexpr DateTime(const Date& date) : Date(date), Time(0, 0, 0) {}
constexpr DateTime(const Time& time) : Date(1, 1, 1900), Time(time) {}
constexpr DateTime(const Date& date, const Time& time) : Date(date), Time(time) {}
constexpr DateTime(const Time& time, const Date& date) : Date(date), Time(time) {}
constexpr DateTime& operator=(const Date& date)
{
day(date.day());
month(date.month());
year(date.year());
return *this;
}
constexpr DateTime& operator=(const Time& time)
{
hour(time.hour());
minute(time.minute());
second(time.second());
return *this;
}
constexpr DateTime& operator=(const DateTime& other) = default;
using Date::operator==;
using Time::operator==;
using Date::operator!=;
using Time::operator!=;
using Date::operator<;
using Time::operator<;
using Date::operator>;
using Time::operator>;
using Date::operator<=;
using Time::operator<=;
using Date::operator>=;
using Time::operator>=;
[[nodiscard]] constexpr bool operator==(const DateTime& other) const
{
return Date::operator==(other) && Time::operator==(other);
}
[[nodiscard]] constexpr bool operator!=(const DateTime& other) const
{
return Date::operator!=(other) || Time::operator!=(other);
}
[[nodiscard]] constexpr bool operator<(const DateTime& other) const
{
return Date::operator<(other) || (Date::operator==(other) && Time::operator<(other));
}
[[nodiscard]] constexpr bool operator<=(const DateTime& other) const
{
return Date::operator<=(other) || (Date::operator==(other) && Time::operator<=(other));
}
[[nodiscard]] constexpr bool operator>(const DateTime& other) const
{
return Date::operator>(other) || (Date::operator==(other) && Time::operator>(other));
}
[[nodiscard]] constexpr bool operator>=(const DateTime& other) const
{
return Date::operator>(other) || (Date::operator==(other) && Time::operator>=(other));
}
// Remove overload ambiguity
[[nodiscard]] bool operator==(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator==(other) && Time::operator==(other);
}
[[nodiscard]] bool operator!=(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator!=(other) || Time::operator!=(other);
}
[[nodiscard]] bool operator<(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator<(other) || (Date::operator==(other) && Time::operator<(other));
}
[[nodiscard]] bool operator<=(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator<=(other) || (Date::operator==(other) && Time::operator<=(other));
}
[[nodiscard]] bool operator>(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator>(other) || (Date::operator==(other) && Time::operator>(other));
}
[[nodiscard]] bool operator>=(const time_t& tOther) const
{
DateTime other{tOther};
return Date::operator>(other) || (Date::operator==(other) && Time::operator>=(other));
}
[[nodiscard]] constexpr bool operator==(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator==(other) && Time::operator==(other);
}
[[nodiscard]] constexpr bool operator!=(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator!=(other) || Time::operator!=(other);
}
[[nodiscard]] constexpr bool operator<(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator<(other) || (Date::operator==(other) && Time::operator<(other));
}
[[nodiscard]] constexpr bool operator<=(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator<=(other) || (Date::operator==(other) && Time::operator<=(other));
}
[[nodiscard]] constexpr bool operator>(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator>(other) || (Date::operator==(other) && Time::operator>(other));
}
[[nodiscard]] constexpr bool operator>=(const struct tm& tOther) const
{
DateTime other{tOther};
return Date::operator>(other) || (Date::operator==(other) && Time::operator>=(other));
}
[[nodiscard]] constexpr operator struct tm() const
{
return {mSecond, mMinute, mHour, mDay, mMonth - 1, (int)(mYear - 1900), 0, 0, 0};
}
[[nodiscard]] static DateTime now() { return DateTime{time(nullptr)}; }
};
[[nodiscard]] inline bool operator==(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This == other;
}
[[nodiscard]] inline bool operator!=(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This != other;
}
[[nodiscard]] inline bool operator<(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This < other;
}
[[nodiscard]] inline bool operator<=(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This <= other;
}
[[nodiscard]] inline bool operator>(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This > other;
}
[[nodiscard]] inline bool operator>=(const time_t& tThis, const DateTime& other)
{
DateTime This{tThis};
return This >= other;
}
[[nodiscard]] inline bool operator==(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This == other;
}
[[nodiscard]] inline bool operator!=(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This != other;
}
[[nodiscard]] inline bool operator<(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This < other;
}
[[nodiscard]] inline bool operator<=(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This <= other;
}
[[nodiscard]] inline bool operator>(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This > other;
}
[[nodiscard]] inline bool operator>=(const time_t& tThis, const Date& other)
{
Date This{tThis};
return This >= other;
}
[[nodiscard]] inline bool operator==(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This == other;
}
[[nodiscard]] inline bool operator!=(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This != other;
}
[[nodiscard]] inline bool operator<(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This < other;
}
[[nodiscard]] inline bool operator<=(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This <= other;
}
[[nodiscard]] inline bool operator>(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This > other;
}
[[nodiscard]] inline bool operator>=(const time_t& tThis, const Time& other)
{
Time This{tThis};
return This >= other;
}
[[nodiscard]] constexpr bool operator==(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This == other;
}
[[nodiscard]] constexpr bool operator!=(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This != other;
}
[[nodiscard]] constexpr bool operator<(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This < other;
}
[[nodiscard]] constexpr bool operator<=(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This <= other;
}
[[nodiscard]] constexpr bool operator>(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This > other;
}
[[nodiscard]] constexpr bool operator>=(const struct tm& tThis, const DateTime& other)
{
DateTime This{tThis};
return This >= other;
}
[[nodiscard]] constexpr bool operator==(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This == other;
}
[[nodiscard]] constexpr bool operator!=(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This != other;
}
[[nodiscard]] constexpr bool operator<(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This < other;
}
[[nodiscard]] constexpr bool operator<=(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This <= other;
}
[[nodiscard]] constexpr bool operator>(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This > other;
}
[[nodiscard]] constexpr bool operator>=(const struct tm& tThis, const Date& other)
{
Date This{tThis};
return This >= other;
}
[[nodiscard]] constexpr bool operator==(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This == other;
}
[[nodiscard]] constexpr bool operator!=(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This != other;
}
[[nodiscard]] constexpr bool operator<(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This < other;
}
[[nodiscard]] constexpr bool operator<=(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This <= other;
}
[[nodiscard]] constexpr bool operator>(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This > other;
}
[[nodiscard]] constexpr bool operator>=(const struct tm& tThis, const Time& other)
{
Time This{tThis};
return This >= other;
}
#endif
| 15,862
|
C++
|
.h
| 479
| 28.187891
| 100
| 0.639809
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,318
|
random.hpp
|
FlagBrew_PKSM-Core/include/utils/random.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef RANDOM_HPP
#define RANDOM_HPP
#include "utils/coretypes.h"
#include <random>
namespace pksm
{
void seedRand(std::seed_seq& seed);
void seedRand(u32 seed);
[[nodiscard]] u32 randomNumber(u32 minInclusive, u32 maxInclusive);
struct UniformRandomBitGenerator
{
using result_type = u32;
static constexpr result_type min() noexcept
{
return std::numeric_limits<result_type>::min();
}
static constexpr result_type max() noexcept
{
return std::numeric_limits<result_type>::max();
}
result_type operator()() const noexcept;
};
}
#endif
| 1,926
|
C++
|
.h
| 49
| 35.367347
| 76
| 0.70198
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,319
|
VersionTables.hpp
|
FlagBrew_PKSM-Core/include/utils/VersionTables.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef VERSION_TABLES_HPP
#define VERSION_TABLES_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/GameVersion.hpp"
#include "enums/Generation.hpp"
#include "enums/Move.hpp"
#include "enums/Species.hpp"
#include <set>
namespace pksm::VersionTables
{
[[nodiscard]] const std::set<int>& availableItems(GameVersion version);
[[nodiscard]] const std::set<Move>& availableMoves(GameVersion version);
[[nodiscard]] const std::set<Species>& availableSpecies(GameVersion version);
[[nodiscard]] const std::set<Ability>& availableAbilities(GameVersion version);
[[nodiscard]] const std::set<Ball>& availableBalls(GameVersion version);
// Not guaranteed to be useful
[[nodiscard]] int maxItem(GameVersion version);
[[nodiscard]] Move maxMove(GameVersion version);
[[nodiscard]] Species maxSpecies(GameVersion version);
[[nodiscard]] Ability maxAbility(GameVersion version);
[[nodiscard]] Ball maxBall(GameVersion version);
// Takes version-specific forms into account
[[nodiscard]] u8 formCount(GameVersion version, Species species);
[[nodiscard]] u8 movePP(Generation gen, Move move, u8 ppUps);
}
#endif
| 2,460
|
C++
|
.h
| 52
| 44.634615
| 83
| 0.740525
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,320
|
ValueConverter.hpp
|
FlagBrew_PKSM-Core/include/utils/ValueConverter.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef VALUECONVERTER_HPP
#define VALUECONVERTER_HPP
#include "enums/Species.hpp"
#include "utils/coretypes.h"
namespace pksm
{
namespace SpeciesConverter
{
[[nodiscard]] Species g1ToNational(u8 v);
[[nodiscard]] u8 nationalToG1(Species v);
[[nodiscard]] Species g3ToNational(u16 v);
[[nodiscard]] u16 nationalToG3(Species v);
}
namespace ItemConverter
{
inline constexpr u16 ITEM_NOT_CONVERTIBLE = 128;
[[nodiscard]] u16 g1ToNational(u8 v);
[[nodiscard]] u8 nationalToG1(u16 v);
[[nodiscard]] u16 g2ToNational(u8 v);
[[nodiscard]] u8 nationalToG2(u16 v);
[[nodiscard]] u16 g3ToNational(u16 v);
[[nodiscard]] u16 nationalToG3(u16 v);
}
}
#endif
| 2,033
|
C++
|
.h
| 50
| 36.84
| 76
| 0.703741
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,321
|
WC6.hpp
|
FlagBrew_PKSM-Core/include/wcx/WC6.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef WC6_HPP
#define WC6_HPP
#include "enums/GameVersion.hpp"
#include "wcx/WCX.hpp"
namespace pksm
{
class WC6 : public WCX
{
private:
[[nodiscard]] int year(void) const override;
[[nodiscard]] int month(void) const override;
[[nodiscard]] int day(void) const override;
void year(int v) override;
void month(int v) override;
void day(int v) override;
[[nodiscard]] u32 rawDate() const;
void rawDate(u32 v);
protected:
u8 data[264];
public:
static constexpr u16 length = 264;
static constexpr u16 lengthFull = 784;
explicit WC6(u8* dt, bool full = false);
[[nodiscard]] std::string_view extension(void) const override { return ".wc6"; }
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] bool bean(void) const override;
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool power(void) const override;
[[nodiscard]] std::string title(void) const override;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] u16 objectQuantity(void) const;
[[nodiscard]] bool multiObtainable(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] u8 cardLocation(void) const override;
[[nodiscard]] bool used(void) const override;
[[nodiscard]] bool oncePerDay(void) const;
// Pokemon properties
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u32 encryptionConstant(void) const;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] Language language(void) const override;
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Move relearnMove(u8 index) const;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] GameVersion version(void) const;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] Gender otGender(void) const;
[[nodiscard]] u8 otIntensity(void) const;
[[nodiscard]] u8 otMemory(void) const;
[[nodiscard]] u16 otTextvar(void) const;
[[nodiscard]] u8 otFeeling(void) const;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 contest(u8 index) const override;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] u16 ev(Stat index) const;
[[nodiscard]] u16 additionalItem(void) const;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 5,224
|
C++
|
.h
| 108
| 41.694444
| 88
| 0.668234
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,322
|
PGT.hpp
|
FlagBrew_PKSM-Core/include/wcx/PGT.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PGT_HPP
#define PGT_HPP
#include "pkx/PK4.hpp"
#include "wcx/WCX.hpp"
#include <memory>
namespace pksm
{
class PGT : public WCX
{
private:
[[nodiscard]] int year(void) const override;
[[nodiscard]] int month(void) const override;
[[nodiscard]] int day(void) const override;
void year(int v) override;
void month(int v) override;
void day(int v) override;
protected:
u8 data[260];
std::unique_ptr<PK4> pokemonData;
public:
static constexpr u16 length = 260;
explicit PGT(u8* pgt);
[[nodiscard]] std::string_view extension() const override { return ".pgt"; }
[[nodiscard]] Generation generation() const override;
[[nodiscard]] bool bean(void) const override;
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool power(void) const override;
[[nodiscard]] virtual std::string title(void) const override;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] bool multiObtainable(void) const override;
// Stubbed functions
[[nodiscard]] u8 cardLocation(void) const override;
[[nodiscard]] bool used(void) const override;
// Pokemon properties
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Language language(void) const override;
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] u8 contest(u8 index) const override;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 4,541
|
C++
|
.h
| 96
| 41
| 84
| 0.672608
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,323
|
PGF.hpp
|
FlagBrew_PKSM-Core/include/wcx/PGF.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PGF_HPP
#define PGF_HPP
#include "wcx/WCX.hpp"
namespace pksm
{
class PGF : public WCX
{
private:
[[nodiscard]] int year(void) const override;
[[nodiscard]] int month(void) const override;
[[nodiscard]] int day(void) const override;
void year(int v) override;
void month(int v) override;
void day(int v) override;
protected:
u8 data[204];
public:
static constexpr u16 length = 204;
explicit PGF(u8* pgf);
[[nodiscard]] std::string_view extension() const override { return ".pgf"; }
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] std::string title(void) const override;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool power(void) const override;
[[nodiscard]] bool bean(void) const override;
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] u8 cardLocation(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] bool used(void) const override;
[[nodiscard]] bool multiObtainable(void) const override;
// Pokemon Properties
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Language language(void) const override;
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] u8 contest(u8 index) const override;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 4,425
|
C++
|
.h
| 92
| 41.73913
| 84
| 0.672917
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,324
|
WC8.hpp
|
FlagBrew_PKSM-Core/include/wcx/WC8.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef WC8_HPP
#define WC8_HPP
#include "enums/GameVersion.hpp"
#include "wcx/WCX.hpp"
namespace pksm
{
class WC8 : public WCX
{
private:
[[nodiscard]] int year(void) const override { return 1900; }
[[nodiscard]] int month(void) const override { return 1; }
[[nodiscard]] int day(void) const override { return 1; }
void year(int) override {}
void month(int) override {}
void day(int) override {}
protected:
u8 data[0x2D0];
int numItems = 0;
public:
static constexpr u16 length = 0x2D0;
explicit WC8(u8* dt);
[[nodiscard]] std::string_view extension(void) const override { return ".wc8"; }
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] bool bean(void) const override { return false; }
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool clothing(void) const;
[[nodiscard]] bool power(void) const override { return false; }
[[nodiscard]] std::string title(void) const override;
[[nodiscard]] std::string title(Language lang) const;
[[nodiscard]] Language titleIndex(void) const;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] u16 objectQuantity(void) const;
// Multiple-item cards
[[nodiscard]] u16 object(int index) const;
[[nodiscard]] u16 objectQuantity(int index) const;
[[nodiscard]] int items(void) const;
[[nodiscard]] bool multiObtainable(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] u8 cardLocation(void) const override { return 0; }
[[nodiscard]] bool used(void) const override;
// Pokemon properties
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Move relearnMove(u8 index) const;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] u8 dynamaxLevel(void) const;
[[nodiscard]] bool canGigantamax(void) const;
[[nodiscard]] u8 ribbonValue(int index) const;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] Gender otGender(void) const;
[[nodiscard]] u16 ev(Stat index) const;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u32 encryptionConstant(void) const;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] Language language(void) const override
{
return Language::UNUSED;
} // Apparently all WCs are now multi-language?
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] std::string nickname(Language lang) const;
[[nodiscard]] Language nicknameLanguage(Language orig) const;
[[nodiscard]] bool nicknamed(Language lang) const;
[[nodiscard]] GameVersion version(void) const;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] std::string otName(Language lang) const;
[[nodiscard]] u8 otIntensity(void) const;
[[nodiscard]] u8 otMemory(void) const;
[[nodiscard]] u16 otTextvar(void) const;
[[nodiscard]] u8 otFeeling(void) const;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 contest(u8) const override { return 0; }
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 5,989
|
C++
|
.h
| 121
| 42.413223
| 88
| 0.66387
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,325
|
WC7.hpp
|
FlagBrew_PKSM-Core/include/wcx/WC7.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef WC7_HPP
#define WC7_HPP
#include "enums/GameVersion.hpp"
#include "wcx/WCX.hpp"
namespace pksm
{
class WC7 : public WCX
{
private:
[[nodiscard]] int year(void) const override;
[[nodiscard]] int month(void) const override;
[[nodiscard]] int day(void) const override;
void year(int v) override;
void month(int v) override;
void day(int v) override;
[[nodiscard]] u32 rawDate() const;
void rawDate(u32 v);
protected:
u8 data[264];
int numItems = 0;
public:
static constexpr u16 length = 264;
static constexpr u16 lengthFull = 784;
explicit WC7(u8* dt, bool full = false);
[[nodiscard]] std::string_view extension(void) const override { return ".wc7"; }
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] bool bean(void) const override;
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool power(void) const override;
[[nodiscard]] std::string title(void) const override;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] u16 objectQuantity(void) const;
// Multiple-item cards
[[nodiscard]] u16 object(int index) const;
[[nodiscard]] u16 objectQuantity(int index) const;
[[nodiscard]] int items(void) const;
[[nodiscard]] bool multiObtainable(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] u8 cardLocation(void) const override;
[[nodiscard]] bool repeatable(void) const;
[[nodiscard]] bool used(void) const override;
[[nodiscard]] bool oncePerDay(void) const;
// Pokemon properties
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u32 encryptionConstant(void) const;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] Language language(void) const override;
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Move relearnMove(u8 index) const;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] GameVersion version(void) const;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] Gender otGender(void) const;
[[nodiscard]] u8 otIntensity(void) const;
[[nodiscard]] u8 otMemory(void) const;
[[nodiscard]] u16 otTextvar(void) const;
[[nodiscard]] u8 otFeeling(void) const;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 contest(u8 index) const override;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] u16 ev(Stat index) const;
[[nodiscard]] u16 additionalItem(void) const;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 5,487
|
C++
|
.h
| 114
| 41.333333
| 88
| 0.665485
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,326
|
WC4.hpp
|
FlagBrew_PKSM-Core/include/wcx/WC4.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef WC4_HPP
#define WC4_HPP
#include "utils/utils.hpp"
#include "wcx/PGT.hpp"
namespace pksm
{
class WC4 : public PGT
{
public:
explicit WC4(u8* wc4);
[[nodiscard]] std::string_view extension() const override { return ".wc4"; }
static constexpr int length = 856;
[[nodiscard]] std::string title(void) const override { return name; };
[[nodiscard]] u16 ID(void) const override { return id; }
private:
std::string name;
u16 id;
};
}
#endif
| 1,797
|
C++
|
.h
| 45
| 36.511111
| 84
| 0.699369
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,327
|
WCX.hpp
|
FlagBrew_PKSM-Core/include/wcx/WCX.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PKSM_WCX
#define PKSM_WCX
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/Gender.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Move.hpp"
#include "enums/Nature.hpp"
#include "enums/Ribbon.hpp"
#include "enums/Species.hpp"
#include "enums/Stat.hpp"
#include "utils/coretypes.h"
#include "utils/DateTime.hpp"
#include <string>
namespace pksm
{
class WCX
{
private:
[[nodiscard]] virtual int year(void) const = 0;
[[nodiscard]] virtual int month(void) const = 0;
[[nodiscard]] virtual int day(void) const = 0;
virtual void year(int v) = 0;
virtual void month(int v) = 0;
virtual void day(int v) = 0;
public:
WCX() {}
WCX(const WCX&) = delete;
WCX& operator=(const WCX&) = delete;
virtual ~WCX(void) = default;
[[nodiscard]] virtual std::string_view extension() const = 0;
[[nodiscard]] virtual Generation generation(void) const = 0;
[[nodiscard]] virtual bool bean(void) const = 0;
[[nodiscard]] virtual bool BP(void) const = 0;
[[nodiscard]] virtual bool item(void) const = 0;
[[nodiscard]] virtual bool pokemon(void) const = 0;
[[nodiscard]] virtual bool power(void) const = 0;
[[nodiscard]] virtual std::string title(void) const = 0;
[[nodiscard]] virtual u8 type(void) const = 0;
[[nodiscard]] Date date(void) const { return Date{(u8)day(), (u8)month(), (u32)year()}; }
void date(const Date& v)
{
day(v.day());
month(v.month());
year(v.year());
}
[[nodiscard]] virtual u16 ID(void) const = 0;
[[nodiscard]] virtual u16 object(void) const = 0;
[[nodiscard]] virtual bool multiObtainable(void) const = 0;
[[nodiscard]] virtual u8 flags(void) const = 0;
[[nodiscard]] virtual u8 cardLocation(void) const = 0;
[[nodiscard]] virtual bool used(void) const = 0;
// Pokemon properties
[[nodiscard]] virtual bool shiny(void) const = 0;
[[nodiscard]] virtual Ability ability(void) const = 0;
[[nodiscard]] virtual u8 abilityType(void) const = 0;
[[nodiscard]] virtual Ball ball(void) const = 0;
[[nodiscard]] virtual bool egg(void) const = 0;
[[nodiscard]] virtual u8 alternativeForm(void) const = 0;
[[nodiscard]] virtual Gender gender(void) const = 0;
[[nodiscard]] virtual u16 heldItem(void) const = 0;
[[nodiscard]] virtual Language language(void) const = 0;
[[nodiscard]] virtual u8 level(void) const = 0;
[[nodiscard]] virtual u8 metLevel(void) const = 0;
[[nodiscard]] virtual Move move(u8 index) const = 0;
[[nodiscard]] virtual Nature nature(void) const = 0;
[[nodiscard]] virtual std::string nickname(void) const = 0;
[[nodiscard]] virtual std::string otName(void) const = 0;
[[nodiscard]] virtual u8 PIDType(void) const = 0;
[[nodiscard]] virtual u16 SID(void) const = 0;
[[nodiscard]] virtual Species species(void) const = 0;
[[nodiscard]] virtual u16 TID(void) const = 0;
[[nodiscard]] virtual u16 eggLocation(void) const = 0;
[[nodiscard]] virtual u16 metLocation(void) const = 0;
[[nodiscard]] virtual u8 contest(u8 index) const = 0;
[[nodiscard]] virtual u8 iv(Stat index) const = 0;
[[nodiscard]] virtual u32 PID(void) const = 0;
[[nodiscard]] virtual bool hasRibbon(Ribbon rib) const = 0;
[[nodiscard]] virtual bool ribbon(Ribbon rib) const = 0;
[[nodiscard]] virtual u16 formSpecies(void) const = 0;
[[nodiscard]] virtual int size(void) const = 0;
[[nodiscard]] virtual const u8* rawData(void) const = 0;
[[nodiscard]] u32 formatTID(void) const;
[[nodiscard]] u32 formatSID(void) const;
};
}
#endif
| 5,605
|
C++
|
.h
| 113
| 43.442478
| 97
| 0.600329
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,328
|
WB7.hpp
|
FlagBrew_PKSM-Core/include/wcx/WB7.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef WB7_HPP
#define WB7_HPP
#include "enums/GameVersion.hpp"
#include "enums/Language.hpp"
#include "wcx/WCX.hpp"
namespace pksm
{
class WB7 : public WCX
{
private:
[[nodiscard]] int year(void) const override;
[[nodiscard]] int month(void) const override;
[[nodiscard]] int day(void) const override;
void year(int v) override;
void month(int v) override;
void day(int v) override;
[[nodiscard]] u32 rawDate() const;
void rawDate(u32 v);
protected:
u8 data[264];
int numItems = 0;
public:
static constexpr u16 length = 264;
static constexpr u16 lengthFull = 784;
explicit WB7(u8* dt, bool full = false);
[[nodiscard]] std::string_view extension() const override { return ".wb7"; }
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] bool bean(void) const override;
[[nodiscard]] bool BP(void) const override;
[[nodiscard]] bool item(void) const override;
[[nodiscard]] bool pokemon(void) const override;
[[nodiscard]] bool power(void) const override;
[[nodiscard]] std::string title(void) const override;
[[nodiscard]] u8 type(void) const override;
[[nodiscard]] u16 ID(void) const override;
[[nodiscard]] u16 object(void) const override;
[[nodiscard]] u16 objectQuantity(void) const;
// Multiple-item cards
[[nodiscard]] u16 object(int index) const;
[[nodiscard]] u16 objectQuantity(int index) const;
[[nodiscard]] int items(void) const;
[[nodiscard]] bool multiObtainable(void) const override;
[[nodiscard]] u8 flags(void) const override;
[[nodiscard]] u8 cardLocation(void) const override;
[[nodiscard]] bool used(void) const override;
[[nodiscard]] bool oncePerDay(void) const;
// Pokemon properties
[[nodiscard]] bool egg(void) const override;
[[nodiscard]] bool shiny(void) const override;
[[nodiscard]] Ability ability(void) const override;
[[nodiscard]] u8 abilityType(void) const override;
[[nodiscard]] Ball ball(void) const override;
[[nodiscard]] u32 encryptionConstant(void) const;
[[nodiscard]] u8 alternativeForm(void) const override;
[[nodiscard]] Gender gender(void) const override;
[[nodiscard]] u16 heldItem(void) const override;
[[nodiscard]] Language language(void) const override
{
return Language::UNUSED;
} // Apparently all WCs are now multi-language?
[[nodiscard]] u8 level(void) const override;
[[nodiscard]] u8 metLevel(void) const override;
[[nodiscard]] Move move(u8 index) const override;
[[nodiscard]] Move relearnMove(u8 index) const;
[[nodiscard]] Nature nature(void) const override;
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] std::string nickname(Language lang) const;
[[nodiscard]] GameVersion version(void) const;
[[nodiscard]] std::string otName(void) const override;
[[nodiscard]] std::string otName(Language lang) const;
[[nodiscard]] Gender otGender(void) const;
[[nodiscard]] u8 otIntensity(void) const;
[[nodiscard]] u8 otMemory(void) const;
[[nodiscard]] u16 otTextvar(void) const;
[[nodiscard]] u8 otFeeling(void) const;
[[nodiscard]] u16 TID(void) const override;
[[nodiscard]] u16 SID(void) const override;
[[nodiscard]] u8 PIDType(void) const override;
[[nodiscard]] u32 PID(void) const override;
[[nodiscard]] Species species(void) const override;
[[nodiscard]] u16 eggLocation(void) const override;
[[nodiscard]] u16 metLocation(void) const override;
[[nodiscard]] u8 contest(u8) const override { return 0; }
[[nodiscard]] u8 awakened(Stat index) const;
[[nodiscard]] u8 iv(Stat index) const override;
[[nodiscard]] u16 ev(Stat index) const;
[[nodiscard]] u16 additionalItem(void) const;
[[nodiscard]] bool hasRibbon(Ribbon) const override { return false; }
[[nodiscard]] bool ribbon(Ribbon) const override { return false; }
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int size(void) const override { return length; }
[[nodiscard]] const u8* rawData(void) const override { return data; }
};
}
#endif
| 5,784
|
C++
|
.h
| 120
| 41.275
| 84
| 0.663242
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,329
|
PCD.hpp
|
FlagBrew_PKSM-Core/include/wcx/PCD.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PCD_HPP
#define PCD_HPP
#include "utils/utils.hpp"
#include "wcx/PGT.hpp"
namespace pksm
{
class PCD : public PGT
{
public:
explicit PCD(u8* pcd);
[[nodiscard]] std::string_view extension() const override { return ".pcd"; }
static constexpr int length = 856;
[[nodiscard]] std::string title(void) const override { return name; };
[[nodiscard]] u16 ID(void) const override { return id; }
private:
std::string name;
u16 id;
};
}
#endif
| 1,797
|
C++
|
.h
| 45
| 36.511111
| 84
| 0.699369
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,330
|
PK3.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK3.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK3_HPP
#define PK3_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK3 : public PKX
{
protected:
static constexpr size_t BlockDataLength = 12;
static constexpr size_t BlockShuffleStart = 32;
// Doesn't use pksm::crypto::pkm method because there's no seed stepping
void crypt(void);
u16 calcChecksum() const;
private:
bool japanese(void) const;
static int swapBits(int value, int p1, int p2);
[[nodiscard]] int eggYear(void) const override { return 1900; }
void eggYear(int) override {}
[[nodiscard]] int eggMonth(void) const override { return 1; }
void eggMonth(int) override {}
[[nodiscard]] int eggDay(void) const override { return 1; }
void eggDay(int) override {}
[[nodiscard]] int metYear(void) const override { return 1900; }
void metYear(int) override {}
[[nodiscard]] int metMonth(void) const override { return 1; }
void metMonth(int) override {}
[[nodiscard]] int metDay(void) const override { return 1; }
void metDay(int) override {}
public:
static constexpr size_t BOX_LENGTH = 80;
static constexpr size_t PARTY_LENGTH = 100;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Deoxys;
PK3(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk3"; }
static u8 getUnownForm(u32 pid);
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] PKXHandler currentHandler(void) const override { return PKXHandler::OT; }
void currentHandler(PKXHandler) override {}
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] bool flagIsBadEgg(void) const;
void flagIsBadEgg(bool v);
[[nodiscard]] bool flagHasSpecies(void) const;
void flagHasSpecies(bool v);
[[nodiscard]] bool flagIsEgg(void) const;
void flagIsEgg(bool v);
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 speciesID3(void) const;
void speciesID3(u16 v);
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem3(void) const;
void heldItem3(u16 v);
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
void heldItem(const Item& item) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 htFriendship(void) const override { return baseFriendship(); }
void htFriendship(u8 v) override {}
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] bool abilityBit(void) const;
void abilityBit(bool v);
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
[[nodiscard]] u8 contestRibbonCount(u8 contest) const;
void contestRibbonCount(u8 contest, u8 count);
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] Move relearnMove(u8) const override { return Move::None; }
void relearnMove(u8, Move) override {}
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
u8 shinyLeaf(void) const;
void shinyLeaf(u8 v);
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
bool hiddenAbility(void) const;
void hiddenAbility(bool v);
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] u16 eggLocation(void) const override { return 0; }
void eggLocation(u16) override {}
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] u8 encounterType(void) const;
void encounterType(u8 v);
[[nodiscard]] u8 characteristic(void) const;
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalRSFRLGE::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalRSFRLGE::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalRSFRLGE::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalRSFRLGE::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalRSFRLGE::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalRSFRLGE::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalRSFRLGE::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalRSFRLGE::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalRSFRLGE::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalRSFRLGE::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalRSFRLGE::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalRSFRLGE::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override { return 0; }
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 12,559
|
C++
|
.h
| 261
| 39.701149
| 95
| 0.652984
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,331
|
PK4.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK4.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK4_HPP
#define PK4_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK4 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 32;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
protected:
static constexpr Species beasts[4] = {
Species::Celebi, Species::Raikou, Species::Entei, Species::Suicune};
static constexpr Move banned[8] = {Move::Cut, Move::Fly, Move::Surf, Move::Strength,
Move::Whirlpool, Move::RockSmash, Move::Waterfall, Move::RockClimb};
public:
static constexpr size_t BOX_LENGTH = 136;
static constexpr size_t PARTY_LENGTH = 236;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Arceus;
PK4(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk4"; }
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] PKXHandler currentHandler(void) const override { return PKXHandler::OT; }
void currentHandler(PKXHandler) override {}
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 htFriendship(void) const override { return baseFriendship(); }
void htFriendship(u8 v) override {}
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] Move relearnMove(u8) const override { return Move::None; }
void relearnMove(u8, Move) override {}
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] u8 shinyLeaf(void) const;
void shinyLeaf(u8 v);
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool hiddenAbility(void) const;
void hiddenAbility(bool v);
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] u8 encounterType(void) const;
void encounterType(u8 v);
[[nodiscard]] u8 characteristic(void) const;
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalDPPtHGSS::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalDPPtHGSS::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalDPPtHGSS::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalDPPtHGSS::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalDPPtHGSS::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalDPPtHGSS::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalDPPtHGSS::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalDPPtHGSS::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalDPPtHGSS::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalDPPtHGSS::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalDPPtHGSS::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalDPPtHGSS::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override
{
return PersonalDPPtHGSS::formStatIndex(formSpecies());
}
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 11,909
|
C++
|
.h
| 247
| 39.850202
| 95
| 0.654552
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,332
|
PK1.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK1.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK1_HPP
#define PK1_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK1 : public PKX
{
private:
u8* shiftedData;
Language lang;
GameVersion versionOfGame = GameVersion::RD; // not even PKHeX tries to do better
bool japanese;
[[nodiscard]] int eggYear(void) const override { return 1900; }
void eggYear(int) override {}
[[nodiscard]] int eggMonth(void) const override { return 1; }
void eggMonth(int) override {}
[[nodiscard]] int eggDay(void) const override { return 1; }
void eggDay(int) override {}
[[nodiscard]] int metYear(void) const override { return 1900; }
void metYear(int) override {}
[[nodiscard]] int metMonth(void) const override { return 1; }
void metMonth(int) override {}
[[nodiscard]] int metDay(void) const override { return 1; }
void metDay(int) override {}
public:
static constexpr size_t JP_LENGTH_WITH_NAMES = 59;
static constexpr size_t INT_LENGTH_WITH_NAMES = 69;
static constexpr size_t BOX_LENGTH = 33;
static constexpr size_t PARTY_LENGTH = 44;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Mew;
PK1(PrivateConstructor, u8* dt, bool japanese = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk1"; }
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override { return Generation::ONE; }
[[nodiscard]] bool isParty(void) const override { return true; }
void decrypt(void) override {}
void encrypt(void) override {}
[[nodiscard]] bool isEncrypted(void) const override { return false; }
[[nodiscard]] u32 encryptionConstant(void) const override { return 0; }
void encryptionConstant(u32 v) override {}
[[nodiscard]] PKXHandler currentHandler(void) const override { return PKXHandler::OT; }
void currentHandler(PKXHandler) override {}
[[nodiscard]] u8 abilityNumber(void) const override { return 0; }
void abilityNumber(u8 v) override {}
void setAbility(u8 abilityNumber) override {}
[[nodiscard]] u32 PID(void) const override { return 0; }
void PID(u32 v) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override { return 0; }
void SID(u16 v) override {}
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] std::string nicknameTransporter(void) const;
void nickname(const std::string_view& v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] std::string transferOT(Language lang) const;
[[nodiscard]] u16 markValue(void) const override { return 0; }
void markValue(u16 v) override {}
[[nodiscard]] u16 checksum(void) const override { return 0; }
void checksum(u16 v) override {}
[[nodiscard]] u16 sanity(void) const override { return 0; }
void sanity(u16 v) override {}
[[nodiscard]] u8 speciesID1(void) const;
void speciesID1(u8 v);
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u8 catchRate(void) const;
void catchRate(u8 v);
[[nodiscard]] u8 heldItem2(void) const;
void heldItem2(u8 v);
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
void heldItem(const Item& item) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] u8 otFriendship(void) const override { return baseFriendship(); }
void otFriendship(u8 v) override {}
[[nodiscard]] u8 htFriendship(void) const override { return baseFriendship(); }
void htFriendship(u8 v) override {}
[[nodiscard]] Ability ability(void) const override { return Ability::None; }
void ability(Ability v) override {}
// EVs in Gen I and II are u16s
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8) const override { return 0; }
void contest(u8 contest, u8 v) override {}
[[nodiscard]] bool hasRibbon(Ribbon) const override { return false; }
[[nodiscard]] bool ribbon(Ribbon) const override { return false; }
void ribbon(Ribbon rib, bool v) override {}
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] Move relearnMove(u8) const override { return Move::None; }
void relearnMove(u8, Move) override {}
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override { return false; }
void egg(bool v) override {}
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override {}
[[nodiscard]] bool fatefulEncounter(void) const override { return false; }
void fatefulEncounter(bool v) override {}
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override { return 0; }
void alternativeForm(u16 v) override {}
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] GameVersion version(void) const override { return versionOfGame; }
void version(GameVersion v) override { versionOfGame = v; }
[[nodiscard]] u16 eggLocation(void) const override { return 0; }
void eggLocation(u16) override {}
[[nodiscard]] u16 metLocation(void) const override { return 0; }
void metLocation(u16 v) override {}
[[nodiscard]] u8 pkrs(void) const override { return 0; }
void pkrs(u8 v) override {}
[[nodiscard]] u8 pkrsDays(void) const override { return 0; }
void pkrsDays(u8 v) override {}
[[nodiscard]] u8 pkrsStrain(void) const override { return 0; }
void pkrsStrain(u8 v) override {}
[[nodiscard]] Ball ball(void) const override { return Ball::Poke; }
void ball(Ball v) override {}
[[nodiscard]] u8 metLevel(void) const override { return 0; }
void metLevel(u8 v) override {}
[[nodiscard]] Gender otGender(void) const override { return Gender::Male; }
void otGender(Gender v) override {}
void refreshChecksum(void) override {}
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override { return 0; }
[[nodiscard]] u16 PSV(void) const override { return 0xFFFF; }
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
[[nodiscard]] int boxLevel() const;
void boxLevel(u8 v);
void updatePartyData(void) override;
void writeG1Types(void);
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 0xF; }
u16 maxEV(void) const override { return 0xFFFF; }
u32 maxEVTotal(void) const override { return 0xFFFFFFFF; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalRGBY::baseHP(u8(species()));
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalRGBY::baseAtk(u8(species()));
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalRGBY::baseDef(u8(species()));
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalRGBY::baseSpe(u8(species()));
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalRGBY::baseSpad(u8(species()));
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalRGBY::baseSpad(u8(species()));
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalRGBY::type1(u8(species()));
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalRGBY::type2(u8(species()));
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalGSC::gender(u8(species()));
}
[[nodiscard]] inline u8 baseFriendship(void) const override { return 70; }
[[nodiscard]] inline u8 baseCatchRate(void) const
{
return PersonalRGBY::catchRate(u8(species()));
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalRGBY::expType(u8(species()));
}
[[nodiscard]] inline Ability abilities(u8) const override { return Ability::None; }
[[nodiscard]] inline u16 formStatIndex(void) const override { return 0; }
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 12,573
|
C++
|
.h
| 247
| 42.295547
| 95
| 0.647628
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,333
|
PK2.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK2.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK2_HPP
#define PK2_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK2 : public PKX
{
private:
u8* shiftedData;
Language lang;
GameVersion versionOfGame = GameVersion::GD;
bool japanese;
bool korean = false;
[[nodiscard]] int eggYear(void) const override { return 1900; }
void eggYear(int) override {}
[[nodiscard]] int eggMonth(void) const override { return 1; }
void eggMonth(int) override {}
[[nodiscard]] int eggDay(void) const override { return 1; }
void eggDay(int) override {}
[[nodiscard]] int metYear(void) const override { return 1900; }
void metYear(int) override {}
[[nodiscard]] int metMonth(void) const override { return 1; }
void metMonth(int) override {}
[[nodiscard]] int metDay(void) const override { return 1; }
void metDay(int) override {}
public:
static constexpr size_t JP_LENGTH_WITH_NAMES = 63;
static constexpr size_t INT_LENGTH_WITH_NAMES = 73;
static constexpr size_t BOX_LENGTH = 32;
static constexpr size_t PARTY_LENGTH = 48;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Celebi;
PK2(PrivateConstructor, u8* dt, bool japanese = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk2"; }
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override { return Generation::TWO; }
[[nodiscard]] bool isParty(void) const override { return true; }
void decrypt(void) override {}
void encrypt(void) override {}
[[nodiscard]] bool isEncrypted(void) const override { return false; }
[[nodiscard]] u32 encryptionConstant(void) const override { return 0; }
void encryptionConstant(u32 v) override {}
[[nodiscard]] PKXHandler currentHandler(void) const override { return PKXHandler::OT; }
void currentHandler(PKXHandler) override {}
[[nodiscard]] u8 abilityNumber(void) const override { return 0; }
void abilityNumber(u8 v) override {}
void setAbility(u8 abilityNumber) override {}
[[nodiscard]] u32 PID(void) const override { return 0; }
void PID(u32 v) override {}
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override { return 0; }
void SID(u16 v) override {}
[[nodiscard]] std::string nickname(void) const override;
[[nodiscard]] std::string nicknameTransporter(void) const;
void nickname(const std::string_view& v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
void languageOverrideLimits(Language v);
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] std::string transferOT(Language lang) const;
[[nodiscard]] u16 markValue(void) const override { return 0; }
void markValue(u16 v) override {}
[[nodiscard]] u16 checksum(void) const override { return 0; }
void checksum(u16 v) override {}
[[nodiscard]] u16 sanity(void) const override { return 0; }
void sanity(u16 v) override {}
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u8 heldItem2(void) const;
void heldItem2(u8 v);
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
void heldItem(const Item& item) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 htFriendship(void) const override { return 0; }
void htFriendship(u8 v) override {}
[[nodiscard]] Ability ability(void) const override { return Ability::None; }
void ability(Ability v) override {}
// EVs in Gen I and II are u16s
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8) const override { return 0; }
void contest(u8 contest, u8 v) override {}
[[nodiscard]] bool hasRibbon(Ribbon) const override { return false; }
[[nodiscard]] bool ribbon(Ribbon) const override { return false; }
void ribbon(Ribbon rib, bool v) override {}
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] Move relearnMove(u8) const override { return Move::None; }
void relearnMove(u8, Move) override {}
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override {}
[[nodiscard]] bool fatefulEncounter(void) const override { return false; }
void fatefulEncounter(bool v) override {}
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] u16 catchData(void) const;
void catchData(u16 v);
[[nodiscard]] u16 eggLocation(void) const override { return 0; }
void eggLocation(u16) override {}
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] Ball ball(void) const override { return Ball::Poke; }
void ball(Ball v) override {}
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
// 1: Morning, 2: Day, 3: Night
[[nodiscard]] u8 metTime() const;
void metTime(u8 v);
void refreshChecksum(void) override {}
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override { return 0; }
[[nodiscard]] u16 PSV(void) const override { return 0xFFFF; }
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 0xF; }
u16 maxEV(void) const override { return 0xFFFF; }
u32 maxEVTotal(void) const override { return 0xFFFFFFFF; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalGSC::baseHP(u8(species()));
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalGSC::baseAtk(u8(species()));
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalGSC::baseDef(u8(species()));
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalGSC::baseSpe(u8(species()));
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalGSC::baseSpa(u8(species()));
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalGSC::baseSpd(u8(species()));
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalGSC::type1(u8(species()));
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalGSC::type2(u8(species()));
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalGSC::gender(u8(species()));
}
[[nodiscard]] inline u8 baseFriendship(void) const override { return 70; }
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalGSC::expType(u8(species()));
}
[[nodiscard]] inline Ability abilities(u8) const override { return Ability::None; }
[[nodiscard]] inline u16 formStatIndex(void) const override { return 0; }
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 12,149
|
C++
|
.h
| 243
| 41.489712
| 95
| 0.648873
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,334
|
PK7.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK7.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK7_HPP
#define PK7_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK7 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 56;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
protected:
static constexpr u8 hyperTrainLookup[6] = {0, 1, 2, 5, 3, 4};
public:
static constexpr size_t BOX_LENGTH = 232;
static constexpr size_t PARTY_LENGTH = 260;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Zeraora;
PK7(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk7"; }
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
// std::unique_ptr<PKX> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
[[nodiscard]] u8 pelagoEventStatus(void) const;
void pelagoEventStatus(u8 v);
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
[[nodiscard]] u8 ribbonContestCount(void) const;
void ribbonContestCount(u8 v);
[[nodiscard]] u8 ribbonBattleCount(void) const;
void ribbonBattleCount(u8 v);
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] Move relearnMove(u8 move) const override;
void relearnMove(u8 move, Move v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] std::string htName(void) const;
void htName(const std::string_view& v);
[[nodiscard]] Gender htGender(void) const;
void htGender(Gender v);
[[nodiscard]] PKXHandler currentHandler(void) const override;
void currentHandler(PKXHandler v) override;
[[nodiscard]] u8 geoRegion(u8 region) const;
void geoRegion(u8 region, u8 v);
[[nodiscard]] u8 geoCountry(u8 country) const;
void geoCountry(u8 country, u8 v);
[[nodiscard]] u8 htFriendship(void) const override;
void htFriendship(u8 v) override;
[[nodiscard]] u8 htAffection(void) const;
void htAffection(u8 v);
[[nodiscard]] u8 htIntensity(void) const;
void htIntensity(u8 v);
[[nodiscard]] u8 htMemory(void) const;
void htMemory(u8 v);
[[nodiscard]] u8 htFeeling(void) const;
void htFeeling(u8 v);
[[nodiscard]] u16 htTextVar(void) const;
void htTextVar(u16 v);
[[nodiscard]] u8 fullness(void) const;
void fullness(u8 v);
[[nodiscard]] u8 enjoyment(void) const;
void enjoyment(u8 v);
// TODO
// u32 formDuration(void) const;
// void formDuration(u32 v);
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 otAffection(void) const;
void otAffection(u8 v);
[[nodiscard]] u8 otIntensity(void) const;
void otIntensity(u8 v);
[[nodiscard]] u8 otMemory(void) const;
void otMemory(u8 v);
[[nodiscard]] u16 otTextVar(void) const;
void otTextVar(u16 v);
[[nodiscard]] u8 otFeeling(void) const;
void otFeeling(u8 v);
[[nodiscard]] u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] bool hyperTrain(Stat stat) const override;
void hyperTrain(Stat stat, bool v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] u8 country(void) const;
void country(u8 v);
[[nodiscard]] u8 region(void) const;
void region(u8 v);
[[nodiscard]] u8 consoleRegion(void) const;
void consoleRegion(u8 v);
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalSMUSUM::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalSMUSUM::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalSMUSUM::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalSMUSUM::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalSMUSUM::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalSMUSUM::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalSMUSUM::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalSMUSUM::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalSMUSUM::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalSMUSUM::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalSMUSUM::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalSMUSUM::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override
{
return PersonalSMUSUM::formStatIndex(formSpecies());
}
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 13,201
|
C++
|
.h
| 284
| 38.088028
| 95
| 0.647868
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,335
|
PK8.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK8.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK8_HPP
#define PK8_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK8 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 80;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
protected:
static constexpr u16 hyperTrainLookup[6] = {0, 1, 2, 5, 3, 4};
public:
static constexpr size_t BOX_LENGTH = 0x148;
static constexpr size_t PARTY_LENGTH = 0x158;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Zarude;
PK8(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk8"; }
// std::unique_ptr<PK1> convertToG1(Sav& save) const override;
// std::unique_ptr<PK2> convertToG2(Sav& save) const override;
// std::unique_ptr<PK3> convertToG3(Sav& save) const override;
// std::unique_ptr<PK4> convertToG4(Sav& save) const override;
// std::unique_ptr<PK5> convertToG5(Sav& save) const override;
// std::unique_ptr<PK6> convertToG6(Sav& save) const override;
// std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
Ability ability(void) const override;
void ability(Ability v) override;
u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
bool favorite(void) const;
void favorite(bool v) const;
bool canGiga(void) const;
void canGiga(bool v) const;
u16 markValue(void) const override;
void markValue(u16 v) override;
u32 PID(void) const override;
void PID(u32 v) override;
Nature origNature(void) const;
void origNature(Nature v);
Nature nature(void) const override;
void nature(Nature v) override;
bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
Gender gender(void) const override;
void gender(Gender g) override;
u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
u8 pkrs(void) const override;
void pkrs(u8 v) override;
u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
bool hasRibbon(Ribbon rib) const override;
bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
u8 ribbonContestCount(void) const;
void ribbonContestCount(u8 v);
u8 ribbonBattleCount(void) const;
void ribbonBattleCount(u8 v);
u8 height(void) const;
void height(u8 v);
u8 weight(void) const;
void weight(u8 v);
std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
Move move(u8 move) const override;
void move(u8 move, Move v) override;
u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
Move relearnMove(u8 move) const override;
void relearnMove(u8 move, Move v) override;
int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
u8 dynamaxLevel(void) const;
void dynamaxLevel(u8 v);
bool egg(void) const override;
void egg(bool v) override;
bool nicknamed(void) const override;
void nicknamed(bool v) override;
std::string htName(void) const;
void htName(const std::string_view& v);
Gender htGender(void) const;
void htGender(Gender v);
Language htLanguage(void) const;
void htLanguage(Language lang);
PKXHandler currentHandler(void) const override;
void currentHandler(PKXHandler v) override;
// Unused
u16 htID(void) const;
void htID(u16 v);
u8 htFriendship(void) const override;
void htFriendship(u8 v) override;
u8 htIntensity(void) const;
void htIntensity(u8 v);
u8 htMemory(void) const;
void htMemory(u8 v);
u8 htFeeling(void) const;
void htFeeling(u8 v);
u16 htTextVar(void) const;
void htTextVar(u16 v);
u8 fullness(void) const;
void fullness(u8 v);
u8 enjoyment(void) const;
void enjoyment(u8 v);
GameVersion version(void) const override;
void version(GameVersion v) override;
u8 battleVersion(void) const;
void battleVersion(u8 v);
u8 country(void) const { return 0; }
void country(u8) {}
u8 region(void) const { return 0; }
void region(u8) {}
u8 consoleRegion(void) const { return 0; }
void consoleRegion(u8) {}
Language language(void) const override;
void language(Language v) override;
u32 formDuration(void) const;
void formDuration(u32 v);
s8 favRibbon(void) const;
void favRibbon(s8 v);
std::string otName(void) const override;
void otName(const std::string_view& v) override;
u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
u8 otAffection(void) const;
void otAffection(u8 v);
u8 otIntensity(void) const;
void otIntensity(u8 v);
u8 otMemory(void) const;
void otMemory(u8 v);
u16 otTextVar(void) const;
void otTextVar(u16 v);
u8 otFeeling(void) const;
void otFeeling(u8 v);
u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
u16 metLocation(void) const override;
void metLocation(u16 v) override;
Ball ball(void) const override;
void ball(Ball v) override;
u8 metLevel(void) const override;
void metLevel(u8 v) override;
Gender otGender(void) const override;
void otGender(Gender v) override;
bool hyperTrain(Stat stat) const override;
void hyperTrain(Stat stat, bool v) override;
bool moveRecordFlag(u8 index) const;
void moveRecordFlag(u8 index, bool v);
u64 homeTracker(void) const;
void homeTracker(u64 v);
int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
int partyLevel(void) const override;
void partyLevel(u8 v) override;
u16 dynamaxType(void) const;
void dynamaxType(u16 v);
void updatePartyData(void) override;
void refreshChecksum(void) override;
Type hpType(void) const override;
void hpType(Type v) override;
u16 TSV(void) const override;
u16 PSV(void) const override;
u8 level(void) const override;
void level(u8 v) override;
bool shiny(void) const override;
void shiny(bool v) override;
u16 formSpecies(void) const override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
inline u8 baseHP(void) const override { return PersonalSWSH::baseHP(formSpecies()); }
inline u8 baseAtk(void) const override { return PersonalSWSH::baseAtk(formSpecies()); }
inline u8 baseDef(void) const override { return PersonalSWSH::baseDef(formSpecies()); }
inline u8 baseSpe(void) const override { return PersonalSWSH::baseSpe(formSpecies()); }
inline u8 baseSpa(void) const override { return PersonalSWSH::baseSpa(formSpecies()); }
inline u8 baseSpd(void) const override { return PersonalSWSH::baseSpd(formSpecies()); }
inline Type type1(void) const override { return PersonalSWSH::type1(formSpecies()); }
inline Type type2(void) const override { return PersonalSWSH::type2(formSpecies()); }
inline u8 genderType(void) const override { return PersonalSWSH::gender(formSpecies()); }
inline u8 baseFriendship(void) const override
{
return PersonalSWSH::baseFriendship(formSpecies());
}
inline u8 expType(void) const override { return PersonalSWSH::expType(formSpecies()); }
inline Ability abilities(u8 n) const override
{
return PersonalSWSH::ability(formSpecies(), n);
}
inline u16 formStatIndex(void) const override
{
return PersonalSWSH::formStatIndex(formSpecies());
}
inline u16 pokedexIndex(void) const { return PersonalSWSH::pokedexIndex(formSpecies()); }
inline u16 armordexIndex(void) const { return PersonalSWSH::armordexIndex(formSpecies()); }
inline u16 crowndexIndex(void) const { return PersonalSWSH::crowndexIndex(formSpecies()); }
inline bool canLearnTR(u8 trID) const
{
return PersonalSWSH::canLearnTR(formSpecies(), trID);
}
private:
u16 statImpl(Stat stat) const override;
};
}
#endif
| 12,775
|
C++
|
.h
| 279
| 37.501792
| 99
| 0.658603
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,336
|
PK6.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK6.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK6_HPP
#define PK6_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK6 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 56;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
public:
static constexpr size_t BOX_LENGTH = 232;
static constexpr size_t PARTY_LENGTH = 260;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Volcanion;
PK6(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk6"; }
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] bool untraded(void) const;
[[nodiscard]] bool untradedEvent(void) const;
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u8 trainingBagHits(void) const;
void trainingBagHits(u8 v);
[[nodiscard]] u8 trainingBag(void) const;
void trainingBag(u8 v);
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
[[nodiscard]] u8 ribbonContestCount(void) const;
void ribbonContestCount(u8 v);
[[nodiscard]] u8 ribbonBattleCount(void) const;
void ribbonBattleCount(u8 v);
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] Move relearnMove(u8 move) const override;
void relearnMove(u8 move, Move v) override;
[[nodiscard]] bool secretSuperTrainingUnlocked(void) const;
void secretSuperTrainingUnlocked(bool v);
[[nodiscard]] bool secretSuperTrainingComplete(void) const;
void secretSuperTrainingComplete(bool v);
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] std::string htName(void) const;
void htName(const std::string_view& v);
[[nodiscard]] Gender htGender(void) const;
void htGender(Gender v);
[[nodiscard]] PKXHandler currentHandler(void) const override;
void currentHandler(PKXHandler v) override;
[[nodiscard]] u8 geoRegion(u8 region) const;
void geoRegion(u8 region, u8 v);
[[nodiscard]] u8 geoCountry(u8 country) const;
void geoCountry(u8 country, u8 v);
[[nodiscard]] u8 htFriendship(void) const override;
void htFriendship(u8 v) override;
[[nodiscard]] u8 htAffection(void) const;
void htAffection(u8 v);
[[nodiscard]] u8 htIntensity(void) const;
void htIntensity(u8 v);
[[nodiscard]] u8 htMemory(void) const;
void htMemory(u8 v);
[[nodiscard]] u8 htFeeling(void) const;
void htFeeling(u8 v);
[[nodiscard]] u16 htTextVar(void) const;
void htTextVar(u16 v);
[[nodiscard]] u8 fullness(void) const;
void fullness(u8 v);
[[nodiscard]] u8 enjoyment(void) const;
void enjoyment(u8 v);
// TODO
// u32 formDuration(void) const;
// void formDuration(u32 v);
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 otAffection(void) const;
void otAffection(u8 v);
[[nodiscard]] u8 otIntensity(void) const;
void otIntensity(u8 v);
[[nodiscard]] u8 otMemory(void) const;
void otMemory(u8 v);
[[nodiscard]] u16 otTextVar(void) const;
void otTextVar(u16 v);
[[nodiscard]] u8 otFeeling(void) const;
void otFeeling(u8 v);
[[nodiscard]] u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] u8 encounterType(void) const;
void encounterType(u8 v);
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] u8 country(void) const;
void country(u8 v);
[[nodiscard]] u8 region(void) const;
void region(u8 v);
[[nodiscard]] u8 consoleRegion(void) const;
void consoleRegion(u8 v);
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalXYORAS::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalXYORAS::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalXYORAS::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalXYORAS::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalXYORAS::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalXYORAS::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalXYORAS::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalXYORAS::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalXYORAS::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalXYORAS::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalXYORAS::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalXYORAS::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override
{
return PersonalXYORAS::formStatIndex(formSpecies());
}
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 13,629
|
C++
|
.h
| 292
| 38.246575
| 95
| 0.649112
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,337
|
PKFilter.hpp
|
FlagBrew_PKSM-Core/include/pkx/PKFilter.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PKFILTER_HPP
#define PKFILTER_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/Gender.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Move.hpp"
#include "enums/Nature.hpp"
#include "enums/Species.hpp"
#include "enums/Stat.hpp"
#include "pkx/IPKFilterable.hpp"
#include <array>
#include <bitset>
#include <string>
#define MAKE_DEFN(name, type) \
public: \
[[nodiscard]] type name(void) const override \
{ \
return type##name; \
} \
void name(type v) override \
{ \
type##name = v; \
} \
[[nodiscard]] bool name##Enabled(void) const \
{ \
return name##Bool; \
} \
void name##Enabled(bool v) \
{ \
name##Bool = v; \
} \
[[nodiscard]] bool name##Inversed(void) const \
{ \
return name##Inverse; \
} \
void name##Inversed(bool v) \
{ \
name##Inverse = v; \
} \
\
private: \
type type##name = type(); \
bool name##Bool = false; \
bool name##Inverse = false
#define MAKE_DEFN_CONSTANT(name, type) \
public: \
[[nodiscard]] type name(void) const override \
{ \
return type##name; \
} \
void name(type v) \
{ \
type##name = v; \
} \
[[nodiscard]] bool name##Enabled(void) const \
{ \
return name##Bool; \
} \
void name##Enabled(bool v) \
{ \
name##Bool = v; \
} \
[[nodiscard]] bool name##Inversed(void) const \
{ \
return name##Inverse; \
} \
void name##Inversed(bool v) \
{ \
name##Inverse = v; \
} \
\
private: \
type type##name = type(); \
bool name##Bool = false; \
bool name##Inverse = false
#define MAKE_NUM_DEFN(name, type, amount, indextype) \
public: \
[[nodiscard]] type name(indextype which) const override \
{ \
return type##name[size_t(which)]; \
} \
void name(indextype which, type v) override \
{ \
type##name[size_t(which)] = v; \
} \
[[nodiscard]] bool name##Enabled(indextype which) const \
{ \
return name##Bool[size_t(which)]; \
} \
void name##Enabled(indextype which, bool v) \
{ \
name##Bool[size_t(which)] = v; \
} \
[[nodiscard]] bool name##Inversed(indextype which) const \
{ \
return name##Inverse[size_t(which)]; \
} \
void name##Inversed(indextype which, bool v) \
{ \
name##Inverse[size_t(which)] = v; \
} \
\
private: \
std::array<type, amount> type##name = std::array<type, amount>(); \
std::bitset<amount> name##Bool = std::bitset<amount>(0); \
std::bitset<amount> name##Inverse = std::bitset<amount>(0)
#define MAKE_NUM_DEFN_CONSTANT(name, type, amount, indextype) \
public: \
[[nodiscard]] type name(indextype which) const override \
{ \
return type##name[size_t(which)]; \
} \
void name(indextype which, type v) \
{ \
type##name[size_t(which)] = v; \
} \
[[nodiscard]] bool name##Enabled(indextype which) const \
{ \
return name##Bool[size_t(which)]; \
} \
void name##Enabled(indextype which, bool v) \
{ \
name##Bool[size_t(which)] = v; \
} \
[[nodiscard]] bool name##Inversed(indextype which) const \
{ \
return name##Inverse[size_t(which)]; \
} \
void name##Inversed(indextype which, bool v) \
{ \
name##Inverse[size_t(which)] = v; \
} \
\
private: \
std::array<type, amount> type##name = std::array<type, amount>(); \
std::bitset<amount> name##Bool = std::bitset<amount>(0); \
std::bitset<amount> name##Inverse = std::bitset<amount>(0)
namespace pksm
{
class PKFilter : public IPKFilterable
{
public:
[[nodiscard]] bool isFilter() const override { return true; }
MAKE_DEFN_CONSTANT(generation, Generation);
MAKE_DEFN(species, Species);
MAKE_DEFN(alternativeForm, u16);
MAKE_DEFN(shiny, bool);
MAKE_DEFN(heldItem, u16);
MAKE_DEFN(level, u8);
MAKE_DEFN(ability, Ability);
MAKE_DEFN_CONSTANT(TSV, u16);
MAKE_DEFN(nature, Nature);
MAKE_DEFN(gender, Gender);
MAKE_NUM_DEFN(move, Move, 4, u8);
MAKE_NUM_DEFN(relearnMove, Move, 4, u8);
MAKE_DEFN(ball, Ball);
MAKE_DEFN(language, Language);
MAKE_DEFN(egg, bool);
MAKE_NUM_DEFN(iv, u8, 6, Stat);
};
}
#undef MAKE_DEFN
#undef MAKE_DEFN_CONSTANT
#undef MAKE_NUM_DEFN
#undef MAKE_NUM_DEFN_CONSTANT
#endif
| 14,833
|
C++
|
.h
| 193
| 70.103627
| 100
| 0.236774
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,338
|
PK5.hpp
|
FlagBrew_PKSM-Core/include/pkx/PK5.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PK5_HPP
#define PK5_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PK5 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 32;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
public:
static constexpr size_t BOX_LENGTH = 136;
static constexpr size_t PARTY_LENGTH = 220;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Genesect;
PK5(PrivateConstructor, u8* dt, bool party = false, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pk5"; }
[[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
// std::unique_ptr<PB7> convertToLGPE(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation(void) const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] PKXHandler currentHandler(void) const override { return PKXHandler::OT; }
void currentHandler(PKXHandler) override {}
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u8 htFriendship(void) const override { return baseFriendship(); }
void htFriendship(u8 v) override {}
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
[[nodiscard]] u8 contest(u8 contest) const override;
void contest(u8 contest, u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon rib) const override;
[[nodiscard]] bool ribbon(Ribbon rib) const override;
void ribbon(Ribbon rib, bool v) override;
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] Move relearnMove(u8) const override { return Move::None; }
void relearnMove(u8, Move) override {}
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool hiddenAbility(void) const;
void hiddenAbility(bool v);
[[nodiscard]] bool nPokemon(void) const;
void nPokemon(bool v);
[[nodiscard]] bool hyperTrain(Stat) const override { return false; }
void hyperTrain(Stat, bool) override {}
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] u8 encounterType(void) const;
void encounterType(u8 v);
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel() const override;
void partyLevel(u8 v) override;
void updatePartyData(void) override;
u16 secondaryStatCalc(Stat stat) const override { return ev(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { ev(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return maxEV(); }
u32 maxSecondaryStatCalcTotal(void) const override { return maxEVTotal(); }
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalBWB2W2::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalBWB2W2::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalBWB2W2::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalBWB2W2::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalBWB2W2::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalBWB2W2::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalBWB2W2::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalBWB2W2::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalBWB2W2::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalBWB2W2::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalBWB2W2::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalBWB2W2::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override
{
return PersonalBWB2W2::formStatIndex(formSpecies());
}
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 11,516
|
C++
|
.h
| 241
| 39.456432
| 95
| 0.654076
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,339
|
IPKFilterable.hpp
|
FlagBrew_PKSM-Core/include/pkx/IPKFilterable.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef IPKFILTERABLE_HPP
#define IPKFILTERABLE_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/Gender.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Move.hpp"
#include "enums/Nature.hpp"
#include "enums/Species.hpp"
#include "enums/Stat.hpp"
#define IFILTERABLE_DEFINE_METHOD(name, type) \
[[nodiscard]] virtual type name() const = 0; \
virtual void name(type v) = 0
#define IFILTERABLE_DEFINE_CONSTANT_METHOD(name, type) virtual type name() const = 0
#define IFILTERABLE_DEFINE_INDEXED_METHOD(name, type, indextype) \
[[nodiscard]] virtual type name(indextype which) const = 0; \
virtual void name(indextype which, type v) = 0
#define IFILTERABLE_DEFINE_CONSTANT_INDEXED_METHOD(name, type, indextype) \
[[nodiscard]] virtual type name(indextype which) const = 0
namespace pksm
{
class IPKFilterable
{
public:
IFILTERABLE_DEFINE_CONSTANT_METHOD(isFilter, bool);
IFILTERABLE_DEFINE_CONSTANT_METHOD(generation, Generation);
IFILTERABLE_DEFINE_METHOD(species, Species);
IFILTERABLE_DEFINE_METHOD(alternativeForm, u16);
IFILTERABLE_DEFINE_METHOD(shiny, bool);
IFILTERABLE_DEFINE_METHOD(heldItem, u16);
IFILTERABLE_DEFINE_METHOD(level, u8);
IFILTERABLE_DEFINE_METHOD(ability, Ability);
IFILTERABLE_DEFINE_CONSTANT_METHOD(TSV, u16);
IFILTERABLE_DEFINE_METHOD(nature, Nature);
IFILTERABLE_DEFINE_METHOD(gender, Gender);
IFILTERABLE_DEFINE_INDEXED_METHOD(move, Move, u8);
IFILTERABLE_DEFINE_INDEXED_METHOD(relearnMove, Move, u8);
IFILTERABLE_DEFINE_METHOD(ball, Ball);
IFILTERABLE_DEFINE_METHOD(language, Language);
IFILTERABLE_DEFINE_METHOD(egg, bool);
IFILTERABLE_DEFINE_INDEXED_METHOD(iv, u8, Stat);
};
}
#undef IFILTERABLE_DEFINE_METHOD
#undef IFILTERABLE_DEFINE_CONSTANT_METHOD
#undef IFILTERABLE_DEFINE_INDEXED_METHOD
#undef IFILTERABLE_DEFINE_CONSTANT_INDEXED_METHOD
#endif
| 3,509
|
C++
|
.h
| 74
| 43.675676
| 100
| 0.686989
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,340
|
PKX.hpp
|
FlagBrew_PKSM-Core/include/pkx/PKX.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PKX_HPP
#define PKX_HPP
#include "enums/Ability.hpp"
#include "enums/Ball.hpp"
#include "enums/GameVersion.hpp"
#include "enums/Gender.hpp"
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include "enums/Move.hpp"
#include "enums/Nature.hpp"
#include "enums/PKXHandler.hpp"
#include "enums/Ribbon.hpp"
#include "enums/Species.hpp"
#include "enums/Stat.hpp"
#include "enums/Type.hpp"
#include "pkx/IPKFilterable.hpp"
#include "pkx/PKFilter.hpp"
#include "sav/Item.hpp"
#include "utils/coretypes.h"
#include "utils/DateTime.hpp"
#include "utils/genToPkx.hpp"
#include <concepts>
#include <memory>
#include <string>
namespace pksm
{
class Sav;
class PK1;
class PK2;
class PK3;
class PK4;
class PK5;
class PK6;
class PK7;
class PK8;
class PB7;
class PKX : public IPKFilterable
{
private:
bool directAccess;
[[nodiscard]] virtual int eggYear(void) const = 0;
virtual void eggYear(int v) = 0;
[[nodiscard]] virtual int eggMonth(void) const = 0;
virtual void eggMonth(int v) = 0;
[[nodiscard]] virtual int eggDay(void) const = 0;
virtual void eggDay(int v) = 0;
[[nodiscard]] virtual int metYear(void) const = 0;
virtual void metYear(int v) = 0;
[[nodiscard]] virtual int metMonth(void) const = 0;
virtual void metMonth(int v) = 0;
[[nodiscard]] virtual int metDay(void) const = 0;
virtual void metDay(int v) = 0;
protected:
struct PrivateConstructor
{
};
PKX(u8* data, size_t length, bool directAccess = false);
[[nodiscard]] u32 expTable(u8 row, u8 col) const;
virtual void reorderMoves(void);
u32 length = 0;
u8* data;
public:
static constexpr Species PKSM_MAX_SPECIES = Species::Calyrex;
// Returns null if length is not valid for that generation, and a party Pokemon depending on
// length, or in Gen I and II a Japanese Pokemon depending on length
[[nodiscard]] static std::unique_ptr<PKX> getPKM(
Generation gen, u8* data, size_t length, bool directAccess = false);
template <Generation::EnumType g>
[[nodiscard]] static std::unique_ptr<typename GenToPkx<g>::PKX> getPKM(
u8* data, size_t length, bool directAccess = false)
{
return getPKM<typename GenToPkx<g>::PKX>(data, length, directAccess);
}
template <std::derived_from<::pksm::PKX> Pkm>
[[nodiscard]] static std::unique_ptr<Pkm> getPKM(
u8* data, size_t length, bool directAccess = false)
{
if constexpr (std::is_same_v<typename GenToPkx<Generation::ONE>::PKX,
std::remove_cvref_t<Pkm>> ||
std::is_same_v<typename GenToPkx<Generation::TWO>::PKX,
std::remove_cvref_t<Pkm>>)
{
if (Pkm::JP_LENGTH_WITH_NAMES == length || Pkm::INT_LENGTH_WITH_NAMES == length)
{
return std::make_unique<Pkm>(PrivateConstructor{}, data,
length == Pkm::JP_LENGTH_WITH_NAMES, directAccess);
}
else if (data == nullptr)
{
return std::make_unique<Pkm>(PrivateConstructor{}, data, false, directAccess);
}
}
else
{
if (Pkm::PARTY_LENGTH == length || Pkm::BOX_LENGTH == length)
{
return std::make_unique<Pkm>(
PrivateConstructor{}, data, length == Pkm::PARTY_LENGTH, directAccess);
}
else if (data == nullptr)
{
return std::make_unique<Pkm>(PrivateConstructor{}, data, false, directAccess);
}
}
return nullptr;
}
[[nodiscard]] virtual ~PKX();
PKX(const PKX& pk);
PKX(PKX&& pk);
PKX& operator=(const PKX& pk);
PKX& operator=(PKX&& pk);
[[nodiscard]] bool operator==(const PKFilter& filter) const;
[[nodiscard]] virtual std::string_view extension(void) const = 0;
[[nodiscard]] std::span<u8> rawData(void) { return {data, length}; }
[[nodiscard]] std::span<const u8> rawData(void) const { return {data, length}; }
[[nodiscard]] u32 getLength(void) const { return length; }
[[nodiscard]] virtual bool isParty(void) const = 0;
virtual void decrypt(void) = 0;
virtual void encrypt(void) = 0;
[[nodiscard]] virtual bool isEncrypted() const = 0;
[[nodiscard]] virtual std::unique_ptr<PK1> convertToG1(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK2> convertToG2(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK3> convertToG3(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK4> convertToG4(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK5> convertToG5(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK6> convertToG6(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK7> convertToG7(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PB7> convertToLGPE(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PK8> convertToG8(Sav& save) const;
[[nodiscard]] virtual std::unique_ptr<PKX> clone(void) const = 0;
[[nodiscard]] std::unique_ptr<PKX> partyClone(void) const;
[[nodiscard]] Generation generation(void) const override = 0;
[[nodiscard]] bool originGen7(void) const;
[[nodiscard]] bool originGen6(void) const;
[[nodiscard]] bool originGen5(void) const;
[[nodiscard]] bool originGen4(void) const;
[[nodiscard]] bool originGen3(void) const;
[[nodiscard]] bool originGen2(void) const;
[[nodiscard]] bool originGen1(void) const;
[[nodiscard]] Generation originGen(void) const;
void fixMoves(void);
[[nodiscard]] static u32 getRandomPID(Species species, Gender gender,
GameVersion originGame, Nature nature, u8 form, u8 abilityNum, bool shiny, u16 tsv,
u32 oldPid, Generation gen);
[[nodiscard]] static Gender genderFromRatio(u32 pid, u8 gt);
// BLOCK A
[[nodiscard]] virtual u32 encryptionConstant(void) const = 0;
virtual void encryptionConstant(u32 v) = 0;
[[nodiscard]] virtual u16 sanity(void) const = 0;
virtual void sanity(u16 v) = 0;
[[nodiscard]] virtual u16 checksum(void) const = 0;
virtual void checksum(u16 v) = 0;
[[nodiscard]] Species species(void) const override = 0;
void species(Species v) override = 0;
[[nodiscard]] u16 heldItem(void) const override = 0;
void heldItem(u16 v) override = 0;
virtual void heldItem(const Item& item) { heldItem(item.id()); }
[[nodiscard]] virtual u16 TID(void) const = 0;
virtual void TID(u16 v) = 0;
[[nodiscard]] virtual u16 SID(void) const = 0;
virtual void SID(u16 v) = 0;
[[nodiscard]] virtual u32 experience(void) const = 0;
virtual void experience(u32 v) = 0;
[[nodiscard]] Ability ability(void) const override = 0;
void ability(Ability v) override = 0;
[[nodiscard]] virtual u8 abilityNumber(void) const = 0;
virtual void abilityNumber(u8 v) = 0;
virtual void setAbility(u8 abilityNumber) = 0;
[[nodiscard]] virtual u16 markValue(void) const = 0;
virtual void markValue(u16 v) = 0;
[[nodiscard]] virtual u32 PID(void) const = 0;
virtual void PID(u32 v) = 0;
[[nodiscard]] Nature nature(void) const override = 0;
void nature(Nature v) override = 0;
[[nodiscard]] virtual bool fatefulEncounter(void) const = 0;
virtual void fatefulEncounter(bool v) = 0;
[[nodiscard]] Gender gender(void) const override = 0;
void gender(Gender g) override = 0;
[[nodiscard]] u16 alternativeForm(void) const override = 0;
void alternativeForm(u16 v) override = 0;
[[nodiscard]] virtual u16 ev(Stat ev) const = 0;
virtual void ev(Stat ev, u16 v) = 0;
[[nodiscard]] virtual u8 contest(u8 contest) const = 0;
virtual void contest(u8 contest, u8 v) = 0;
[[nodiscard]] virtual u8 pkrs(void) const = 0;
virtual void pkrs(u8 v) = 0;
[[nodiscard]] virtual u8 pkrsDays(void) const = 0;
virtual void pkrsDays(u8 v) = 0;
[[nodiscard]] virtual u8 pkrsStrain(void) const = 0;
virtual void pkrsStrain(u8 v) = 0;
[[nodiscard]] virtual bool hasRibbon(Ribbon rib) const = 0;
[[nodiscard]] virtual bool ribbon(Ribbon rib) const = 0;
virtual void ribbon(Ribbon rib, bool v) = 0;
// BLOCK B
[[nodiscard]] virtual std::string nickname(void) const = 0;
virtual void nickname(const std::string_view& v) = 0;
[[nodiscard]] Move move(u8 move) const override = 0;
void move(u8 move, Move v) override = 0;
[[nodiscard]] Move relearnMove(u8 move) const override = 0;
void relearnMove(u8 move, Move v) override = 0;
[[nodiscard]] virtual u8 PP(u8 move) const = 0;
virtual void PP(u8 move, u8 v) = 0;
[[nodiscard]] virtual u8 PPUp(u8 move) const = 0;
virtual void PPUp(u8 move, u8 v) = 0;
[[nodiscard]] u8 iv(Stat iv) const override = 0;
void iv(Stat iv, u8 v) override = 0;
[[nodiscard]] bool egg(void) const override = 0;
void egg(bool v) override = 0;
[[nodiscard]] virtual bool nicknamed(void) const = 0;
virtual void nicknamed(bool v) = 0;
[[nodiscard]] virtual bool hyperTrain(Stat stat) const = 0;
virtual void hyperTrain(Stat stat, bool v) = 0;
[[nodiscard]] u8 maxPP(u8 move) const;
void healPP();
void healPP(u8 move) { PP(move, maxPP(move)); }
// BLOCK C
[[nodiscard]] virtual PKXHandler currentHandler(void) const = 0;
virtual void currentHandler(PKXHandler v) = 0;
// BLOCK D
[[nodiscard]] virtual std::string otName(void) const = 0;
virtual void otName(const std::string_view& v) = 0;
[[nodiscard]] virtual u8 otFriendship(void) const = 0;
virtual void otFriendship(u8 v) = 0;
[[nodiscard]] virtual u8 htFriendship(void) const = 0;
virtual void htFriendship(u8 v) = 0;
// Raw information handled in private functions
[[nodiscard]] virtual Date eggDate(void) const
{
return Date{(u8)eggDay(), (u8)eggMonth(), (u32)eggYear()};
}
virtual void eggDate(const Date& v)
{
eggDay(v.day());
eggMonth(v.month());
eggYear(v.year());
}
[[nodiscard]] virtual Date metDate(void) const
{
return Date{(u8)metDay(), (u8)metMonth(), (u32)metYear()};
}
virtual void metDate(const Date& v)
{
metDay(v.day());
metMonth(v.month());
metYear(v.year());
}
[[nodiscard]] virtual u16 eggLocation(void) const = 0;
virtual void eggLocation(u16 v) = 0;
[[nodiscard]] virtual u16 metLocation(void) const = 0;
virtual void metLocation(u16 v) = 0;
[[nodiscard]] Ball ball(void) const override = 0;
void ball(Ball v) override = 0;
[[nodiscard]] virtual u8 metLevel(void) const = 0;
virtual void metLevel(u8 v) = 0;
[[nodiscard]] virtual Gender otGender(void) const = 0;
virtual void otGender(Gender v) = 0;
[[nodiscard]] virtual GameVersion version(void) const = 0;
virtual void version(GameVersion v) = 0;
[[nodiscard]] Language language(void) const override = 0;
void language(Language v) override = 0;
[[nodiscard]] u8 currentFriendship(void) const
{
return currentHandler() == PKXHandler::OT ? otFriendship() : htFriendship();
}
void currentFriendship(u8 v)
{
if (currentHandler() == PKXHandler::OT)
{
otFriendship(v);
}
else
{
htFriendship(v);
}
}
[[nodiscard]] u8 oppositeFriendship(void) const
{
return currentHandler() == PKXHandler::NonOT ? otFriendship() : htFriendship();
}
void oppositeFriendship(u8 v)
{
if (currentHandler() == PKXHandler::NonOT)
{
otFriendship(v);
}
else
{
htFriendship(v);
}
}
virtual void refreshChecksum(void) = 0;
[[nodiscard]] virtual Type hpType(void) const = 0;
virtual void hpType(Type v) = 0;
[[nodiscard]] u16 TSV(void) const override = 0;
[[nodiscard]] virtual u16 PSV(void) const = 0;
[[nodiscard]] u32 versionTID(void) const;
[[nodiscard]] u32 versionSID(void) const;
[[nodiscard]] u32 formatTID(void) const;
[[nodiscard]] u32 formatSID(void) const;
[[nodiscard]] u8 level(void) const override = 0;
void level(u8 v) override = 0;
[[nodiscard]] bool shiny(void) const override = 0;
void shiny(bool v) override = 0;
[[nodiscard]] virtual u16 formSpecies(void) const = 0;
[[nodiscard]] u16 stat(Stat stat) const
{
if (species() == Species::Shedinja && stat == Stat::HP)
{
return 1;
}
return statImpl(stat);
}
// Hehehehe... to be done
// virtual u8 sleepTurns(void) const = 0;
// virtual void sleepTurns(u8 v) = 0;
// virtual bool poison(void) const = 0;
// virtual void poison(bool v) = 0;
// virtual bool burn(void) const = 0;
// virtual void burn(bool v) = 0;
// virtual bool frozen(void) const = 0;
// virtual void frozen(bool v) = 0;
// virtual bool paralyzed(void) const = 0;
// virtual void paralyzed(bool v) = 0;
// virtual bool toxic(void) const = 0;
// virtual void toxic(bool v) = 0;
// -1 means not a party pokemon
[[nodiscard]] virtual int partyCurrHP(void) const = 0;
virtual void partyCurrHP(u16 v) = 0;
[[nodiscard]] virtual int partyStat(Stat stat) const = 0;
virtual void partyStat(Stat stat, u16 v) = 0;
[[nodiscard]] virtual int partyLevel(void) const = 0;
virtual void partyLevel(u8 v) = 0;
// Takes any calculated stats and writes them into the party offsets, provided they exist
virtual void updatePartyData(void) = 0;
virtual u8 maxIV(void) const = 0;
virtual u16 maxEV(void) const = 0;
virtual u32 maxEVTotal(void) const = 0;
virtual u16 secondaryStatCalc(Stat stat) const = 0;
virtual void secondaryStatCalc(Stat stat, u16 v) = 0;
virtual u16 maxSecondaryStatCalc(void) const = 0;
virtual u32 maxSecondaryStatCalcTotal(void) const = 0;
// Personal interface
[[nodiscard]] virtual u8 baseHP(void) const = 0;
[[nodiscard]] virtual u8 baseAtk(void) const = 0;
[[nodiscard]] virtual u8 baseDef(void) const = 0;
[[nodiscard]] virtual u8 baseSpe(void) const = 0;
[[nodiscard]] virtual u8 baseSpa(void) const = 0;
[[nodiscard]] virtual u8 baseSpd(void) const = 0;
[[nodiscard]] virtual Type type1(void) const = 0;
[[nodiscard]] virtual Type type2(void) const = 0;
[[nodiscard]] virtual u8 genderType(void) const = 0;
[[nodiscard]] virtual u8 baseFriendship(void) const = 0;
[[nodiscard]] virtual u8 expType(void) const = 0;
[[nodiscard]] virtual Ability abilities(u8 n) const = 0;
[[nodiscard]] virtual u16 formStatIndex(void) const = 0;
[[nodiscard]] bool isFilter() const final { return false; }
private:
[[nodiscard]] virtual u16 statImpl(Stat stat) const = 0;
};
}
#endif
| 19,105
|
C++
|
.h
| 386
| 40.455959
| 100
| 0.55324
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,341
|
PB7.hpp
|
FlagBrew_PKSM-Core/include/pkx/PB7.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PB7_HPP
#define PB7_HPP
#include "personal/personal.hpp"
#include "pkx/PKX.hpp"
namespace pksm
{
class PB7 : public PKX
{
private:
static constexpr size_t BLOCK_LENGTH = 56;
static constexpr size_t ENCRYPTION_START = 8;
[[nodiscard]] int eggYear(void) const override;
void eggYear(int v) override;
[[nodiscard]] int eggMonth(void) const override;
void eggMonth(int v) override;
[[nodiscard]] int eggDay(void) const override;
void eggDay(int v) override;
[[nodiscard]] int metYear(void) const override;
void metYear(int v) override;
[[nodiscard]] int metMonth(void) const override;
void metMonth(int v) override;
[[nodiscard]] int metDay(void) const override;
void metDay(int v) override;
protected:
static constexpr u8 hyperTrainLookup[6] = {0, 1, 2, 5, 3, 4};
public:
static constexpr size_t BOX_LENGTH = 232;
static constexpr size_t PARTY_LENGTH = 260;
static constexpr Species FORMAT_SPECIES_LIMIT = Species::Melmetal;
PB7(PrivateConstructor, u8* dt, bool party = true, bool directAccess = false);
[[nodiscard]] std::string_view extension() const override { return ".pb7"; }
// [[nodiscard]] std::unique_ptr<PK1> convertToG1(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK2> convertToG2(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK3> convertToG3(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK4> convertToG4(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK5> convertToG5(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK6> convertToG6(Sav& save) const override;
// [[nodiscard]] std::unique_ptr<PK7> convertToG7(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PK8> convertToG8(Sav& save) const override;
[[nodiscard]] std::unique_ptr<PKX> clone(void) const override;
[[nodiscard]] Generation generation() const override;
void decrypt(void) override;
void encrypt(void) override;
[[nodiscard]] bool isEncrypted(void) const override;
[[nodiscard]] bool isParty(void) const override { return getLength() == PARTY_LENGTH; }
[[nodiscard]] u32 encryptionConstant(void) const override;
void encryptionConstant(u32 v) override;
[[nodiscard]] u16 sanity(void) const override;
void sanity(u16 v) override;
[[nodiscard]] u16 checksum(void) const override;
void checksum(u16 v) override;
[[nodiscard]] Species species(void) const override;
void species(Species v) override;
[[nodiscard]] u16 heldItem(void) const override;
void heldItem(u16 v) override;
[[nodiscard]] u16 TID(void) const override;
void TID(u16 v) override;
[[nodiscard]] u16 SID(void) const override;
void SID(u16 v) override;
[[nodiscard]] u32 experience(void) const override;
void experience(u32 v) override;
[[nodiscard]] Ability ability(void) const override;
void ability(Ability v) override;
[[nodiscard]] u8 abilityNumber(void) const override;
void abilityNumber(u8 v) override;
void setAbility(u8 abilityNumber) override;
[[nodiscard]] u16 markValue(void) const override;
void markValue(u16 v) override;
[[nodiscard]] u32 PID(void) const override;
void PID(u32 v) override;
[[nodiscard]] Nature nature(void) const override;
void nature(Nature v) override;
[[nodiscard]] bool fatefulEncounter(void) const override;
void fatefulEncounter(bool v) override;
[[nodiscard]] Gender gender(void) const override;
void gender(Gender g) override;
[[nodiscard]] u16 alternativeForm(void) const override;
void alternativeForm(u16 v) override;
[[nodiscard]] u16 ev(Stat ev) const override;
void ev(Stat ev, u16 v) override;
// Stubbed; data no longer exists
[[nodiscard]] u8 contest(u8) const override { return 0; }
void contest(u8, u8) override {}
// Replaced by
[[nodiscard]] u8 awakened(Stat stat) const;
void awakened(Stat stat, u8 v);
[[nodiscard]] u8 pelagoEventStatus(void) const;
void pelagoEventStatus(u8 v);
[[nodiscard]] u8 pkrs(void) const override;
void pkrs(u8 v) override;
[[nodiscard]] u8 pkrsDays(void) const override;
void pkrsDays(u8 v) override;
[[nodiscard]] u8 pkrsStrain(void) const override;
void pkrsStrain(u8 v) override;
[[nodiscard]] bool hasRibbon(Ribbon) const override { return false; }
[[nodiscard]] bool ribbon(Ribbon) const override { return false; }
void ribbon(Ribbon, bool) override {}
[[nodiscard]] std::string nickname(void) const override;
void nickname(const std::string_view& v) override;
[[nodiscard]] Move move(u8 move) const override;
void move(u8 move, Move v) override;
[[nodiscard]] u8 PP(u8 move) const override;
void PP(u8 move, u8 v) override;
[[nodiscard]] u8 PPUp(u8 move) const override;
void PPUp(u8 move, u8 v) override;
[[nodiscard]] Move relearnMove(u8 move) const override;
void relearnMove(u8 move, Move v) override;
[[nodiscard]] u8 iv(Stat iv) const override;
void iv(Stat iv, u8 v) override;
[[nodiscard]] bool egg(void) const override;
void egg(bool v) override;
[[nodiscard]] bool nicknamed(void) const override;
void nicknamed(bool v) override;
[[nodiscard]] std::string htName(void) const;
void htName(const std::string_view& v);
[[nodiscard]] Gender htGender(void) const;
void htGender(Gender v);
[[nodiscard]] PKXHandler currentHandler(void) const override;
void currentHandler(PKXHandler v) override;
[[nodiscard]] u8 htFriendship(void) const;
void htFriendship(u8 v);
[[nodiscard]] u8 htIntensity(void) const;
void htIntensity(u8 v);
[[nodiscard]] u8 htMemory(void) const;
void htMemory(u8 v);
[[nodiscard]] u8 htFeeling(void) const;
void htFeeling(u8 v);
[[nodiscard]] u16 htTextVar(void) const;
void htTextVar(u16 v);
[[nodiscard]] u8 fullness(void) const;
void fullness(u8 v);
[[nodiscard]] u8 enjoyment(void) const;
void enjoyment(u8 v);
[[nodiscard]] std::string otName(void) const override;
void otName(const std::string_view& v) override;
[[nodiscard]] u8 otFriendship(void) const override;
void otFriendship(u8 v) override;
[[nodiscard]] u16 eggLocation(void) const override;
void eggLocation(u16 v) override;
[[nodiscard]] u16 metLocation(void) const override;
void metLocation(u16 v) override;
[[nodiscard]] Ball ball(void) const override;
void ball(Ball v) override;
[[nodiscard]] u8 metLevel(void) const override;
void metLevel(u8 v) override;
[[nodiscard]] Gender otGender(void) const override;
void otGender(Gender v) override;
[[nodiscard]] bool hyperTrain(Stat stat) const override;
void hyperTrain(Stat stat, bool v) override;
[[nodiscard]] GameVersion version(void) const override;
void version(GameVersion v) override;
[[nodiscard]] Language language(void) const override;
void language(Language v) override;
void refreshChecksum(void) override;
[[nodiscard]] Type hpType(void) const override;
void hpType(Type v) override;
[[nodiscard]] u16 TSV(void) const override;
[[nodiscard]] u16 PSV(void) const override;
[[nodiscard]] u8 level(void) const override;
void level(u8 v) override;
[[nodiscard]] bool shiny(void) const override;
void shiny(bool v) override;
[[nodiscard]] u16 formSpecies(void) const override;
[[nodiscard]] u16 CP(void) const;
[[nodiscard]] int partyCurrHP(void) const override;
void partyCurrHP(u16 v) override;
[[nodiscard]] int partyStat(Stat stat) const override;
void partyStat(Stat stat, u16 v) override;
[[nodiscard]] int partyLevel(void) const override;
void partyLevel(u8 v) override;
[[nodiscard]] u16 partyCP(void) const;
void partyCP(u16 v);
void updatePartyData(void) override;
[[nodiscard]] u8 height(void) const;
void height(u8 v);
[[nodiscard]] u8 weight(void) const;
void weight(u8 v);
u8 maxIV(void) const override { return 31; }
u16 maxEV(void) const override { return 252; }
u32 maxEVTotal(void) const override { return 510; }
u16 secondaryStatCalc(Stat stat) const override { return awakened(stat); }
void secondaryStatCalc(Stat stat, u16 v) override { awakened(stat, v); }
u16 maxSecondaryStatCalc(void) const override { return 200; }
u32 maxSecondaryStatCalcTotal(void) const override { return 200 * 6; }
[[nodiscard]] inline u8 baseHP(void) const override
{
return PersonalLGPE::baseHP(formSpecies());
}
[[nodiscard]] inline u8 baseAtk(void) const override
{
return PersonalLGPE::baseAtk(formSpecies());
}
[[nodiscard]] inline u8 baseDef(void) const override
{
return PersonalLGPE::baseDef(formSpecies());
}
[[nodiscard]] inline u8 baseSpe(void) const override
{
return PersonalLGPE::baseSpe(formSpecies());
}
[[nodiscard]] inline u8 baseSpa(void) const override
{
return PersonalLGPE::baseSpa(formSpecies());
}
[[nodiscard]] inline u8 baseSpd(void) const override
{
return PersonalLGPE::baseSpd(formSpecies());
}
[[nodiscard]] inline Type type1(void) const override
{
return PersonalLGPE::type1(formSpecies());
}
[[nodiscard]] inline Type type2(void) const override
{
return PersonalLGPE::type2(formSpecies());
}
[[nodiscard]] inline u8 genderType(void) const override
{
return PersonalLGPE::gender(formSpecies());
}
[[nodiscard]] inline u8 baseFriendship(void) const override
{
return PersonalLGPE::baseFriendship(formSpecies());
}
[[nodiscard]] inline u8 expType(void) const override
{
return PersonalLGPE::expType(formSpecies());
}
[[nodiscard]] inline Ability abilities(u8 n) const override
{
return PersonalLGPE::ability(formSpecies(), n);
}
[[nodiscard]] inline u16 formStatIndex(void) const override
{
return PersonalLGPE::formStatIndex(formSpecies());
}
private:
[[nodiscard]] u16 statImpl(Stat stat) const override;
};
}
#endif
| 12,447
|
C++
|
.h
| 266
| 38.413534
| 95
| 0.646496
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,342
|
Species.hpp
|
FlagBrew_PKSM-Core/include/enums/Species.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef SPECIES_HPP
#define SPECIES_HPP
#include "enums/Generation.hpp"
#include "enums/Language.hpp"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Species;
namespace internal
{
class Species_impl
{
friend class pksm::Species;
private:
enum class SpeciesEnum : u16
{
None,
Bulbasaur,
Ivysaur,
Venusaur,
Charmander,
Charmeleon,
Charizard,
Squirtle,
Wartortle,
Blastoise,
Caterpie,
Metapod,
Butterfree,
Weedle,
Kakuna,
Beedrill,
Pidgey,
Pidgeotto,
Pidgeot,
Rattata,
Raticate,
Spearow,
Fearow,
Ekans,
Arbok,
Pikachu,
Raichu,
Sandshrew,
Sandslash,
NidoranF,
Nidorina,
Nidoqueen,
NidoranM,
Nidorino,
Nidoking,
Clefairy,
Clefable,
Vulpix,
Ninetales,
Jigglypuff,
Wigglytuff,
Zubat,
Golbat,
Oddish,
Gloom,
Vileplume,
Paras,
Parasect,
Venonat,
Venomoth,
Diglett,
Dugtrio,
Meowth,
Persian,
Psyduck,
Golduck,
Mankey,
Primeape,
Growlithe,
Arcanine,
Poliwag,
Poliwhirl,
Poliwrath,
Abra,
Kadabra,
Alakazam,
Machop,
Machoke,
Machamp,
Bellsprout,
Weepinbell,
Victreebel,
Tentacool,
Tentacruel,
Geodude,
Graveler,
Golem,
Ponyta,
Rapidash,
Slowpoke,
Slowbro,
Magnemite,
Magneton,
Farfetchd,
Doduo,
Dodrio,
Seel,
Dewgong,
Grimer,
Muk,
Shellder,
Cloyster,
Gastly,
Haunter,
Gengar,
Onix,
Drowzee,
Hypno,
Krabby,
Kingler,
Voltorb,
Electrode,
Exeggcute,
Exeggutor,
Cubone,
Marowak,
Hitmonlee,
Hitmonchan,
Lickitung,
Koffing,
Weezing,
Rhyhorn,
Rhydon,
Chansey,
Tangela,
Kangaskhan,
Horsea,
Seadra,
Goldeen,
Seaking,
Staryu,
Starmie,
MrMime,
Scyther,
Jynx,
Electabuzz,
Magmar,
Pinsir,
Tauros,
Magikarp,
Gyarados,
Lapras,
Ditto,
Eevee,
Vaporeon,
Jolteon,
Flareon,
Porygon,
Omanyte,
Omastar,
Kabuto,
Kabutops,
Aerodactyl,
Snorlax,
Articuno,
Zapdos,
Moltres,
Dratini,
Dragonair,
Dragonite,
Mewtwo,
Mew,
Chikorita,
Bayleef,
Meganium,
Cyndaquil,
Quilava,
Typhlosion,
Totodile,
Croconaw,
Feraligatr,
Sentret,
Furret,
Hoothoot,
Noctowl,
Ledyba,
Ledian,
Spinarak,
Ariados,
Crobat,
Chinchou,
Lanturn,
Pichu,
Cleffa,
Igglybuff,
Togepi,
Togetic,
Natu,
Xatu,
Mareep,
Flaaffy,
Ampharos,
Bellossom,
Marill,
Azumarill,
Sudowoodo,
Politoed,
Hoppip,
Skiploom,
Jumpluff,
Aipom,
Sunkern,
Sunflora,
Yanma,
Wooper,
Quagsire,
Espeon,
Umbreon,
Murkrow,
Slowking,
Misdreavus,
Unown,
Wobbuffet,
Girafarig,
Pineco,
Forretress,
Dunsparce,
Gligar,
Steelix,
Snubbull,
Granbull,
Qwilfish,
Scizor,
Shuckle,
Heracross,
Sneasel,
Teddiursa,
Ursaring,
Slugma,
Magcargo,
Swinub,
Piloswine,
Corsola,
Remoraid,
Octillery,
Delibird,
Mantine,
Skarmory,
Houndour,
Houndoom,
Kingdra,
Phanpy,
Donphan,
Porygon2,
Stantler,
Smeargle,
Tyrogue,
Hitmontop,
Smoochum,
Elekid,
Magby,
Miltank,
Blissey,
Raikou,
Entei,
Suicune,
Larvitar,
Pupitar,
Tyranitar,
Lugia,
HoOh,
Celebi,
Treecko,
Grovyle,
Sceptile,
Torchic,
Combusken,
Blaziken,
Mudkip,
Marshtomp,
Swampert,
Poochyena,
Mightyena,
Zigzagoon,
Linoone,
Wurmple,
Silcoon,
Beautifly,
Cascoon,
Dustox,
Lotad,
Lombre,
Ludicolo,
Seedot,
Nuzleaf,
Shiftry,
Taillow,
Swellow,
Wingull,
Pelipper,
Ralts,
Kirlia,
Gardevoir,
Surskit,
Masquerain,
Shroomish,
Breloom,
Slakoth,
Vigoroth,
Slaking,
Nincada,
Ninjask,
Shedinja,
Whismur,
Loudred,
Exploud,
Makuhita,
Hariyama,
Azurill,
Nosepass,
Skitty,
Delcatty,
Sableye,
Mawile,
Aron,
Lairon,
Aggron,
Meditite,
Medicham,
Electrike,
Manectric,
Plusle,
Minun,
Volbeat,
Illumise,
Roselia,
Gulpin,
Swalot,
Carvanha,
Sharpedo,
Wailmer,
Wailord,
Numel,
Camerupt,
Torkoal,
Spoink,
Grumpig,
Spinda,
Trapinch,
Vibrava,
Flygon,
Cacnea,
Cacturne,
Swablu,
Altaria,
Zangoose,
Seviper,
Lunatone,
Solrock,
Barboach,
Whiscash,
Corphish,
Crawdaunt,
Baltoy,
Claydol,
Lileep,
Cradily,
Anorith,
Armaldo,
Feebas,
Milotic,
Castform,
Kecleon,
Shuppet,
Banette,
Duskull,
Dusclops,
Tropius,
Chimecho,
Absol,
Wynaut,
Snorunt,
Glalie,
Spheal,
Sealeo,
Walrein,
Clamperl,
Huntail,
Gorebyss,
Relicanth,
Luvdisc,
Bagon,
Shelgon,
Salamence,
Beldum,
Metang,
Metagross,
Regirock,
Regice,
Registeel,
Latias,
Latios,
Kyogre,
Groudon,
Rayquaza,
Jirachi,
Deoxys,
Turtwig,
Grotle,
Torterra,
Chimchar,
Monferno,
Infernape,
Piplup,
Prinplup,
Empoleon,
Starly,
Staravia,
Staraptor,
Bidoof,
Bibarel,
Kricketot,
Kricketune,
Shinx,
Luxio,
Luxray,
Budew,
Roserade,
Cranidos,
Rampardos,
Shieldon,
Bastiodon,
Burmy,
Wormadam,
Mothim,
Combee,
Vespiquen,
Pachirisu,
Buizel,
Floatzel,
Cherubi,
Cherrim,
Shellos,
Gastrodon,
Ambipom,
Drifloon,
Drifblim,
Buneary,
Lopunny,
Mismagius,
Honchkrow,
Glameow,
Purugly,
Chingling,
Stunky,
Skuntank,
Bronzor,
Bronzong,
Bonsly,
MimeJr,
Happiny,
Chatot,
Spiritomb,
Gible,
Gabite,
Garchomp,
Munchlax,
Riolu,
Lucario,
Hippopotas,
Hippowdon,
Skorupi,
Drapion,
Croagunk,
Toxicroak,
Carnivine,
Finneon,
Lumineon,
Mantyke,
Snover,
Abomasnow,
Weavile,
Magnezone,
Lickilicky,
Rhyperior,
Tangrowth,
Electivire,
Magmortar,
Togekiss,
Yanmega,
Leafeon,
Glaceon,
Gliscor,
Mamoswine,
PorygonZ,
Gallade,
Probopass,
Dusknoir,
Froslass,
Rotom,
Uxie,
Mesprit,
Azelf,
Dialga,
Palkia,
Heatran,
Regigigas,
Giratina,
Cresselia,
Phione,
Manaphy,
Darkrai,
Shaymin,
Arceus,
Victini,
Snivy,
Servine,
Serperior,
Tepig,
Pignite,
Emboar,
Oshawott,
Dewott,
Samurott,
Patrat,
Watchog,
Lillipup,
Herdier,
Stoutland,
Purrloin,
Liepard,
Pansage,
Simisage,
Pansear,
Simisear,
Panpour,
Simipour,
Munna,
Musharna,
Pidove,
Tranquill,
Unfezant,
Blitzle,
Zebstrika,
Roggenrola,
Boldore,
Gigalith,
Woobat,
Swoobat,
Drilbur,
Excadrill,
Audino,
Timburr,
Gurdurr,
Conkeldurr,
Tympole,
Palpitoad,
Seismitoad,
Throh,
Sawk,
Sewaddle,
Swadloon,
Leavanny,
Venipede,
Whirlipede,
Scolipede,
Cottonee,
Whimsicott,
Petilil,
Lilligant,
Basculin,
Sandile,
Krokorok,
Krookodile,
Darumaka,
Darmanitan,
Maractus,
Dwebble,
Crustle,
Scraggy,
Scrafty,
Sigilyph,
Yamask,
Cofagrigus,
Tirtouga,
Carracosta,
Archen,
Archeops,
Trubbish,
Garbodor,
Zorua,
Zoroark,
Minccino,
Cinccino,
Gothita,
Gothorita,
Gothitelle,
Solosis,
Duosion,
Reuniclus,
Ducklett,
Swanna,
Vanillite,
Vanillish,
Vanilluxe,
Deerling,
Sawsbuck,
Emolga,
Karrablast,
Escavalier,
Foongus,
Amoonguss,
Frillish,
Jellicent,
Alomomola,
Joltik,
Galvantula,
Ferroseed,
Ferrothorn,
Klink,
Klang,
Klinklang,
Tynamo,
Eelektrik,
Eelektross,
Elgyem,
Beheeyem,
Litwick,
Lampent,
Chandelure,
Axew,
Fraxure,
Haxorus,
Cubchoo,
Beartic,
Cryogonal,
Shelmet,
Accelgor,
Stunfisk,
Mienfoo,
Mienshao,
Druddigon,
Golett,
Golurk,
Pawniard,
Bisharp,
Bouffalant,
Rufflet,
Braviary,
Vullaby,
Mandibuzz,
Heatmor,
Durant,
Deino,
Zweilous,
Hydreigon,
Larvesta,
Volcarona,
Cobalion,
Terrakion,
Virizion,
Tornadus,
Thundurus,
Reshiram,
Zekrom,
Landorus,
Kyurem,
Keldeo,
Meloetta,
Genesect,
Chespin,
Quilladin,
Chesnaught,
Fennekin,
Braixen,
Delphox,
Froakie,
Frogadier,
Greninja,
Bunnelby,
Diggersby,
Fletchling,
Fletchinder,
Talonflame,
Scatterbug,
Spewpa,
Vivillon,
Litleo,
Pyroar,
Flabebe,
Floette,
Florges,
Skiddo,
Gogoat,
Pancham,
Pangoro,
Furfrou,
Espurr,
Meowstic,
Honedge,
Doublade,
Aegislash,
Spritzee,
Aromatisse,
Swirlix,
Slurpuff,
Inkay,
Malamar,
Binacle,
Barbaracle,
Skrelp,
Dragalge,
Clauncher,
Clawitzer,
Helioptile,
Heliolisk,
Tyrunt,
Tyrantrum,
Amaura,
Aurorus,
Sylveon,
Hawlucha,
Dedenne,
Carbink,
Goomy,
Sliggoo,
Goodra,
Klefki,
Phantump,
Trevenant,
Pumpkaboo,
Gourgeist,
Bergmite,
Avalugg,
Noibat,
Noivern,
Xerneas,
Yveltal,
Zygarde,
Diancie,
Hoopa,
Volcanion,
Rowlet,
Dartrix,
Decidueye,
Litten,
Torracat,
Incineroar,
Popplio,
Brionne,
Primarina,
Pikipek,
Trumbeak,
Toucannon,
Yungoos,
Gumshoos,
Grubbin,
Charjabug,
Vikavolt,
Crabrawler,
Crabominable,
Oricorio,
Cutiefly,
Ribombee,
Rockruff,
Lycanroc,
Wishiwashi,
Mareanie,
Toxapex,
Mudbray,
Mudsdale,
Dewpider,
Araquanid,
Fomantis,
Lurantis,
Morelull,
Shiinotic,
Salandit,
Salazzle,
Stufful,
Bewear,
Bounsweet,
Steenee,
Tsareena,
Comfey,
Oranguru,
Passimian,
Wimpod,
Golisopod,
Sandygast,
Palossand,
Pyukumuku,
TypeNull,
Silvally,
Minior,
Komala,
Turtonator,
Togedemaru,
Mimikyu,
Bruxish,
Drampa,
Dhelmise,
Jangmoo,
Hakamoo,
Kommoo,
TapuKoko,
TapuLele,
TapuBulu,
TapuFini,
Cosmog,
Cosmoem,
Solgaleo,
Lunala,
Nihilego,
Buzzwole,
Pheromosa,
Xurkitree,
Celesteela,
Kartana,
Guzzlord,
Necrozma,
Magearna,
Marshadow,
Poipole,
Naganadel,
Stakataka,
Blacephalon,
Zeraora,
Meltan,
Melmetal,
Grookey,
Thwackey,
Rillaboom,
Scorbunny,
Raboot,
Cinderace,
Sobble,
Drizzile,
Inteleon,
Skwovet,
Greedent,
Rookidee,
Corvisquire,
Corviknight,
Blipbug,
Dottler,
Orbeetle,
Nickit,
Thievul,
Gossifleur,
Eldegoss,
Wooloo,
Dubwool,
Chewtle,
Drednaw,
Yamper,
Boltund,
Rolycoly,
Carkol,
Coalossal,
Applin,
Flapple,
Appletun,
Silicobra,
Sandaconda,
Cramorant,
Arrokuda,
Barraskewda,
Toxel,
Toxtricity,
Sizzlipede,
Centiskorch,
Clobbopus,
Grapploct,
Sinistea,
Polteageist,
Hatenna,
Hattrem,
Hatterene,
Impidimp,
Morgrem,
Grimmsnarl,
Obstagoon,
Perrserker,
Cursola,
Sirfetchd,
MrRime,
Runerigus,
Milcery,
Alcremie,
Falinks,
Pincurchin,
Snom,
Frosmoth,
Stonjourner,
Eiscue,
Indeedee,
Morpeko,
Cufant,
Copperajah,
Dracozolt,
Arctozolt,
Dracovish,
Arctovish,
Duraludon,
Dreepy,
Drakloak,
Dragapult,
Zacian,
Zamazenta,
Eternatus,
Kubfu,
Urshifu,
Zarude,
Regieleki,
Regidrago,
Glastrier,
Spectrier,
Calyrex,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<SpeciesEnum>>::max()
} v;
constexpr explicit Species_impl(SpeciesEnum v) : v(v) {}
constexpr Species_impl(const Species_impl&) = default;
constexpr Species_impl(Species_impl&&) = default;
constexpr Species_impl& operator=(const Species_impl&) = default;
constexpr Species_impl& operator=(Species_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator SpeciesEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Species_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Species
{
private:
internal::Species_impl impl;
public:
using EnumType = internal::Species_impl::SpeciesEnum;
constexpr Species() noexcept : impl(EnumType{0}) {}
constexpr Species(const internal::Species_impl& impl) noexcept : impl(impl) {}
constexpr explicit Species(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Species& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Species_impl None{EnumType::None};
static constexpr internal::Species_impl Bulbasaur{EnumType::Bulbasaur};
static constexpr internal::Species_impl Ivysaur{EnumType::Ivysaur};
static constexpr internal::Species_impl Venusaur{EnumType::Venusaur};
static constexpr internal::Species_impl Charmander{EnumType::Charmander};
static constexpr internal::Species_impl Charmeleon{EnumType::Charmeleon};
static constexpr internal::Species_impl Charizard{EnumType::Charizard};
static constexpr internal::Species_impl Squirtle{EnumType::Squirtle};
static constexpr internal::Species_impl Wartortle{EnumType::Wartortle};
static constexpr internal::Species_impl Blastoise{EnumType::Blastoise};
static constexpr internal::Species_impl Caterpie{EnumType::Caterpie};
static constexpr internal::Species_impl Metapod{EnumType::Metapod};
static constexpr internal::Species_impl Butterfree{EnumType::Butterfree};
static constexpr internal::Species_impl Weedle{EnumType::Weedle};
static constexpr internal::Species_impl Kakuna{EnumType::Kakuna};
static constexpr internal::Species_impl Beedrill{EnumType::Beedrill};
static constexpr internal::Species_impl Pidgey{EnumType::Pidgey};
static constexpr internal::Species_impl Pidgeotto{EnumType::Pidgeotto};
static constexpr internal::Species_impl Pidgeot{EnumType::Pidgeot};
static constexpr internal::Species_impl Rattata{EnumType::Rattata};
static constexpr internal::Species_impl Raticate{EnumType::Raticate};
static constexpr internal::Species_impl Spearow{EnumType::Spearow};
static constexpr internal::Species_impl Fearow{EnumType::Fearow};
static constexpr internal::Species_impl Ekans{EnumType::Ekans};
static constexpr internal::Species_impl Arbok{EnumType::Arbok};
static constexpr internal::Species_impl Pikachu{EnumType::Pikachu};
static constexpr internal::Species_impl Raichu{EnumType::Raichu};
static constexpr internal::Species_impl Sandshrew{EnumType::Sandshrew};
static constexpr internal::Species_impl Sandslash{EnumType::Sandslash};
static constexpr internal::Species_impl NidoranF{EnumType::NidoranF};
static constexpr internal::Species_impl Nidorina{EnumType::Nidorina};
static constexpr internal::Species_impl Nidoqueen{EnumType::Nidoqueen};
static constexpr internal::Species_impl NidoranM{EnumType::NidoranM};
static constexpr internal::Species_impl Nidorino{EnumType::Nidorino};
static constexpr internal::Species_impl Nidoking{EnumType::Nidoking};
static constexpr internal::Species_impl Clefairy{EnumType::Clefairy};
static constexpr internal::Species_impl Clefable{EnumType::Clefable};
static constexpr internal::Species_impl Vulpix{EnumType::Vulpix};
static constexpr internal::Species_impl Ninetales{EnumType::Ninetales};
static constexpr internal::Species_impl Jigglypuff{EnumType::Jigglypuff};
static constexpr internal::Species_impl Wigglytuff{EnumType::Wigglytuff};
static constexpr internal::Species_impl Zubat{EnumType::Zubat};
static constexpr internal::Species_impl Golbat{EnumType::Golbat};
static constexpr internal::Species_impl Oddish{EnumType::Oddish};
static constexpr internal::Species_impl Gloom{EnumType::Gloom};
static constexpr internal::Species_impl Vileplume{EnumType::Vileplume};
static constexpr internal::Species_impl Paras{EnumType::Paras};
static constexpr internal::Species_impl Parasect{EnumType::Parasect};
static constexpr internal::Species_impl Venonat{EnumType::Venonat};
static constexpr internal::Species_impl Venomoth{EnumType::Venomoth};
static constexpr internal::Species_impl Diglett{EnumType::Diglett};
static constexpr internal::Species_impl Dugtrio{EnumType::Dugtrio};
static constexpr internal::Species_impl Meowth{EnumType::Meowth};
static constexpr internal::Species_impl Persian{EnumType::Persian};
static constexpr internal::Species_impl Psyduck{EnumType::Psyduck};
static constexpr internal::Species_impl Golduck{EnumType::Golduck};
static constexpr internal::Species_impl Mankey{EnumType::Mankey};
static constexpr internal::Species_impl Primeape{EnumType::Primeape};
static constexpr internal::Species_impl Growlithe{EnumType::Growlithe};
static constexpr internal::Species_impl Arcanine{EnumType::Arcanine};
static constexpr internal::Species_impl Poliwag{EnumType::Poliwag};
static constexpr internal::Species_impl Poliwhirl{EnumType::Poliwhirl};
static constexpr internal::Species_impl Poliwrath{EnumType::Poliwrath};
static constexpr internal::Species_impl Abra{EnumType::Abra};
static constexpr internal::Species_impl Kadabra{EnumType::Kadabra};
static constexpr internal::Species_impl Alakazam{EnumType::Alakazam};
static constexpr internal::Species_impl Machop{EnumType::Machop};
static constexpr internal::Species_impl Machoke{EnumType::Machoke};
static constexpr internal::Species_impl Machamp{EnumType::Machamp};
static constexpr internal::Species_impl Bellsprout{EnumType::Bellsprout};
static constexpr internal::Species_impl Weepinbell{EnumType::Weepinbell};
static constexpr internal::Species_impl Victreebel{EnumType::Victreebel};
static constexpr internal::Species_impl Tentacool{EnumType::Tentacool};
static constexpr internal::Species_impl Tentacruel{EnumType::Tentacruel};
static constexpr internal::Species_impl Geodude{EnumType::Geodude};
static constexpr internal::Species_impl Graveler{EnumType::Graveler};
static constexpr internal::Species_impl Golem{EnumType::Golem};
static constexpr internal::Species_impl Ponyta{EnumType::Ponyta};
static constexpr internal::Species_impl Rapidash{EnumType::Rapidash};
static constexpr internal::Species_impl Slowpoke{EnumType::Slowpoke};
static constexpr internal::Species_impl Slowbro{EnumType::Slowbro};
static constexpr internal::Species_impl Magnemite{EnumType::Magnemite};
static constexpr internal::Species_impl Magneton{EnumType::Magneton};
static constexpr internal::Species_impl Farfetchd{EnumType::Farfetchd};
static constexpr internal::Species_impl Doduo{EnumType::Doduo};
static constexpr internal::Species_impl Dodrio{EnumType::Dodrio};
static constexpr internal::Species_impl Seel{EnumType::Seel};
static constexpr internal::Species_impl Dewgong{EnumType::Dewgong};
static constexpr internal::Species_impl Grimer{EnumType::Grimer};
static constexpr internal::Species_impl Muk{EnumType::Muk};
static constexpr internal::Species_impl Shellder{EnumType::Shellder};
static constexpr internal::Species_impl Cloyster{EnumType::Cloyster};
static constexpr internal::Species_impl Gastly{EnumType::Gastly};
static constexpr internal::Species_impl Haunter{EnumType::Haunter};
static constexpr internal::Species_impl Gengar{EnumType::Gengar};
static constexpr internal::Species_impl Onix{EnumType::Onix};
static constexpr internal::Species_impl Drowzee{EnumType::Drowzee};
static constexpr internal::Species_impl Hypno{EnumType::Hypno};
static constexpr internal::Species_impl Krabby{EnumType::Krabby};
static constexpr internal::Species_impl Kingler{EnumType::Kingler};
static constexpr internal::Species_impl Voltorb{EnumType::Voltorb};
static constexpr internal::Species_impl Electrode{EnumType::Electrode};
static constexpr internal::Species_impl Exeggcute{EnumType::Exeggcute};
static constexpr internal::Species_impl Exeggutor{EnumType::Exeggutor};
static constexpr internal::Species_impl Cubone{EnumType::Cubone};
static constexpr internal::Species_impl Marowak{EnumType::Marowak};
static constexpr internal::Species_impl Hitmonlee{EnumType::Hitmonlee};
static constexpr internal::Species_impl Hitmonchan{EnumType::Hitmonchan};
static constexpr internal::Species_impl Lickitung{EnumType::Lickitung};
static constexpr internal::Species_impl Koffing{EnumType::Koffing};
static constexpr internal::Species_impl Weezing{EnumType::Weezing};
static constexpr internal::Species_impl Rhyhorn{EnumType::Rhyhorn};
static constexpr internal::Species_impl Rhydon{EnumType::Rhydon};
static constexpr internal::Species_impl Chansey{EnumType::Chansey};
static constexpr internal::Species_impl Tangela{EnumType::Tangela};
static constexpr internal::Species_impl Kangaskhan{EnumType::Kangaskhan};
static constexpr internal::Species_impl Horsea{EnumType::Horsea};
static constexpr internal::Species_impl Seadra{EnumType::Seadra};
static constexpr internal::Species_impl Goldeen{EnumType::Goldeen};
static constexpr internal::Species_impl Seaking{EnumType::Seaking};
static constexpr internal::Species_impl Staryu{EnumType::Staryu};
static constexpr internal::Species_impl Starmie{EnumType::Starmie};
static constexpr internal::Species_impl MrMime{EnumType::MrMime};
static constexpr internal::Species_impl Scyther{EnumType::Scyther};
static constexpr internal::Species_impl Jynx{EnumType::Jynx};
static constexpr internal::Species_impl Electabuzz{EnumType::Electabuzz};
static constexpr internal::Species_impl Magmar{EnumType::Magmar};
static constexpr internal::Species_impl Pinsir{EnumType::Pinsir};
static constexpr internal::Species_impl Tauros{EnumType::Tauros};
static constexpr internal::Species_impl Magikarp{EnumType::Magikarp};
static constexpr internal::Species_impl Gyarados{EnumType::Gyarados};
static constexpr internal::Species_impl Lapras{EnumType::Lapras};
static constexpr internal::Species_impl Ditto{EnumType::Ditto};
static constexpr internal::Species_impl Eevee{EnumType::Eevee};
static constexpr internal::Species_impl Vaporeon{EnumType::Vaporeon};
static constexpr internal::Species_impl Jolteon{EnumType::Jolteon};
static constexpr internal::Species_impl Flareon{EnumType::Flareon};
static constexpr internal::Species_impl Porygon{EnumType::Porygon};
static constexpr internal::Species_impl Omanyte{EnumType::Omanyte};
static constexpr internal::Species_impl Omastar{EnumType::Omastar};
static constexpr internal::Species_impl Kabuto{EnumType::Kabuto};
static constexpr internal::Species_impl Kabutops{EnumType::Kabutops};
static constexpr internal::Species_impl Aerodactyl{EnumType::Aerodactyl};
static constexpr internal::Species_impl Snorlax{EnumType::Snorlax};
static constexpr internal::Species_impl Articuno{EnumType::Articuno};
static constexpr internal::Species_impl Zapdos{EnumType::Zapdos};
static constexpr internal::Species_impl Moltres{EnumType::Moltres};
static constexpr internal::Species_impl Dratini{EnumType::Dratini};
static constexpr internal::Species_impl Dragonair{EnumType::Dragonair};
static constexpr internal::Species_impl Dragonite{EnumType::Dragonite};
static constexpr internal::Species_impl Mewtwo{EnumType::Mewtwo};
static constexpr internal::Species_impl Mew{EnumType::Mew};
static constexpr internal::Species_impl Chikorita{EnumType::Chikorita};
static constexpr internal::Species_impl Bayleef{EnumType::Bayleef};
static constexpr internal::Species_impl Meganium{EnumType::Meganium};
static constexpr internal::Species_impl Cyndaquil{EnumType::Cyndaquil};
static constexpr internal::Species_impl Quilava{EnumType::Quilava};
static constexpr internal::Species_impl Typhlosion{EnumType::Typhlosion};
static constexpr internal::Species_impl Totodile{EnumType::Totodile};
static constexpr internal::Species_impl Croconaw{EnumType::Croconaw};
static constexpr internal::Species_impl Feraligatr{EnumType::Feraligatr};
static constexpr internal::Species_impl Sentret{EnumType::Sentret};
static constexpr internal::Species_impl Furret{EnumType::Furret};
static constexpr internal::Species_impl Hoothoot{EnumType::Hoothoot};
static constexpr internal::Species_impl Noctowl{EnumType::Noctowl};
static constexpr internal::Species_impl Ledyba{EnumType::Ledyba};
static constexpr internal::Species_impl Ledian{EnumType::Ledian};
static constexpr internal::Species_impl Spinarak{EnumType::Spinarak};
static constexpr internal::Species_impl Ariados{EnumType::Ariados};
static constexpr internal::Species_impl Crobat{EnumType::Crobat};
static constexpr internal::Species_impl Chinchou{EnumType::Chinchou};
static constexpr internal::Species_impl Lanturn{EnumType::Lanturn};
static constexpr internal::Species_impl Pichu{EnumType::Pichu};
static constexpr internal::Species_impl Cleffa{EnumType::Cleffa};
static constexpr internal::Species_impl Igglybuff{EnumType::Igglybuff};
static constexpr internal::Species_impl Togepi{EnumType::Togepi};
static constexpr internal::Species_impl Togetic{EnumType::Togetic};
static constexpr internal::Species_impl Natu{EnumType::Natu};
static constexpr internal::Species_impl Xatu{EnumType::Xatu};
static constexpr internal::Species_impl Mareep{EnumType::Mareep};
static constexpr internal::Species_impl Flaaffy{EnumType::Flaaffy};
static constexpr internal::Species_impl Ampharos{EnumType::Ampharos};
static constexpr internal::Species_impl Bellossom{EnumType::Bellossom};
static constexpr internal::Species_impl Marill{EnumType::Marill};
static constexpr internal::Species_impl Azumarill{EnumType::Azumarill};
static constexpr internal::Species_impl Sudowoodo{EnumType::Sudowoodo};
static constexpr internal::Species_impl Politoed{EnumType::Politoed};
static constexpr internal::Species_impl Hoppip{EnumType::Hoppip};
static constexpr internal::Species_impl Skiploom{EnumType::Skiploom};
static constexpr internal::Species_impl Jumpluff{EnumType::Jumpluff};
static constexpr internal::Species_impl Aipom{EnumType::Aipom};
static constexpr internal::Species_impl Sunkern{EnumType::Sunkern};
static constexpr internal::Species_impl Sunflora{EnumType::Sunflora};
static constexpr internal::Species_impl Yanma{EnumType::Yanma};
static constexpr internal::Species_impl Wooper{EnumType::Wooper};
static constexpr internal::Species_impl Quagsire{EnumType::Quagsire};
static constexpr internal::Species_impl Espeon{EnumType::Espeon};
static constexpr internal::Species_impl Umbreon{EnumType::Umbreon};
static constexpr internal::Species_impl Murkrow{EnumType::Murkrow};
static constexpr internal::Species_impl Slowking{EnumType::Slowking};
static constexpr internal::Species_impl Misdreavus{EnumType::Misdreavus};
static constexpr internal::Species_impl Unown{EnumType::Unown};
static constexpr internal::Species_impl Wobbuffet{EnumType::Wobbuffet};
static constexpr internal::Species_impl Girafarig{EnumType::Girafarig};
static constexpr internal::Species_impl Pineco{EnumType::Pineco};
static constexpr internal::Species_impl Forretress{EnumType::Forretress};
static constexpr internal::Species_impl Dunsparce{EnumType::Dunsparce};
static constexpr internal::Species_impl Gligar{EnumType::Gligar};
static constexpr internal::Species_impl Steelix{EnumType::Steelix};
static constexpr internal::Species_impl Snubbull{EnumType::Snubbull};
static constexpr internal::Species_impl Granbull{EnumType::Granbull};
static constexpr internal::Species_impl Qwilfish{EnumType::Qwilfish};
static constexpr internal::Species_impl Scizor{EnumType::Scizor};
static constexpr internal::Species_impl Shuckle{EnumType::Shuckle};
static constexpr internal::Species_impl Heracross{EnumType::Heracross};
static constexpr internal::Species_impl Sneasel{EnumType::Sneasel};
static constexpr internal::Species_impl Teddiursa{EnumType::Teddiursa};
static constexpr internal::Species_impl Ursaring{EnumType::Ursaring};
static constexpr internal::Species_impl Slugma{EnumType::Slugma};
static constexpr internal::Species_impl Magcargo{EnumType::Magcargo};
static constexpr internal::Species_impl Swinub{EnumType::Swinub};
static constexpr internal::Species_impl Piloswine{EnumType::Piloswine};
static constexpr internal::Species_impl Corsola{EnumType::Corsola};
static constexpr internal::Species_impl Remoraid{EnumType::Remoraid};
static constexpr internal::Species_impl Octillery{EnumType::Octillery};
static constexpr internal::Species_impl Delibird{EnumType::Delibird};
static constexpr internal::Species_impl Mantine{EnumType::Mantine};
static constexpr internal::Species_impl Skarmory{EnumType::Skarmory};
static constexpr internal::Species_impl Houndour{EnumType::Houndour};
static constexpr internal::Species_impl Houndoom{EnumType::Houndoom};
static constexpr internal::Species_impl Kingdra{EnumType::Kingdra};
static constexpr internal::Species_impl Phanpy{EnumType::Phanpy};
static constexpr internal::Species_impl Donphan{EnumType::Donphan};
static constexpr internal::Species_impl Porygon2{EnumType::Porygon2};
static constexpr internal::Species_impl Stantler{EnumType::Stantler};
static constexpr internal::Species_impl Smeargle{EnumType::Smeargle};
static constexpr internal::Species_impl Tyrogue{EnumType::Tyrogue};
static constexpr internal::Species_impl Hitmontop{EnumType::Hitmontop};
static constexpr internal::Species_impl Smoochum{EnumType::Smoochum};
static constexpr internal::Species_impl Elekid{EnumType::Elekid};
static constexpr internal::Species_impl Magby{EnumType::Magby};
static constexpr internal::Species_impl Miltank{EnumType::Miltank};
static constexpr internal::Species_impl Blissey{EnumType::Blissey};
static constexpr internal::Species_impl Raikou{EnumType::Raikou};
static constexpr internal::Species_impl Entei{EnumType::Entei};
static constexpr internal::Species_impl Suicune{EnumType::Suicune};
static constexpr internal::Species_impl Larvitar{EnumType::Larvitar};
static constexpr internal::Species_impl Pupitar{EnumType::Pupitar};
static constexpr internal::Species_impl Tyranitar{EnumType::Tyranitar};
static constexpr internal::Species_impl Lugia{EnumType::Lugia};
static constexpr internal::Species_impl HoOh{EnumType::HoOh};
static constexpr internal::Species_impl Celebi{EnumType::Celebi};
static constexpr internal::Species_impl Treecko{EnumType::Treecko};
static constexpr internal::Species_impl Grovyle{EnumType::Grovyle};
static constexpr internal::Species_impl Sceptile{EnumType::Sceptile};
static constexpr internal::Species_impl Torchic{EnumType::Torchic};
static constexpr internal::Species_impl Combusken{EnumType::Combusken};
static constexpr internal::Species_impl Blaziken{EnumType::Blaziken};
static constexpr internal::Species_impl Mudkip{EnumType::Mudkip};
static constexpr internal::Species_impl Marshtomp{EnumType::Marshtomp};
static constexpr internal::Species_impl Swampert{EnumType::Swampert};
static constexpr internal::Species_impl Poochyena{EnumType::Poochyena};
static constexpr internal::Species_impl Mightyena{EnumType::Mightyena};
static constexpr internal::Species_impl Zigzagoon{EnumType::Zigzagoon};
static constexpr internal::Species_impl Linoone{EnumType::Linoone};
static constexpr internal::Species_impl Wurmple{EnumType::Wurmple};
static constexpr internal::Species_impl Silcoon{EnumType::Silcoon};
static constexpr internal::Species_impl Beautifly{EnumType::Beautifly};
static constexpr internal::Species_impl Cascoon{EnumType::Cascoon};
static constexpr internal::Species_impl Dustox{EnumType::Dustox};
static constexpr internal::Species_impl Lotad{EnumType::Lotad};
static constexpr internal::Species_impl Lombre{EnumType::Lombre};
static constexpr internal::Species_impl Ludicolo{EnumType::Ludicolo};
static constexpr internal::Species_impl Seedot{EnumType::Seedot};
static constexpr internal::Species_impl Nuzleaf{EnumType::Nuzleaf};
static constexpr internal::Species_impl Shiftry{EnumType::Shiftry};
static constexpr internal::Species_impl Taillow{EnumType::Taillow};
static constexpr internal::Species_impl Swellow{EnumType::Swellow};
static constexpr internal::Species_impl Wingull{EnumType::Wingull};
static constexpr internal::Species_impl Pelipper{EnumType::Pelipper};
static constexpr internal::Species_impl Ralts{EnumType::Ralts};
static constexpr internal::Species_impl Kirlia{EnumType::Kirlia};
static constexpr internal::Species_impl Gardevoir{EnumType::Gardevoir};
static constexpr internal::Species_impl Surskit{EnumType::Surskit};
static constexpr internal::Species_impl Masquerain{EnumType::Masquerain};
static constexpr internal::Species_impl Shroomish{EnumType::Shroomish};
static constexpr internal::Species_impl Breloom{EnumType::Breloom};
static constexpr internal::Species_impl Slakoth{EnumType::Slakoth};
static constexpr internal::Species_impl Vigoroth{EnumType::Vigoroth};
static constexpr internal::Species_impl Slaking{EnumType::Slaking};
static constexpr internal::Species_impl Nincada{EnumType::Nincada};
static constexpr internal::Species_impl Ninjask{EnumType::Ninjask};
static constexpr internal::Species_impl Shedinja{EnumType::Shedinja};
static constexpr internal::Species_impl Whismur{EnumType::Whismur};
static constexpr internal::Species_impl Loudred{EnumType::Loudred};
static constexpr internal::Species_impl Exploud{EnumType::Exploud};
static constexpr internal::Species_impl Makuhita{EnumType::Makuhita};
static constexpr internal::Species_impl Hariyama{EnumType::Hariyama};
static constexpr internal::Species_impl Azurill{EnumType::Azurill};
static constexpr internal::Species_impl Nosepass{EnumType::Nosepass};
static constexpr internal::Species_impl Skitty{EnumType::Skitty};
static constexpr internal::Species_impl Delcatty{EnumType::Delcatty};
static constexpr internal::Species_impl Sableye{EnumType::Sableye};
static constexpr internal::Species_impl Mawile{EnumType::Mawile};
static constexpr internal::Species_impl Aron{EnumType::Aron};
static constexpr internal::Species_impl Lairon{EnumType::Lairon};
static constexpr internal::Species_impl Aggron{EnumType::Aggron};
static constexpr internal::Species_impl Meditite{EnumType::Meditite};
static constexpr internal::Species_impl Medicham{EnumType::Medicham};
static constexpr internal::Species_impl Electrike{EnumType::Electrike};
static constexpr internal::Species_impl Manectric{EnumType::Manectric};
static constexpr internal::Species_impl Plusle{EnumType::Plusle};
static constexpr internal::Species_impl Minun{EnumType::Minun};
static constexpr internal::Species_impl Volbeat{EnumType::Volbeat};
static constexpr internal::Species_impl Illumise{EnumType::Illumise};
static constexpr internal::Species_impl Roselia{EnumType::Roselia};
static constexpr internal::Species_impl Gulpin{EnumType::Gulpin};
static constexpr internal::Species_impl Swalot{EnumType::Swalot};
static constexpr internal::Species_impl Carvanha{EnumType::Carvanha};
static constexpr internal::Species_impl Sharpedo{EnumType::Sharpedo};
static constexpr internal::Species_impl Wailmer{EnumType::Wailmer};
static constexpr internal::Species_impl Wailord{EnumType::Wailord};
static constexpr internal::Species_impl Numel{EnumType::Numel};
static constexpr internal::Species_impl Camerupt{EnumType::Camerupt};
static constexpr internal::Species_impl Torkoal{EnumType::Torkoal};
static constexpr internal::Species_impl Spoink{EnumType::Spoink};
static constexpr internal::Species_impl Grumpig{EnumType::Grumpig};
static constexpr internal::Species_impl Spinda{EnumType::Spinda};
static constexpr internal::Species_impl Trapinch{EnumType::Trapinch};
static constexpr internal::Species_impl Vibrava{EnumType::Vibrava};
static constexpr internal::Species_impl Flygon{EnumType::Flygon};
static constexpr internal::Species_impl Cacnea{EnumType::Cacnea};
static constexpr internal::Species_impl Cacturne{EnumType::Cacturne};
static constexpr internal::Species_impl Swablu{EnumType::Swablu};
static constexpr internal::Species_impl Altaria{EnumType::Altaria};
static constexpr internal::Species_impl Zangoose{EnumType::Zangoose};
static constexpr internal::Species_impl Seviper{EnumType::Seviper};
static constexpr internal::Species_impl Lunatone{EnumType::Lunatone};
static constexpr internal::Species_impl Solrock{EnumType::Solrock};
static constexpr internal::Species_impl Barboach{EnumType::Barboach};
static constexpr internal::Species_impl Whiscash{EnumType::Whiscash};
static constexpr internal::Species_impl Corphish{EnumType::Corphish};
static constexpr internal::Species_impl Crawdaunt{EnumType::Crawdaunt};
static constexpr internal::Species_impl Baltoy{EnumType::Baltoy};
static constexpr internal::Species_impl Claydol{EnumType::Claydol};
static constexpr internal::Species_impl Lileep{EnumType::Lileep};
static constexpr internal::Species_impl Cradily{EnumType::Cradily};
static constexpr internal::Species_impl Anorith{EnumType::Anorith};
static constexpr internal::Species_impl Armaldo{EnumType::Armaldo};
static constexpr internal::Species_impl Feebas{EnumType::Feebas};
static constexpr internal::Species_impl Milotic{EnumType::Milotic};
static constexpr internal::Species_impl Castform{EnumType::Castform};
static constexpr internal::Species_impl Kecleon{EnumType::Kecleon};
static constexpr internal::Species_impl Shuppet{EnumType::Shuppet};
static constexpr internal::Species_impl Banette{EnumType::Banette};
static constexpr internal::Species_impl Duskull{EnumType::Duskull};
static constexpr internal::Species_impl Dusclops{EnumType::Dusclops};
static constexpr internal::Species_impl Tropius{EnumType::Tropius};
static constexpr internal::Species_impl Chimecho{EnumType::Chimecho};
static constexpr internal::Species_impl Absol{EnumType::Absol};
static constexpr internal::Species_impl Wynaut{EnumType::Wynaut};
static constexpr internal::Species_impl Snorunt{EnumType::Snorunt};
static constexpr internal::Species_impl Glalie{EnumType::Glalie};
static constexpr internal::Species_impl Spheal{EnumType::Spheal};
static constexpr internal::Species_impl Sealeo{EnumType::Sealeo};
static constexpr internal::Species_impl Walrein{EnumType::Walrein};
static constexpr internal::Species_impl Clamperl{EnumType::Clamperl};
static constexpr internal::Species_impl Huntail{EnumType::Huntail};
static constexpr internal::Species_impl Gorebyss{EnumType::Gorebyss};
static constexpr internal::Species_impl Relicanth{EnumType::Relicanth};
static constexpr internal::Species_impl Luvdisc{EnumType::Luvdisc};
static constexpr internal::Species_impl Bagon{EnumType::Bagon};
static constexpr internal::Species_impl Shelgon{EnumType::Shelgon};
static constexpr internal::Species_impl Salamence{EnumType::Salamence};
static constexpr internal::Species_impl Beldum{EnumType::Beldum};
static constexpr internal::Species_impl Metang{EnumType::Metang};
static constexpr internal::Species_impl Metagross{EnumType::Metagross};
static constexpr internal::Species_impl Regirock{EnumType::Regirock};
static constexpr internal::Species_impl Regice{EnumType::Regice};
static constexpr internal::Species_impl Registeel{EnumType::Registeel};
static constexpr internal::Species_impl Latias{EnumType::Latias};
static constexpr internal::Species_impl Latios{EnumType::Latios};
static constexpr internal::Species_impl Kyogre{EnumType::Kyogre};
static constexpr internal::Species_impl Groudon{EnumType::Groudon};
static constexpr internal::Species_impl Rayquaza{EnumType::Rayquaza};
static constexpr internal::Species_impl Jirachi{EnumType::Jirachi};
static constexpr internal::Species_impl Deoxys{EnumType::Deoxys};
static constexpr internal::Species_impl Turtwig{EnumType::Turtwig};
static constexpr internal::Species_impl Grotle{EnumType::Grotle};
static constexpr internal::Species_impl Torterra{EnumType::Torterra};
static constexpr internal::Species_impl Chimchar{EnumType::Chimchar};
static constexpr internal::Species_impl Monferno{EnumType::Monferno};
static constexpr internal::Species_impl Infernape{EnumType::Infernape};
static constexpr internal::Species_impl Piplup{EnumType::Piplup};
static constexpr internal::Species_impl Prinplup{EnumType::Prinplup};
static constexpr internal::Species_impl Empoleon{EnumType::Empoleon};
static constexpr internal::Species_impl Starly{EnumType::Starly};
static constexpr internal::Species_impl Staravia{EnumType::Staravia};
static constexpr internal::Species_impl Staraptor{EnumType::Staraptor};
static constexpr internal::Species_impl Bidoof{EnumType::Bidoof};
static constexpr internal::Species_impl Bibarel{EnumType::Bibarel};
static constexpr internal::Species_impl Kricketot{EnumType::Kricketot};
static constexpr internal::Species_impl Kricketune{EnumType::Kricketune};
static constexpr internal::Species_impl Shinx{EnumType::Shinx};
static constexpr internal::Species_impl Luxio{EnumType::Luxio};
static constexpr internal::Species_impl Luxray{EnumType::Luxray};
static constexpr internal::Species_impl Budew{EnumType::Budew};
static constexpr internal::Species_impl Roserade{EnumType::Roserade};
static constexpr internal::Species_impl Cranidos{EnumType::Cranidos};
static constexpr internal::Species_impl Rampardos{EnumType::Rampardos};
static constexpr internal::Species_impl Shieldon{EnumType::Shieldon};
static constexpr internal::Species_impl Bastiodon{EnumType::Bastiodon};
static constexpr internal::Species_impl Burmy{EnumType::Burmy};
static constexpr internal::Species_impl Wormadam{EnumType::Wormadam};
static constexpr internal::Species_impl Mothim{EnumType::Mothim};
static constexpr internal::Species_impl Combee{EnumType::Combee};
static constexpr internal::Species_impl Vespiquen{EnumType::Vespiquen};
static constexpr internal::Species_impl Pachirisu{EnumType::Pachirisu};
static constexpr internal::Species_impl Buizel{EnumType::Buizel};
static constexpr internal::Species_impl Floatzel{EnumType::Floatzel};
static constexpr internal::Species_impl Cherubi{EnumType::Cherubi};
static constexpr internal::Species_impl Cherrim{EnumType::Cherrim};
static constexpr internal::Species_impl Shellos{EnumType::Shellos};
static constexpr internal::Species_impl Gastrodon{EnumType::Gastrodon};
static constexpr internal::Species_impl Ambipom{EnumType::Ambipom};
static constexpr internal::Species_impl Drifloon{EnumType::Drifloon};
static constexpr internal::Species_impl Drifblim{EnumType::Drifblim};
static constexpr internal::Species_impl Buneary{EnumType::Buneary};
static constexpr internal::Species_impl Lopunny{EnumType::Lopunny};
static constexpr internal::Species_impl Mismagius{EnumType::Mismagius};
static constexpr internal::Species_impl Honchkrow{EnumType::Honchkrow};
static constexpr internal::Species_impl Glameow{EnumType::Glameow};
static constexpr internal::Species_impl Purugly{EnumType::Purugly};
static constexpr internal::Species_impl Chingling{EnumType::Chingling};
static constexpr internal::Species_impl Stunky{EnumType::Stunky};
static constexpr internal::Species_impl Skuntank{EnumType::Skuntank};
static constexpr internal::Species_impl Bronzor{EnumType::Bronzor};
static constexpr internal::Species_impl Bronzong{EnumType::Bronzong};
static constexpr internal::Species_impl Bonsly{EnumType::Bonsly};
static constexpr internal::Species_impl MimeJr{EnumType::MimeJr};
static constexpr internal::Species_impl Happiny{EnumType::Happiny};
static constexpr internal::Species_impl Chatot{EnumType::Chatot};
static constexpr internal::Species_impl Spiritomb{EnumType::Spiritomb};
static constexpr internal::Species_impl Gible{EnumType::Gible};
static constexpr internal::Species_impl Gabite{EnumType::Gabite};
static constexpr internal::Species_impl Garchomp{EnumType::Garchomp};
static constexpr internal::Species_impl Munchlax{EnumType::Munchlax};
static constexpr internal::Species_impl Riolu{EnumType::Riolu};
static constexpr internal::Species_impl Lucario{EnumType::Lucario};
static constexpr internal::Species_impl Hippopotas{EnumType::Hippopotas};
static constexpr internal::Species_impl Hippowdon{EnumType::Hippowdon};
static constexpr internal::Species_impl Skorupi{EnumType::Skorupi};
static constexpr internal::Species_impl Drapion{EnumType::Drapion};
static constexpr internal::Species_impl Croagunk{EnumType::Croagunk};
static constexpr internal::Species_impl Toxicroak{EnumType::Toxicroak};
static constexpr internal::Species_impl Carnivine{EnumType::Carnivine};
static constexpr internal::Species_impl Finneon{EnumType::Finneon};
static constexpr internal::Species_impl Lumineon{EnumType::Lumineon};
static constexpr internal::Species_impl Mantyke{EnumType::Mantyke};
static constexpr internal::Species_impl Snover{EnumType::Snover};
static constexpr internal::Species_impl Abomasnow{EnumType::Abomasnow};
static constexpr internal::Species_impl Weavile{EnumType::Weavile};
static constexpr internal::Species_impl Magnezone{EnumType::Magnezone};
static constexpr internal::Species_impl Lickilicky{EnumType::Lickilicky};
static constexpr internal::Species_impl Rhyperior{EnumType::Rhyperior};
static constexpr internal::Species_impl Tangrowth{EnumType::Tangrowth};
static constexpr internal::Species_impl Electivire{EnumType::Electivire};
static constexpr internal::Species_impl Magmortar{EnumType::Magmortar};
static constexpr internal::Species_impl Togekiss{EnumType::Togekiss};
static constexpr internal::Species_impl Yanmega{EnumType::Yanmega};
static constexpr internal::Species_impl Leafeon{EnumType::Leafeon};
static constexpr internal::Species_impl Glaceon{EnumType::Glaceon};
static constexpr internal::Species_impl Gliscor{EnumType::Gliscor};
static constexpr internal::Species_impl Mamoswine{EnumType::Mamoswine};
static constexpr internal::Species_impl PorygonZ{EnumType::PorygonZ};
static constexpr internal::Species_impl Gallade{EnumType::Gallade};
static constexpr internal::Species_impl Probopass{EnumType::Probopass};
static constexpr internal::Species_impl Dusknoir{EnumType::Dusknoir};
static constexpr internal::Species_impl Froslass{EnumType::Froslass};
static constexpr internal::Species_impl Rotom{EnumType::Rotom};
static constexpr internal::Species_impl Uxie{EnumType::Uxie};
static constexpr internal::Species_impl Mesprit{EnumType::Mesprit};
static constexpr internal::Species_impl Azelf{EnumType::Azelf};
static constexpr internal::Species_impl Dialga{EnumType::Dialga};
static constexpr internal::Species_impl Palkia{EnumType::Palkia};
static constexpr internal::Species_impl Heatran{EnumType::Heatran};
static constexpr internal::Species_impl Regigigas{EnumType::Regigigas};
static constexpr internal::Species_impl Giratina{EnumType::Giratina};
static constexpr internal::Species_impl Cresselia{EnumType::Cresselia};
static constexpr internal::Species_impl Phione{EnumType::Phione};
static constexpr internal::Species_impl Manaphy{EnumType::Manaphy};
static constexpr internal::Species_impl Darkrai{EnumType::Darkrai};
static constexpr internal::Species_impl Shaymin{EnumType::Shaymin};
static constexpr internal::Species_impl Arceus{EnumType::Arceus};
static constexpr internal::Species_impl Victini{EnumType::Victini};
static constexpr internal::Species_impl Snivy{EnumType::Snivy};
static constexpr internal::Species_impl Servine{EnumType::Servine};
static constexpr internal::Species_impl Serperior{EnumType::Serperior};
static constexpr internal::Species_impl Tepig{EnumType::Tepig};
static constexpr internal::Species_impl Pignite{EnumType::Pignite};
static constexpr internal::Species_impl Emboar{EnumType::Emboar};
static constexpr internal::Species_impl Oshawott{EnumType::Oshawott};
static constexpr internal::Species_impl Dewott{EnumType::Dewott};
static constexpr internal::Species_impl Samurott{EnumType::Samurott};
static constexpr internal::Species_impl Patrat{EnumType::Patrat};
static constexpr internal::Species_impl Watchog{EnumType::Watchog};
static constexpr internal::Species_impl Lillipup{EnumType::Lillipup};
static constexpr internal::Species_impl Herdier{EnumType::Herdier};
static constexpr internal::Species_impl Stoutland{EnumType::Stoutland};
static constexpr internal::Species_impl Purrloin{EnumType::Purrloin};
static constexpr internal::Species_impl Liepard{EnumType::Liepard};
static constexpr internal::Species_impl Pansage{EnumType::Pansage};
static constexpr internal::Species_impl Simisage{EnumType::Simisage};
static constexpr internal::Species_impl Pansear{EnumType::Pansear};
static constexpr internal::Species_impl Simisear{EnumType::Simisear};
static constexpr internal::Species_impl Panpour{EnumType::Panpour};
static constexpr internal::Species_impl Simipour{EnumType::Simipour};
static constexpr internal::Species_impl Munna{EnumType::Munna};
static constexpr internal::Species_impl Musharna{EnumType::Musharna};
static constexpr internal::Species_impl Pidove{EnumType::Pidove};
static constexpr internal::Species_impl Tranquill{EnumType::Tranquill};
static constexpr internal::Species_impl Unfezant{EnumType::Unfezant};
static constexpr internal::Species_impl Blitzle{EnumType::Blitzle};
static constexpr internal::Species_impl Zebstrika{EnumType::Zebstrika};
static constexpr internal::Species_impl Roggenrola{EnumType::Roggenrola};
static constexpr internal::Species_impl Boldore{EnumType::Boldore};
static constexpr internal::Species_impl Gigalith{EnumType::Gigalith};
static constexpr internal::Species_impl Woobat{EnumType::Woobat};
static constexpr internal::Species_impl Swoobat{EnumType::Swoobat};
static constexpr internal::Species_impl Drilbur{EnumType::Drilbur};
static constexpr internal::Species_impl Excadrill{EnumType::Excadrill};
static constexpr internal::Species_impl Audino{EnumType::Audino};
static constexpr internal::Species_impl Timburr{EnumType::Timburr};
static constexpr internal::Species_impl Gurdurr{EnumType::Gurdurr};
static constexpr internal::Species_impl Conkeldurr{EnumType::Conkeldurr};
static constexpr internal::Species_impl Tympole{EnumType::Tympole};
static constexpr internal::Species_impl Palpitoad{EnumType::Palpitoad};
static constexpr internal::Species_impl Seismitoad{EnumType::Seismitoad};
static constexpr internal::Species_impl Throh{EnumType::Throh};
static constexpr internal::Species_impl Sawk{EnumType::Sawk};
static constexpr internal::Species_impl Sewaddle{EnumType::Sewaddle};
static constexpr internal::Species_impl Swadloon{EnumType::Swadloon};
static constexpr internal::Species_impl Leavanny{EnumType::Leavanny};
static constexpr internal::Species_impl Venipede{EnumType::Venipede};
static constexpr internal::Species_impl Whirlipede{EnumType::Whirlipede};
static constexpr internal::Species_impl Scolipede{EnumType::Scolipede};
static constexpr internal::Species_impl Cottonee{EnumType::Cottonee};
static constexpr internal::Species_impl Whimsicott{EnumType::Whimsicott};
static constexpr internal::Species_impl Petilil{EnumType::Petilil};
static constexpr internal::Species_impl Lilligant{EnumType::Lilligant};
static constexpr internal::Species_impl Basculin{EnumType::Basculin};
static constexpr internal::Species_impl Sandile{EnumType::Sandile};
static constexpr internal::Species_impl Krokorok{EnumType::Krokorok};
static constexpr internal::Species_impl Krookodile{EnumType::Krookodile};
static constexpr internal::Species_impl Darumaka{EnumType::Darumaka};
static constexpr internal::Species_impl Darmanitan{EnumType::Darmanitan};
static constexpr internal::Species_impl Maractus{EnumType::Maractus};
static constexpr internal::Species_impl Dwebble{EnumType::Dwebble};
static constexpr internal::Species_impl Crustle{EnumType::Crustle};
static constexpr internal::Species_impl Scraggy{EnumType::Scraggy};
static constexpr internal::Species_impl Scrafty{EnumType::Scrafty};
static constexpr internal::Species_impl Sigilyph{EnumType::Sigilyph};
static constexpr internal::Species_impl Yamask{EnumType::Yamask};
static constexpr internal::Species_impl Cofagrigus{EnumType::Cofagrigus};
static constexpr internal::Species_impl Tirtouga{EnumType::Tirtouga};
static constexpr internal::Species_impl Carracosta{EnumType::Carracosta};
static constexpr internal::Species_impl Archen{EnumType::Archen};
static constexpr internal::Species_impl Archeops{EnumType::Archeops};
static constexpr internal::Species_impl Trubbish{EnumType::Trubbish};
static constexpr internal::Species_impl Garbodor{EnumType::Garbodor};
static constexpr internal::Species_impl Zorua{EnumType::Zorua};
static constexpr internal::Species_impl Zoroark{EnumType::Zoroark};
static constexpr internal::Species_impl Minccino{EnumType::Minccino};
static constexpr internal::Species_impl Cinccino{EnumType::Cinccino};
static constexpr internal::Species_impl Gothita{EnumType::Gothita};
static constexpr internal::Species_impl Gothorita{EnumType::Gothorita};
static constexpr internal::Species_impl Gothitelle{EnumType::Gothitelle};
static constexpr internal::Species_impl Solosis{EnumType::Solosis};
static constexpr internal::Species_impl Duosion{EnumType::Duosion};
static constexpr internal::Species_impl Reuniclus{EnumType::Reuniclus};
static constexpr internal::Species_impl Ducklett{EnumType::Ducklett};
static constexpr internal::Species_impl Swanna{EnumType::Swanna};
static constexpr internal::Species_impl Vanillite{EnumType::Vanillite};
static constexpr internal::Species_impl Vanillish{EnumType::Vanillish};
static constexpr internal::Species_impl Vanilluxe{EnumType::Vanilluxe};
static constexpr internal::Species_impl Deerling{EnumType::Deerling};
static constexpr internal::Species_impl Sawsbuck{EnumType::Sawsbuck};
static constexpr internal::Species_impl Emolga{EnumType::Emolga};
static constexpr internal::Species_impl Karrablast{EnumType::Karrablast};
static constexpr internal::Species_impl Escavalier{EnumType::Escavalier};
static constexpr internal::Species_impl Foongus{EnumType::Foongus};
static constexpr internal::Species_impl Amoonguss{EnumType::Amoonguss};
static constexpr internal::Species_impl Frillish{EnumType::Frillish};
static constexpr internal::Species_impl Jellicent{EnumType::Jellicent};
static constexpr internal::Species_impl Alomomola{EnumType::Alomomola};
static constexpr internal::Species_impl Joltik{EnumType::Joltik};
static constexpr internal::Species_impl Galvantula{EnumType::Galvantula};
static constexpr internal::Species_impl Ferroseed{EnumType::Ferroseed};
static constexpr internal::Species_impl Ferrothorn{EnumType::Ferrothorn};
static constexpr internal::Species_impl Klink{EnumType::Klink};
static constexpr internal::Species_impl Klang{EnumType::Klang};
static constexpr internal::Species_impl Klinklang{EnumType::Klinklang};
static constexpr internal::Species_impl Tynamo{EnumType::Tynamo};
static constexpr internal::Species_impl Eelektrik{EnumType::Eelektrik};
static constexpr internal::Species_impl Eelektross{EnumType::Eelektross};
static constexpr internal::Species_impl Elgyem{EnumType::Elgyem};
static constexpr internal::Species_impl Beheeyem{EnumType::Beheeyem};
static constexpr internal::Species_impl Litwick{EnumType::Litwick};
static constexpr internal::Species_impl Lampent{EnumType::Lampent};
static constexpr internal::Species_impl Chandelure{EnumType::Chandelure};
static constexpr internal::Species_impl Axew{EnumType::Axew};
static constexpr internal::Species_impl Fraxure{EnumType::Fraxure};
static constexpr internal::Species_impl Haxorus{EnumType::Haxorus};
static constexpr internal::Species_impl Cubchoo{EnumType::Cubchoo};
static constexpr internal::Species_impl Beartic{EnumType::Beartic};
static constexpr internal::Species_impl Cryogonal{EnumType::Cryogonal};
static constexpr internal::Species_impl Shelmet{EnumType::Shelmet};
static constexpr internal::Species_impl Accelgor{EnumType::Accelgor};
static constexpr internal::Species_impl Stunfisk{EnumType::Stunfisk};
static constexpr internal::Species_impl Mienfoo{EnumType::Mienfoo};
static constexpr internal::Species_impl Mienshao{EnumType::Mienshao};
static constexpr internal::Species_impl Druddigon{EnumType::Druddigon};
static constexpr internal::Species_impl Golett{EnumType::Golett};
static constexpr internal::Species_impl Golurk{EnumType::Golurk};
static constexpr internal::Species_impl Pawniard{EnumType::Pawniard};
static constexpr internal::Species_impl Bisharp{EnumType::Bisharp};
static constexpr internal::Species_impl Bouffalant{EnumType::Bouffalant};
static constexpr internal::Species_impl Rufflet{EnumType::Rufflet};
static constexpr internal::Species_impl Braviary{EnumType::Braviary};
static constexpr internal::Species_impl Vullaby{EnumType::Vullaby};
static constexpr internal::Species_impl Mandibuzz{EnumType::Mandibuzz};
static constexpr internal::Species_impl Heatmor{EnumType::Heatmor};
static constexpr internal::Species_impl Durant{EnumType::Durant};
static constexpr internal::Species_impl Deino{EnumType::Deino};
static constexpr internal::Species_impl Zweilous{EnumType::Zweilous};
static constexpr internal::Species_impl Hydreigon{EnumType::Hydreigon};
static constexpr internal::Species_impl Larvesta{EnumType::Larvesta};
static constexpr internal::Species_impl Volcarona{EnumType::Volcarona};
static constexpr internal::Species_impl Cobalion{EnumType::Cobalion};
static constexpr internal::Species_impl Terrakion{EnumType::Terrakion};
static constexpr internal::Species_impl Virizion{EnumType::Virizion};
static constexpr internal::Species_impl Tornadus{EnumType::Tornadus};
static constexpr internal::Species_impl Thundurus{EnumType::Thundurus};
static constexpr internal::Species_impl Reshiram{EnumType::Reshiram};
static constexpr internal::Species_impl Zekrom{EnumType::Zekrom};
static constexpr internal::Species_impl Landorus{EnumType::Landorus};
static constexpr internal::Species_impl Kyurem{EnumType::Kyurem};
static constexpr internal::Species_impl Keldeo{EnumType::Keldeo};
static constexpr internal::Species_impl Meloetta{EnumType::Meloetta};
static constexpr internal::Species_impl Genesect{EnumType::Genesect};
static constexpr internal::Species_impl Chespin{EnumType::Chespin};
static constexpr internal::Species_impl Quilladin{EnumType::Quilladin};
static constexpr internal::Species_impl Chesnaught{EnumType::Chesnaught};
static constexpr internal::Species_impl Fennekin{EnumType::Fennekin};
static constexpr internal::Species_impl Braixen{EnumType::Braixen};
static constexpr internal::Species_impl Delphox{EnumType::Delphox};
static constexpr internal::Species_impl Froakie{EnumType::Froakie};
static constexpr internal::Species_impl Frogadier{EnumType::Frogadier};
static constexpr internal::Species_impl Greninja{EnumType::Greninja};
static constexpr internal::Species_impl Bunnelby{EnumType::Bunnelby};
static constexpr internal::Species_impl Diggersby{EnumType::Diggersby};
static constexpr internal::Species_impl Fletchling{EnumType::Fletchling};
static constexpr internal::Species_impl Fletchinder{EnumType::Fletchinder};
static constexpr internal::Species_impl Talonflame{EnumType::Talonflame};
static constexpr internal::Species_impl Scatterbug{EnumType::Scatterbug};
static constexpr internal::Species_impl Spewpa{EnumType::Spewpa};
static constexpr internal::Species_impl Vivillon{EnumType::Vivillon};
static constexpr internal::Species_impl Litleo{EnumType::Litleo};
static constexpr internal::Species_impl Pyroar{EnumType::Pyroar};
static constexpr internal::Species_impl Flabebe{EnumType::Flabebe};
static constexpr internal::Species_impl Floette{EnumType::Floette};
static constexpr internal::Species_impl Florges{EnumType::Florges};
static constexpr internal::Species_impl Skiddo{EnumType::Skiddo};
static constexpr internal::Species_impl Gogoat{EnumType::Gogoat};
static constexpr internal::Species_impl Pancham{EnumType::Pancham};
static constexpr internal::Species_impl Pangoro{EnumType::Pangoro};
static constexpr internal::Species_impl Furfrou{EnumType::Furfrou};
static constexpr internal::Species_impl Espurr{EnumType::Espurr};
static constexpr internal::Species_impl Meowstic{EnumType::Meowstic};
static constexpr internal::Species_impl Honedge{EnumType::Honedge};
static constexpr internal::Species_impl Doublade{EnumType::Doublade};
static constexpr internal::Species_impl Aegislash{EnumType::Aegislash};
static constexpr internal::Species_impl Spritzee{EnumType::Spritzee};
static constexpr internal::Species_impl Aromatisse{EnumType::Aromatisse};
static constexpr internal::Species_impl Swirlix{EnumType::Swirlix};
static constexpr internal::Species_impl Slurpuff{EnumType::Slurpuff};
static constexpr internal::Species_impl Inkay{EnumType::Inkay};
static constexpr internal::Species_impl Malamar{EnumType::Malamar};
static constexpr internal::Species_impl Binacle{EnumType::Binacle};
static constexpr internal::Species_impl Barbaracle{EnumType::Barbaracle};
static constexpr internal::Species_impl Skrelp{EnumType::Skrelp};
static constexpr internal::Species_impl Dragalge{EnumType::Dragalge};
static constexpr internal::Species_impl Clauncher{EnumType::Clauncher};
static constexpr internal::Species_impl Clawitzer{EnumType::Clawitzer};
static constexpr internal::Species_impl Helioptile{EnumType::Helioptile};
static constexpr internal::Species_impl Heliolisk{EnumType::Heliolisk};
static constexpr internal::Species_impl Tyrunt{EnumType::Tyrunt};
static constexpr internal::Species_impl Tyrantrum{EnumType::Tyrantrum};
static constexpr internal::Species_impl Amaura{EnumType::Amaura};
static constexpr internal::Species_impl Aurorus{EnumType::Aurorus};
static constexpr internal::Species_impl Sylveon{EnumType::Sylveon};
static constexpr internal::Species_impl Hawlucha{EnumType::Hawlucha};
static constexpr internal::Species_impl Dedenne{EnumType::Dedenne};
static constexpr internal::Species_impl Carbink{EnumType::Carbink};
static constexpr internal::Species_impl Goomy{EnumType::Goomy};
static constexpr internal::Species_impl Sliggoo{EnumType::Sliggoo};
static constexpr internal::Species_impl Goodra{EnumType::Goodra};
static constexpr internal::Species_impl Klefki{EnumType::Klefki};
static constexpr internal::Species_impl Phantump{EnumType::Phantump};
static constexpr internal::Species_impl Trevenant{EnumType::Trevenant};
static constexpr internal::Species_impl Pumpkaboo{EnumType::Pumpkaboo};
static constexpr internal::Species_impl Gourgeist{EnumType::Gourgeist};
static constexpr internal::Species_impl Bergmite{EnumType::Bergmite};
static constexpr internal::Species_impl Avalugg{EnumType::Avalugg};
static constexpr internal::Species_impl Noibat{EnumType::Noibat};
static constexpr internal::Species_impl Noivern{EnumType::Noivern};
static constexpr internal::Species_impl Xerneas{EnumType::Xerneas};
static constexpr internal::Species_impl Yveltal{EnumType::Yveltal};
static constexpr internal::Species_impl Zygarde{EnumType::Zygarde};
static constexpr internal::Species_impl Diancie{EnumType::Diancie};
static constexpr internal::Species_impl Hoopa{EnumType::Hoopa};
static constexpr internal::Species_impl Volcanion{EnumType::Volcanion};
static constexpr internal::Species_impl Rowlet{EnumType::Rowlet};
static constexpr internal::Species_impl Dartrix{EnumType::Dartrix};
static constexpr internal::Species_impl Decidueye{EnumType::Decidueye};
static constexpr internal::Species_impl Litten{EnumType::Litten};
static constexpr internal::Species_impl Torracat{EnumType::Torracat};
static constexpr internal::Species_impl Incineroar{EnumType::Incineroar};
static constexpr internal::Species_impl Popplio{EnumType::Popplio};
static constexpr internal::Species_impl Brionne{EnumType::Brionne};
static constexpr internal::Species_impl Primarina{EnumType::Primarina};
static constexpr internal::Species_impl Pikipek{EnumType::Pikipek};
static constexpr internal::Species_impl Trumbeak{EnumType::Trumbeak};
static constexpr internal::Species_impl Toucannon{EnumType::Toucannon};
static constexpr internal::Species_impl Yungoos{EnumType::Yungoos};
static constexpr internal::Species_impl Gumshoos{EnumType::Gumshoos};
static constexpr internal::Species_impl Grubbin{EnumType::Grubbin};
static constexpr internal::Species_impl Charjabug{EnumType::Charjabug};
static constexpr internal::Species_impl Vikavolt{EnumType::Vikavolt};
static constexpr internal::Species_impl Crabrawler{EnumType::Crabrawler};
static constexpr internal::Species_impl Crabominable{EnumType::Crabominable};
static constexpr internal::Species_impl Oricorio{EnumType::Oricorio};
static constexpr internal::Species_impl Cutiefly{EnumType::Cutiefly};
static constexpr internal::Species_impl Ribombee{EnumType::Ribombee};
static constexpr internal::Species_impl Rockruff{EnumType::Rockruff};
static constexpr internal::Species_impl Lycanroc{EnumType::Lycanroc};
static constexpr internal::Species_impl Wishiwashi{EnumType::Wishiwashi};
static constexpr internal::Species_impl Mareanie{EnumType::Mareanie};
static constexpr internal::Species_impl Toxapex{EnumType::Toxapex};
static constexpr internal::Species_impl Mudbray{EnumType::Mudbray};
static constexpr internal::Species_impl Mudsdale{EnumType::Mudsdale};
static constexpr internal::Species_impl Dewpider{EnumType::Dewpider};
static constexpr internal::Species_impl Araquanid{EnumType::Araquanid};
static constexpr internal::Species_impl Fomantis{EnumType::Fomantis};
static constexpr internal::Species_impl Lurantis{EnumType::Lurantis};
static constexpr internal::Species_impl Morelull{EnumType::Morelull};
static constexpr internal::Species_impl Shiinotic{EnumType::Shiinotic};
static constexpr internal::Species_impl Salandit{EnumType::Salandit};
static constexpr internal::Species_impl Salazzle{EnumType::Salazzle};
static constexpr internal::Species_impl Stufful{EnumType::Stufful};
static constexpr internal::Species_impl Bewear{EnumType::Bewear};
static constexpr internal::Species_impl Bounsweet{EnumType::Bounsweet};
static constexpr internal::Species_impl Steenee{EnumType::Steenee};
static constexpr internal::Species_impl Tsareena{EnumType::Tsareena};
static constexpr internal::Species_impl Comfey{EnumType::Comfey};
static constexpr internal::Species_impl Oranguru{EnumType::Oranguru};
static constexpr internal::Species_impl Passimian{EnumType::Passimian};
static constexpr internal::Species_impl Wimpod{EnumType::Wimpod};
static constexpr internal::Species_impl Golisopod{EnumType::Golisopod};
static constexpr internal::Species_impl Sandygast{EnumType::Sandygast};
static constexpr internal::Species_impl Palossand{EnumType::Palossand};
static constexpr internal::Species_impl Pyukumuku{EnumType::Pyukumuku};
static constexpr internal::Species_impl TypeNull{EnumType::TypeNull};
static constexpr internal::Species_impl Silvally{EnumType::Silvally};
static constexpr internal::Species_impl Minior{EnumType::Minior};
static constexpr internal::Species_impl Komala{EnumType::Komala};
static constexpr internal::Species_impl Turtonator{EnumType::Turtonator};
static constexpr internal::Species_impl Togedemaru{EnumType::Togedemaru};
static constexpr internal::Species_impl Mimikyu{EnumType::Mimikyu};
static constexpr internal::Species_impl Bruxish{EnumType::Bruxish};
static constexpr internal::Species_impl Drampa{EnumType::Drampa};
static constexpr internal::Species_impl Dhelmise{EnumType::Dhelmise};
static constexpr internal::Species_impl Jangmoo{EnumType::Jangmoo};
static constexpr internal::Species_impl Hakamoo{EnumType::Hakamoo};
static constexpr internal::Species_impl Kommoo{EnumType::Kommoo};
static constexpr internal::Species_impl TapuKoko{EnumType::TapuKoko};
static constexpr internal::Species_impl TapuLele{EnumType::TapuLele};
static constexpr internal::Species_impl TapuBulu{EnumType::TapuBulu};
static constexpr internal::Species_impl TapuFini{EnumType::TapuFini};
static constexpr internal::Species_impl Cosmog{EnumType::Cosmog};
static constexpr internal::Species_impl Cosmoem{EnumType::Cosmoem};
static constexpr internal::Species_impl Solgaleo{EnumType::Solgaleo};
static constexpr internal::Species_impl Lunala{EnumType::Lunala};
static constexpr internal::Species_impl Nihilego{EnumType::Nihilego};
static constexpr internal::Species_impl Buzzwole{EnumType::Buzzwole};
static constexpr internal::Species_impl Pheromosa{EnumType::Pheromosa};
static constexpr internal::Species_impl Xurkitree{EnumType::Xurkitree};
static constexpr internal::Species_impl Celesteela{EnumType::Celesteela};
static constexpr internal::Species_impl Kartana{EnumType::Kartana};
static constexpr internal::Species_impl Guzzlord{EnumType::Guzzlord};
static constexpr internal::Species_impl Necrozma{EnumType::Necrozma};
static constexpr internal::Species_impl Magearna{EnumType::Magearna};
static constexpr internal::Species_impl Marshadow{EnumType::Marshadow};
static constexpr internal::Species_impl Poipole{EnumType::Poipole};
static constexpr internal::Species_impl Naganadel{EnumType::Naganadel};
static constexpr internal::Species_impl Stakataka{EnumType::Stakataka};
static constexpr internal::Species_impl Blacephalon{EnumType::Blacephalon};
static constexpr internal::Species_impl Zeraora{EnumType::Zeraora};
static constexpr internal::Species_impl Meltan{EnumType::Meltan};
static constexpr internal::Species_impl Melmetal{EnumType::Melmetal};
static constexpr internal::Species_impl Grookey{EnumType::Grookey};
static constexpr internal::Species_impl Thwackey{EnumType::Thwackey};
static constexpr internal::Species_impl Rillaboom{EnumType::Rillaboom};
static constexpr internal::Species_impl Scorbunny{EnumType::Scorbunny};
static constexpr internal::Species_impl Raboot{EnumType::Raboot};
static constexpr internal::Species_impl Cinderace{EnumType::Cinderace};
static constexpr internal::Species_impl Sobble{EnumType::Sobble};
static constexpr internal::Species_impl Drizzile{EnumType::Drizzile};
static constexpr internal::Species_impl Inteleon{EnumType::Inteleon};
static constexpr internal::Species_impl Skwovet{EnumType::Skwovet};
static constexpr internal::Species_impl Greedent{EnumType::Greedent};
static constexpr internal::Species_impl Rookidee{EnumType::Rookidee};
static constexpr internal::Species_impl Corvisquire{EnumType::Corvisquire};
static constexpr internal::Species_impl Corviknight{EnumType::Corviknight};
static constexpr internal::Species_impl Blipbug{EnumType::Blipbug};
static constexpr internal::Species_impl Dottler{EnumType::Dottler};
static constexpr internal::Species_impl Orbeetle{EnumType::Orbeetle};
static constexpr internal::Species_impl Nickit{EnumType::Nickit};
static constexpr internal::Species_impl Thievul{EnumType::Thievul};
static constexpr internal::Species_impl Gossifleur{EnumType::Gossifleur};
static constexpr internal::Species_impl Eldegoss{EnumType::Eldegoss};
static constexpr internal::Species_impl Wooloo{EnumType::Wooloo};
static constexpr internal::Species_impl Dubwool{EnumType::Dubwool};
static constexpr internal::Species_impl Chewtle{EnumType::Chewtle};
static constexpr internal::Species_impl Drednaw{EnumType::Drednaw};
static constexpr internal::Species_impl Yamper{EnumType::Yamper};
static constexpr internal::Species_impl Boltund{EnumType::Boltund};
static constexpr internal::Species_impl Rolycoly{EnumType::Rolycoly};
static constexpr internal::Species_impl Carkol{EnumType::Carkol};
static constexpr internal::Species_impl Coalossal{EnumType::Coalossal};
static constexpr internal::Species_impl Applin{EnumType::Applin};
static constexpr internal::Species_impl Flapple{EnumType::Flapple};
static constexpr internal::Species_impl Appletun{EnumType::Appletun};
static constexpr internal::Species_impl Silicobra{EnumType::Silicobra};
static constexpr internal::Species_impl Sandaconda{EnumType::Sandaconda};
static constexpr internal::Species_impl Cramorant{EnumType::Cramorant};
static constexpr internal::Species_impl Arrokuda{EnumType::Arrokuda};
static constexpr internal::Species_impl Barraskewda{EnumType::Barraskewda};
static constexpr internal::Species_impl Toxel{EnumType::Toxel};
static constexpr internal::Species_impl Toxtricity{EnumType::Toxtricity};
static constexpr internal::Species_impl Sizzlipede{EnumType::Sizzlipede};
static constexpr internal::Species_impl Centiskorch{EnumType::Centiskorch};
static constexpr internal::Species_impl Clobbopus{EnumType::Clobbopus};
static constexpr internal::Species_impl Grapploct{EnumType::Grapploct};
static constexpr internal::Species_impl Sinistea{EnumType::Sinistea};
static constexpr internal::Species_impl Polteageist{EnumType::Polteageist};
static constexpr internal::Species_impl Hatenna{EnumType::Hatenna};
static constexpr internal::Species_impl Hattrem{EnumType::Hattrem};
static constexpr internal::Species_impl Hatterene{EnumType::Hatterene};
static constexpr internal::Species_impl Impidimp{EnumType::Impidimp};
static constexpr internal::Species_impl Morgrem{EnumType::Morgrem};
static constexpr internal::Species_impl Grimmsnarl{EnumType::Grimmsnarl};
static constexpr internal::Species_impl Obstagoon{EnumType::Obstagoon};
static constexpr internal::Species_impl Perrserker{EnumType::Perrserker};
static constexpr internal::Species_impl Cursola{EnumType::Cursola};
static constexpr internal::Species_impl Sirfetchd{EnumType::Sirfetchd};
static constexpr internal::Species_impl MrRime{EnumType::MrRime};
static constexpr internal::Species_impl Runerigus{EnumType::Runerigus};
static constexpr internal::Species_impl Milcery{EnumType::Milcery};
static constexpr internal::Species_impl Alcremie{EnumType::Alcremie};
static constexpr internal::Species_impl Falinks{EnumType::Falinks};
static constexpr internal::Species_impl Pincurchin{EnumType::Pincurchin};
static constexpr internal::Species_impl Snom{EnumType::Snom};
static constexpr internal::Species_impl Frosmoth{EnumType::Frosmoth};
static constexpr internal::Species_impl Stonjourner{EnumType::Stonjourner};
static constexpr internal::Species_impl Eiscue{EnumType::Eiscue};
static constexpr internal::Species_impl Indeedee{EnumType::Indeedee};
static constexpr internal::Species_impl Morpeko{EnumType::Morpeko};
static constexpr internal::Species_impl Cufant{EnumType::Cufant};
static constexpr internal::Species_impl Copperajah{EnumType::Copperajah};
static constexpr internal::Species_impl Dracozolt{EnumType::Dracozolt};
static constexpr internal::Species_impl Arctozolt{EnumType::Arctozolt};
static constexpr internal::Species_impl Dracovish{EnumType::Dracovish};
static constexpr internal::Species_impl Arctovish{EnumType::Arctovish};
static constexpr internal::Species_impl Duraludon{EnumType::Duraludon};
static constexpr internal::Species_impl Dreepy{EnumType::Dreepy};
static constexpr internal::Species_impl Drakloak{EnumType::Drakloak};
static constexpr internal::Species_impl Dragapult{EnumType::Dragapult};
static constexpr internal::Species_impl Zacian{EnumType::Zacian};
static constexpr internal::Species_impl Zamazenta{EnumType::Zamazenta};
static constexpr internal::Species_impl Eternatus{EnumType::Eternatus};
static constexpr internal::Species_impl Kubfu{EnumType::Kubfu};
static constexpr internal::Species_impl Urshifu{EnumType::Urshifu};
static constexpr internal::Species_impl Zarude{EnumType::Zarude};
static constexpr internal::Species_impl Regieleki{EnumType::Regieleki};
static constexpr internal::Species_impl Regidrago{EnumType::Regidrago};
static constexpr internal::Species_impl Glastrier{EnumType::Glastrier};
static constexpr internal::Species_impl Spectrier{EnumType::Spectrier};
static constexpr internal::Species_impl Calyrex{EnumType::Calyrex};
static constexpr internal::Species_impl INVALID{EnumType::INVALID};
};
}
#endif
| 95,860
|
C++
|
.h
| 1,889
| 38.030175
| 99
| 0.64199
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,343
|
Gender.hpp
|
FlagBrew_PKSM-Core/include/enums/Gender.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GENDER_HPP
#define GENDER_HPP
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Gender;
namespace internal
{
class Gender_impl
{
friend class pksm::Gender;
private:
enum class GenderEnum : u8
{
Male = 0,
Female = 1,
Genderless = 2,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<GenderEnum>>::max()
} v;
constexpr explicit Gender_impl(GenderEnum v) : v(v) {}
constexpr Gender_impl(const Gender_impl&) = default;
constexpr Gender_impl(Gender_impl&&) = default;
constexpr Gender_impl& operator=(const Gender_impl&) = default;
constexpr Gender_impl& operator=(Gender_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator GenderEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Gender_impl& other) const noexcept = default;
};
}
class Gender
{
private:
internal::Gender_impl impl;
public:
using EnumType = internal::Gender_impl::GenderEnum;
constexpr Gender() noexcept : impl(EnumType::INVALID) {}
constexpr Gender(const internal::Gender_impl& impl) noexcept : impl(impl) {}
constexpr explicit Gender(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Gender& other) const noexcept = default;
static constexpr internal::Gender_impl Male{EnumType::Male};
static constexpr internal::Gender_impl Female{EnumType::Female};
static constexpr internal::Gender_impl Genderless{EnumType::Genderless};
static constexpr internal::Gender_impl INVALID{EnumType::INVALID};
};
}
#endif
| 3,746
|
C++
|
.h
| 91
| 33.813187
| 98
| 0.640242
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,344
|
GameVersion.hpp
|
FlagBrew_PKSM-Core/include/enums/GameVersion.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GAMEVERSION_HPP
#define GAMEVERSION_HPP
#include "enums/Generation.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class GameVersion;
namespace internal
{
class GameVersion_impl
{
friend class pksm::GameVersion;
private:
enum class GameVersionEnum : u8
{
None = 0,
/// Pokémon Sapphire (GBA)
S = 1,
/// Pokémon Ruby (GBA)
R = 2,
/// Pokémon Emerald (GBA)
E = 3,
/// Pokémon FireRed (GBA)
FR = 4,
/// Pokémon LeafGreen (GBA)
LG = 5,
/// Pokémon Colosseum & Pokémon XD (GameCube)
CXD = 15,
/// Pokémon Diamond (NDS)
D = 10,
/// Pokémon Pearl (NDS)
P = 11,
/// Pokémon Platinum (NDS)
Pt = 12,
/// Pokémon Heart Gold (NDS)
HG = 7,
/// Pokémon Soul Silver (NDS)
SS = 8,
/// Pokémon White (NDS)
W = 20,
/// Pokémon Black (NDS)
B = 21,
/// Pokémon White 2 (NDS)
W2 = 22,
/// Pokémon Black 2 (NDS)
B2 = 23,
/// Pokémon X (3DS)
X = 24,
/// Pokémon Y (3DS)
Y = 25,
/// Pokémon Alpha Sapphire (3DS)
AS = 26,
/// Pokémon Omega Ruby (3DS)
OR = 27,
/// Pokémon Sun (3DS)
SN = 30,
/// Pokémon Moon (3DS)
MN = 31,
/// Pokémon Ultra Sun (3DS)
US = 32,
/// Pokémon Ultra Moon (3DS)
UM = 33,
/// Pokémon GO (GO -> Lets Go transfers)
GO = 34,
/// Pokémon Red (3DS Virtual Console)
RD = 35,
/// Pokémon Green[JP]/Blue[INT] (3DS Virtual Console)
GN = 36,
/// Pokémon Blue[JP] (3DS Virtual Console)
BU = 37,
/// Pokémon Yellow [JP] (3DS Virtual Console)
YW = 38,
/// Pokémon Gold (3DS Virtual Console)
GD = 39,
/// Pokémon Silver (3DS Virtual Console)
SV = 40,
/// Pokémon Crystal (3DS Virtual Console)
C = 41,
/// Pokémon Let's Go Pikachu (NX)
GP = 42,
/// Pokémon Let's Go Eevee (NX)
GE = 43,
/// Pokémon Sword (NX)
SW = 44,
/// Pokémon Shield (NX)
SH = 45,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<GameVersionEnum>>::max()
} v;
constexpr explicit GameVersion_impl(GameVersionEnum v) : v(v) {}
constexpr GameVersion_impl(const GameVersion_impl&) = default;
constexpr GameVersion_impl(GameVersion_impl&&) = default;
constexpr GameVersion_impl& operator=(const GameVersion_impl&) = default;
constexpr GameVersion_impl& operator=(GameVersion_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr explicit operator pksm::Generation() const noexcept
{
switch (v)
{
case GameVersionEnum::S: // 1:
case GameVersionEnum::R: // 2:
case GameVersionEnum::E: // 3:
case GameVersionEnum::FR: // 4:
case GameVersionEnum::LG: // 5:
case GameVersionEnum::CXD: // 15:
return Generation::THREE;
case GameVersionEnum::D: // 10:
case GameVersionEnum::P: // 11:
case GameVersionEnum::Pt: // 12:
case GameVersionEnum::HG: // 7:
case GameVersionEnum::SS: // 8:
return Generation::FOUR;
case GameVersionEnum::W: // 20:
case GameVersionEnum::B: // 21:
case GameVersionEnum::W2: // 22:
case GameVersionEnum::B2: // 23:
return Generation::FIVE;
case GameVersionEnum::X: // 24:
case GameVersionEnum::Y: // 25:
case GameVersionEnum::AS: // 26:
case GameVersionEnum::OR: // 27:
return Generation::SIX;
case GameVersionEnum::SN: // 30:
case GameVersionEnum::MN: // 31:
case GameVersionEnum::US: // 32:
case GameVersionEnum::UM: // 33:
return Generation::SEVEN;
case GameVersionEnum::GP: // 42:
case GameVersionEnum::GE: // 43:
return Generation::LGPE;
case GameVersionEnum::SW: // 44:
case GameVersionEnum::SH: // 45:
return Generation::EIGHT;
case GameVersionEnum::RD: // 35:
case GameVersionEnum::GN: // 36:
case GameVersionEnum::BU: // 37:
case GameVersionEnum::YW: // 38:
return Generation::ONE;
case GameVersionEnum::GD: // 39:
case GameVersionEnum::SV: // 40:
case GameVersionEnum::C: // 41:
return Generation::TWO;
case GameVersionEnum::None: // 0:
case GameVersionEnum::GO: // 34:
case GameVersionEnum::INVALID:
return Generation::UNUSED;
}
return Generation::UNUSED;
}
constexpr operator GameVersionEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const GameVersion_impl& other) const noexcept
{
if (static_cast<Generation>(*this) == static_cast<Generation>(other))
{
return v <=> other.v;
}
return static_cast<Generation>(*this) <=> static_cast<Generation>(other);
}
};
}
class GameVersion
{
private:
internal::GameVersion_impl impl;
public:
using EnumType = internal::GameVersion_impl::GameVersionEnum;
constexpr GameVersion() noexcept : impl(EnumType::INVALID) {}
constexpr GameVersion(const internal::GameVersion_impl& impl) noexcept : impl(impl) {}
constexpr explicit GameVersion(std::underlying_type_t<EnumType> v) noexcept
: impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr explicit operator pksm::Generation() const noexcept
{
return static_cast<Generation>(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
static constexpr GameVersion newestVersion(const Generation& gen) noexcept
{
switch (gen)
{
case Generation::ONE:
return GameVersion::YW;
case Generation::TWO:
return GameVersion::C;
case Generation::THREE:
return GameVersion::LG;
case Generation::FOUR:
return GameVersion::HG;
case Generation::FIVE:
return GameVersion::B2;
case Generation::SIX:
return GameVersion::OR;
case Generation::SEVEN:
return GameVersion::UM;
case Generation::EIGHT:
return GameVersion::SH;
case Generation::LGPE:
return GameVersion::GE;
default:
return GameVersion::INVALID;
}
}
static constexpr GameVersion oldestVersion(const Generation& gen) noexcept
{
switch (gen)
{
case Generation::ONE:
return GameVersion::RD;
case Generation::TWO:
return GameVersion::GD;
case Generation::THREE:
return GameVersion::S;
case Generation::FOUR:
return GameVersion::D;
case Generation::FIVE:
return GameVersion::W;
case Generation::SIX:
return GameVersion::X;
case Generation::SEVEN:
return GameVersion::SN;
case Generation::EIGHT:
return GameVersion::SW;
case Generation::LGPE:
return GameVersion::GP;
default:
return GameVersion::INVALID;
}
}
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const GameVersion&) const noexcept = default;
static constexpr internal::GameVersion_impl None{EnumType::None};
/// Pokémon Sapphire (GBA)
static constexpr internal::GameVersion_impl S{EnumType::S};
/// Pokémon Ruby (GBA)
static constexpr internal::GameVersion_impl R{EnumType::R};
/// Pokémon Emerald (GBA)
static constexpr internal::GameVersion_impl E{EnumType::E};
/// Pokémon FireRed (GBA)
static constexpr internal::GameVersion_impl FR{EnumType::FR};
/// Pokémon LeafGreen (GBA)
static constexpr internal::GameVersion_impl LG{EnumType::LG};
/// Pokémon Colosseum & Pokémon XD (GameCube)
static constexpr internal::GameVersion_impl CXD{EnumType::CXD};
/// Pokémon Diamond (NDS)
static constexpr internal::GameVersion_impl D{EnumType::D};
/// Pokémon Pearl (NDS)
static constexpr internal::GameVersion_impl P{EnumType::P};
/// Pokémon Platinum (NDS)
static constexpr internal::GameVersion_impl Pt{EnumType::Pt};
/// Pokémon Heart Gold (NDS)
static constexpr internal::GameVersion_impl HG{EnumType::HG};
/// Pokémon Soul Silver (NDS)
static constexpr internal::GameVersion_impl SS{EnumType::SS};
/// Pokémon White (NDS)
static constexpr internal::GameVersion_impl W{EnumType::W};
/// Pokémon Black (NDS)
static constexpr internal::GameVersion_impl B{EnumType::B};
/// Pokémon White 2 (NDS)
static constexpr internal::GameVersion_impl W2{EnumType::W2};
/// Pokémon Black 2 (NDS)
static constexpr internal::GameVersion_impl B2{EnumType::B2};
/// Pokémon X (3DS)
static constexpr internal::GameVersion_impl X{EnumType::X};
/// Pokémon Y (3DS)
static constexpr internal::GameVersion_impl Y{EnumType::Y};
/// Pokémon Alpha Sapphire (3DS)
static constexpr internal::GameVersion_impl AS{EnumType::AS};
/// Pokémon Omega Ruby (3DS)
static constexpr internal::GameVersion_impl OR{EnumType::OR};
/// Pokémon Sun (3DS)
static constexpr internal::GameVersion_impl SN{EnumType::SN};
/// Pokémon Moon (3DS)
static constexpr internal::GameVersion_impl MN{EnumType::MN};
/// Pokémon Ultra Sun (3DS)
static constexpr internal::GameVersion_impl US{EnumType::US};
/// Pokémon Ultra Moon (3DS)
static constexpr internal::GameVersion_impl UM{EnumType::UM};
/// Pokémon GO (GO -> Lets Go transfers)
static constexpr internal::GameVersion_impl GO{EnumType::GO};
/// Pokémon Red (3DS Virtual Console)
static constexpr internal::GameVersion_impl RD{EnumType::RD};
/// Pokémon Green[JP]/Blue[INT] (3DS Virtual Console)
static constexpr internal::GameVersion_impl GN{EnumType::GN};
/// Pokémon Blue[JP] (3DS Virtual Console)
static constexpr internal::GameVersion_impl BU{EnumType::BU};
/// Pokémon Yellow [JP] (3DS Virtual Console)
static constexpr internal::GameVersion_impl YW{EnumType::YW};
/// Pokémon Gold (3DS Virtual Console)
static constexpr internal::GameVersion_impl GD{EnumType::GD};
/// Pokémon Silver (3DS Virtual Console)
static constexpr internal::GameVersion_impl SV{EnumType::SV};
/// Pokémon Crystal (3DS Virtual Console)
static constexpr internal::GameVersion_impl C{EnumType::C};
/// Pokémon Let's Go Pikachu (NX)
static constexpr internal::GameVersion_impl GP{EnumType::GP};
/// Pokémon Let's Go Eevee (NX)
static constexpr internal::GameVersion_impl GE{EnumType::GE};
/// Pokémon Sword (NX)
static constexpr internal::GameVersion_impl SW{EnumType::SW};
/// Pokémon Shield (NX)
static constexpr internal::GameVersion_impl SH{EnumType::SH};
static constexpr internal::GameVersion_impl INVALID{EnumType::INVALID};
};
}
#endif
| 15,084
|
C++
|
.h
| 346
| 29.988439
| 94
| 0.534631
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,345
|
Stat.hpp
|
FlagBrew_PKSM-Core/include/enums/Stat.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef STAT_HPP
#define STAT_HPP
#include "utils/coretypes.h"
namespace pksm
{
enum class Stat : u8
{
HP,
ATK,
DEF,
SPD,
SPATK,
SPDEF
};
}
#endif
| 1,481
|
C++
|
.h
| 41
| 32.97561
| 76
| 0.703343
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,346
|
Ribbon.hpp
|
FlagBrew_PKSM-Core/include/enums/Ribbon.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef RIBBONS_HPP
#define RIBBONS_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Ribbon;
namespace internal
{
class Ribbon_impl
{
friend class pksm::Ribbon;
private:
enum class RibbonEnum : u32
{
ChampionKalos,
ChampionG3Hoenn,
ChampionSinnoh,
BestFriends,
Training,
BattlerSkillful,
BattlerExpert,
Effort,
Alert,
Shock,
Downcast,
Careless,
Relax,
Snooze,
Smile,
Gorgeous,
Royal,
GorgeousRoyal,
Artist,
Footprint,
Record,
Legend,
Country,
National,
Earth,
World,
Classic,
Premier,
Event,
Birthday,
Special,
Souvenir,
Wishing,
ChampionBattle,
ChampionRegional,
ChampionNational,
ChampionWorld,
MemoryContest,
MemoryBattle,
ChampionG6Hoenn,
ContestStar,
MasterCoolness,
MasterBeauty,
MasterCuteness,
MasterCleverness,
MasterToughness,
G3Cool,
G3CoolSuper,
G3CoolHyper,
G3CoolMaster,
G3Beauty,
G3BeautySuper,
G3BeautyHyper,
G3BeautyMaster,
G3Cute,
G3CuteSuper,
G3CuteHyper,
G3CuteMaster,
G3Smart,
G3SmartSuper,
G3SmartHyper,
G3SmartMaster,
G3Tough,
G3ToughSuper,
G3ToughHyper,
G3ToughMaster,
G4Cool,
G4CoolSuper,
G4CoolHyper,
G4CoolMaster,
G4Beauty,
G4BeautySuper,
G4BeautyHyper,
G4BeautyMaster,
G4Cute,
G4CuteSuper,
G4CuteHyper,
G4CuteMaster,
G4Smart,
G4SmartSuper,
G4SmartHyper,
G4SmartMaster,
G4Tough,
G4ToughSuper,
G4ToughHyper,
G4ToughMaster,
Winning,
Victory,
Ability,
AbilityGreat,
AbilityDouble,
AbilityMulti,
AbilityPair,
AbilityWorld,
ChampionAlola,
BattleRoyale,
BattleTreeGreat,
BattleTreeMaster,
ChampionGalar,
TowerMaster,
MasterRank,
MarkLunchtime,
MarkSleepyTime,
MarkDusk,
MarkDawn,
MarkCloudy,
MarkRainy,
MarkStormy,
MarkSnowy,
MarkBlizzard,
MarkDry,
MarkSandstorm,
MarkMisty,
MarkDestiny,
MarkFishing,
MarkCurry,
MarkUncommon,
MarkRare,
MarkRowdy,
MarkAbsentMinded,
MarkJittery,
MarkExcited,
MarkCharismatic,
MarkCalmness,
MarkIntense,
MarkZonedOut,
MarkJoyful,
MarkAngry,
MarkSmiley,
MarkTeary,
MarkUpbeat,
MarkPeeved,
MarkIntellectual,
MarkFerocious,
MarkCrafty,
MarkScowling,
MarkKindly,
MarkFlustered,
MarkPumpedUp,
MarkZeroEnergy,
MarkPrideful,
MarkUnsure,
MarkHumble,
MarkThorny,
MarkVigor,
MarkSlump,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<RibbonEnum>>::max()
} v;
constexpr explicit Ribbon_impl(RibbonEnum v) : v(v) {}
constexpr Ribbon_impl(const Ribbon_impl&) = default;
constexpr Ribbon_impl(Ribbon_impl&&) = default;
constexpr Ribbon_impl& operator=(const Ribbon_impl&) = default;
constexpr Ribbon_impl& operator=(Ribbon_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator RibbonEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ribbon_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Ribbon
{
private:
internal::Ribbon_impl impl;
public:
using EnumType = internal::Ribbon_impl::RibbonEnum;
constexpr Ribbon() noexcept : impl(EnumType{0}) {}
constexpr Ribbon(const internal::Ribbon_impl& impl) noexcept : impl(impl) {}
constexpr explicit Ribbon(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ribbon& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Ribbon_impl ChampionKalos{EnumType::ChampionKalos};
static constexpr internal::Ribbon_impl ChampionG3Hoenn{EnumType::ChampionG3Hoenn};
static constexpr internal::Ribbon_impl ChampionSinnoh{EnumType::ChampionSinnoh};
static constexpr internal::Ribbon_impl BestFriends{EnumType::BestFriends};
static constexpr internal::Ribbon_impl Training{EnumType::Training};
static constexpr internal::Ribbon_impl BattlerSkillful{EnumType::BattlerSkillful};
static constexpr internal::Ribbon_impl BattlerExpert{EnumType::BattlerExpert};
static constexpr internal::Ribbon_impl Effort{EnumType::Effort};
static constexpr internal::Ribbon_impl Alert{EnumType::Alert};
static constexpr internal::Ribbon_impl Shock{EnumType::Shock};
static constexpr internal::Ribbon_impl Downcast{EnumType::Downcast};
static constexpr internal::Ribbon_impl Careless{EnumType::Careless};
static constexpr internal::Ribbon_impl Relax{EnumType::Relax};
static constexpr internal::Ribbon_impl Snooze{EnumType::Snooze};
static constexpr internal::Ribbon_impl Smile{EnumType::Smile};
static constexpr internal::Ribbon_impl Gorgeous{EnumType::Gorgeous};
static constexpr internal::Ribbon_impl Royal{EnumType::Royal};
static constexpr internal::Ribbon_impl GorgeousRoyal{EnumType::GorgeousRoyal};
static constexpr internal::Ribbon_impl Artist{EnumType::Artist};
static constexpr internal::Ribbon_impl Footprint{EnumType::Footprint};
static constexpr internal::Ribbon_impl Record{EnumType::Record};
static constexpr internal::Ribbon_impl Legend{EnumType::Legend};
static constexpr internal::Ribbon_impl Country{EnumType::Country};
static constexpr internal::Ribbon_impl National{EnumType::National};
static constexpr internal::Ribbon_impl Earth{EnumType::Earth};
static constexpr internal::Ribbon_impl World{EnumType::World};
static constexpr internal::Ribbon_impl Classic{EnumType::Classic};
static constexpr internal::Ribbon_impl Premier{EnumType::Premier};
static constexpr internal::Ribbon_impl Event{EnumType::Event};
static constexpr internal::Ribbon_impl Birthday{EnumType::Birthday};
static constexpr internal::Ribbon_impl Special{EnumType::Special};
static constexpr internal::Ribbon_impl Souvenir{EnumType::Souvenir};
static constexpr internal::Ribbon_impl Wishing{EnumType::Wishing};
static constexpr internal::Ribbon_impl ChampionBattle{EnumType::ChampionBattle};
static constexpr internal::Ribbon_impl ChampionRegional{EnumType::ChampionRegional};
static constexpr internal::Ribbon_impl ChampionNational{EnumType::ChampionNational};
static constexpr internal::Ribbon_impl ChampionWorld{EnumType::ChampionWorld};
static constexpr internal::Ribbon_impl MemoryContest{EnumType::MemoryContest};
static constexpr internal::Ribbon_impl MemoryBattle{EnumType::MemoryBattle};
static constexpr internal::Ribbon_impl ChampionG6Hoenn{EnumType::ChampionG6Hoenn};
static constexpr internal::Ribbon_impl ContestStar{EnumType::ContestStar};
static constexpr internal::Ribbon_impl MasterCoolness{EnumType::MasterCoolness};
static constexpr internal::Ribbon_impl MasterBeauty{EnumType::MasterBeauty};
static constexpr internal::Ribbon_impl MasterCuteness{EnumType::MasterCuteness};
static constexpr internal::Ribbon_impl MasterCleverness{EnumType::MasterCleverness};
static constexpr internal::Ribbon_impl MasterToughness{EnumType::MasterToughness};
static constexpr internal::Ribbon_impl G3Cool{EnumType::G3Cool};
static constexpr internal::Ribbon_impl G3CoolSuper{EnumType::G3CoolSuper};
static constexpr internal::Ribbon_impl G3CoolHyper{EnumType::G3CoolHyper};
static constexpr internal::Ribbon_impl G3CoolMaster{EnumType::G3CoolMaster};
static constexpr internal::Ribbon_impl G3Beauty{EnumType::G3Beauty};
static constexpr internal::Ribbon_impl G3BeautySuper{EnumType::G3BeautySuper};
static constexpr internal::Ribbon_impl G3BeautyHyper{EnumType::G3BeautyHyper};
static constexpr internal::Ribbon_impl G3BeautyMaster{EnumType::G3BeautyMaster};
static constexpr internal::Ribbon_impl G3Cute{EnumType::G3Cute};
static constexpr internal::Ribbon_impl G3CuteSuper{EnumType::G3CuteSuper};
static constexpr internal::Ribbon_impl G3CuteHyper{EnumType::G3CuteHyper};
static constexpr internal::Ribbon_impl G3CuteMaster{EnumType::G3CuteMaster};
static constexpr internal::Ribbon_impl G3Smart{EnumType::G3Smart};
static constexpr internal::Ribbon_impl G3SmartSuper{EnumType::G3SmartSuper};
static constexpr internal::Ribbon_impl G3SmartHyper{EnumType::G3SmartHyper};
static constexpr internal::Ribbon_impl G3SmartMaster{EnumType::G3SmartMaster};
static constexpr internal::Ribbon_impl G3Tough{EnumType::G3Tough};
static constexpr internal::Ribbon_impl G3ToughSuper{EnumType::G3ToughSuper};
static constexpr internal::Ribbon_impl G3ToughHyper{EnumType::G3ToughHyper};
static constexpr internal::Ribbon_impl G3ToughMaster{EnumType::G3ToughMaster};
static constexpr internal::Ribbon_impl G4Cool{EnumType::G4Cool};
static constexpr internal::Ribbon_impl G4CoolSuper{EnumType::G4CoolSuper};
static constexpr internal::Ribbon_impl G4CoolHyper{EnumType::G4CoolHyper};
static constexpr internal::Ribbon_impl G4CoolMaster{EnumType::G4CoolMaster};
static constexpr internal::Ribbon_impl G4Beauty{EnumType::G4Beauty};
static constexpr internal::Ribbon_impl G4BeautySuper{EnumType::G4BeautySuper};
static constexpr internal::Ribbon_impl G4BeautyHyper{EnumType::G4BeautyHyper};
static constexpr internal::Ribbon_impl G4BeautyMaster{EnumType::G4BeautyMaster};
static constexpr internal::Ribbon_impl G4Cute{EnumType::G4Cute};
static constexpr internal::Ribbon_impl G4CuteSuper{EnumType::G4CuteSuper};
static constexpr internal::Ribbon_impl G4CuteHyper{EnumType::G4CuteHyper};
static constexpr internal::Ribbon_impl G4CuteMaster{EnumType::G4CuteMaster};
static constexpr internal::Ribbon_impl G4Smart{EnumType::G4Smart};
static constexpr internal::Ribbon_impl G4SmartSuper{EnumType::G4SmartSuper};
static constexpr internal::Ribbon_impl G4SmartHyper{EnumType::G4SmartHyper};
static constexpr internal::Ribbon_impl G4SmartMaster{EnumType::G4SmartMaster};
static constexpr internal::Ribbon_impl G4Tough{EnumType::G4Tough};
static constexpr internal::Ribbon_impl G4ToughSuper{EnumType::G4ToughSuper};
static constexpr internal::Ribbon_impl G4ToughHyper{EnumType::G4ToughHyper};
static constexpr internal::Ribbon_impl G4ToughMaster{EnumType::G4ToughMaster};
static constexpr internal::Ribbon_impl Winning{EnumType::Winning};
static constexpr internal::Ribbon_impl Victory{EnumType::Victory};
static constexpr internal::Ribbon_impl Ability{EnumType::Ability};
static constexpr internal::Ribbon_impl AbilityGreat{EnumType::AbilityGreat};
static constexpr internal::Ribbon_impl AbilityDouble{EnumType::AbilityDouble};
static constexpr internal::Ribbon_impl AbilityMulti{EnumType::AbilityMulti};
static constexpr internal::Ribbon_impl AbilityPair{EnumType::AbilityPair};
static constexpr internal::Ribbon_impl AbilityWorld{EnumType::AbilityWorld};
static constexpr internal::Ribbon_impl ChampionAlola{EnumType::ChampionAlola};
static constexpr internal::Ribbon_impl BattleRoyale{EnumType::BattleRoyale};
static constexpr internal::Ribbon_impl BattleTreeGreat{EnumType::BattleTreeGreat};
static constexpr internal::Ribbon_impl BattleTreeMaster{EnumType::BattleTreeMaster};
static constexpr internal::Ribbon_impl ChampionGalar{EnumType::ChampionGalar};
static constexpr internal::Ribbon_impl TowerMaster{EnumType::TowerMaster};
static constexpr internal::Ribbon_impl MasterRank{EnumType::MasterRank};
static constexpr internal::Ribbon_impl MarkLunchtime{EnumType::MarkLunchtime};
static constexpr internal::Ribbon_impl MarkSleepyTime{EnumType::MarkSleepyTime};
static constexpr internal::Ribbon_impl MarkDusk{EnumType::MarkDusk};
static constexpr internal::Ribbon_impl MarkDawn{EnumType::MarkDawn};
static constexpr internal::Ribbon_impl MarkCloudy{EnumType::MarkCloudy};
static constexpr internal::Ribbon_impl MarkRainy{EnumType::MarkRainy};
static constexpr internal::Ribbon_impl MarkStormy{EnumType::MarkStormy};
static constexpr internal::Ribbon_impl MarkSnowy{EnumType::MarkSnowy};
static constexpr internal::Ribbon_impl MarkBlizzard{EnumType::MarkBlizzard};
static constexpr internal::Ribbon_impl MarkDry{EnumType::MarkDry};
static constexpr internal::Ribbon_impl MarkSandstorm{EnumType::MarkSandstorm};
static constexpr internal::Ribbon_impl MarkMisty{EnumType::MarkMisty};
static constexpr internal::Ribbon_impl MarkDestiny{EnumType::MarkDestiny};
static constexpr internal::Ribbon_impl MarkFishing{EnumType::MarkFishing};
static constexpr internal::Ribbon_impl MarkCurry{EnumType::MarkCurry};
static constexpr internal::Ribbon_impl MarkUncommon{EnumType::MarkUncommon};
static constexpr internal::Ribbon_impl MarkRare{EnumType::MarkRare};
static constexpr internal::Ribbon_impl MarkRowdy{EnumType::MarkRowdy};
static constexpr internal::Ribbon_impl MarkAbsentMinded{EnumType::MarkAbsentMinded};
static constexpr internal::Ribbon_impl MarkJittery{EnumType::MarkJittery};
static constexpr internal::Ribbon_impl MarkExcited{EnumType::MarkExcited};
static constexpr internal::Ribbon_impl MarkCharismatic{EnumType::MarkCharismatic};
static constexpr internal::Ribbon_impl MarkCalmness{EnumType::MarkCalmness};
static constexpr internal::Ribbon_impl MarkIntense{EnumType::MarkIntense};
static constexpr internal::Ribbon_impl MarkZonedOut{EnumType::MarkZonedOut};
static constexpr internal::Ribbon_impl MarkJoyful{EnumType::MarkJoyful};
static constexpr internal::Ribbon_impl MarkAngry{EnumType::MarkAngry};
static constexpr internal::Ribbon_impl MarkSmiley{EnumType::MarkSmiley};
static constexpr internal::Ribbon_impl MarkTeary{EnumType::MarkTeary};
static constexpr internal::Ribbon_impl MarkUpbeat{EnumType::MarkUpbeat};
static constexpr internal::Ribbon_impl MarkPeeved{EnumType::MarkPeeved};
static constexpr internal::Ribbon_impl MarkIntellectual{EnumType::MarkIntellectual};
static constexpr internal::Ribbon_impl MarkFerocious{EnumType::MarkFerocious};
static constexpr internal::Ribbon_impl MarkCrafty{EnumType::MarkCrafty};
static constexpr internal::Ribbon_impl MarkScowling{EnumType::MarkScowling};
static constexpr internal::Ribbon_impl MarkKindly{EnumType::MarkKindly};
static constexpr internal::Ribbon_impl MarkFlustered{EnumType::MarkFlustered};
static constexpr internal::Ribbon_impl MarkPumpedUp{EnumType::MarkPumpedUp};
static constexpr internal::Ribbon_impl MarkZeroEnergy{EnumType::MarkZeroEnergy};
static constexpr internal::Ribbon_impl MarkPrideful{EnumType::MarkPrideful};
static constexpr internal::Ribbon_impl MarkUnsure{EnumType::MarkUnsure};
static constexpr internal::Ribbon_impl MarkHumble{EnumType::MarkHumble};
static constexpr internal::Ribbon_impl MarkThorny{EnumType::MarkThorny};
static constexpr internal::Ribbon_impl MarkVigor{EnumType::MarkVigor};
static constexpr internal::Ribbon_impl MarkSlump{EnumType::MarkSlump};
// G4 aliases
static constexpr internal::Ribbon_impl G4CoolGreat{EnumType::G4CoolSuper};
static constexpr internal::Ribbon_impl G4CoolUltra{EnumType::G4CoolHyper};
static constexpr internal::Ribbon_impl G4BeautyGreat{EnumType::G4BeautySuper};
static constexpr internal::Ribbon_impl G4BeautyUltra{EnumType::G4BeautyHyper};
static constexpr internal::Ribbon_impl G4CuteGreat{EnumType::G4CuteSuper};
static constexpr internal::Ribbon_impl G4CuteUltra{EnumType::G4CuteHyper};
static constexpr internal::Ribbon_impl G4SmartGreat{EnumType::G4SmartSuper};
static constexpr internal::Ribbon_impl G4SmartUltra{EnumType::G4SmartHyper};
static constexpr internal::Ribbon_impl G4ToughGreat{EnumType::G4ToughSuper};
static constexpr internal::Ribbon_impl G4ToughUltra{EnumType::G4ToughHyper};
static constexpr internal::Ribbon_impl INVALID{EnumType::INVALID};
};
}
#endif
| 20,677
|
C++
|
.h
| 394
| 40.941624
| 98
| 0.667835
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,347
|
Language.hpp
|
FlagBrew_PKSM-Core/include/enums/Language.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef LANGUAGE_HPP
#define LANGUAGE_HPP
#ifndef _PKSMCORE_CONFIGURED
#include "PKSMCORE_CONFIG.h"
#endif
#include "enums/Generation.hpp"
#include "utils/coretypes.h"
#include <limits>
#include <type_traits>
namespace pksm
{
enum class Language : u8
{
None [[maybe_unused]] = 0,
JPN = 1,
ENG,
FRE,
ITA,
GER,
UNUSED [[maybe_unused]],
SPA,
KOR,
CHS,
CHT,
#ifdef _PKSMCORE_EXTRA_LANGUAGES
_PKSMCORE_EXTRA_LANGUAGES,
#endif
INVALID [[maybe_unused]] = std::numeric_limits<std::underlying_type_t<Language>>::max()
};
[[nodiscard]] Language getSafeLanguage(Generation gen, Language originalLang);
}
#endif
| 2,015
|
C++
|
.h
| 57
| 31.701754
| 95
| 0.691953
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,348
|
Ability.hpp
|
FlagBrew_PKSM-Core/include/enums/Ability.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef ABILITY_HPP
#define ABILITY_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Ability;
namespace internal
{
class Ability_impl
{
friend class pksm::Ability;
private:
enum class AbilityEnum : u16
{
None,
Stench,
Drizzle,
SpeedBoost,
BattleArmor,
Sturdy,
Damp,
Limber,
SandVeil,
Static,
VoltAbsorb,
WaterAbsorb,
Oblivious,
CloudNine,
CompoundEyes,
Insomnia,
ColorChange,
Immunity,
FlashFire,
ShieldDust,
OwnTempo,
SuctionCups,
Intimidate,
ShadowTag,
RoughSkin,
WonderGuard,
Levitate,
EffectSpore,
Synchronize,
ClearBody,
NaturalCure,
LightningRod,
SereneGrace,
SwiftSwim,
Chlorophyll,
Illuminate,
Trace,
HugePower,
PoisonPoint,
InnerFocus,
MagmaArmor,
WaterVeil,
MagnetPull,
Soundproof,
RainDish,
SandStream,
Pressure,
ThickFat,
EarlyBird,
FlameBody,
RunAway,
KeenEye,
HyperCutter,
Pickup,
Truant,
Hustle,
CuteCharm,
Plus,
Minus,
Forecast,
StickyHold,
ShedSkin,
Guts,
MarvelScale,
LiquidOoze,
Overgrow,
Blaze,
Torrent,
Swarm,
RockHead,
Drought,
ArenaTrap,
VitalSpirit,
WhiteSmoke,
PurePower,
ShellArmor,
AirLock,
TangledFeet,
MotorDrive,
Rivalry,
Steadfast,
SnowCloak,
Gluttony,
AngerPoint,
Unburden,
Heatproof,
Simple,
DrySkin,
Download,
IronFist,
PoisonHeal,
Adaptability,
SkillLink,
Hydration,
SolarPower,
QuickFeet,
Normalize,
Sniper,
MagicGuard,
NoGuard,
Stall,
Technician,
LeafGuard,
Klutz,
MoldBreaker,
SuperLuck,
Aftermath,
Anticipation,
Forewarn,
Unaware,
TintedLens,
Filter,
SlowStart,
Scrappy,
StormDrain,
IceBody,
SolidRock,
SnowWarning,
HoneyGather,
Frisk,
Reckless,
Multitype,
FlowerGift,
BadDreams,
Pickpocket,
SheerForce,
Contrary,
Unnerve,
Defiant,
Defeatist,
CursedBody,
Healer,
FriendGuard,
WeakArmor,
HeavyMetal,
LightMetal,
Multiscale,
ToxicBoost,
FlareBoost,
Harvest,
Telepathy,
Moody,
Overcoat,
PoisonTouch,
Regenerator,
BigPecks,
SandRush,
WonderSkin,
Analytic,
Illusion,
Imposter,
Infiltrator,
Mummy,
Moxie,
Justified,
Rattled,
MagicBounce,
SapSipper,
Prankster,
SandForce,
IronBarbs,
ZenMode,
VictoryStar,
Turboblaze,
Teravolt,
AromaVeil,
FlowerVeil,
CheekPouch,
Protean,
FurCoat,
Magician,
Bulletproof,
Competitive,
StrongJaw,
Refrigerate,
SweetVeil,
StanceChange,
GaleWings,
MegaLauncher,
GrassPelt,
Symbiosis,
ToughClaws,
Pixilate,
Gooey,
Aerilate,
ParentalBond,
DarkAura,
FairyAura,
AuraBreak,
PrimordialSea,
DesolateLand,
DeltaStream,
Stamina,
WimpOut,
EmergencyExit,
WaterCompaction,
Merciless,
ShieldsDown,
Stakeout,
WaterBubble,
Steelworker,
Berserk,
SlushRush,
LongReach,
LiquidVoice,
Triage,
Galvanize,
SurgeSurfer,
Schooling,
Disguise,
BattleBond,
PowerConstruct,
Corrosion,
Comatose,
QueenlyMajesty,
InnardsOut,
Dancer,
Battery,
Fluffy,
Dazzling,
SoulHeart,
TanglingHair,
Receiver,
PowerofAlchemy,
BeastBoost,
RKSSystem,
ElectricSurge,
PsychicSurge,
MistySurge,
GrassySurge,
FullMetalBody,
ShadowShield,
PrismArmor,
Neuroforce,
IntrepidSword,
DauntlessShield,
Libero,
BallFetch,
CottonDown,
PropellerTail,
MirrorArmor,
GulpMissile,
Stalwart,
SteamEngine,
PunkRock,
SandSpit,
IceScales,
Ripen,
IceFace,
PowerSpot,
Mimicry,
ScreenCleaner,
SteelySpirit,
PerishBody,
WanderingSpirit,
GorillaTactics,
NeutralizingGas,
PastelVeil,
HungerSwitch,
QuickDraw,
UnseenFist,
CuriousMedicine,
Transistor,
DragonsMaw,
ChillingNeigh,
GrimNeigh,
AsOneI,
AsOneG,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<AbilityEnum>>::max()
} v;
constexpr explicit Ability_impl(AbilityEnum v) : v(v) {}
constexpr Ability_impl(const Ability_impl&) = default;
constexpr Ability_impl(Ability_impl&&) = default;
constexpr Ability_impl& operator=(const Ability_impl&) = default;
constexpr Ability_impl& operator=(Ability_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator AbilityEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ability_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Ability
{
private:
internal::Ability_impl impl;
public:
using EnumType = internal::Ability_impl::AbilityEnum;
constexpr Ability() noexcept : impl(EnumType::INVALID) {}
constexpr Ability(const internal::Ability_impl& impl) noexcept : impl(impl) {}
constexpr explicit Ability(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ability& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Ability_impl None{EnumType::None};
static constexpr internal::Ability_impl Stench{EnumType::Stench};
static constexpr internal::Ability_impl Drizzle{EnumType::Drizzle};
static constexpr internal::Ability_impl SpeedBoost{EnumType::SpeedBoost};
static constexpr internal::Ability_impl BattleArmor{EnumType::BattleArmor};
static constexpr internal::Ability_impl Sturdy{EnumType::Sturdy};
static constexpr internal::Ability_impl Damp{EnumType::Damp};
static constexpr internal::Ability_impl Limber{EnumType::Limber};
static constexpr internal::Ability_impl SandVeil{EnumType::SandVeil};
static constexpr internal::Ability_impl Static{EnumType::Static};
static constexpr internal::Ability_impl VoltAbsorb{EnumType::VoltAbsorb};
static constexpr internal::Ability_impl WaterAbsorb{EnumType::WaterAbsorb};
static constexpr internal::Ability_impl Oblivious{EnumType::Oblivious};
static constexpr internal::Ability_impl CloudNine{EnumType::CloudNine};
static constexpr internal::Ability_impl CompoundEyes{EnumType::CompoundEyes};
static constexpr internal::Ability_impl Insomnia{EnumType::Insomnia};
static constexpr internal::Ability_impl ColorChange{EnumType::ColorChange};
static constexpr internal::Ability_impl Immunity{EnumType::Immunity};
static constexpr internal::Ability_impl FlashFire{EnumType::FlashFire};
static constexpr internal::Ability_impl ShieldDust{EnumType::ShieldDust};
static constexpr internal::Ability_impl OwnTempo{EnumType::OwnTempo};
static constexpr internal::Ability_impl SuctionCups{EnumType::SuctionCups};
static constexpr internal::Ability_impl Intimidate{EnumType::Intimidate};
static constexpr internal::Ability_impl ShadowTag{EnumType::ShadowTag};
static constexpr internal::Ability_impl RoughSkin{EnumType::RoughSkin};
static constexpr internal::Ability_impl WonderGuard{EnumType::WonderGuard};
static constexpr internal::Ability_impl Levitate{EnumType::Levitate};
static constexpr internal::Ability_impl EffectSpore{EnumType::EffectSpore};
static constexpr internal::Ability_impl Synchronize{EnumType::Synchronize};
static constexpr internal::Ability_impl ClearBody{EnumType::ClearBody};
static constexpr internal::Ability_impl NaturalCure{EnumType::NaturalCure};
static constexpr internal::Ability_impl LightningRod{EnumType::LightningRod};
static constexpr internal::Ability_impl SereneGrace{EnumType::SereneGrace};
static constexpr internal::Ability_impl SwiftSwim{EnumType::SwiftSwim};
static constexpr internal::Ability_impl Chlorophyll{EnumType::Chlorophyll};
static constexpr internal::Ability_impl Illuminate{EnumType::Illuminate};
static constexpr internal::Ability_impl Trace{EnumType::Trace};
static constexpr internal::Ability_impl HugePower{EnumType::HugePower};
static constexpr internal::Ability_impl PoisonPoint{EnumType::PoisonPoint};
static constexpr internal::Ability_impl InnerFocus{EnumType::InnerFocus};
static constexpr internal::Ability_impl MagmaArmor{EnumType::MagmaArmor};
static constexpr internal::Ability_impl WaterVeil{EnumType::WaterVeil};
static constexpr internal::Ability_impl MagnetPull{EnumType::MagnetPull};
static constexpr internal::Ability_impl Soundproof{EnumType::Soundproof};
static constexpr internal::Ability_impl RainDish{EnumType::RainDish};
static constexpr internal::Ability_impl SandStream{EnumType::SandStream};
static constexpr internal::Ability_impl Pressure{EnumType::Pressure};
static constexpr internal::Ability_impl ThickFat{EnumType::ThickFat};
static constexpr internal::Ability_impl EarlyBird{EnumType::EarlyBird};
static constexpr internal::Ability_impl FlameBody{EnumType::FlameBody};
static constexpr internal::Ability_impl RunAway{EnumType::RunAway};
static constexpr internal::Ability_impl KeenEye{EnumType::KeenEye};
static constexpr internal::Ability_impl HyperCutter{EnumType::HyperCutter};
static constexpr internal::Ability_impl Pickup{EnumType::Pickup};
static constexpr internal::Ability_impl Truant{EnumType::Truant};
static constexpr internal::Ability_impl Hustle{EnumType::Hustle};
static constexpr internal::Ability_impl CuteCharm{EnumType::CuteCharm};
static constexpr internal::Ability_impl Plus{EnumType::Plus};
static constexpr internal::Ability_impl Minus{EnumType::Minus};
static constexpr internal::Ability_impl Forecast{EnumType::Forecast};
static constexpr internal::Ability_impl StickyHold{EnumType::StickyHold};
static constexpr internal::Ability_impl ShedSkin{EnumType::ShedSkin};
static constexpr internal::Ability_impl Guts{EnumType::Guts};
static constexpr internal::Ability_impl MarvelScale{EnumType::MarvelScale};
static constexpr internal::Ability_impl LiquidOoze{EnumType::LiquidOoze};
static constexpr internal::Ability_impl Overgrow{EnumType::Overgrow};
static constexpr internal::Ability_impl Blaze{EnumType::Blaze};
static constexpr internal::Ability_impl Torrent{EnumType::Torrent};
static constexpr internal::Ability_impl Swarm{EnumType::Swarm};
static constexpr internal::Ability_impl RockHead{EnumType::RockHead};
static constexpr internal::Ability_impl Drought{EnumType::Drought};
static constexpr internal::Ability_impl ArenaTrap{EnumType::ArenaTrap};
static constexpr internal::Ability_impl VitalSpirit{EnumType::VitalSpirit};
static constexpr internal::Ability_impl WhiteSmoke{EnumType::WhiteSmoke};
static constexpr internal::Ability_impl PurePower{EnumType::PurePower};
static constexpr internal::Ability_impl ShellArmor{EnumType::ShellArmor};
static constexpr internal::Ability_impl AirLock{EnumType::AirLock};
static constexpr internal::Ability_impl TangledFeet{EnumType::TangledFeet};
static constexpr internal::Ability_impl MotorDrive{EnumType::MotorDrive};
static constexpr internal::Ability_impl Rivalry{EnumType::Rivalry};
static constexpr internal::Ability_impl Steadfast{EnumType::Steadfast};
static constexpr internal::Ability_impl SnowCloak{EnumType::SnowCloak};
static constexpr internal::Ability_impl Gluttony{EnumType::Gluttony};
static constexpr internal::Ability_impl AngerPoint{EnumType::AngerPoint};
static constexpr internal::Ability_impl Unburden{EnumType::Unburden};
static constexpr internal::Ability_impl Heatproof{EnumType::Heatproof};
static constexpr internal::Ability_impl Simple{EnumType::Simple};
static constexpr internal::Ability_impl DrySkin{EnumType::DrySkin};
static constexpr internal::Ability_impl Download{EnumType::Download};
static constexpr internal::Ability_impl IronFist{EnumType::IronFist};
static constexpr internal::Ability_impl PoisonHeal{EnumType::PoisonHeal};
static constexpr internal::Ability_impl Adaptability{EnumType::Adaptability};
static constexpr internal::Ability_impl SkillLink{EnumType::SkillLink};
static constexpr internal::Ability_impl Hydration{EnumType::Hydration};
static constexpr internal::Ability_impl SolarPower{EnumType::SolarPower};
static constexpr internal::Ability_impl QuickFeet{EnumType::QuickFeet};
static constexpr internal::Ability_impl Normalize{EnumType::Normalize};
static constexpr internal::Ability_impl Sniper{EnumType::Sniper};
static constexpr internal::Ability_impl MagicGuard{EnumType::MagicGuard};
static constexpr internal::Ability_impl NoGuard{EnumType::NoGuard};
static constexpr internal::Ability_impl Stall{EnumType::Stall};
static constexpr internal::Ability_impl Technician{EnumType::Technician};
static constexpr internal::Ability_impl LeafGuard{EnumType::LeafGuard};
static constexpr internal::Ability_impl Klutz{EnumType::Klutz};
static constexpr internal::Ability_impl MoldBreaker{EnumType::MoldBreaker};
static constexpr internal::Ability_impl SuperLuck{EnumType::SuperLuck};
static constexpr internal::Ability_impl Aftermath{EnumType::Aftermath};
static constexpr internal::Ability_impl Anticipation{EnumType::Anticipation};
static constexpr internal::Ability_impl Forewarn{EnumType::Forewarn};
static constexpr internal::Ability_impl Unaware{EnumType::Unaware};
static constexpr internal::Ability_impl TintedLens{EnumType::TintedLens};
static constexpr internal::Ability_impl Filter{EnumType::Filter};
static constexpr internal::Ability_impl SlowStart{EnumType::SlowStart};
static constexpr internal::Ability_impl Scrappy{EnumType::Scrappy};
static constexpr internal::Ability_impl StormDrain{EnumType::StormDrain};
static constexpr internal::Ability_impl IceBody{EnumType::IceBody};
static constexpr internal::Ability_impl SolidRock{EnumType::SolidRock};
static constexpr internal::Ability_impl SnowWarning{EnumType::SnowWarning};
static constexpr internal::Ability_impl HoneyGather{EnumType::HoneyGather};
static constexpr internal::Ability_impl Frisk{EnumType::Frisk};
static constexpr internal::Ability_impl Reckless{EnumType::Reckless};
static constexpr internal::Ability_impl Multitype{EnumType::Multitype};
static constexpr internal::Ability_impl FlowerGift{EnumType::FlowerGift};
static constexpr internal::Ability_impl BadDreams{EnumType::BadDreams};
static constexpr internal::Ability_impl Pickpocket{EnumType::Pickpocket};
static constexpr internal::Ability_impl SheerForce{EnumType::SheerForce};
static constexpr internal::Ability_impl Contrary{EnumType::Contrary};
static constexpr internal::Ability_impl Unnerve{EnumType::Unnerve};
static constexpr internal::Ability_impl Defiant{EnumType::Defiant};
static constexpr internal::Ability_impl Defeatist{EnumType::Defeatist};
static constexpr internal::Ability_impl CursedBody{EnumType::CursedBody};
static constexpr internal::Ability_impl Healer{EnumType::Healer};
static constexpr internal::Ability_impl FriendGuard{EnumType::FriendGuard};
static constexpr internal::Ability_impl WeakArmor{EnumType::WeakArmor};
static constexpr internal::Ability_impl HeavyMetal{EnumType::HeavyMetal};
static constexpr internal::Ability_impl LightMetal{EnumType::LightMetal};
static constexpr internal::Ability_impl Multiscale{EnumType::Multiscale};
static constexpr internal::Ability_impl ToxicBoost{EnumType::ToxicBoost};
static constexpr internal::Ability_impl FlareBoost{EnumType::FlareBoost};
static constexpr internal::Ability_impl Harvest{EnumType::Harvest};
static constexpr internal::Ability_impl Telepathy{EnumType::Telepathy};
static constexpr internal::Ability_impl Moody{EnumType::Moody};
static constexpr internal::Ability_impl Overcoat{EnumType::Overcoat};
static constexpr internal::Ability_impl PoisonTouch{EnumType::PoisonTouch};
static constexpr internal::Ability_impl Regenerator{EnumType::Regenerator};
static constexpr internal::Ability_impl BigPecks{EnumType::BigPecks};
static constexpr internal::Ability_impl SandRush{EnumType::SandRush};
static constexpr internal::Ability_impl WonderSkin{EnumType::WonderSkin};
static constexpr internal::Ability_impl Analytic{EnumType::Analytic};
static constexpr internal::Ability_impl Illusion{EnumType::Illusion};
static constexpr internal::Ability_impl Imposter{EnumType::Imposter};
static constexpr internal::Ability_impl Infiltrator{EnumType::Infiltrator};
static constexpr internal::Ability_impl Mummy{EnumType::Mummy};
static constexpr internal::Ability_impl Moxie{EnumType::Moxie};
static constexpr internal::Ability_impl Justified{EnumType::Justified};
static constexpr internal::Ability_impl Rattled{EnumType::Rattled};
static constexpr internal::Ability_impl MagicBounce{EnumType::MagicBounce};
static constexpr internal::Ability_impl SapSipper{EnumType::SapSipper};
static constexpr internal::Ability_impl Prankster{EnumType::Prankster};
static constexpr internal::Ability_impl SandForce{EnumType::SandForce};
static constexpr internal::Ability_impl IronBarbs{EnumType::IronBarbs};
static constexpr internal::Ability_impl ZenMode{EnumType::ZenMode};
static constexpr internal::Ability_impl VictoryStar{EnumType::VictoryStar};
static constexpr internal::Ability_impl Turboblaze{EnumType::Turboblaze};
static constexpr internal::Ability_impl Teravolt{EnumType::Teravolt};
static constexpr internal::Ability_impl AromaVeil{EnumType::AromaVeil};
static constexpr internal::Ability_impl FlowerVeil{EnumType::FlowerVeil};
static constexpr internal::Ability_impl CheekPouch{EnumType::CheekPouch};
static constexpr internal::Ability_impl Protean{EnumType::Protean};
static constexpr internal::Ability_impl FurCoat{EnumType::FurCoat};
static constexpr internal::Ability_impl Magician{EnumType::Magician};
static constexpr internal::Ability_impl Bulletproof{EnumType::Bulletproof};
static constexpr internal::Ability_impl Competitive{EnumType::Competitive};
static constexpr internal::Ability_impl StrongJaw{EnumType::StrongJaw};
static constexpr internal::Ability_impl Refrigerate{EnumType::Refrigerate};
static constexpr internal::Ability_impl SweetVeil{EnumType::SweetVeil};
static constexpr internal::Ability_impl StanceChange{EnumType::StanceChange};
static constexpr internal::Ability_impl GaleWings{EnumType::GaleWings};
static constexpr internal::Ability_impl MegaLauncher{EnumType::MegaLauncher};
static constexpr internal::Ability_impl GrassPelt{EnumType::GrassPelt};
static constexpr internal::Ability_impl Symbiosis{EnumType::Symbiosis};
static constexpr internal::Ability_impl ToughClaws{EnumType::ToughClaws};
static constexpr internal::Ability_impl Pixilate{EnumType::Pixilate};
static constexpr internal::Ability_impl Gooey{EnumType::Gooey};
static constexpr internal::Ability_impl Aerilate{EnumType::Aerilate};
static constexpr internal::Ability_impl ParentalBond{EnumType::ParentalBond};
static constexpr internal::Ability_impl DarkAura{EnumType::DarkAura};
static constexpr internal::Ability_impl FairyAura{EnumType::FairyAura};
static constexpr internal::Ability_impl AuraBreak{EnumType::AuraBreak};
static constexpr internal::Ability_impl PrimordialSea{EnumType::PrimordialSea};
static constexpr internal::Ability_impl DesolateLand{EnumType::DesolateLand};
static constexpr internal::Ability_impl DeltaStream{EnumType::DeltaStream};
static constexpr internal::Ability_impl Stamina{EnumType::Stamina};
static constexpr internal::Ability_impl WimpOut{EnumType::WimpOut};
static constexpr internal::Ability_impl EmergencyExit{EnumType::EmergencyExit};
static constexpr internal::Ability_impl WaterCompaction{EnumType::WaterCompaction};
static constexpr internal::Ability_impl Merciless{EnumType::Merciless};
static constexpr internal::Ability_impl ShieldsDown{EnumType::ShieldsDown};
static constexpr internal::Ability_impl Stakeout{EnumType::Stakeout};
static constexpr internal::Ability_impl WaterBubble{EnumType::WaterBubble};
static constexpr internal::Ability_impl Steelworker{EnumType::Steelworker};
static constexpr internal::Ability_impl Berserk{EnumType::Berserk};
static constexpr internal::Ability_impl SlushRush{EnumType::SlushRush};
static constexpr internal::Ability_impl LongReach{EnumType::LongReach};
static constexpr internal::Ability_impl LiquidVoice{EnumType::LiquidVoice};
static constexpr internal::Ability_impl Triage{EnumType::Triage};
static constexpr internal::Ability_impl Galvanize{EnumType::Galvanize};
static constexpr internal::Ability_impl SurgeSurfer{EnumType::SurgeSurfer};
static constexpr internal::Ability_impl Schooling{EnumType::Schooling};
static constexpr internal::Ability_impl Disguise{EnumType::Disguise};
static constexpr internal::Ability_impl BattleBond{EnumType::BattleBond};
static constexpr internal::Ability_impl PowerConstruct{EnumType::PowerConstruct};
static constexpr internal::Ability_impl Corrosion{EnumType::Corrosion};
static constexpr internal::Ability_impl Comatose{EnumType::Comatose};
static constexpr internal::Ability_impl QueenlyMajesty{EnumType::QueenlyMajesty};
static constexpr internal::Ability_impl InnardsOut{EnumType::InnardsOut};
static constexpr internal::Ability_impl Dancer{EnumType::Dancer};
static constexpr internal::Ability_impl Battery{EnumType::Battery};
static constexpr internal::Ability_impl Fluffy{EnumType::Fluffy};
static constexpr internal::Ability_impl Dazzling{EnumType::Dazzling};
static constexpr internal::Ability_impl SoulHeart{EnumType::SoulHeart};
static constexpr internal::Ability_impl TanglingHair{EnumType::TanglingHair};
static constexpr internal::Ability_impl Receiver{EnumType::Receiver};
static constexpr internal::Ability_impl PowerofAlchemy{EnumType::PowerofAlchemy};
static constexpr internal::Ability_impl BeastBoost{EnumType::BeastBoost};
static constexpr internal::Ability_impl RKSSystem{EnumType::RKSSystem};
static constexpr internal::Ability_impl ElectricSurge{EnumType::ElectricSurge};
static constexpr internal::Ability_impl PsychicSurge{EnumType::PsychicSurge};
static constexpr internal::Ability_impl MistySurge{EnumType::MistySurge};
static constexpr internal::Ability_impl GrassySurge{EnumType::GrassySurge};
static constexpr internal::Ability_impl FullMetalBody{EnumType::FullMetalBody};
static constexpr internal::Ability_impl ShadowShield{EnumType::ShadowShield};
static constexpr internal::Ability_impl PrismArmor{EnumType::PrismArmor};
static constexpr internal::Ability_impl Neuroforce{EnumType::Neuroforce};
static constexpr internal::Ability_impl IntrepidSword{EnumType::IntrepidSword};
static constexpr internal::Ability_impl DauntlessShield{EnumType::DauntlessShield};
static constexpr internal::Ability_impl Libero{EnumType::Libero};
static constexpr internal::Ability_impl BallFetch{EnumType::BallFetch};
static constexpr internal::Ability_impl CottonDown{EnumType::CottonDown};
static constexpr internal::Ability_impl PropellerTail{EnumType::PropellerTail};
static constexpr internal::Ability_impl MirrorArmor{EnumType::MirrorArmor};
static constexpr internal::Ability_impl GulpMissile{EnumType::GulpMissile};
static constexpr internal::Ability_impl Stalwart{EnumType::Stalwart};
static constexpr internal::Ability_impl SteamEngine{EnumType::SteamEngine};
static constexpr internal::Ability_impl PunkRock{EnumType::PunkRock};
static constexpr internal::Ability_impl SandSpit{EnumType::SandSpit};
static constexpr internal::Ability_impl IceScales{EnumType::IceScales};
static constexpr internal::Ability_impl Ripen{EnumType::Ripen};
static constexpr internal::Ability_impl IceFace{EnumType::IceFace};
static constexpr internal::Ability_impl PowerSpot{EnumType::PowerSpot};
static constexpr internal::Ability_impl Mimicry{EnumType::Mimicry};
static constexpr internal::Ability_impl ScreenCleaner{EnumType::ScreenCleaner};
static constexpr internal::Ability_impl SteelySpirit{EnumType::SteelySpirit};
static constexpr internal::Ability_impl PerishBody{EnumType::PerishBody};
static constexpr internal::Ability_impl WanderingSpirit{EnumType::WanderingSpirit};
static constexpr internal::Ability_impl GorillaTactics{EnumType::GorillaTactics};
static constexpr internal::Ability_impl NeutralizingGas{EnumType::NeutralizingGas};
static constexpr internal::Ability_impl PastelVeil{EnumType::PastelVeil};
static constexpr internal::Ability_impl HungerSwitch{EnumType::HungerSwitch};
static constexpr internal::Ability_impl QuickDraw{EnumType::QuickDraw};
static constexpr internal::Ability_impl UnseenFist{EnumType::UnseenFist};
static constexpr internal::Ability_impl CuriousMedicine{EnumType::CuriousMedicine};
static constexpr internal::Ability_impl Transistor{EnumType::Transistor};
static constexpr internal::Ability_impl DragonsMaw{EnumType::DragonsMaw};
static constexpr internal::Ability_impl ChillingNeigh{EnumType::ChillingNeigh};
static constexpr internal::Ability_impl GrimNeigh{EnumType::GrimNeigh};
static constexpr internal::Ability_impl AsOneI{EnumType::AsOneI};
static constexpr internal::Ability_impl AsOneG{EnumType::AsOneG};
static constexpr internal::Ability_impl INVALID{EnumType::INVALID};
};
}
#endif
| 32,480
|
C++
|
.h
| 627
| 39.657097
| 99
| 0.656979
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,349
|
Move.hpp
|
FlagBrew_PKSM-Core/include/enums/Move.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef MOVE_HPP
#define MOVE_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Move;
namespace internal
{
class Move_impl
{
friend class pksm::Move;
private:
enum class MoveEnum : u16
{
None,
Pound,
KarateChop,
DoubleSlap,
CometPunch,
MegaPunch,
PayDay,
FirePunch,
IcePunch,
ThunderPunch,
Scratch,
ViseGrip,
Guillotine,
RazorWind,
SwordsDance,
Cut,
Gust,
WingAttack,
Whirlwind,
Fly,
Bind,
Slam,
VineWhip,
Stomp,
DoubleKick,
MegaKick,
JumpKick,
RollingKick,
SandAttack,
Headbutt,
HornAttack,
FuryAttack,
HornDrill,
Tackle,
BodySlam,
Wrap,
TakeDown,
Thrash,
DoubleEdge,
TailWhip,
PoisonSting,
Twineedle,
PinMissile,
Leer,
Bite,
Growl,
Roar,
Sing,
Supersonic,
SonicBoom,
Disable,
Acid,
Ember,
Flamethrower,
Mist,
WaterGun,
HydroPump,
Surf,
IceBeam,
Blizzard,
Psybeam,
BubbleBeam,
AuroraBeam,
HyperBeam,
Peck,
DrillPeck,
Submission,
LowKick,
Counter,
SeismicToss,
Strength,
Absorb,
MegaDrain,
LeechSeed,
Growth,
RazorLeaf,
SolarBeam,
PoisonPowder,
StunSpore,
SleepPowder,
PetalDance,
StringShot,
DragonRage,
FireSpin,
ThunderShock,
Thunderbolt,
ThunderWave,
Thunder,
RockThrow,
Earthquake,
Fissure,
Dig,
Toxic,
Confusion,
Psychic,
Hypnosis,
Meditate,
Agility,
QuickAttack,
Rage,
Teleport,
NightShade,
Mimic,
Screech,
DoubleTeam,
Recover,
Harden,
Minimize,
Smokescreen,
ConfuseRay,
Withdraw,
DefenseCurl,
Barrier,
LightScreen,
Haze,
Reflect,
FocusEnergy,
Bide,
Metronome,
MirrorMove,
SelfDestruct,
EggBomb,
Lick,
Smog,
Sludge,
BoneClub,
FireBlast,
Waterfall,
Clamp,
Swift,
SkullBash,
SpikeCannon,
Constrict,
Amnesia,
Kinesis,
SoftBoiled,
HighJumpKick,
Glare,
DreamEater,
PoisonGas,
Barrage,
LeechLife,
LovelyKiss,
SkyAttack,
Transform,
Bubble,
DizzyPunch,
Spore,
Flash,
Psywave,
Splash,
AcidArmor,
Crabhammer,
Explosion,
FurySwipes,
Bonemerang,
Rest,
RockSlide,
HyperFang,
Sharpen,
Conversion,
TriAttack,
SuperFang,
Slash,
Substitute,
Struggle,
Sketch,
TripleKick,
Thief,
SpiderWeb,
MindReader,
Nightmare,
FlameWheel,
Snore,
Curse,
Flail,
Conversion2,
Aeroblast,
CottonSpore,
Reversal,
Spite,
PowderSnow,
Protect,
MachPunch,
ScaryFace,
FeintAttack,
SweetKiss,
BellyDrum,
SludgeBomb,
MudSlap,
Octazooka,
Spikes,
ZapCannon,
Foresight,
DestinyBond,
PerishSong,
IcyWind,
Detect,
BoneRush,
LockOn,
Outrage,
Sandstorm,
GigaDrain,
Endure,
Charm,
Rollout,
FalseSwipe,
Swagger,
MilkDrink,
Spark,
FuryCutter,
SteelWing,
MeanLook,
Attract,
SleepTalk,
HealBell,
Return,
Present,
Frustration,
Safeguard,
PainSplit,
SacredFire,
Magnitude,
DynamicPunch,
Megahorn,
DragonBreath,
BatonPass,
Encore,
Pursuit,
RapidSpin,
SweetScent,
IronTail,
MetalClaw,
VitalThrow,
MorningSun,
Synthesis,
Moonlight,
HiddenPower,
CrossChop,
Twister,
RainDance,
SunnyDay,
Crunch,
MirrorCoat,
PsychUp,
ExtremeSpeed,
AncientPower,
ShadowBall,
FutureSight,
RockSmash,
Whirlpool,
BeatUp,
FakeOut,
Uproar,
Stockpile,
SpitUp,
Swallow,
HeatWave,
Hail,
Torment,
Flatter,
WillOWisp,
Memento,
Facade,
FocusPunch,
SmellingSalts,
FollowMe,
NaturePower,
Charge,
Taunt,
HelpingHand,
Trick,
RolePlay,
Wish,
Assist,
Ingrain,
Superpower,
MagicCoat,
Recycle,
Revenge,
BrickBreak,
Yawn,
KnockOff,
Endeavor,
Eruption,
SkillSwap,
Imprison,
Refresh,
Grudge,
Snatch,
SecretPower,
Dive,
ArmThrust,
Camouflage,
TailGlow,
LusterPurge,
MistBall,
FeatherDance,
TeeterDance,
BlazeKick,
MudSport,
IceBall,
NeedleArm,
SlackOff,
HyperVoice,
PoisonFang,
CrushClaw,
BlastBurn,
HydroCannon,
MeteorMash,
Astonish,
WeatherBall,
Aromatherapy,
FakeTears,
AirCutter,
Overheat,
OdorSleuth,
RockTomb,
SilverWind,
MetalSound,
GrassWhistle,
Tickle,
CosmicPower,
WaterSpout,
SignalBeam,
ShadowPunch,
Extrasensory,
SkyUppercut,
SandTomb,
SheerCold,
MuddyWater,
BulletSeed,
AerialAce,
IcicleSpear,
IronDefense,
Block,
Howl,
DragonClaw,
FrenzyPlant,
BulkUp,
Bounce,
MudShot,
PoisonTail,
Covet,
VoltTackle,
MagicalLeaf,
WaterSport,
CalmMind,
LeafBlade,
DragonDance,
RockBlast,
ShockWave,
WaterPulse,
DoomDesire,
PsychoBoost,
Roost,
Gravity,
MiracleEye,
WakeUpSlap,
HammerArm,
GyroBall,
HealingWish,
Brine,
NaturalGift,
Feint,
Pluck,
Tailwind,
Acupressure,
MetalBurst,
Uturn,
CloseCombat,
Payback,
Assurance,
Embargo,
Fling,
PsychoShift,
TrumpCard,
HealBlock,
WringOut,
PowerTrick,
GastroAcid,
LuckyChant,
MeFirst,
Copycat,
PowerSwap,
GuardSwap,
Punishment,
LastResort,
WorrySeed,
SuckerPunch,
ToxicSpikes,
HeartSwap,
AquaRing,
MagnetRise,
FlareBlitz,
ForcePalm,
AuraSphere,
RockPolish,
PoisonJab,
DarkPulse,
NightSlash,
AquaTail,
SeedBomb,
AirSlash,
XScissor,
BugBuzz,
DragonPulse,
DragonRush,
PowerGem,
DrainPunch,
VacuumWave,
FocusBlast,
EnergyBall,
BraveBird,
EarthPower,
Switcheroo,
GigaImpact,
NastyPlot,
BulletPunch,
Avalanche,
IceShard,
ShadowClaw,
ThunderFang,
IceFang,
FireFang,
ShadowSneak,
MudBomb,
PsychoCut,
ZenHeadbutt,
MirrorShot,
FlashCannon,
RockClimb,
Defog,
TrickRoom,
DracoMeteor,
Discharge,
LavaPlume,
LeafStorm,
PowerWhip,
RockWrecker,
CrossPoison,
GunkShot,
IronHead,
MagnetBomb,
StoneEdge,
Captivate,
StealthRock,
GrassKnot,
Chatter,
Judgment,
BugBite,
ChargeBeam,
WoodHammer,
AquaJet,
AttackOrder,
DefendOrder,
HealOrder,
HeadSmash,
DoubleHit,
RoarofTime,
SpacialRend,
LunarDance,
CrushGrip,
MagmaStorm,
DarkVoid,
SeedFlare,
OminousWind,
ShadowForce,
HoneClaws,
WideGuard,
GuardSplit,
PowerSplit,
WonderRoom,
Psyshock,
Venoshock,
Autotomize,
RagePowder,
Telekinesis,
MagicRoom,
SmackDown,
StormThrow,
FlameBurst,
SludgeWave,
QuiverDance,
HeavySlam,
Synchronoise,
ElectroBall,
Soak,
FlameCharge,
Coil,
LowSweep,
AcidSpray,
FoulPlay,
SimpleBeam,
Entrainment,
AfterYou,
Round,
EchoedVoice,
ChipAway,
ClearSmog,
StoredPower,
QuickGuard,
AllySwitch,
Scald,
ShellSmash,
HealPulse,
Hex,
SkyDrop,
ShiftGear,
CircleThrow,
Incinerate,
Quash,
Acrobatics,
ReflectType,
Retaliate,
FinalGambit,
Bestow,
Inferno,
WaterPledge,
FirePledge,
GrassPledge,
VoltSwitch,
StruggleBug,
Bulldoze,
FrostBreath,
DragonTail,
WorkUp,
Electroweb,
WildCharge,
DrillRun,
DualChop,
HeartStamp,
HornLeech,
SacredSword,
RazorShell,
HeatCrash,
LeafTornado,
Steamroller,
CottonGuard,
NightDaze,
Psystrike,
TailSlap,
Hurricane,
HeadCharge,
GearGrind,
SearingShot,
TechnoBlast,
RelicSong,
SecretSword,
Glaciate,
BoltStrike,
BlueFlare,
FieryDance,
FreezeShock,
IceBurn,
Snarl,
IcicleCrash,
Vcreate,
FusionFlare,
FusionBolt,
FlyingPress,
MatBlock,
Belch,
Rototiller,
StickyWeb,
FellStinger,
PhantomForce,
TrickorTreat,
NobleRoar,
IonDeluge,
ParabolicCharge,
ForestsCurse,
PetalBlizzard,
FreezeDry,
DisarmingVoice,
PartingShot,
TopsyTurvy,
DrainingKiss,
CraftyShield,
FlowerShield,
GrassyTerrain,
MistyTerrain,
Electrify,
PlayRough,
FairyWind,
Moonblast,
Boomburst,
FairyLock,
KingsShield,
PlayNice,
Confide,
DiamondStorm,
SteamEruption,
HyperspaceHole,
WaterShuriken,
MysticalFire,
SpikyShield,
AromaticMist,
EerieImpulse,
VenomDrench,
Powder,
Geomancy,
MagneticFlux,
HappyHour,
ElectricTerrain,
DazzlingGleam,
Celebrate,
HoldHands,
BabyDollEyes,
Nuzzle,
HoldBack,
Infestation,
PowerUpPunch,
OblivionWing,
ThousandArrows,
ThousandWaves,
LandsWrath,
LightofRuin,
OriginPulse,
PrecipiceBlades,
DragonAscent,
HyperspaceFury,
BreakneckBlitzA,
BreakneckBlitzB,
AllOutPummelingA,
AllOutPummelingB,
SupersonicSkystrikeA,
SupersonicSkystrikeB,
AcidDownpourA,
AcidDownpourB,
TectonicRageA,
TectonicRageB,
ContinentalCrushA,
ContinentalCrushB,
SavageSpinOutA,
SavageSpinOutB,
NeverEndingNightmareA,
NeverEndingNightmareB,
CorkscrewCrashA,
CorkscrewCrashB,
InfernoOverdriveA,
InfernoOverdriveB,
HydroVortexA,
HydroVortexB,
BloomDoomA,
BloomDoomB,
GigavoltHavocA,
GigavoltHavocB,
ShatteredPsycheA,
ShatteredPsycheB,
SubzeroSlammerA,
SubzeroSlammerB,
DevastatingDrakeA,
DevastatingDrakeB,
BlackHoleEclipseA,
BlackHoleEclipseB,
TwinkleTackleA,
TwinkleTackleB,
Catastropika,
ShoreUp,
FirstImpression,
BanefulBunker,
SpiritShackle,
DarkestLariat,
SparklingAria,
IceHammer,
FloralHealing,
HighHorsepower,
StrengthSap,
SolarBlade,
Leafage,
Spotlight,
ToxicThread,
LaserFocus,
GearUp,
ThroatChop,
PollenPuff,
AnchorShot,
PsychicTerrain,
Lunge,
FireLash,
PowerTrip,
BurnUp,
SpeedSwap,
SmartStrike,
Purify,
RevelationDance,
CoreEnforcer,
TropKick,
Instruct,
BeakBlast,
ClangingScales,
DragonHammer,
BrutalSwing,
AuroraVeil,
SinisterArrowRaid,
MaliciousMoonsault,
OceanicOperetta,
GuardianofAlola,
SoulStealing7StarStrike,
StokedSparksurfer,
PulverizingPancake,
ExtremeEvoboost,
GenesisSupernova,
ShellTrap,
FleurCannon,
PsychicFangs,
StompingTantrum,
ShadowBone,
Accelerock,
Liquidation,
PrismaticLaser,
SpectralThief,
SunsteelStrike,
MoongeistBeam,
TearfulLook,
ZingZap,
NaturesMadness,
MultiAttack,
TenMillionVoltThunderbolt,
MindBlown,
PlasmaFists,
PhotonGeyser,
LightThatBurnstheSky,
SearingSunrazeSmash,
MenacingMoonrazeMaelstrom,
LetsSnuggleForever,
SplinteredStormshards,
ClangorousSoulblaze,
ZippyZap,
SplishySplash,
FloatyFall,
PikaPapow,
BouncyBubble,
BuzzyBuzz,
SizzlySlide,
GlitzyGlow,
BaddyBad,
SappySeed,
FreezyFrost,
SparklySwirl,
VeeveeVolley,
DoubleIronBash,
MaxGuard,
DynamaxCannon,
SnipeShot,
JawLock,
StuffCheeks,
NoRetreat,
TarShot,
MagicPowder,
DragonDarts,
Teatime,
Octolock,
BoltBeak,
FishiousRend,
CourtChange,
MaxFlare,
MaxFlutterby,
MaxLightning,
MaxStrike,
MaxKnuckle,
MaxPhantasm,
MaxHailstorm,
MaxOoze,
MaxGeyser,
MaxAirstream,
MaxStarfall,
MaxWyrmwind,
MaxMindstorm,
MaxRockfall,
MaxQuake,
MaxDarkness,
MaxOvergrowth,
MaxSteelspike,
ClangorousSoul,
BodyPress,
Decorate,
DrumBeating,
SnapTrap,
PyroBall,
BehemothBlade,
BehemothBash,
AuraWheel,
BreakingSwipe,
BranchPoke,
Overdrive,
AppleAcid,
GravApple,
SpiritBreak,
StrangeSteam,
LifeDew,
Obstruct,
FalseSurrender,
MeteorAssault,
Eternabeam,
SteelBeam,
ExpandingForce,
SteelRoller,
ScaleShot,
MeteorBeam,
ShellSideArm,
MistyExplosion,
GrassyGlide,
RisingVoltage,
TerrainPulse,
SkitterSmack,
BurningJealousy,
LashOut,
Poltergeist,
CorrosiveGas,
Coaching,
FlipTurn,
TripleAxel,
DualWingbeat,
ScorchingSands,
JungleHealing,
WickedBlow,
SurgingStrikes,
ThunderCage,
DragonEnergy,
FreezingGlare,
FieryWrath,
ThunderousKick,
GlacialLance,
AstralBarrage,
EerieSpell,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<MoveEnum>>::max()
} v;
constexpr explicit Move_impl(MoveEnum v) : v(v) {}
constexpr Move_impl(const Move_impl&) = default;
constexpr Move_impl(Move_impl&&) = default;
constexpr Move_impl& operator=(const Move_impl&) = default;
constexpr Move_impl& operator=(Move_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator MoveEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Move_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Move
{
private:
internal::Move_impl impl;
public:
using EnumType = internal::Move_impl::MoveEnum;
constexpr Move() noexcept : impl(EnumType::INVALID) {}
constexpr Move(const internal::Move_impl& impl) noexcept : impl(impl) {}
constexpr explicit Move(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v}) {}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Move& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Move_impl None{EnumType::None};
static constexpr internal::Move_impl Pound{EnumType::Pound};
static constexpr internal::Move_impl KarateChop{EnumType::KarateChop};
static constexpr internal::Move_impl DoubleSlap{EnumType::DoubleSlap};
static constexpr internal::Move_impl CometPunch{EnumType::CometPunch};
static constexpr internal::Move_impl MegaPunch{EnumType::MegaPunch};
static constexpr internal::Move_impl PayDay{EnumType::PayDay};
static constexpr internal::Move_impl FirePunch{EnumType::FirePunch};
static constexpr internal::Move_impl IcePunch{EnumType::IcePunch};
static constexpr internal::Move_impl ThunderPunch{EnumType::ThunderPunch};
static constexpr internal::Move_impl Scratch{EnumType::Scratch};
static constexpr internal::Move_impl ViseGrip{EnumType::ViseGrip};
static constexpr internal::Move_impl Guillotine{EnumType::Guillotine};
static constexpr internal::Move_impl RazorWind{EnumType::RazorWind};
static constexpr internal::Move_impl SwordsDance{EnumType::SwordsDance};
static constexpr internal::Move_impl Cut{EnumType::Cut};
static constexpr internal::Move_impl Gust{EnumType::Gust};
static constexpr internal::Move_impl WingAttack{EnumType::WingAttack};
static constexpr internal::Move_impl Whirlwind{EnumType::Whirlwind};
static constexpr internal::Move_impl Fly{EnumType::Fly};
static constexpr internal::Move_impl Bind{EnumType::Bind};
static constexpr internal::Move_impl Slam{EnumType::Slam};
static constexpr internal::Move_impl VineWhip{EnumType::VineWhip};
static constexpr internal::Move_impl Stomp{EnumType::Stomp};
static constexpr internal::Move_impl DoubleKick{EnumType::DoubleKick};
static constexpr internal::Move_impl MegaKick{EnumType::MegaKick};
static constexpr internal::Move_impl JumpKick{EnumType::JumpKick};
static constexpr internal::Move_impl RollingKick{EnumType::RollingKick};
static constexpr internal::Move_impl SandAttack{EnumType::SandAttack};
static constexpr internal::Move_impl Headbutt{EnumType::Headbutt};
static constexpr internal::Move_impl HornAttack{EnumType::HornAttack};
static constexpr internal::Move_impl FuryAttack{EnumType::FuryAttack};
static constexpr internal::Move_impl HornDrill{EnumType::HornDrill};
static constexpr internal::Move_impl Tackle{EnumType::Tackle};
static constexpr internal::Move_impl BodySlam{EnumType::BodySlam};
static constexpr internal::Move_impl Wrap{EnumType::Wrap};
static constexpr internal::Move_impl TakeDown{EnumType::TakeDown};
static constexpr internal::Move_impl Thrash{EnumType::Thrash};
static constexpr internal::Move_impl DoubleEdge{EnumType::DoubleEdge};
static constexpr internal::Move_impl TailWhip{EnumType::TailWhip};
static constexpr internal::Move_impl PoisonSting{EnumType::PoisonSting};
static constexpr internal::Move_impl Twineedle{EnumType::Twineedle};
static constexpr internal::Move_impl PinMissile{EnumType::PinMissile};
static constexpr internal::Move_impl Leer{EnumType::Leer};
static constexpr internal::Move_impl Bite{EnumType::Bite};
static constexpr internal::Move_impl Growl{EnumType::Growl};
static constexpr internal::Move_impl Roar{EnumType::Roar};
static constexpr internal::Move_impl Sing{EnumType::Sing};
static constexpr internal::Move_impl Supersonic{EnumType::Supersonic};
static constexpr internal::Move_impl SonicBoom{EnumType::SonicBoom};
static constexpr internal::Move_impl Disable{EnumType::Disable};
static constexpr internal::Move_impl Acid{EnumType::Acid};
static constexpr internal::Move_impl Ember{EnumType::Ember};
static constexpr internal::Move_impl Flamethrower{EnumType::Flamethrower};
static constexpr internal::Move_impl Mist{EnumType::Mist};
static constexpr internal::Move_impl WaterGun{EnumType::WaterGun};
static constexpr internal::Move_impl HydroPump{EnumType::HydroPump};
static constexpr internal::Move_impl Surf{EnumType::Surf};
static constexpr internal::Move_impl IceBeam{EnumType::IceBeam};
static constexpr internal::Move_impl Blizzard{EnumType::Blizzard};
static constexpr internal::Move_impl Psybeam{EnumType::Psybeam};
static constexpr internal::Move_impl BubbleBeam{EnumType::BubbleBeam};
static constexpr internal::Move_impl AuroraBeam{EnumType::AuroraBeam};
static constexpr internal::Move_impl HyperBeam{EnumType::HyperBeam};
static constexpr internal::Move_impl Peck{EnumType::Peck};
static constexpr internal::Move_impl DrillPeck{EnumType::DrillPeck};
static constexpr internal::Move_impl Submission{EnumType::Submission};
static constexpr internal::Move_impl LowKick{EnumType::LowKick};
static constexpr internal::Move_impl Counter{EnumType::Counter};
static constexpr internal::Move_impl SeismicToss{EnumType::SeismicToss};
static constexpr internal::Move_impl Strength{EnumType::Strength};
static constexpr internal::Move_impl Absorb{EnumType::Absorb};
static constexpr internal::Move_impl MegaDrain{EnumType::MegaDrain};
static constexpr internal::Move_impl LeechSeed{EnumType::LeechSeed};
static constexpr internal::Move_impl Growth{EnumType::Growth};
static constexpr internal::Move_impl RazorLeaf{EnumType::RazorLeaf};
static constexpr internal::Move_impl SolarBeam{EnumType::SolarBeam};
static constexpr internal::Move_impl PoisonPowder{EnumType::PoisonPowder};
static constexpr internal::Move_impl StunSpore{EnumType::StunSpore};
static constexpr internal::Move_impl SleepPowder{EnumType::SleepPowder};
static constexpr internal::Move_impl PetalDance{EnumType::PetalDance};
static constexpr internal::Move_impl StringShot{EnumType::StringShot};
static constexpr internal::Move_impl DragonRage{EnumType::DragonRage};
static constexpr internal::Move_impl FireSpin{EnumType::FireSpin};
static constexpr internal::Move_impl ThunderShock{EnumType::ThunderShock};
static constexpr internal::Move_impl Thunderbolt{EnumType::Thunderbolt};
static constexpr internal::Move_impl ThunderWave{EnumType::ThunderWave};
static constexpr internal::Move_impl Thunder{EnumType::Thunder};
static constexpr internal::Move_impl RockThrow{EnumType::RockThrow};
static constexpr internal::Move_impl Earthquake{EnumType::Earthquake};
static constexpr internal::Move_impl Fissure{EnumType::Fissure};
static constexpr internal::Move_impl Dig{EnumType::Dig};
static constexpr internal::Move_impl Toxic{EnumType::Toxic};
static constexpr internal::Move_impl Confusion{EnumType::Confusion};
static constexpr internal::Move_impl Psychic{EnumType::Psychic};
static constexpr internal::Move_impl Hypnosis{EnumType::Hypnosis};
static constexpr internal::Move_impl Meditate{EnumType::Meditate};
static constexpr internal::Move_impl Agility{EnumType::Agility};
static constexpr internal::Move_impl QuickAttack{EnumType::QuickAttack};
static constexpr internal::Move_impl Rage{EnumType::Rage};
static constexpr internal::Move_impl Teleport{EnumType::Teleport};
static constexpr internal::Move_impl NightShade{EnumType::NightShade};
static constexpr internal::Move_impl Mimic{EnumType::Mimic};
static constexpr internal::Move_impl Screech{EnumType::Screech};
static constexpr internal::Move_impl DoubleTeam{EnumType::DoubleTeam};
static constexpr internal::Move_impl Recover{EnumType::Recover};
static constexpr internal::Move_impl Harden{EnumType::Harden};
static constexpr internal::Move_impl Minimize{EnumType::Minimize};
static constexpr internal::Move_impl Smokescreen{EnumType::Smokescreen};
static constexpr internal::Move_impl ConfuseRay{EnumType::ConfuseRay};
static constexpr internal::Move_impl Withdraw{EnumType::Withdraw};
static constexpr internal::Move_impl DefenseCurl{EnumType::DefenseCurl};
static constexpr internal::Move_impl Barrier{EnumType::Barrier};
static constexpr internal::Move_impl LightScreen{EnumType::LightScreen};
static constexpr internal::Move_impl Haze{EnumType::Haze};
static constexpr internal::Move_impl Reflect{EnumType::Reflect};
static constexpr internal::Move_impl FocusEnergy{EnumType::FocusEnergy};
static constexpr internal::Move_impl Bide{EnumType::Bide};
static constexpr internal::Move_impl Metronome{EnumType::Metronome};
static constexpr internal::Move_impl MirrorMove{EnumType::MirrorMove};
static constexpr internal::Move_impl SelfDestruct{EnumType::SelfDestruct};
static constexpr internal::Move_impl EggBomb{EnumType::EggBomb};
static constexpr internal::Move_impl Lick{EnumType::Lick};
static constexpr internal::Move_impl Smog{EnumType::Smog};
static constexpr internal::Move_impl Sludge{EnumType::Sludge};
static constexpr internal::Move_impl BoneClub{EnumType::BoneClub};
static constexpr internal::Move_impl FireBlast{EnumType::FireBlast};
static constexpr internal::Move_impl Waterfall{EnumType::Waterfall};
static constexpr internal::Move_impl Clamp{EnumType::Clamp};
static constexpr internal::Move_impl Swift{EnumType::Swift};
static constexpr internal::Move_impl SkullBash{EnumType::SkullBash};
static constexpr internal::Move_impl SpikeCannon{EnumType::SpikeCannon};
static constexpr internal::Move_impl Constrict{EnumType::Constrict};
static constexpr internal::Move_impl Amnesia{EnumType::Amnesia};
static constexpr internal::Move_impl Kinesis{EnumType::Kinesis};
static constexpr internal::Move_impl SoftBoiled{EnumType::SoftBoiled};
static constexpr internal::Move_impl HighJumpKick{EnumType::HighJumpKick};
static constexpr internal::Move_impl Glare{EnumType::Glare};
static constexpr internal::Move_impl DreamEater{EnumType::DreamEater};
static constexpr internal::Move_impl PoisonGas{EnumType::PoisonGas};
static constexpr internal::Move_impl Barrage{EnumType::Barrage};
static constexpr internal::Move_impl LeechLife{EnumType::LeechLife};
static constexpr internal::Move_impl LovelyKiss{EnumType::LovelyKiss};
static constexpr internal::Move_impl SkyAttack{EnumType::SkyAttack};
static constexpr internal::Move_impl Transform{EnumType::Transform};
static constexpr internal::Move_impl Bubble{EnumType::Bubble};
static constexpr internal::Move_impl DizzyPunch{EnumType::DizzyPunch};
static constexpr internal::Move_impl Spore{EnumType::Spore};
static constexpr internal::Move_impl Flash{EnumType::Flash};
static constexpr internal::Move_impl Psywave{EnumType::Psywave};
static constexpr internal::Move_impl Splash{EnumType::Splash};
static constexpr internal::Move_impl AcidArmor{EnumType::AcidArmor};
static constexpr internal::Move_impl Crabhammer{EnumType::Crabhammer};
static constexpr internal::Move_impl Explosion{EnumType::Explosion};
static constexpr internal::Move_impl FurySwipes{EnumType::FurySwipes};
static constexpr internal::Move_impl Bonemerang{EnumType::Bonemerang};
static constexpr internal::Move_impl Rest{EnumType::Rest};
static constexpr internal::Move_impl RockSlide{EnumType::RockSlide};
static constexpr internal::Move_impl HyperFang{EnumType::HyperFang};
static constexpr internal::Move_impl Sharpen{EnumType::Sharpen};
static constexpr internal::Move_impl Conversion{EnumType::Conversion};
static constexpr internal::Move_impl TriAttack{EnumType::TriAttack};
static constexpr internal::Move_impl SuperFang{EnumType::SuperFang};
static constexpr internal::Move_impl Slash{EnumType::Slash};
static constexpr internal::Move_impl Substitute{EnumType::Substitute};
static constexpr internal::Move_impl Struggle{EnumType::Struggle};
static constexpr internal::Move_impl Sketch{EnumType::Sketch};
static constexpr internal::Move_impl TripleKick{EnumType::TripleKick};
static constexpr internal::Move_impl Thief{EnumType::Thief};
static constexpr internal::Move_impl SpiderWeb{EnumType::SpiderWeb};
static constexpr internal::Move_impl MindReader{EnumType::MindReader};
static constexpr internal::Move_impl Nightmare{EnumType::Nightmare};
static constexpr internal::Move_impl FlameWheel{EnumType::FlameWheel};
static constexpr internal::Move_impl Snore{EnumType::Snore};
static constexpr internal::Move_impl Curse{EnumType::Curse};
static constexpr internal::Move_impl Flail{EnumType::Flail};
static constexpr internal::Move_impl Conversion2{EnumType::Conversion2};
static constexpr internal::Move_impl Aeroblast{EnumType::Aeroblast};
static constexpr internal::Move_impl CottonSpore{EnumType::CottonSpore};
static constexpr internal::Move_impl Reversal{EnumType::Reversal};
static constexpr internal::Move_impl Spite{EnumType::Spite};
static constexpr internal::Move_impl PowderSnow{EnumType::PowderSnow};
static constexpr internal::Move_impl Protect{EnumType::Protect};
static constexpr internal::Move_impl MachPunch{EnumType::MachPunch};
static constexpr internal::Move_impl ScaryFace{EnumType::ScaryFace};
static constexpr internal::Move_impl FeintAttack{EnumType::FeintAttack};
static constexpr internal::Move_impl SweetKiss{EnumType::SweetKiss};
static constexpr internal::Move_impl BellyDrum{EnumType::BellyDrum};
static constexpr internal::Move_impl SludgeBomb{EnumType::SludgeBomb};
static constexpr internal::Move_impl MudSlap{EnumType::MudSlap};
static constexpr internal::Move_impl Octazooka{EnumType::Octazooka};
static constexpr internal::Move_impl Spikes{EnumType::Spikes};
static constexpr internal::Move_impl ZapCannon{EnumType::ZapCannon};
static constexpr internal::Move_impl Foresight{EnumType::Foresight};
static constexpr internal::Move_impl DestinyBond{EnumType::DestinyBond};
static constexpr internal::Move_impl PerishSong{EnumType::PerishSong};
static constexpr internal::Move_impl IcyWind{EnumType::IcyWind};
static constexpr internal::Move_impl Detect{EnumType::Detect};
static constexpr internal::Move_impl BoneRush{EnumType::BoneRush};
static constexpr internal::Move_impl LockOn{EnumType::LockOn};
static constexpr internal::Move_impl Outrage{EnumType::Outrage};
static constexpr internal::Move_impl Sandstorm{EnumType::Sandstorm};
static constexpr internal::Move_impl GigaDrain{EnumType::GigaDrain};
static constexpr internal::Move_impl Endure{EnumType::Endure};
static constexpr internal::Move_impl Charm{EnumType::Charm};
static constexpr internal::Move_impl Rollout{EnumType::Rollout};
static constexpr internal::Move_impl FalseSwipe{EnumType::FalseSwipe};
static constexpr internal::Move_impl Swagger{EnumType::Swagger};
static constexpr internal::Move_impl MilkDrink{EnumType::MilkDrink};
static constexpr internal::Move_impl Spark{EnumType::Spark};
static constexpr internal::Move_impl FuryCutter{EnumType::FuryCutter};
static constexpr internal::Move_impl SteelWing{EnumType::SteelWing};
static constexpr internal::Move_impl MeanLook{EnumType::MeanLook};
static constexpr internal::Move_impl Attract{EnumType::Attract};
static constexpr internal::Move_impl SleepTalk{EnumType::SleepTalk};
static constexpr internal::Move_impl HealBell{EnumType::HealBell};
static constexpr internal::Move_impl Return{EnumType::Return};
static constexpr internal::Move_impl Present{EnumType::Present};
static constexpr internal::Move_impl Frustration{EnumType::Frustration};
static constexpr internal::Move_impl Safeguard{EnumType::Safeguard};
static constexpr internal::Move_impl PainSplit{EnumType::PainSplit};
static constexpr internal::Move_impl SacredFire{EnumType::SacredFire};
static constexpr internal::Move_impl Magnitude{EnumType::Magnitude};
static constexpr internal::Move_impl DynamicPunch{EnumType::DynamicPunch};
static constexpr internal::Move_impl Megahorn{EnumType::Megahorn};
static constexpr internal::Move_impl DragonBreath{EnumType::DragonBreath};
static constexpr internal::Move_impl BatonPass{EnumType::BatonPass};
static constexpr internal::Move_impl Encore{EnumType::Encore};
static constexpr internal::Move_impl Pursuit{EnumType::Pursuit};
static constexpr internal::Move_impl RapidSpin{EnumType::RapidSpin};
static constexpr internal::Move_impl SweetScent{EnumType::SweetScent};
static constexpr internal::Move_impl IronTail{EnumType::IronTail};
static constexpr internal::Move_impl MetalClaw{EnumType::MetalClaw};
static constexpr internal::Move_impl VitalThrow{EnumType::VitalThrow};
static constexpr internal::Move_impl MorningSun{EnumType::MorningSun};
static constexpr internal::Move_impl Synthesis{EnumType::Synthesis};
static constexpr internal::Move_impl Moonlight{EnumType::Moonlight};
static constexpr internal::Move_impl HiddenPower{EnumType::HiddenPower};
static constexpr internal::Move_impl CrossChop{EnumType::CrossChop};
static constexpr internal::Move_impl Twister{EnumType::Twister};
static constexpr internal::Move_impl RainDance{EnumType::RainDance};
static constexpr internal::Move_impl SunnyDay{EnumType::SunnyDay};
static constexpr internal::Move_impl Crunch{EnumType::Crunch};
static constexpr internal::Move_impl MirrorCoat{EnumType::MirrorCoat};
static constexpr internal::Move_impl PsychUp{EnumType::PsychUp};
static constexpr internal::Move_impl ExtremeSpeed{EnumType::ExtremeSpeed};
static constexpr internal::Move_impl AncientPower{EnumType::AncientPower};
static constexpr internal::Move_impl ShadowBall{EnumType::ShadowBall};
static constexpr internal::Move_impl FutureSight{EnumType::FutureSight};
static constexpr internal::Move_impl RockSmash{EnumType::RockSmash};
static constexpr internal::Move_impl Whirlpool{EnumType::Whirlpool};
static constexpr internal::Move_impl BeatUp{EnumType::BeatUp};
static constexpr internal::Move_impl FakeOut{EnumType::FakeOut};
static constexpr internal::Move_impl Uproar{EnumType::Uproar};
static constexpr internal::Move_impl Stockpile{EnumType::Stockpile};
static constexpr internal::Move_impl SpitUp{EnumType::SpitUp};
static constexpr internal::Move_impl Swallow{EnumType::Swallow};
static constexpr internal::Move_impl HeatWave{EnumType::HeatWave};
static constexpr internal::Move_impl Hail{EnumType::Hail};
static constexpr internal::Move_impl Torment{EnumType::Torment};
static constexpr internal::Move_impl Flatter{EnumType::Flatter};
static constexpr internal::Move_impl WillOWisp{EnumType::WillOWisp};
static constexpr internal::Move_impl Memento{EnumType::Memento};
static constexpr internal::Move_impl Facade{EnumType::Facade};
static constexpr internal::Move_impl FocusPunch{EnumType::FocusPunch};
static constexpr internal::Move_impl SmellingSalts{EnumType::SmellingSalts};
static constexpr internal::Move_impl FollowMe{EnumType::FollowMe};
static constexpr internal::Move_impl NaturePower{EnumType::NaturePower};
static constexpr internal::Move_impl Charge{EnumType::Charge};
static constexpr internal::Move_impl Taunt{EnumType::Taunt};
static constexpr internal::Move_impl HelpingHand{EnumType::HelpingHand};
static constexpr internal::Move_impl Trick{EnumType::Trick};
static constexpr internal::Move_impl RolePlay{EnumType::RolePlay};
static constexpr internal::Move_impl Wish{EnumType::Wish};
static constexpr internal::Move_impl Assist{EnumType::Assist};
static constexpr internal::Move_impl Ingrain{EnumType::Ingrain};
static constexpr internal::Move_impl Superpower{EnumType::Superpower};
static constexpr internal::Move_impl MagicCoat{EnumType::MagicCoat};
static constexpr internal::Move_impl Recycle{EnumType::Recycle};
static constexpr internal::Move_impl Revenge{EnumType::Revenge};
static constexpr internal::Move_impl BrickBreak{EnumType::BrickBreak};
static constexpr internal::Move_impl Yawn{EnumType::Yawn};
static constexpr internal::Move_impl KnockOff{EnumType::KnockOff};
static constexpr internal::Move_impl Endeavor{EnumType::Endeavor};
static constexpr internal::Move_impl Eruption{EnumType::Eruption};
static constexpr internal::Move_impl SkillSwap{EnumType::SkillSwap};
static constexpr internal::Move_impl Imprison{EnumType::Imprison};
static constexpr internal::Move_impl Refresh{EnumType::Refresh};
static constexpr internal::Move_impl Grudge{EnumType::Grudge};
static constexpr internal::Move_impl Snatch{EnumType::Snatch};
static constexpr internal::Move_impl SecretPower{EnumType::SecretPower};
static constexpr internal::Move_impl Dive{EnumType::Dive};
static constexpr internal::Move_impl ArmThrust{EnumType::ArmThrust};
static constexpr internal::Move_impl Camouflage{EnumType::Camouflage};
static constexpr internal::Move_impl TailGlow{EnumType::TailGlow};
static constexpr internal::Move_impl LusterPurge{EnumType::LusterPurge};
static constexpr internal::Move_impl MistBall{EnumType::MistBall};
static constexpr internal::Move_impl FeatherDance{EnumType::FeatherDance};
static constexpr internal::Move_impl TeeterDance{EnumType::TeeterDance};
static constexpr internal::Move_impl BlazeKick{EnumType::BlazeKick};
static constexpr internal::Move_impl MudSport{EnumType::MudSport};
static constexpr internal::Move_impl IceBall{EnumType::IceBall};
static constexpr internal::Move_impl NeedleArm{EnumType::NeedleArm};
static constexpr internal::Move_impl SlackOff{EnumType::SlackOff};
static constexpr internal::Move_impl HyperVoice{EnumType::HyperVoice};
static constexpr internal::Move_impl PoisonFang{EnumType::PoisonFang};
static constexpr internal::Move_impl CrushClaw{EnumType::CrushClaw};
static constexpr internal::Move_impl BlastBurn{EnumType::BlastBurn};
static constexpr internal::Move_impl HydroCannon{EnumType::HydroCannon};
static constexpr internal::Move_impl MeteorMash{EnumType::MeteorMash};
static constexpr internal::Move_impl Astonish{EnumType::Astonish};
static constexpr internal::Move_impl WeatherBall{EnumType::WeatherBall};
static constexpr internal::Move_impl Aromatherapy{EnumType::Aromatherapy};
static constexpr internal::Move_impl FakeTears{EnumType::FakeTears};
static constexpr internal::Move_impl AirCutter{EnumType::AirCutter};
static constexpr internal::Move_impl Overheat{EnumType::Overheat};
static constexpr internal::Move_impl OdorSleuth{EnumType::OdorSleuth};
static constexpr internal::Move_impl RockTomb{EnumType::RockTomb};
static constexpr internal::Move_impl SilverWind{EnumType::SilverWind};
static constexpr internal::Move_impl MetalSound{EnumType::MetalSound};
static constexpr internal::Move_impl GrassWhistle{EnumType::GrassWhistle};
static constexpr internal::Move_impl Tickle{EnumType::Tickle};
static constexpr internal::Move_impl CosmicPower{EnumType::CosmicPower};
static constexpr internal::Move_impl WaterSpout{EnumType::WaterSpout};
static constexpr internal::Move_impl SignalBeam{EnumType::SignalBeam};
static constexpr internal::Move_impl ShadowPunch{EnumType::ShadowPunch};
static constexpr internal::Move_impl Extrasensory{EnumType::Extrasensory};
static constexpr internal::Move_impl SkyUppercut{EnumType::SkyUppercut};
static constexpr internal::Move_impl SandTomb{EnumType::SandTomb};
static constexpr internal::Move_impl SheerCold{EnumType::SheerCold};
static constexpr internal::Move_impl MuddyWater{EnumType::MuddyWater};
static constexpr internal::Move_impl BulletSeed{EnumType::BulletSeed};
static constexpr internal::Move_impl AerialAce{EnumType::AerialAce};
static constexpr internal::Move_impl IcicleSpear{EnumType::IcicleSpear};
static constexpr internal::Move_impl IronDefense{EnumType::IronDefense};
static constexpr internal::Move_impl Block{EnumType::Block};
static constexpr internal::Move_impl Howl{EnumType::Howl};
static constexpr internal::Move_impl DragonClaw{EnumType::DragonClaw};
static constexpr internal::Move_impl FrenzyPlant{EnumType::FrenzyPlant};
static constexpr internal::Move_impl BulkUp{EnumType::BulkUp};
static constexpr internal::Move_impl Bounce{EnumType::Bounce};
static constexpr internal::Move_impl MudShot{EnumType::MudShot};
static constexpr internal::Move_impl PoisonTail{EnumType::PoisonTail};
static constexpr internal::Move_impl Covet{EnumType::Covet};
static constexpr internal::Move_impl VoltTackle{EnumType::VoltTackle};
static constexpr internal::Move_impl MagicalLeaf{EnumType::MagicalLeaf};
static constexpr internal::Move_impl WaterSport{EnumType::WaterSport};
static constexpr internal::Move_impl CalmMind{EnumType::CalmMind};
static constexpr internal::Move_impl LeafBlade{EnumType::LeafBlade};
static constexpr internal::Move_impl DragonDance{EnumType::DragonDance};
static constexpr internal::Move_impl RockBlast{EnumType::RockBlast};
static constexpr internal::Move_impl ShockWave{EnumType::ShockWave};
static constexpr internal::Move_impl WaterPulse{EnumType::WaterPulse};
static constexpr internal::Move_impl DoomDesire{EnumType::DoomDesire};
static constexpr internal::Move_impl PsychoBoost{EnumType::PsychoBoost};
static constexpr internal::Move_impl Roost{EnumType::Roost};
static constexpr internal::Move_impl Gravity{EnumType::Gravity};
static constexpr internal::Move_impl MiracleEye{EnumType::MiracleEye};
static constexpr internal::Move_impl WakeUpSlap{EnumType::WakeUpSlap};
static constexpr internal::Move_impl HammerArm{EnumType::HammerArm};
static constexpr internal::Move_impl GyroBall{EnumType::GyroBall};
static constexpr internal::Move_impl HealingWish{EnumType::HealingWish};
static constexpr internal::Move_impl Brine{EnumType::Brine};
static constexpr internal::Move_impl NaturalGift{EnumType::NaturalGift};
static constexpr internal::Move_impl Feint{EnumType::Feint};
static constexpr internal::Move_impl Pluck{EnumType::Pluck};
static constexpr internal::Move_impl Tailwind{EnumType::Tailwind};
static constexpr internal::Move_impl Acupressure{EnumType::Acupressure};
static constexpr internal::Move_impl MetalBurst{EnumType::MetalBurst};
static constexpr internal::Move_impl Uturn{EnumType::Uturn};
static constexpr internal::Move_impl CloseCombat{EnumType::CloseCombat};
static constexpr internal::Move_impl Payback{EnumType::Payback};
static constexpr internal::Move_impl Assurance{EnumType::Assurance};
static constexpr internal::Move_impl Embargo{EnumType::Embargo};
static constexpr internal::Move_impl Fling{EnumType::Fling};
static constexpr internal::Move_impl PsychoShift{EnumType::PsychoShift};
static constexpr internal::Move_impl TrumpCard{EnumType::TrumpCard};
static constexpr internal::Move_impl HealBlock{EnumType::HealBlock};
static constexpr internal::Move_impl WringOut{EnumType::WringOut};
static constexpr internal::Move_impl PowerTrick{EnumType::PowerTrick};
static constexpr internal::Move_impl GastroAcid{EnumType::GastroAcid};
static constexpr internal::Move_impl LuckyChant{EnumType::LuckyChant};
static constexpr internal::Move_impl MeFirst{EnumType::MeFirst};
static constexpr internal::Move_impl Copycat{EnumType::Copycat};
static constexpr internal::Move_impl PowerSwap{EnumType::PowerSwap};
static constexpr internal::Move_impl GuardSwap{EnumType::GuardSwap};
static constexpr internal::Move_impl Punishment{EnumType::Punishment};
static constexpr internal::Move_impl LastResort{EnumType::LastResort};
static constexpr internal::Move_impl WorrySeed{EnumType::WorrySeed};
static constexpr internal::Move_impl SuckerPunch{EnumType::SuckerPunch};
static constexpr internal::Move_impl ToxicSpikes{EnumType::ToxicSpikes};
static constexpr internal::Move_impl HeartSwap{EnumType::HeartSwap};
static constexpr internal::Move_impl AquaRing{EnumType::AquaRing};
static constexpr internal::Move_impl MagnetRise{EnumType::MagnetRise};
static constexpr internal::Move_impl FlareBlitz{EnumType::FlareBlitz};
static constexpr internal::Move_impl ForcePalm{EnumType::ForcePalm};
static constexpr internal::Move_impl AuraSphere{EnumType::AuraSphere};
static constexpr internal::Move_impl RockPolish{EnumType::RockPolish};
static constexpr internal::Move_impl PoisonJab{EnumType::PoisonJab};
static constexpr internal::Move_impl DarkPulse{EnumType::DarkPulse};
static constexpr internal::Move_impl NightSlash{EnumType::NightSlash};
static constexpr internal::Move_impl AquaTail{EnumType::AquaTail};
static constexpr internal::Move_impl SeedBomb{EnumType::SeedBomb};
static constexpr internal::Move_impl AirSlash{EnumType::AirSlash};
static constexpr internal::Move_impl XScissor{EnumType::XScissor};
static constexpr internal::Move_impl BugBuzz{EnumType::BugBuzz};
static constexpr internal::Move_impl DragonPulse{EnumType::DragonPulse};
static constexpr internal::Move_impl DragonRush{EnumType::DragonRush};
static constexpr internal::Move_impl PowerGem{EnumType::PowerGem};
static constexpr internal::Move_impl DrainPunch{EnumType::DrainPunch};
static constexpr internal::Move_impl VacuumWave{EnumType::VacuumWave};
static constexpr internal::Move_impl FocusBlast{EnumType::FocusBlast};
static constexpr internal::Move_impl EnergyBall{EnumType::EnergyBall};
static constexpr internal::Move_impl BraveBird{EnumType::BraveBird};
static constexpr internal::Move_impl EarthPower{EnumType::EarthPower};
static constexpr internal::Move_impl Switcheroo{EnumType::Switcheroo};
static constexpr internal::Move_impl GigaImpact{EnumType::GigaImpact};
static constexpr internal::Move_impl NastyPlot{EnumType::NastyPlot};
static constexpr internal::Move_impl BulletPunch{EnumType::BulletPunch};
static constexpr internal::Move_impl Avalanche{EnumType::Avalanche};
static constexpr internal::Move_impl IceShard{EnumType::IceShard};
static constexpr internal::Move_impl ShadowClaw{EnumType::ShadowClaw};
static constexpr internal::Move_impl ThunderFang{EnumType::ThunderFang};
static constexpr internal::Move_impl IceFang{EnumType::IceFang};
static constexpr internal::Move_impl FireFang{EnumType::FireFang};
static constexpr internal::Move_impl ShadowSneak{EnumType::ShadowSneak};
static constexpr internal::Move_impl MudBomb{EnumType::MudBomb};
static constexpr internal::Move_impl PsychoCut{EnumType::PsychoCut};
static constexpr internal::Move_impl ZenHeadbutt{EnumType::ZenHeadbutt};
static constexpr internal::Move_impl MirrorShot{EnumType::MirrorShot};
static constexpr internal::Move_impl FlashCannon{EnumType::FlashCannon};
static constexpr internal::Move_impl RockClimb{EnumType::RockClimb};
static constexpr internal::Move_impl Defog{EnumType::Defog};
static constexpr internal::Move_impl TrickRoom{EnumType::TrickRoom};
static constexpr internal::Move_impl DracoMeteor{EnumType::DracoMeteor};
static constexpr internal::Move_impl Discharge{EnumType::Discharge};
static constexpr internal::Move_impl LavaPlume{EnumType::LavaPlume};
static constexpr internal::Move_impl LeafStorm{EnumType::LeafStorm};
static constexpr internal::Move_impl PowerWhip{EnumType::PowerWhip};
static constexpr internal::Move_impl RockWrecker{EnumType::RockWrecker};
static constexpr internal::Move_impl CrossPoison{EnumType::CrossPoison};
static constexpr internal::Move_impl GunkShot{EnumType::GunkShot};
static constexpr internal::Move_impl IronHead{EnumType::IronHead};
static constexpr internal::Move_impl MagnetBomb{EnumType::MagnetBomb};
static constexpr internal::Move_impl StoneEdge{EnumType::StoneEdge};
static constexpr internal::Move_impl Captivate{EnumType::Captivate};
static constexpr internal::Move_impl StealthRock{EnumType::StealthRock};
static constexpr internal::Move_impl GrassKnot{EnumType::GrassKnot};
static constexpr internal::Move_impl Chatter{EnumType::Chatter};
static constexpr internal::Move_impl Judgment{EnumType::Judgment};
static constexpr internal::Move_impl BugBite{EnumType::BugBite};
static constexpr internal::Move_impl ChargeBeam{EnumType::ChargeBeam};
static constexpr internal::Move_impl WoodHammer{EnumType::WoodHammer};
static constexpr internal::Move_impl AquaJet{EnumType::AquaJet};
static constexpr internal::Move_impl AttackOrder{EnumType::AttackOrder};
static constexpr internal::Move_impl DefendOrder{EnumType::DefendOrder};
static constexpr internal::Move_impl HealOrder{EnumType::HealOrder};
static constexpr internal::Move_impl HeadSmash{EnumType::HeadSmash};
static constexpr internal::Move_impl DoubleHit{EnumType::DoubleHit};
static constexpr internal::Move_impl RoarofTime{EnumType::RoarofTime};
static constexpr internal::Move_impl SpacialRend{EnumType::SpacialRend};
static constexpr internal::Move_impl LunarDance{EnumType::LunarDance};
static constexpr internal::Move_impl CrushGrip{EnumType::CrushGrip};
static constexpr internal::Move_impl MagmaStorm{EnumType::MagmaStorm};
static constexpr internal::Move_impl DarkVoid{EnumType::DarkVoid};
static constexpr internal::Move_impl SeedFlare{EnumType::SeedFlare};
static constexpr internal::Move_impl OminousWind{EnumType::OminousWind};
static constexpr internal::Move_impl ShadowForce{EnumType::ShadowForce};
static constexpr internal::Move_impl HoneClaws{EnumType::HoneClaws};
static constexpr internal::Move_impl WideGuard{EnumType::WideGuard};
static constexpr internal::Move_impl GuardSplit{EnumType::GuardSplit};
static constexpr internal::Move_impl PowerSplit{EnumType::PowerSplit};
static constexpr internal::Move_impl WonderRoom{EnumType::WonderRoom};
static constexpr internal::Move_impl Psyshock{EnumType::Psyshock};
static constexpr internal::Move_impl Venoshock{EnumType::Venoshock};
static constexpr internal::Move_impl Autotomize{EnumType::Autotomize};
static constexpr internal::Move_impl RagePowder{EnumType::RagePowder};
static constexpr internal::Move_impl Telekinesis{EnumType::Telekinesis};
static constexpr internal::Move_impl MagicRoom{EnumType::MagicRoom};
static constexpr internal::Move_impl SmackDown{EnumType::SmackDown};
static constexpr internal::Move_impl StormThrow{EnumType::StormThrow};
static constexpr internal::Move_impl FlameBurst{EnumType::FlameBurst};
static constexpr internal::Move_impl SludgeWave{EnumType::SludgeWave};
static constexpr internal::Move_impl QuiverDance{EnumType::QuiverDance};
static constexpr internal::Move_impl HeavySlam{EnumType::HeavySlam};
static constexpr internal::Move_impl Synchronoise{EnumType::Synchronoise};
static constexpr internal::Move_impl ElectroBall{EnumType::ElectroBall};
static constexpr internal::Move_impl Soak{EnumType::Soak};
static constexpr internal::Move_impl FlameCharge{EnumType::FlameCharge};
static constexpr internal::Move_impl Coil{EnumType::Coil};
static constexpr internal::Move_impl LowSweep{EnumType::LowSweep};
static constexpr internal::Move_impl AcidSpray{EnumType::AcidSpray};
static constexpr internal::Move_impl FoulPlay{EnumType::FoulPlay};
static constexpr internal::Move_impl SimpleBeam{EnumType::SimpleBeam};
static constexpr internal::Move_impl Entrainment{EnumType::Entrainment};
static constexpr internal::Move_impl AfterYou{EnumType::AfterYou};
static constexpr internal::Move_impl Round{EnumType::Round};
static constexpr internal::Move_impl EchoedVoice{EnumType::EchoedVoice};
static constexpr internal::Move_impl ChipAway{EnumType::ChipAway};
static constexpr internal::Move_impl ClearSmog{EnumType::ClearSmog};
static constexpr internal::Move_impl StoredPower{EnumType::StoredPower};
static constexpr internal::Move_impl QuickGuard{EnumType::QuickGuard};
static constexpr internal::Move_impl AllySwitch{EnumType::AllySwitch};
static constexpr internal::Move_impl Scald{EnumType::Scald};
static constexpr internal::Move_impl ShellSmash{EnumType::ShellSmash};
static constexpr internal::Move_impl HealPulse{EnumType::HealPulse};
static constexpr internal::Move_impl Hex{EnumType::Hex};
static constexpr internal::Move_impl SkyDrop{EnumType::SkyDrop};
static constexpr internal::Move_impl ShiftGear{EnumType::ShiftGear};
static constexpr internal::Move_impl CircleThrow{EnumType::CircleThrow};
static constexpr internal::Move_impl Incinerate{EnumType::Incinerate};
static constexpr internal::Move_impl Quash{EnumType::Quash};
static constexpr internal::Move_impl Acrobatics{EnumType::Acrobatics};
static constexpr internal::Move_impl ReflectType{EnumType::ReflectType};
static constexpr internal::Move_impl Retaliate{EnumType::Retaliate};
static constexpr internal::Move_impl FinalGambit{EnumType::FinalGambit};
static constexpr internal::Move_impl Bestow{EnumType::Bestow};
static constexpr internal::Move_impl Inferno{EnumType::Inferno};
static constexpr internal::Move_impl WaterPledge{EnumType::WaterPledge};
static constexpr internal::Move_impl FirePledge{EnumType::FirePledge};
static constexpr internal::Move_impl GrassPledge{EnumType::GrassPledge};
static constexpr internal::Move_impl VoltSwitch{EnumType::VoltSwitch};
static constexpr internal::Move_impl StruggleBug{EnumType::StruggleBug};
static constexpr internal::Move_impl Bulldoze{EnumType::Bulldoze};
static constexpr internal::Move_impl FrostBreath{EnumType::FrostBreath};
static constexpr internal::Move_impl DragonTail{EnumType::DragonTail};
static constexpr internal::Move_impl WorkUp{EnumType::WorkUp};
static constexpr internal::Move_impl Electroweb{EnumType::Electroweb};
static constexpr internal::Move_impl WildCharge{EnumType::WildCharge};
static constexpr internal::Move_impl DrillRun{EnumType::DrillRun};
static constexpr internal::Move_impl DualChop{EnumType::DualChop};
static constexpr internal::Move_impl HeartStamp{EnumType::HeartStamp};
static constexpr internal::Move_impl HornLeech{EnumType::HornLeech};
static constexpr internal::Move_impl SacredSword{EnumType::SacredSword};
static constexpr internal::Move_impl RazorShell{EnumType::RazorShell};
static constexpr internal::Move_impl HeatCrash{EnumType::HeatCrash};
static constexpr internal::Move_impl LeafTornado{EnumType::LeafTornado};
static constexpr internal::Move_impl Steamroller{EnumType::Steamroller};
static constexpr internal::Move_impl CottonGuard{EnumType::CottonGuard};
static constexpr internal::Move_impl NightDaze{EnumType::NightDaze};
static constexpr internal::Move_impl Psystrike{EnumType::Psystrike};
static constexpr internal::Move_impl TailSlap{EnumType::TailSlap};
static constexpr internal::Move_impl Hurricane{EnumType::Hurricane};
static constexpr internal::Move_impl HeadCharge{EnumType::HeadCharge};
static constexpr internal::Move_impl GearGrind{EnumType::GearGrind};
static constexpr internal::Move_impl SearingShot{EnumType::SearingShot};
static constexpr internal::Move_impl TechnoBlast{EnumType::TechnoBlast};
static constexpr internal::Move_impl RelicSong{EnumType::RelicSong};
static constexpr internal::Move_impl SecretSword{EnumType::SecretSword};
static constexpr internal::Move_impl Glaciate{EnumType::Glaciate};
static constexpr internal::Move_impl BoltStrike{EnumType::BoltStrike};
static constexpr internal::Move_impl BlueFlare{EnumType::BlueFlare};
static constexpr internal::Move_impl FieryDance{EnumType::FieryDance};
static constexpr internal::Move_impl FreezeShock{EnumType::FreezeShock};
static constexpr internal::Move_impl IceBurn{EnumType::IceBurn};
static constexpr internal::Move_impl Snarl{EnumType::Snarl};
static constexpr internal::Move_impl IcicleCrash{EnumType::IcicleCrash};
static constexpr internal::Move_impl Vcreate{EnumType::Vcreate};
static constexpr internal::Move_impl FusionFlare{EnumType::FusionFlare};
static constexpr internal::Move_impl FusionBolt{EnumType::FusionBolt};
static constexpr internal::Move_impl FlyingPress{EnumType::FlyingPress};
static constexpr internal::Move_impl MatBlock{EnumType::MatBlock};
static constexpr internal::Move_impl Belch{EnumType::Belch};
static constexpr internal::Move_impl Rototiller{EnumType::Rototiller};
static constexpr internal::Move_impl StickyWeb{EnumType::StickyWeb};
static constexpr internal::Move_impl FellStinger{EnumType::FellStinger};
static constexpr internal::Move_impl PhantomForce{EnumType::PhantomForce};
static constexpr internal::Move_impl TrickorTreat{EnumType::TrickorTreat};
static constexpr internal::Move_impl NobleRoar{EnumType::NobleRoar};
static constexpr internal::Move_impl IonDeluge{EnumType::IonDeluge};
static constexpr internal::Move_impl ParabolicCharge{EnumType::ParabolicCharge};
static constexpr internal::Move_impl ForestsCurse{EnumType::ForestsCurse};
static constexpr internal::Move_impl PetalBlizzard{EnumType::PetalBlizzard};
static constexpr internal::Move_impl FreezeDry{EnumType::FreezeDry};
static constexpr internal::Move_impl DisarmingVoice{EnumType::DisarmingVoice};
static constexpr internal::Move_impl PartingShot{EnumType::PartingShot};
static constexpr internal::Move_impl TopsyTurvy{EnumType::TopsyTurvy};
static constexpr internal::Move_impl DrainingKiss{EnumType::DrainingKiss};
static constexpr internal::Move_impl CraftyShield{EnumType::CraftyShield};
static constexpr internal::Move_impl FlowerShield{EnumType::FlowerShield};
static constexpr internal::Move_impl GrassyTerrain{EnumType::GrassyTerrain};
static constexpr internal::Move_impl MistyTerrain{EnumType::MistyTerrain};
static constexpr internal::Move_impl Electrify{EnumType::Electrify};
static constexpr internal::Move_impl PlayRough{EnumType::PlayRough};
static constexpr internal::Move_impl FairyWind{EnumType::FairyWind};
static constexpr internal::Move_impl Moonblast{EnumType::Moonblast};
static constexpr internal::Move_impl Boomburst{EnumType::Boomburst};
static constexpr internal::Move_impl FairyLock{EnumType::FairyLock};
static constexpr internal::Move_impl KingsShield{EnumType::KingsShield};
static constexpr internal::Move_impl PlayNice{EnumType::PlayNice};
static constexpr internal::Move_impl Confide{EnumType::Confide};
static constexpr internal::Move_impl DiamondStorm{EnumType::DiamondStorm};
static constexpr internal::Move_impl SteamEruption{EnumType::SteamEruption};
static constexpr internal::Move_impl HyperspaceHole{EnumType::HyperspaceHole};
static constexpr internal::Move_impl WaterShuriken{EnumType::WaterShuriken};
static constexpr internal::Move_impl MysticalFire{EnumType::MysticalFire};
static constexpr internal::Move_impl SpikyShield{EnumType::SpikyShield};
static constexpr internal::Move_impl AromaticMist{EnumType::AromaticMist};
static constexpr internal::Move_impl EerieImpulse{EnumType::EerieImpulse};
static constexpr internal::Move_impl VenomDrench{EnumType::VenomDrench};
static constexpr internal::Move_impl Powder{EnumType::Powder};
static constexpr internal::Move_impl Geomancy{EnumType::Geomancy};
static constexpr internal::Move_impl MagneticFlux{EnumType::MagneticFlux};
static constexpr internal::Move_impl HappyHour{EnumType::HappyHour};
static constexpr internal::Move_impl ElectricTerrain{EnumType::ElectricTerrain};
static constexpr internal::Move_impl DazzlingGleam{EnumType::DazzlingGleam};
static constexpr internal::Move_impl Celebrate{EnumType::Celebrate};
static constexpr internal::Move_impl HoldHands{EnumType::HoldHands};
static constexpr internal::Move_impl BabyDollEyes{EnumType::BabyDollEyes};
static constexpr internal::Move_impl Nuzzle{EnumType::Nuzzle};
static constexpr internal::Move_impl HoldBack{EnumType::HoldBack};
static constexpr internal::Move_impl Infestation{EnumType::Infestation};
static constexpr internal::Move_impl PowerUpPunch{EnumType::PowerUpPunch};
static constexpr internal::Move_impl OblivionWing{EnumType::OblivionWing};
static constexpr internal::Move_impl ThousandArrows{EnumType::ThousandArrows};
static constexpr internal::Move_impl ThousandWaves{EnumType::ThousandWaves};
static constexpr internal::Move_impl LandsWrath{EnumType::LandsWrath};
static constexpr internal::Move_impl LightofRuin{EnumType::LightofRuin};
static constexpr internal::Move_impl OriginPulse{EnumType::OriginPulse};
static constexpr internal::Move_impl PrecipiceBlades{EnumType::PrecipiceBlades};
static constexpr internal::Move_impl DragonAscent{EnumType::DragonAscent};
static constexpr internal::Move_impl HyperspaceFury{EnumType::HyperspaceFury};
static constexpr internal::Move_impl BreakneckBlitzA{EnumType::BreakneckBlitzA};
static constexpr internal::Move_impl BreakneckBlitzB{EnumType::BreakneckBlitzB};
static constexpr internal::Move_impl AllOutPummelingA{EnumType::AllOutPummelingA};
static constexpr internal::Move_impl AllOutPummelingB{EnumType::AllOutPummelingB};
static constexpr internal::Move_impl SupersonicSkystrikeA{EnumType::SupersonicSkystrikeA};
static constexpr internal::Move_impl SupersonicSkystrikeB{EnumType::SupersonicSkystrikeB};
static constexpr internal::Move_impl AcidDownpourA{EnumType::AcidDownpourA};
static constexpr internal::Move_impl AcidDownpourB{EnumType::AcidDownpourB};
static constexpr internal::Move_impl TectonicRageA{EnumType::TectonicRageA};
static constexpr internal::Move_impl TectonicRageB{EnumType::TectonicRageB};
static constexpr internal::Move_impl ContinentalCrushA{EnumType::ContinentalCrushA};
static constexpr internal::Move_impl ContinentalCrushB{EnumType::ContinentalCrushB};
static constexpr internal::Move_impl SavageSpinOutA{EnumType::SavageSpinOutA};
static constexpr internal::Move_impl SavageSpinOutB{EnumType::SavageSpinOutB};
static constexpr internal::Move_impl NeverEndingNightmareA{EnumType::NeverEndingNightmareA};
static constexpr internal::Move_impl NeverEndingNightmareB{EnumType::NeverEndingNightmareB};
static constexpr internal::Move_impl CorkscrewCrashA{EnumType::CorkscrewCrashA};
static constexpr internal::Move_impl CorkscrewCrashB{EnumType::CorkscrewCrashB};
static constexpr internal::Move_impl InfernoOverdriveA{EnumType::InfernoOverdriveA};
static constexpr internal::Move_impl InfernoOverdriveB{EnumType::InfernoOverdriveB};
static constexpr internal::Move_impl HydroVortexA{EnumType::HydroVortexA};
static constexpr internal::Move_impl HydroVortexB{EnumType::HydroVortexB};
static constexpr internal::Move_impl BloomDoomA{EnumType::BloomDoomA};
static constexpr internal::Move_impl BloomDoomB{EnumType::BloomDoomB};
static constexpr internal::Move_impl GigavoltHavocA{EnumType::GigavoltHavocA};
static constexpr internal::Move_impl GigavoltHavocB{EnumType::GigavoltHavocB};
static constexpr internal::Move_impl ShatteredPsycheA{EnumType::ShatteredPsycheA};
static constexpr internal::Move_impl ShatteredPsycheB{EnumType::ShatteredPsycheB};
static constexpr internal::Move_impl SubzeroSlammerA{EnumType::SubzeroSlammerA};
static constexpr internal::Move_impl SubzeroSlammerB{EnumType::SubzeroSlammerB};
static constexpr internal::Move_impl DevastatingDrakeA{EnumType::DevastatingDrakeA};
static constexpr internal::Move_impl DevastatingDrakeB{EnumType::DevastatingDrakeB};
static constexpr internal::Move_impl BlackHoleEclipseA{EnumType::BlackHoleEclipseA};
static constexpr internal::Move_impl BlackHoleEclipseB{EnumType::BlackHoleEclipseB};
static constexpr internal::Move_impl TwinkleTackleA{EnumType::TwinkleTackleA};
static constexpr internal::Move_impl TwinkleTackleB{EnumType::TwinkleTackleB};
static constexpr internal::Move_impl Catastropika{EnumType::Catastropika};
static constexpr internal::Move_impl ShoreUp{EnumType::ShoreUp};
static constexpr internal::Move_impl FirstImpression{EnumType::FirstImpression};
static constexpr internal::Move_impl BanefulBunker{EnumType::BanefulBunker};
static constexpr internal::Move_impl SpiritShackle{EnumType::SpiritShackle};
static constexpr internal::Move_impl DarkestLariat{EnumType::DarkestLariat};
static constexpr internal::Move_impl SparklingAria{EnumType::SparklingAria};
static constexpr internal::Move_impl IceHammer{EnumType::IceHammer};
static constexpr internal::Move_impl FloralHealing{EnumType::FloralHealing};
static constexpr internal::Move_impl HighHorsepower{EnumType::HighHorsepower};
static constexpr internal::Move_impl StrengthSap{EnumType::StrengthSap};
static constexpr internal::Move_impl SolarBlade{EnumType::SolarBlade};
static constexpr internal::Move_impl Leafage{EnumType::Leafage};
static constexpr internal::Move_impl Spotlight{EnumType::Spotlight};
static constexpr internal::Move_impl ToxicThread{EnumType::ToxicThread};
static constexpr internal::Move_impl LaserFocus{EnumType::LaserFocus};
static constexpr internal::Move_impl GearUp{EnumType::GearUp};
static constexpr internal::Move_impl ThroatChop{EnumType::ThroatChop};
static constexpr internal::Move_impl PollenPuff{EnumType::PollenPuff};
static constexpr internal::Move_impl AnchorShot{EnumType::AnchorShot};
static constexpr internal::Move_impl PsychicTerrain{EnumType::PsychicTerrain};
static constexpr internal::Move_impl Lunge{EnumType::Lunge};
static constexpr internal::Move_impl FireLash{EnumType::FireLash};
static constexpr internal::Move_impl PowerTrip{EnumType::PowerTrip};
static constexpr internal::Move_impl BurnUp{EnumType::BurnUp};
static constexpr internal::Move_impl SpeedSwap{EnumType::SpeedSwap};
static constexpr internal::Move_impl SmartStrike{EnumType::SmartStrike};
static constexpr internal::Move_impl Purify{EnumType::Purify};
static constexpr internal::Move_impl RevelationDance{EnumType::RevelationDance};
static constexpr internal::Move_impl CoreEnforcer{EnumType::CoreEnforcer};
static constexpr internal::Move_impl TropKick{EnumType::TropKick};
static constexpr internal::Move_impl Instruct{EnumType::Instruct};
static constexpr internal::Move_impl BeakBlast{EnumType::BeakBlast};
static constexpr internal::Move_impl ClangingScales{EnumType::ClangingScales};
static constexpr internal::Move_impl DragonHammer{EnumType::DragonHammer};
static constexpr internal::Move_impl BrutalSwing{EnumType::BrutalSwing};
static constexpr internal::Move_impl AuroraVeil{EnumType::AuroraVeil};
static constexpr internal::Move_impl SinisterArrowRaid{EnumType::SinisterArrowRaid};
static constexpr internal::Move_impl MaliciousMoonsault{EnumType::MaliciousMoonsault};
static constexpr internal::Move_impl OceanicOperetta{EnumType::OceanicOperetta};
static constexpr internal::Move_impl GuardianofAlola{EnumType::GuardianofAlola};
static constexpr internal::Move_impl SoulStealing7StarStrike{
EnumType::SoulStealing7StarStrike};
static constexpr internal::Move_impl StokedSparksurfer{EnumType::StokedSparksurfer};
static constexpr internal::Move_impl PulverizingPancake{EnumType::PulverizingPancake};
static constexpr internal::Move_impl ExtremeEvoboost{EnumType::ExtremeEvoboost};
static constexpr internal::Move_impl GenesisSupernova{EnumType::GenesisSupernova};
static constexpr internal::Move_impl ShellTrap{EnumType::ShellTrap};
static constexpr internal::Move_impl FleurCannon{EnumType::FleurCannon};
static constexpr internal::Move_impl PsychicFangs{EnumType::PsychicFangs};
static constexpr internal::Move_impl StompingTantrum{EnumType::StompingTantrum};
static constexpr internal::Move_impl ShadowBone{EnumType::ShadowBone};
static constexpr internal::Move_impl Accelerock{EnumType::Accelerock};
static constexpr internal::Move_impl Liquidation{EnumType::Liquidation};
static constexpr internal::Move_impl PrismaticLaser{EnumType::PrismaticLaser};
static constexpr internal::Move_impl SpectralThief{EnumType::SpectralThief};
static constexpr internal::Move_impl SunsteelStrike{EnumType::SunsteelStrike};
static constexpr internal::Move_impl MoongeistBeam{EnumType::MoongeistBeam};
static constexpr internal::Move_impl TearfulLook{EnumType::TearfulLook};
static constexpr internal::Move_impl ZingZap{EnumType::ZingZap};
static constexpr internal::Move_impl NaturesMadness{EnumType::NaturesMadness};
static constexpr internal::Move_impl MultiAttack{EnumType::MultiAttack};
static constexpr internal::Move_impl TenMillionVoltThunderbolt{
EnumType::TenMillionVoltThunderbolt};
static constexpr internal::Move_impl MindBlown{EnumType::MindBlown};
static constexpr internal::Move_impl PlasmaFists{EnumType::PlasmaFists};
static constexpr internal::Move_impl PhotonGeyser{EnumType::PhotonGeyser};
static constexpr internal::Move_impl LightThatBurnstheSky{EnumType::LightThatBurnstheSky};
static constexpr internal::Move_impl SearingSunrazeSmash{EnumType::SearingSunrazeSmash};
static constexpr internal::Move_impl MenacingMoonrazeMaelstrom{
EnumType::MenacingMoonrazeMaelstrom};
static constexpr internal::Move_impl LetsSnuggleForever{EnumType::LetsSnuggleForever};
static constexpr internal::Move_impl SplinteredStormshards{EnumType::SplinteredStormshards};
static constexpr internal::Move_impl ClangorousSoulblaze{EnumType::ClangorousSoulblaze};
static constexpr internal::Move_impl ZippyZap{EnumType::ZippyZap};
static constexpr internal::Move_impl SplishySplash{EnumType::SplishySplash};
static constexpr internal::Move_impl FloatyFall{EnumType::FloatyFall};
static constexpr internal::Move_impl PikaPapow{EnumType::PikaPapow};
static constexpr internal::Move_impl BouncyBubble{EnumType::BouncyBubble};
static constexpr internal::Move_impl BuzzyBuzz{EnumType::BuzzyBuzz};
static constexpr internal::Move_impl SizzlySlide{EnumType::SizzlySlide};
static constexpr internal::Move_impl GlitzyGlow{EnumType::GlitzyGlow};
static constexpr internal::Move_impl BaddyBad{EnumType::BaddyBad};
static constexpr internal::Move_impl SappySeed{EnumType::SappySeed};
static constexpr internal::Move_impl FreezyFrost{EnumType::FreezyFrost};
static constexpr internal::Move_impl SparklySwirl{EnumType::SparklySwirl};
static constexpr internal::Move_impl VeeveeVolley{EnumType::VeeveeVolley};
static constexpr internal::Move_impl DoubleIronBash{EnumType::DoubleIronBash};
static constexpr internal::Move_impl MaxGuard{EnumType::MaxGuard};
static constexpr internal::Move_impl DynamaxCannon{EnumType::DynamaxCannon};
static constexpr internal::Move_impl SnipeShot{EnumType::SnipeShot};
static constexpr internal::Move_impl JawLock{EnumType::JawLock};
static constexpr internal::Move_impl StuffCheeks{EnumType::StuffCheeks};
static constexpr internal::Move_impl NoRetreat{EnumType::NoRetreat};
static constexpr internal::Move_impl TarShot{EnumType::TarShot};
static constexpr internal::Move_impl MagicPowder{EnumType::MagicPowder};
static constexpr internal::Move_impl DragonDarts{EnumType::DragonDarts};
static constexpr internal::Move_impl Teatime{EnumType::Teatime};
static constexpr internal::Move_impl Octolock{EnumType::Octolock};
static constexpr internal::Move_impl BoltBeak{EnumType::BoltBeak};
static constexpr internal::Move_impl FishiousRend{EnumType::FishiousRend};
static constexpr internal::Move_impl CourtChange{EnumType::CourtChange};
static constexpr internal::Move_impl MaxFlare{EnumType::MaxFlare};
static constexpr internal::Move_impl MaxFlutterby{EnumType::MaxFlutterby};
static constexpr internal::Move_impl MaxLightning{EnumType::MaxLightning};
static constexpr internal::Move_impl MaxStrike{EnumType::MaxStrike};
static constexpr internal::Move_impl MaxKnuckle{EnumType::MaxKnuckle};
static constexpr internal::Move_impl MaxPhantasm{EnumType::MaxPhantasm};
static constexpr internal::Move_impl MaxHailstorm{EnumType::MaxHailstorm};
static constexpr internal::Move_impl MaxOoze{EnumType::MaxOoze};
static constexpr internal::Move_impl MaxGeyser{EnumType::MaxGeyser};
static constexpr internal::Move_impl MaxAirstream{EnumType::MaxAirstream};
static constexpr internal::Move_impl MaxStarfall{EnumType::MaxStarfall};
static constexpr internal::Move_impl MaxWyrmwind{EnumType::MaxWyrmwind};
static constexpr internal::Move_impl MaxMindstorm{EnumType::MaxMindstorm};
static constexpr internal::Move_impl MaxRockfall{EnumType::MaxRockfall};
static constexpr internal::Move_impl MaxQuake{EnumType::MaxQuake};
static constexpr internal::Move_impl MaxDarkness{EnumType::MaxDarkness};
static constexpr internal::Move_impl MaxOvergrowth{EnumType::MaxOvergrowth};
static constexpr internal::Move_impl MaxSteelspike{EnumType::MaxSteelspike};
static constexpr internal::Move_impl ClangorousSoul{EnumType::ClangorousSoul};
static constexpr internal::Move_impl BodyPress{EnumType::BodyPress};
static constexpr internal::Move_impl Decorate{EnumType::Decorate};
static constexpr internal::Move_impl DrumBeating{EnumType::DrumBeating};
static constexpr internal::Move_impl SnapTrap{EnumType::SnapTrap};
static constexpr internal::Move_impl PyroBall{EnumType::PyroBall};
static constexpr internal::Move_impl BehemothBlade{EnumType::BehemothBlade};
static constexpr internal::Move_impl BehemothBash{EnumType::BehemothBash};
static constexpr internal::Move_impl AuraWheel{EnumType::AuraWheel};
static constexpr internal::Move_impl BreakingSwipe{EnumType::BreakingSwipe};
static constexpr internal::Move_impl BranchPoke{EnumType::BranchPoke};
static constexpr internal::Move_impl Overdrive{EnumType::Overdrive};
static constexpr internal::Move_impl AppleAcid{EnumType::AppleAcid};
static constexpr internal::Move_impl GravApple{EnumType::GravApple};
static constexpr internal::Move_impl SpiritBreak{EnumType::SpiritBreak};
static constexpr internal::Move_impl StrangeSteam{EnumType::StrangeSteam};
static constexpr internal::Move_impl LifeDew{EnumType::LifeDew};
static constexpr internal::Move_impl Obstruct{EnumType::Obstruct};
static constexpr internal::Move_impl FalseSurrender{EnumType::FalseSurrender};
static constexpr internal::Move_impl MeteorAssault{EnumType::MeteorAssault};
static constexpr internal::Move_impl Eternabeam{EnumType::Eternabeam};
static constexpr internal::Move_impl SteelBeam{EnumType::SteelBeam};
static constexpr internal::Move_impl ExpandingForce{EnumType::ExpandingForce};
static constexpr internal::Move_impl SteelRoller{EnumType::SteelRoller};
static constexpr internal::Move_impl ScaleShot{EnumType::ScaleShot};
static constexpr internal::Move_impl MeteorBeam{EnumType::MeteorBeam};
static constexpr internal::Move_impl ShellSideArm{EnumType::ShellSideArm};
static constexpr internal::Move_impl MistyExplosion{EnumType::MistyExplosion};
static constexpr internal::Move_impl GrassyGlide{EnumType::GrassyGlide};
static constexpr internal::Move_impl RisingVoltage{EnumType::RisingVoltage};
static constexpr internal::Move_impl TerrainPulse{EnumType::TerrainPulse};
static constexpr internal::Move_impl SkitterSmack{EnumType::SkitterSmack};
static constexpr internal::Move_impl BurningJealousy{EnumType::BurningJealousy};
static constexpr internal::Move_impl LashOut{EnumType::LashOut};
static constexpr internal::Move_impl Poltergeist{EnumType::Poltergeist};
static constexpr internal::Move_impl CorrosiveGas{EnumType::CorrosiveGas};
static constexpr internal::Move_impl Coaching{EnumType::Coaching};
static constexpr internal::Move_impl FlipTurn{EnumType::FlipTurn};
static constexpr internal::Move_impl TripleAxel{EnumType::TripleAxel};
static constexpr internal::Move_impl DualWingbeat{EnumType::DualWingbeat};
static constexpr internal::Move_impl ScorchingSands{EnumType::ScorchingSands};
static constexpr internal::Move_impl JungleHealing{EnumType::JungleHealing};
static constexpr internal::Move_impl WickedBlow{EnumType::WickedBlow};
static constexpr internal::Move_impl SurgingStrikes{EnumType::SurgingStrikes};
static constexpr internal::Move_impl ThunderCage{EnumType::ThunderCage};
static constexpr internal::Move_impl DragonEnergy{EnumType::DragonEnergy};
static constexpr internal::Move_impl FreezingGlare{EnumType::FreezingGlare};
static constexpr internal::Move_impl FieryWrath{EnumType::FieryWrath};
static constexpr internal::Move_impl ThunderousKick{EnumType::ThunderousKick};
static constexpr internal::Move_impl GlacialLance{EnumType::GlacialLance};
static constexpr internal::Move_impl AstralBarrage{EnumType::AstralBarrage};
static constexpr internal::Move_impl EerieSpell{EnumType::EerieSpell};
static constexpr internal::Move_impl INVALID{EnumType::INVALID};
};
}
#endif
| 91,226
|
C++
|
.h
| 1,746
| 39.550974
| 100
| 0.652757
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,350
|
Nature.hpp
|
FlagBrew_PKSM-Core/include/enums/Nature.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef NATURE_HPP
#define NATURE_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Nature;
namespace internal
{
class Nature_impl
{
friend class pksm::Nature;
private:
enum class NatureEnum : u8
{
Hardy,
Lonely,
Brave,
Adamant,
Naughty,
Bold,
Docile,
Relaxed,
Impish,
Lax,
Timid,
Hasty,
Serious,
Jolly,
Naive,
Modest,
Mild,
Quiet,
Bashful,
Rash,
Calm,
Gentle,
Sassy,
Careful,
Quirky,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<NatureEnum>>::max()
} v;
constexpr explicit Nature_impl(NatureEnum v) : v(v) {}
constexpr Nature_impl(const Nature_impl&) = default;
constexpr Nature_impl(Nature_impl&&) = default;
constexpr Nature_impl& operator=(const Nature_impl&) = default;
constexpr Nature_impl& operator=(Nature_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator NatureEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Nature_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Nature
{
private:
internal::Nature_impl impl;
public:
using EnumType = internal::Nature_impl::NatureEnum;
constexpr Nature() noexcept : impl(EnumType{0}) {}
constexpr Nature(const internal::Nature_impl& impl) noexcept : impl(impl) {}
constexpr explicit Nature(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v})
{
}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Nature& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Nature_impl Hardy{EnumType::Hardy};
static constexpr internal::Nature_impl Lonely{EnumType::Lonely};
static constexpr internal::Nature_impl Brave{EnumType::Brave};
static constexpr internal::Nature_impl Adamant{EnumType::Adamant};
static constexpr internal::Nature_impl Naughty{EnumType::Naughty};
static constexpr internal::Nature_impl Bold{EnumType::Bold};
static constexpr internal::Nature_impl Docile{EnumType::Docile};
static constexpr internal::Nature_impl Relaxed{EnumType::Relaxed};
static constexpr internal::Nature_impl Impish{EnumType::Impish};
static constexpr internal::Nature_impl Lax{EnumType::Lax};
static constexpr internal::Nature_impl Timid{EnumType::Timid};
static constexpr internal::Nature_impl Hasty{EnumType::Hasty};
static constexpr internal::Nature_impl Serious{EnumType::Serious};
static constexpr internal::Nature_impl Jolly{EnumType::Jolly};
static constexpr internal::Nature_impl Naive{EnumType::Naive};
static constexpr internal::Nature_impl Modest{EnumType::Modest};
static constexpr internal::Nature_impl Mild{EnumType::Mild};
static constexpr internal::Nature_impl Quiet{EnumType::Quiet};
static constexpr internal::Nature_impl Bashful{EnumType::Bashful};
static constexpr internal::Nature_impl Rash{EnumType::Rash};
static constexpr internal::Nature_impl Calm{EnumType::Calm};
static constexpr internal::Nature_impl Gentle{EnumType::Gentle};
static constexpr internal::Nature_impl Sassy{EnumType::Sassy};
static constexpr internal::Nature_impl Careful{EnumType::Careful};
static constexpr internal::Nature_impl Quirky{EnumType::Quirky};
static constexpr internal::Nature_impl INVALID{EnumType::INVALID};
};
}
#endif
| 6,046
|
C++
|
.h
| 141
| 33.680851
| 98
| 0.631015
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,351
|
PKXHandler.hpp
|
FlagBrew_PKSM-Core/include/enums/PKXHandler.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef HANDLER_HPP
#define HANDLER_HPP
namespace pksm
{
enum class PKXHandler
{
OT,
NonOT
};
}
#endif
| 1,410
|
C++
|
.h
| 36
| 36.638889
| 76
| 0.720642
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,352
|
Ball.hpp
|
FlagBrew_PKSM-Core/include/enums/Ball.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef BALL_HPP
#define BALL_HPP
#include "enums/Language.hpp"
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <limits>
#include <type_traits>
namespace pksm
{
class Ball;
namespace internal
{
class Ball_impl
{
friend class pksm::Ball;
private:
enum class BallEnum : u8
{
None,
Master,
Ultra,
Great,
Poke,
Safari,
Net,
Dive,
Nest,
Repeat,
Timer,
Luxury,
Premier,
Dusk,
Heal,
Quick,
Cherish,
Fast,
Level,
Lure,
Heavy,
Love,
Friend,
Moon,
Sport,
Dream,
Beast,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<BallEnum>>::max()
} v;
constexpr explicit Ball_impl(BallEnum v) : v(v) {}
constexpr Ball_impl(const Ball_impl&) = default;
constexpr Ball_impl(Ball_impl&&) = default;
constexpr Ball_impl& operator=(const Ball_impl&) = default;
constexpr Ball_impl& operator=(Ball_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator BallEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ball_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Ball
{
private:
internal::Ball_impl impl;
public:
using EnumType = internal::Ball_impl::BallEnum;
constexpr Ball() noexcept : impl(EnumType::INVALID) {}
constexpr Ball(const internal::Ball_impl& impl) noexcept : impl(impl) {}
constexpr explicit Ball(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v}) {}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Ball& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Ball_impl None{EnumType::None};
static constexpr internal::Ball_impl Master{EnumType::Master};
static constexpr internal::Ball_impl Ultra{EnumType::Ultra};
static constexpr internal::Ball_impl Great{EnumType::Great};
static constexpr internal::Ball_impl Poke{EnumType::Poke};
static constexpr internal::Ball_impl Safari{EnumType::Safari};
static constexpr internal::Ball_impl Net{EnumType::Net};
static constexpr internal::Ball_impl Dive{EnumType::Dive};
static constexpr internal::Ball_impl Nest{EnumType::Nest};
static constexpr internal::Ball_impl Repeat{EnumType::Repeat};
static constexpr internal::Ball_impl Timer{EnumType::Timer};
static constexpr internal::Ball_impl Luxury{EnumType::Luxury};
static constexpr internal::Ball_impl Premier{EnumType::Premier};
static constexpr internal::Ball_impl Dusk{EnumType::Dusk};
static constexpr internal::Ball_impl Heal{EnumType::Heal};
static constexpr internal::Ball_impl Quick{EnumType::Quick};
static constexpr internal::Ball_impl Cherish{EnumType::Cherish};
static constexpr internal::Ball_impl Fast{EnumType::Fast};
static constexpr internal::Ball_impl Level{EnumType::Level};
static constexpr internal::Ball_impl Lure{EnumType::Lure};
static constexpr internal::Ball_impl Heavy{EnumType::Heavy};
static constexpr internal::Ball_impl Love{EnumType::Love};
static constexpr internal::Ball_impl Friend{EnumType::Friend};
static constexpr internal::Ball_impl Moon{EnumType::Moon};
static constexpr internal::Ball_impl Sport{EnumType::Sport};
static constexpr internal::Ball_impl Dream{EnumType::Dream};
static constexpr internal::Ball_impl Beast{EnumType::Beast};
static constexpr internal::Ball_impl INVALID{EnumType::INVALID};
};
}
#endif
| 6,066
|
C++
|
.h
| 143
| 33.111888
| 99
| 0.622478
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,353
|
Generation.hpp
|
FlagBrew_PKSM-Core/include/enums/Generation.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef GENERATION_HPP
#define GENERATION_HPP
#include "utils/coretypes.h"
#include <compare>
#include <concepts>
#include <string>
#include <type_traits>
namespace pksm
{
class Generation;
namespace internal
{
class Generation_impl
{
friend class pksm::Generation;
private:
// values MUST remain consistent
enum class GenerationEnum : u32
{
ONE = 7,
TWO = 8,
THREE = 6,
FOUR = 0,
FIVE = 1,
SIX = 2,
SEVEN = 3,
LGPE = 4,
EIGHT = 5,
UNUSED [[maybe_unused]] = 0xFFFFFFFF
} v;
constexpr explicit Generation_impl(GenerationEnum v) : v(v) {}
constexpr Generation_impl(const Generation_impl&) = default;
constexpr Generation_impl(Generation_impl&&) = default;
constexpr Generation_impl& operator=(const Generation_impl&) = default;
constexpr Generation_impl& operator=(Generation_impl&&) = default;
public:
template <std::integral T>
[[nodiscard]] constexpr explicit operator T() const noexcept
{
return T(v);
}
[[nodiscard]] constexpr explicit operator const char*() const noexcept
{
switch (v)
{
using enum GenerationEnum;
case LGPE:
return "LGPE";
case ONE:
return "1";
case TWO:
return "2";
case THREE:
return "3";
case FOUR:
return "4";
case FIVE:
return "5";
case SIX:
return "6";
case SEVEN:
return "7";
case EIGHT:
return "8";
case UNUSED:
return "INVALID";
}
return "INVALID";
}
[[nodiscard]] constexpr explicit operator std::string_view() const
{
return std::string_view{static_cast<const char*>(*this)};
}
[[nodiscard]] explicit operator std::string() const
{
return std::string{static_cast<const char*>(*this)};
}
[[nodiscard]] constexpr operator GenerationEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Generation_impl& other) const noexcept
{
switch (v)
{
using enum GenerationEnum;
case ONE:
switch (other.v)
{
case ONE:
return std::strong_ordering::equal;
case TWO:
case THREE:
case FOUR:
case FIVE:
case SIX:
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case TWO:
switch (other.v)
{
case ONE:
return std::strong_ordering::greater;
case TWO:
return std::strong_ordering::equal;
case THREE:
case FOUR:
case FIVE:
case SIX:
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case THREE:
switch (other.v)
{
case ONE:
case TWO:
return std::strong_ordering::greater;
case THREE:
return std::strong_ordering::equal;
case FOUR:
case FIVE:
case SIX:
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case FOUR:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
return std::strong_ordering::greater;
case FOUR:
return std::strong_ordering::equal;
case FIVE:
case SIX:
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case FIVE:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
case FOUR:
return std::strong_ordering::greater;
case FIVE:
return std::strong_ordering::equal;
case SIX:
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case SIX:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
case FOUR:
case FIVE:
return std::strong_ordering::greater;
case SIX:
return std::strong_ordering::equal;
case SEVEN:
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case SEVEN:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
case FOUR:
case FIVE:
case SIX:
return std::strong_ordering::greater;
case SEVEN:
return std::strong_ordering::equal;
case LGPE:
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case LGPE:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
case FOUR:
case FIVE:
case SIX:
case SEVEN:
return std::strong_ordering::greater;
case LGPE:
return std::strong_ordering::equal;
case EIGHT:
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case EIGHT:
switch (other.v)
{
case ONE:
case TWO:
case THREE:
case FOUR:
case FIVE:
case SIX:
case SEVEN:
case LGPE:
return std::strong_ordering::greater;
case EIGHT:
return std::strong_ordering::equal;
case UNUSED:
return std::strong_ordering::less;
}
return std::strong_ordering::less;
case UNUSED:
return other.v == UNUSED ? std::strong_ordering::equal
: std::strong_ordering::greater;
}
return v <=> other.v;
}
};
}
class Generation
{
private:
internal::Generation_impl impl;
public:
using EnumType = internal::Generation_impl::GenerationEnum;
constexpr Generation() noexcept : impl(EnumType::UNUSED) {}
constexpr Generation(const internal::Generation_impl& impl) noexcept : impl(impl) {}
constexpr explicit Generation(std::underlying_type_t<EnumType> v) noexcept
: impl(EnumType{v})
{
}
template <std::integral T>
[[nodiscard]] constexpr explicit operator T() const noexcept
{
return static_cast<T>(impl);
}
[[nodiscard]] constexpr operator EnumType() const noexcept
{
return static_cast<EnumType>(impl);
}
[[nodiscard]] constexpr explicit operator const char*() const noexcept
{
return static_cast<const char*>(impl);
}
[[nodiscard]] constexpr explicit operator std::string_view() const
{
return static_cast<std::string_view>(impl);
}
[[nodiscard]] explicit operator std::string() const
{
return static_cast<std::string>(impl);
}
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Generation& other) const noexcept = default;
[[nodiscard]] static constexpr Generation fromString(const std::string_view& str)
{
if (str == "1")
{
return Generation::ONE;
}
else if (str == "2")
{
return Generation::TWO;
}
else if (str == "3")
{
return Generation::THREE;
}
else if (str == "4")
{
return Generation::FOUR;
}
else if (str == "5")
{
return Generation::FIVE;
}
else if (str == "6")
{
return Generation::SIX;
}
else if (str == "7")
{
return Generation::SEVEN;
}
else if (str == "LGPE")
{
return Generation::LGPE;
}
else if (str == "8")
{
return Generation::EIGHT;
}
return Generation::UNUSED;
}
static constexpr internal::Generation_impl ONE{EnumType::ONE};
static constexpr internal::Generation_impl TWO{EnumType::TWO};
static constexpr internal::Generation_impl THREE{EnumType::THREE};
static constexpr internal::Generation_impl FOUR{EnumType::FOUR};
static constexpr internal::Generation_impl FIVE{EnumType::FIVE};
static constexpr internal::Generation_impl SIX{EnumType::SIX};
static constexpr internal::Generation_impl SEVEN{EnumType::SEVEN};
static constexpr internal::Generation_impl LGPE{EnumType::LGPE};
static constexpr internal::Generation_impl EIGHT{EnumType::EIGHT};
static constexpr internal::Generation_impl UNUSED{EnumType::UNUSED};
};
}
#endif
| 14,602
|
C++
|
.h
| 366
| 20.773224
| 92
| 0.410543
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,354
|
Type.hpp
|
FlagBrew_PKSM-Core/include/enums/Type.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef TYPE_HPP
#define TYPE_HPP
#include "enums/Language.hpp"
#include <compare>
#include <concepts>
#include <limits>
#include <string>
#include <type_traits>
namespace pksm
{
class Type;
namespace internal
{
class Type_impl
{
friend class pksm::Type;
private:
enum class TypeEnum : u8
{
Normal,
Fighting,
Flying,
Poison,
Ground,
Rock,
Bug,
Ghost,
Steel,
Fire,
Water,
Grass,
Electric,
Psychic,
Ice,
Dragon,
Dark,
Fairy,
INVALID [[maybe_unused]] =
std::numeric_limits<std::underlying_type_t<TypeEnum>>::max()
} v;
constexpr explicit Type_impl(TypeEnum v) : v(v) {}
constexpr Type_impl(const Type_impl&) = default;
constexpr Type_impl(Type_impl&&) = default;
constexpr Type_impl& operator=(const Type_impl&) = default;
constexpr Type_impl& operator=(Type_impl&&) = default;
public:
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(v);
}
constexpr operator TypeEnum() const noexcept { return v; }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Type_impl& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const;
};
}
class Type
{
private:
internal::Type_impl impl;
public:
using EnumType = internal::Type_impl::TypeEnum;
constexpr Type() noexcept : impl(EnumType{0}) {}
constexpr Type(const internal::Type_impl& impl) noexcept : impl(impl) {}
constexpr explicit Type(std::underlying_type_t<EnumType> v) noexcept : impl(EnumType{v}) {}
template <std::integral T>
constexpr explicit operator T() const noexcept
{
return T(impl);
}
constexpr operator EnumType() const noexcept { return static_cast<EnumType>(impl); }
[[nodiscard]] constexpr std::strong_ordering operator<=>(
const Type& other) const noexcept = default;
[[nodiscard]] const std::string& localize(Language lang) const
{
return impl.localize(lang);
}
static constexpr internal::Type_impl Normal{EnumType::Normal};
static constexpr internal::Type_impl Fighting{EnumType::Fighting};
static constexpr internal::Type_impl Flying{EnumType::Flying};
static constexpr internal::Type_impl Poison{EnumType::Poison};
static constexpr internal::Type_impl Ground{EnumType::Ground};
static constexpr internal::Type_impl Rock{EnumType::Rock};
static constexpr internal::Type_impl Bug{EnumType::Bug};
static constexpr internal::Type_impl Ghost{EnumType::Ghost};
static constexpr internal::Type_impl Steel{EnumType::Steel};
static constexpr internal::Type_impl Fire{EnumType::Fire};
static constexpr internal::Type_impl Water{EnumType::Water};
static constexpr internal::Type_impl Grass{EnumType::Grass};
static constexpr internal::Type_impl Electric{EnumType::Electric};
static constexpr internal::Type_impl Psychic{EnumType::Psychic};
static constexpr internal::Type_impl Ice{EnumType::Ice};
static constexpr internal::Type_impl Dragon{EnumType::Dragon};
static constexpr internal::Type_impl Dark{EnumType::Dark};
static constexpr internal::Type_impl Fairy{EnumType::Fairy};
static constexpr internal::Type_impl INVALID{EnumType::INVALID};
};
}
#endif
| 5,248
|
C++
|
.h
| 125
| 33.208
| 99
| 0.627182
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,355
|
i18n_internal.hpp
|
FlagBrew_PKSM-Core/source/i18n/i18n_internal.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef I18N_INTERNAL_HPP
#define I18N_INTERNAL_HPP
#include "enums/Language.hpp"
#include "utils/_map_macro.hpp"
#include "utils/coretypes.h"
#include "utils/i18n.hpp"
#include "utils/io.hpp"
#include <atomic>
#include <functional>
#include <time.h>
#include <unordered_map>
#ifndef _PKSMCORE_CONFIGURED
#include "PKSMCORE_CONFIG.h"
#endif
#ifndef _PKSMCORE_GETLINE_FUNC
#define _PKSMCORE_GETLINE_FUNC getline
#endif
#ifdef _PKSMCORE_EXTRA_LANGUAGES
#define LANGUAGES_TO_USE JPN, ENG, FRE, ITA, GER, SPA, KOR, CHS, CHT, _PKSMCORE_EXTRA_LANGUAGES
#else
#define LANGUAGES_TO_USE JPN, ENG, FRE, ITA, GER, SPA, KOR, CHS, CHT
#endif
#define MAKE_GENERIC_LANGMAP(lang) \
ret.insert_or_assign(pksm::Language::lang, decltype(ret)::mapped_type{});
namespace i18n
{
enum class LangState : u8
{
UNINITIALIZED,
INITIALIZING,
INITIALIZED
};
inline const std::string emptyString = "";
inline const std::map<u16, std::string> emptyU16Map = {};
inline const std::map<u8, std::string> emptyU8Map = {};
#ifdef _PKSMCORE_DISABLE_THREAD_SAFETY
extern std::unordered_map<pksm::Language, LangState> languages;
#else
extern std::unordered_map<pksm::Language, std::atomic<LangState>> languages;
#endif
inline void checkInitialized(pksm::Language lang)
{
auto found = languages.find(lang);
if (found == languages.end())
{
found = languages.find(pksm::Language::ENG);
}
if (found->second == LangState::UNINITIALIZED)
{
i18n::init(found->first);
}
#ifndef _PKSMCORE_DISABLE_THREAD_SAFETY
while (found->second != LangState::INITIALIZED)
{
found->second.wait(LangState::INITIALIZING);
}
#endif
}
std::string folder(pksm::Language lang);
void load(pksm::Language lang, const std::string& name, std::vector<std::string>& array);
template <std::integral T>
void load(pksm::Language lang, const std::string& name, std::map<T, std::string>& map)
{
std::string path = io::exists(_PKSMCORE_LANG_FOLDER + folder(lang) + name)
? _PKSMCORE_LANG_FOLDER + folder(lang) + name
: _PKSMCORE_LANG_FOLDER + folder(pksm::Language::ENG) + name;
std::string tmp;
FILE* values = fopen(path.c_str(), "rt");
if (values)
{
if (ferror(values))
{
fclose(values);
return;
}
char* data = static_cast<char*>(malloc(128));
size_t size = 0;
while (!feof(values) && !ferror(values))
{
size = std::max(size, (size_t)128);
if (_PKSMCORE_GETLINE_FUNC(&data, &size, values) >= 0)
{
tmp = std::string(data);
tmp = tmp.substr(0, tmp.find('\n'));
// 0 automatically deduces the base: 0x prefix makes it hexadecimal, 0 prefix
// makes it octal
T val = std::stoll(tmp.substr(0, tmp.find('|')), 0, 0);
map[val] = tmp.substr(0, tmp.find('\r')).substr(tmp.find('|') + 1);
}
else
{
break;
}
}
fclose(values);
free(data);
}
}
}
#endif
| 4,753
|
C++
|
.h
| 125
| 30.936
| 100
| 0.606113
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,356
|
personal2.h
|
FlagBrew_PKSM-Core/source/personal/personal2.h
|
constexpr int personal2_size = 2520;
constexpr int personal2_entrysize = 10;
| 82
|
C++
|
.h
| 2
| 40
| 41
| 0.7625
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,357
|
personal8.h
|
FlagBrew_PKSM-Core/source/personal/personal8.h
|
constexpr int personal8_size = 47680;
constexpr int personal8_entrysize = 40;
| 83
|
C++
|
.h
| 2
| 40.5
| 42
| 0.765432
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,358
|
personal4.h
|
FlagBrew_PKSM-Core/source/personal/personal4.h
|
constexpr int personal4_size = 8128;
constexpr int personal4_entrysize = 16;
| 82
|
C++
|
.h
| 2
| 40
| 41
| 0.7625
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,359
|
personal7.h
|
FlagBrew_PKSM-Core/source/personal/personal7.h
|
constexpr int personal7_size = 16592;
constexpr int personal7_entrysize = 17;
| 83
|
C++
|
.h
| 2
| 40.5
| 42
| 0.765432
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,360
|
personal3.h
|
FlagBrew_PKSM-Core/source/personal/personal3.h
|
constexpr int personal3_size = 5031;
constexpr int personal3_entrysize = 13;
| 82
|
C++
|
.h
| 2
| 40
| 41
| 0.7625
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,361
|
personal5.h
|
FlagBrew_PKSM-Core/source/personal/personal5.h
|
constexpr int personal5_size = 12053;
constexpr int personal5_entrysize = 17;
| 83
|
C++
|
.h
| 2
| 40.5
| 42
| 0.765432
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,362
|
personal6.h
|
FlagBrew_PKSM-Core/source/personal/personal6.h
|
constexpr int personal6_size = 14042;
constexpr int personal6_entrysize = 17;
| 83
|
C++
|
.h
| 2
| 40.5
| 42
| 0.765432
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,363
|
personal7b.h
|
FlagBrew_PKSM-Core/source/personal/personal7b.h
|
constexpr int personal7b_size = 16660;
constexpr int personal7b_entrysize = 17;
| 85
|
C++
|
.h
| 2
| 41.5
| 43
| 0.771084
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.