void Item_factory::load_gun(JsonObject& jo) { it_gun* gun_template = new it_gun(); gun_template->ammo = jo.get_string("ammo"); gun_template->skill_used = Skill::skill(jo.get_string("skill")); gun_template->dmg_bonus = jo.get_int("ranged_damage"); gun_template->range = jo.get_int("range"); gun_template->dispersion = jo.get_int("dispersion"); gun_template->recoil = jo.get_int("recoil"); gun_template->durability = jo.get_int("durability"); gun_template->burst = jo.get_int("burst"); gun_template->clip = jo.get_int("clip_size"); gun_template->reload_time = jo.get_int("reload"); gun_template->pierce = jo.get_int("pierce", 0); gun_template->ammo_effects = jo.get_tags("ammo_effects"); if ( jo.has_array("valid_mod_locations") ) { JsonArray jarr = jo.get_array("valid_mod_locations"); while (jarr.has_more()){ JsonArray curr = jarr.next_array(); gun_template->valid_mod_locations.insert(std::pair<std::string, int>(curr.get_string(0), curr.get_int(1))); gun_template->occupied_mod_locations.insert(std::pair<std::string, int>(curr.get_string(0), 0)); } } itype *new_item_template = gun_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_container(JsonObject &jo) { it_container* container_template = new it_container(); container_template->contains = jo.get_int("contains"); itype *new_item_template = container_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_tool(JsonObject& jo) { it_tool* tool_template = new it_tool(); tool_template->ammo = jo.get_string("ammo"); tool_template->max_charges = jo.get_int("max_charges"); tool_template->def_charges = jo.get_int("initial_charges"); tool_template->charges_per_use = jo.get_int("charges_per_use"); tool_template->turns_per_charge = jo.get_int("turns_per_charge"); tool_template->revert_to = jo.get_string("revert_to"); itype *new_item_template = tool_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_book(JsonObject& jo) { it_book* book_template = new it_book(); book_template->level = jo.get_int("max_level"); book_template->req = jo.get_int("required_level"); book_template->fun = jo.get_int("fun"); book_template->intel = jo.get_int("intelligence"); book_template->time = jo.get_int("time"); book_template->type = Skill::skill(jo.get_string("skill")); book_template->chapters = jo.get_int("chapters", -1); itype *new_item_template = book_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_armor(JsonObject& jo) { it_armor* armor_template = new it_armor(); armor_template->encumber = jo.get_int("encumbrance"); armor_template->coverage = jo.get_int("coverage"); armor_template->thickness = jo.get_int("material_thickness"); armor_template->env_resist = jo.get_int("enviromental_protection"); armor_template->warmth = jo.get_int("warmth"); armor_template->storage = jo.get_int("storage"); armor_template->power_armor = jo.get_bool("power_armor", false); armor_template->covers = jo.has_member("covers") ? flags_from_json(jo, "covers", "bodyparts") : 0; itype *new_item_template = armor_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_ammo(JsonObject& jo) { it_ammo* ammo_template = new it_ammo(); ammo_template->type = jo.get_string("ammo_type"); ammo_template->casing = jo.get_string("casing", ""); ammo_template->damage = jo.get_int("damage"); ammo_template->pierce = jo.get_int("pierce"); ammo_template->range = jo.get_int("range"); ammo_template->dispersion = jo.get_int("dispersion"); ammo_template->recoil = jo.get_int("recoil"); ammo_template->count = jo.get_int("count"); ammo_template->stack_size = jo.get_int("stack_size", ammo_template->count); ammo_template->ammo_effects = jo.get_tags("effects"); itype *new_item_template = ammo_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_veh_part(JsonObject& jo) { it_var_veh_part* veh_par_template = new it_var_veh_part(); veh_par_template->min_bigness = jo.get_int("min-bigness"); veh_par_template->max_bigness = jo.get_int("max-bigness"); const std::string big_aspect = jo.get_string("bigness-aspect"); if (big_aspect == "WHEEL_DIAMETER") { veh_par_template->bigness_aspect = BIGNESS_WHEEL_DIAMETER; veh_par_template->engine = false; } else if (big_aspect == "ENGINE_DISPLACEMENT") { veh_par_template->bigness_aspect = BIGNESS_ENGINE_DISPLACEMENT; veh_par_template->engine = true; } else { throw std::string("invalid bigness-aspect: ") + big_aspect; } load_basic_info(jo, veh_par_template); }
void Item_factory::load_gunmod(JsonObject& jo) { it_gunmod* gunmod_template = new it_gunmod(); gunmod_template->damage = jo.get_int("damage_modifier", 0); gunmod_template->loudness = jo.get_int("loudness_modifier", 0); gunmod_template->newtype = jo.get_string("ammo_modifier"); gunmod_template->used_on_pistol = is_mod_target(jo, "mod_targets", "pistol"); gunmod_template->used_on_shotgun = is_mod_target(jo, "mod_targets", "shotgun"); gunmod_template->used_on_smg = is_mod_target(jo, "mod_targets", "smg"); gunmod_template->used_on_rifle = is_mod_target(jo, "mod_targets", "rifle"); gunmod_template->dispersion = jo.get_int("dispersion_modifier", 0); gunmod_template->recoil = jo.get_int("recoil_modifier", 0); gunmod_template->burst = jo.get_int("burst_modifier", 0); gunmod_template->clip = jo.get_int("clip_size_modifier", 0); gunmod_template->acceptible_ammo_types = jo.get_tags("acceptable_ammo"); itype *new_item_template = gunmod_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_gun(JsonObject& jo) { it_gun* gun_template = new it_gun(); gun_template->ammo = jo.get_string("ammo"); gun_template->skill_used = Skill::skill(jo.get_string("skill")); gun_template->dmg_bonus = jo.get_int("ranged_damage"); gun_template->range = jo.get_int("range"); gun_template->dispersion = jo.get_int("dispersion"); gun_template->recoil = jo.get_int("recoil"); gun_template->durability = jo.get_int("durability"); gun_template->burst = jo.get_int("burst"); gun_template->clip = jo.get_int("clip_size"); gun_template->reload_time = jo.get_int("reload"); gun_template->pierce = jo.get_int("pierce", 0); gun_template->ammo_effects = jo.get_tags("ammo_effects"); itype *new_item_template = gun_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_comestible(JsonObject& jo) { it_comest* comest_template = new it_comest(); comest_template->comesttype = jo.get_string("comestible_type"); comest_template->tool = jo.get_string("tool", "null"); comest_template->container = jo.get_string("container", "null"); comest_template->quench = jo.get_int("quench", 0); comest_template->nutr = jo.get_int("nutrition", 0); comest_template->spoils = jo.get_int("spoils_in", 0); comest_template->addict = jo.get_int("addiction_potential", 0); comest_template->charges = jo.get_int("charges", 0); if(jo.has_member("stack_size")) { comest_template->stack_size = jo.get_int("stack_size"); } else { comest_template->stack_size = comest_template->charges; } comest_template->stim = jo.get_int("stim", 0); comest_template->healthy = jo.get_int("heal", 0); comest_template->fun = jo.get_int("fun", 0); comest_template->add = addiction_type(jo.get_string("addiction_type")); itype *new_item_template = comest_template; load_basic_info(jo, new_item_template); }
void Item_factory::load_generic(JsonObject& jo) { itype *new_item_template = new itype(); load_basic_info(jo, new_item_template); }
void Item_factory::load_bionic(JsonObject& jo) { it_bionic* bionic_template = new it_bionic(); bionic_template->difficulty = jo.get_int("difficulty"); load_basic_info(jo, bionic_template); }