Adapting music to web, fixing scripts, fixing bug in initial state
This commit is contained in:
1 parent
c3f449b999
commit
5ecf5fb9d7
43 files changed
+875
-388
No files matched your search
@@ -83,29 +83,40 @@ void GameState::save(nlohmann::json& out) const
|
||||
|
||||
void GameState::load(const nlohmann::json& in)
|
||||
{
|
||||
//logger() << "GameState::load step 1" << std::endl;
|
||||
|
||||
// --- World ---
|
||||
currentLocationName = in.value("currentLocationName", currentLocationName);
|
||||
isDarklands = in.value("isDarklands", isDarklands);
|
||||
isNight = in.value("isNight", isNight);
|
||||
isDawn = in.value("isDawn", isDawn);
|
||||
|
||||
//() << "GameState::load step 2" << std::endl;
|
||||
|
||||
|
||||
// --- Player resources ---
|
||||
playerHp = in.value("playerHp", playerHp);
|
||||
playerMaxHp = in.value("playerMaxHp", playerMaxHp);
|
||||
money = in.value("money", money);
|
||||
|
||||
//logger() << "GameState::load step 3" << std::endl;
|
||||
|
||||
// --- Script globals ---
|
||||
globalInts.clear();
|
||||
if (in.contains("globalInts") && in["globalInts"].is_object()) {
|
||||
for (const auto& [k, v] : in["globalInts"].items())
|
||||
globalInts[k] = v.get<int>();
|
||||
}
|
||||
//logger() << "GameState::load step 4" << std::endl;
|
||||
|
||||
globalFloats.clear();
|
||||
if (in.contains("globalFloats") && in["globalFloats"].is_object()) {
|
||||
for (const auto& [k, v] : in["globalFloats"].items())
|
||||
globalFloats[k] = v.get<float>();
|
||||
}
|
||||
|
||||
//logger() << "GameState::load step 5" << std::endl;
|
||||
|
||||
// --- Tutorial ---
|
||||
tutorialStep = static_cast<TutorialStep>(in.value("tutorialStep", static_cast<int>(tutorialStep)));
|
||||
uniIntTutorialState = static_cast<UniIntTutorialState>(in.value("uniIntTutorialState", static_cast<int>(uniIntTutorialState)));
|
||||
@@ -115,15 +126,21 @@ void GameState::load(const nlohmann::json& in)
|
||||
tutorialJournalScreenOpened = in.value("tutorialJournalScreenOpened", tutorialJournalScreenOpened);
|
||||
tutorialNeedOpenTaxiScreen = in.value("tutorialNeedOpenTaxiScreen", tutorialNeedOpenTaxiScreen);
|
||||
|
||||
//logger() << "GameState::load step 6" << std::endl;
|
||||
|
||||
// --- Phone / chat ---
|
||||
if (in.contains("chatUnread") && in["chatUnread"].is_array()) {
|
||||
for (int i = 0; i < 3 && i < static_cast<int>(in["chatUnread"].size()); ++i)
|
||||
chatUnread[i] = in["chatUnread"][i].get<bool>();
|
||||
}
|
||||
//logger() << "GameState::load step 7" << std::endl;
|
||||
|
||||
if (in.contains("chatPreviewMsg") && in["chatPreviewMsg"].is_array()) {
|
||||
for (int i = 0; i < 3 && i < static_cast<int>(in["chatPreviewMsg"].size()); ++i)
|
||||
chatPreviewMsg[i] = in["chatPreviewMsg"][i].get<std::string>();
|
||||
}
|
||||
//logger() << "GameState::load step 8" << std::endl;
|
||||
|
||||
if (in.contains("chatHistory") && in["chatHistory"].is_array()) {
|
||||
for (int i = 0; i < 3 && i < static_cast<int>(in["chatHistory"].size()); ++i) {
|
||||
chatHistory[i].clear();
|
||||
@@ -136,26 +153,38 @@ void GameState::load(const nlohmann::json& in)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//logger() << "GameState::load step 8" << std::endl;
|
||||
|
||||
// --- Inventory ---
|
||||
if (in.contains("inventory")) inventory.load(in["inventory"]);
|
||||
|
||||
//logger() << "GameState::load step 9" << std::endl;
|
||||
|
||||
// --- Quest journal ---
|
||||
if (in.contains("questJournal")) questJournal.load(in["questJournal"]);
|
||||
|
||||
logger() << "GameState::load step 10" << std::endl;
|
||||
|
||||
// --- Locations ---
|
||||
if (in.contains("locations") && in["locations"].is_object()) {
|
||||
for (const auto& [name, locJson] : in["locations"].items()) {
|
||||
//logger() << "GameState::load step 10.1: " << name << std::endl;
|
||||
|
||||
auto it = locations.find(name);
|
||||
if (it != locations.end() && it->second) {
|
||||
it->second->load(locJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
//logger() << "GameState::load step 11" << std::endl;
|
||||
|
||||
|
||||
// --- Taxi ---
|
||||
taxiIsCalled = in.value("taxiIsCalled", taxiIsCalled);
|
||||
//logger() << "GameState::load step 12" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
} // namespace FRG
|
||||
Reference in new issue
Block a user