forked from Martmists-GH/BDSP_rombase
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
011647b
commit 43c77ff
Showing
5 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "externals/il2cpp-api.h" | ||
#include "memory/json.h" | ||
#include "memory/vector.h" | ||
|
||
namespace RomData | ||
{ | ||
struct ShinyRates | ||
{ | ||
uint32_t baseRolls; | ||
uint32_t charmRolls; | ||
uint32_t masudaRolls; | ||
}; | ||
|
||
JSON_TEMPLATE | ||
void to_json(GENERIC_JSON& j, const ShinyRates& s) { | ||
j = nn::json { | ||
{"baseRolls", s.baseRolls}, | ||
{"charmRolls", s.charmRolls}, | ||
{"masudaRolls", s.masudaRolls}, | ||
}; | ||
} | ||
|
||
JSON_TEMPLATE | ||
void from_json(const GENERIC_JSON& j, ShinyRates& s) { | ||
j.at("baseRolls").get_to(s.baseRolls); | ||
j.at("charmRolls").get_to(s.charmRolls); | ||
j.at("masudaRolls").get_to(s.masudaRolls); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "exlaunch.hpp" | ||
|
||
#include "helpers.h" | ||
#include "memory/json.h" | ||
#include "memory/string.h" | ||
|
||
#include "romdata/data/ShinyRates.h" | ||
|
||
#include "logger/logger.h" | ||
|
||
static RomData::ShinyRates shinyRatesData; | ||
static bool isShinyRatesDataLoaded = false; | ||
|
||
const char* shinyRatesFolderPath = "rom:/Data/ExtraData/ShinyRates/"; | ||
|
||
void LoadShinyRates() | ||
{ | ||
nn::string filePath(shinyRatesFolderPath); | ||
filePath.append("shiny_rates.json"); | ||
Logger::log("Checking Shiny Rates for %s!\n", filePath.c_str()); | ||
|
||
nn::json j = FsHelper::loadJsonFileFromPath(filePath.c_str()); | ||
if (j != nullptr && !j.is_discarded()) | ||
{ | ||
Logger::log("Parsed Shiny Rates for %s!\n", filePath.c_str()); | ||
shinyRatesData = j.get<RomData::ShinyRates>(); | ||
isShinyRatesDataLoaded = true; | ||
} | ||
else | ||
{ | ||
Logger::log("Error when parsing Shiny Rates data!\n"); | ||
// Default - Lumi odds | ||
shinyRatesData = { | ||
.baseRolls = 8, | ||
.charmRolls = 2, | ||
.masudaRolls = 6, | ||
}; | ||
isShinyRatesDataLoaded = true; | ||
} | ||
} | ||
|
||
RomData::ShinyRates GetShinyRates() | ||
{ | ||
if (!isShinyRatesDataLoaded) | ||
LoadShinyRates(); | ||
|
||
return shinyRatesData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters