mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Added Rando::Context::ParseTricksJson.
This commit is contained in:
parent
713d34a12c
commit
11bdd48f43
4 changed files with 29 additions and 0 deletions
|
@ -399,6 +399,7 @@ void Context::ParseSpoiler(const char* spoilerFileName) {
|
|||
Rando::Settings::GetInstance()->ParseJson(spoilerFileJson);
|
||||
ParseItemLocationsJson(spoilerFileJson);
|
||||
ParseHintJson(spoilerFileJson);
|
||||
ParseTricksJson(spoilerFileJson);
|
||||
mEntranceShuffler->ParseJson(spoilerFileJson);
|
||||
mDungeons->ParseJson(spoilerFileJson);
|
||||
mTrials->ParseJson(spoilerFileJson);
|
||||
|
@ -467,6 +468,17 @@ void Context::ParseHintJson(nlohmann::json spoilerFileJson) {
|
|||
CreateStaticHints();
|
||||
}
|
||||
|
||||
void Context::ParseTricksJson(nlohmann::json spoilerFileJson) {
|
||||
nlohmann::json enabledTricksJson = spoilerFileJson["enabledTricks"];
|
||||
const auto& settings = Rando::Settings::GetInstance();
|
||||
for (auto it : enabledTricksJson) {
|
||||
int rt = settings->GetRandomizerTrickByName(it);
|
||||
if (rt != -1) {
|
||||
mTrickOptions[rt].Set(RO_GENERIC_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<EntranceShuffler> Context::GetEntranceShuffler() {
|
||||
return mEntranceShuffler;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ class Context {
|
|||
void ParseItemLocationsJson(nlohmann::json spoilerFileJson);
|
||||
void WriteHintJson(nlohmann::ordered_json& spoilerFileJson);
|
||||
void ParseHintJson(nlohmann::json spoilerFileJson);
|
||||
void ParseTricksJson(nlohmann::json spoilerFileJson);
|
||||
std::map<RandomizerCheck, ItemOverride> overrides = {};
|
||||
std::vector<std::vector<RandomizerCheck>> playthroughLocations = {};
|
||||
std::vector<RandomizerCheck> everyPossibleLocation = {};
|
||||
|
|
|
@ -1739,6 +1739,14 @@ TrickOption& Settings::GetTrickOption(const RandomizerTrick key) {
|
|||
return mTrickOptions[key];
|
||||
}
|
||||
|
||||
int Settings::GetRandomizerTrickByName(const std::string& name) {
|
||||
const auto& it = mTrickNameToEnum.find(name);
|
||||
if (it == mTrickNameToEnum.end()) {
|
||||
return -1;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void Context::ResetTrickOptions() {
|
||||
for (int count = 0; count < RT_MAX; count++) {
|
||||
mTrickOptions[count].Set(0); // RANDOTODO this can probably be done better
|
||||
|
|
|
@ -50,6 +50,14 @@ class Settings {
|
|||
*/
|
||||
TrickOption& GetTrickOption(RandomizerTrick key);
|
||||
|
||||
/**
|
||||
* @brief Get the RandomizerTrick corresponding to the provided name.
|
||||
*
|
||||
* @param name
|
||||
* @return int RandomizerTrick index or -1 if not found
|
||||
*/
|
||||
int GetRandomizerTrickByName(const std::string& name);
|
||||
|
||||
/**
|
||||
* @brief Returns a reference to the entire array of options.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue