void mutation_branch::load( JsonObject &jsobj ) { const std::string id = jsobj.get_string( "id" ); mutation_branch &new_mut = mutation_data[id]; JsonArray jsarr; new_mut.name = _(jsobj.get_string("name").c_str()); new_mut.description = _(jsobj.get_string("description").c_str()); new_mut.points = jsobj.get_int("points"); new_mut.visibility = jsobj.get_int("visibility", 0); new_mut.ugliness = jsobj.get_int("ugliness", 0); new_mut.startingtrait = jsobj.get_bool("starting_trait", false); new_mut.mixed_effect = jsobj.get_bool("mixed_effect", false); new_mut.activated = jsobj.get_bool("active", false); new_mut.cost = jsobj.get_int("cost", 0); new_mut.cooldown = jsobj.get_int("time",0); new_mut.hunger = jsobj.get_bool("hunger",false); new_mut.thirst = jsobj.get_bool("thirst",false); new_mut.fatigue = jsobj.get_bool("fatigue",false); new_mut.valid = jsobj.get_bool("valid", true); new_mut.purifiable = jsobj.get_bool("purifiable", true); new_mut.initial_ma_styles = jsobj.get_string_array( "initial_ma_styles" ); new_mut.threshold = jsobj.get_bool("threshold", false); new_mut.profession = jsobj.get_bool("profession", false); load_mutation_mods(jsobj, "passive_mods", new_mut.mods); /* Not currently supported due to inability to save active mutation state load_mutation_mods(jsobj, "active_mods", new_mut.mods); */ new_mut.prereqs = jsobj.get_string_array( "prereqs" ); // Helps to be able to have a trait require more than one other trait // (Individual prereq-lists are "OR", not "AND".) // Traits shoud NOT appear in both lists for a given mutation, unless // you want that trait to satisfy both requirements. // These are additional to the first list. new_mut.prereqs2 = jsobj.get_string_array( "prereqs2" ); // Dedicated-purpose prereq slot for Threshold mutations // Stuff like Huge might fit in more than one mutcat post-threshold, so yeah new_mut.threshreq = jsobj.get_string_array( "threshreq" ); new_mut.cancels = jsobj.get_string_array( "cancels" ); new_mut.replacements = jsobj.get_string_array( "changes_to" ); new_mut.additions = jsobj.get_string_array( "leads_to" ); jsarr = jsobj.get_array("category"); while (jsarr.has_more()) { std::string s = jsarr.next_string(); new_mut.category.push_back(s); mutations_category[s].push_back(id); } jsarr = jsobj.get_array("wet_protection"); while (jsarr.has_more()) { JsonObject jo = jsarr.next_object(); std::string part_id = jo.get_string("part"); int ignored = jo.get_int("ignored", 0); int neutral = jo.get_int("neutral", 0); int good = jo.get_int("good", 0); tripoint protect = tripoint(ignored, neutral, good); new_mut.protection[part_id] = mutation_wet(body_parts[part_id], protect); } }
void load_mutation(JsonObject &jsobj) { trait new_trait; JsonArray jsarr; std::string id = jsobj.get_string("id"); new_trait.name = _(jsobj.get_string("name").c_str()); new_trait.description = _(jsobj.get_string("description").c_str()); new_trait.points = jsobj.get_int("points"); new_trait.visibility = jsobj.get_int("visibility", 0); new_trait.ugliness = jsobj.get_int("ugliness", 0); new_trait.startingtrait = jsobj.get_bool("starting_trait", false); traits[id] = new_trait; mutation_data[id].valid = jsobj.get_bool("valid", true); mutation_data[id].purifiable = jsobj.get_bool("purifiable", true); mutation_data[id].threshold = jsobj.get_bool("threshold", false); jsarr = jsobj.get_array("prereqs"); while (jsarr.has_more()) { mutation_data[id].prereqs.push_back(jsarr.next_string()); } // Helps to be able to have a trait require more than one other trait // (Individual prereq-lists are "OR", not "AND".) // Traits shoud NOT appear in both lists for a given mutation, unless // you want that trait to satisfy both requirements. // These are additional to the first list, and will likely NOT be regained // if you lose the mutation they prereq'd for. jsarr = jsobj.get_array("prereqs2"); while (jsarr.has_more()) { mutation_data[id].prereqs2.push_back(jsarr.next_string()); } // Dedicated-purpose prereq slot for Threshold mutations jsarr = jsobj.get_array("threshreq"); // Stuff like Huge might fit in more than one mutcat post-threshold, so yeah while (jsarr.has_more()) { mutation_data[id].threshreq.push_back(jsarr.next_string()); } jsarr = jsobj.get_array("cancels"); while (jsarr.has_more()) { mutation_data[id].cancels.push_back(jsarr.next_string()); } jsarr = jsobj.get_array("changes_to"); while (jsarr.has_more()) { mutation_data[id].replacements.push_back(jsarr.next_string()); } jsarr = jsobj.get_array("leads_to"); while (jsarr.has_more()) { mutation_data[id].additions.push_back(jsarr.next_string()); } jsarr = jsobj.get_array("category"); while (jsarr.has_more()) { std::string s = jsarr.next_string(); mutation_data[id].category.push_back(s); mutations_category[s].push_back(id); } jsarr = jsobj.get_array("wet_protection"); while (jsarr.has_more()) { JsonObject jo = jsarr.next_object(); std::string part_id = jo.get_string("part"); int ignored = jo.get_int("ignored", 0); int neutral = jo.get_int("neutral", 0); int good = jo.get_int("good", 0); tripoint protect = tripoint(ignored, neutral, good); mutation_data[id].protection[part_id] = mutation_wet(body_parts[part_id], protect); } }