本文整理汇总了C++中JsonArray::next_int方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::next_int方法的具体用法?C++ JsonArray::next_int怎么用?C++ JsonArray::next_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::next_int方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
void it_artifact_tool::deserialize(JsonObject &jo)
{
id = jo.get_string("id");
name = jo.get_string("name");
description = jo.get_string("description");
sym = jo.get_int("sym");
color = int_to_color(jo.get_int("color"));
price = jo.get_int("price");
m1 = jo.get_string("m1");
m2 = jo.get_string("m2");
volume = jo.get_int("volume");
weight = jo.get_int("weight");
melee_dam = jo.get_int("melee_dam");
melee_cut = jo.get_int("melee_cut");
m_to_hit = jo.get_int("m_to_hit");
item_tags = jo.get_tags("item_flags");
max_charges = jo.get_long("max_charges");
def_charges = jo.get_long("def_charges");
std::vector<int> rand_charges;
JsonArray jarr = jo.get_array("rand_charges");
while (jarr.has_more()){
rand_charges.push_back(jarr.next_long());
}
charges_per_use = jo.get_int("charges_per_use");
turns_per_charge = jo.get_int("turns_per_charge");
ammo = jo.get_string("ammo");
revert_to = jo.get_string("revert_to");
charge_type = (art_charge)jo.get_int("charge_type");
JsonArray ja = jo.get_array("effects_wielded");
while (ja.has_more()) {
effects_wielded.push_back((art_effect_passive)ja.next_int());
}
ja = jo.get_array("effects_activated");
while (ja.has_more()) {
effects_activated.push_back((art_effect_active)ja.next_int());
}
ja = jo.get_array("effects_carried");
while (ja.has_more()) {
effects_carried.push_back((art_effect_passive)ja.next_int());
}
}
示例2: LoadMonsterGroup
void MonsterGroupManager::LoadMonsterGroup(JsonObject &jo)
{
MonsterGroup g;
g.name = mongroup_id( jo.get_string("name") );
g.defaultMonster = mtype_id( jo.get_string("default") );
if (jo.has_array("monsters")) {
JsonArray monarr = jo.get_array("monsters");
while (monarr.has_more()) {
JsonObject mon = monarr.next_object();
const mtype_id name = mtype_id( mon.get_string("monster") );
int freq = mon.get_int("freq");
int cost = mon.get_int("cost_multiplier");
int pack_min = 1;
int pack_max = 1;
if(mon.has_member("pack_size")) {
JsonArray packarr = mon.get_array("pack_size");
pack_min = packarr.next_int();
pack_max = packarr.next_int();
}
int starts = 0;
int ends = 0;
if(mon.has_member("starts")) {
if (ACTIVE_WORLD_OPTIONS["MONSTER_UPGRADE_FACTOR"] > 0) {
starts = mon.get_int("starts") * ACTIVE_WORLD_OPTIONS["MONSTER_UPGRADE_FACTOR"];
} else {
// Default value if the monster upgrade factor is set to 0.0 - off
starts = mon.get_int("starts");
}
}
if(mon.has_member("ends")) {
if (ACTIVE_WORLD_OPTIONS["MONSTER_UPGRADE_FACTOR"] > 0) {
ends = mon.get_int("ends") * ACTIVE_WORLD_OPTIONS["MONSTER_UPGRADE_FACTOR"];
} else {
// Default value if the monster upgrade factor is set to 0.0 - off
ends = mon.get_int("ends");
}
}
MonsterGroupEntry new_mon_group = MonsterGroupEntry(name, freq, cost, pack_min, pack_max, starts,
ends);
if(mon.has_member("conditions")) {
JsonArray conditions_arr = mon.get_array("conditions");
while(conditions_arr.has_more()) {
new_mon_group.conditions.push_back(conditions_arr.next_string());
}
}
g.monsters.push_back(new_mon_group);
}
}
g.replace_monster_group = jo.get_bool("replace_monster_group", false);
g.new_monster_group = mongroup_id( jo.get_string("new_monster_group_id", mongroup_id::NULL_ID.str() ) );
g.monster_group_time = jo.get_int("replacement_time", 0);
g.is_safe = jo.get_bool( "is_safe", false );
monsterGroupMap[g.name] = g;
}
示例3: while
std::vector<int> JsonObject::get_int_array(const std::string &name)
{
JsonArray ja = get_array(name);
std::vector<int> ret;
while (ja.has_more()) {
ret.push_back(ja.next_int());
}
return ret;
}
示例4: deserialize
void it_artifact_armor::deserialize(JsonObject &jo)
{
id = jo.get_string("id");
name = jo.get_string("name");
description = jo.get_string("description");
sym = jo.get_int("sym");
color = int_to_color(jo.get_int("color"));
price = jo.get_int("price");
// LEGACY: Since it seems artifacts get serialized out to disk, and they're
// dynamic, we need to allow for them to be read from disk for, oh, I guess
// quite some time. Loading and saving once will write things out as a JSON
// array.
if (jo.has_string("m1")) {
materials.push_back(jo.get_string("m1"));
}
if (jo.has_string("m2")) {
materials.push_back(jo.get_string("m2"));
}
// Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and
// a materials array in our serialized objects at the same time.
if (jo.has_array("materials")) {
JsonArray jarr = jo.get_array("materials");
for (int i = 0; i < jarr.size(); ++i) {
materials.push_back(jarr.get_string(i));
}
}
if (materials.size() == 0) {
// I don't think we need this, but a lot of code seems to want at least
// one material and I'm not sure I found every single corner case.
materials.push_back("null");
}
volume = jo.get_int("volume");
weight = jo.get_int("weight");
melee_dam = jo.get_int("melee_dam");
melee_cut = jo.get_int("melee_cut");
m_to_hit = jo.get_int("m_to_hit");
item_tags = jo.get_tags("item_flags");
jo.read( "covers", covers);
encumber = jo.get_int("encumber");
coverage = jo.get_int("coverage");
thickness = jo.get_int("material_thickness");
env_resist = jo.get_int("env_resist");
warmth = jo.get_int("warmth");
storage = jo.get_int("storage");
power_armor = jo.get_bool("power_armor");
JsonArray ja = jo.get_array("effects_worn");
while (ja.has_more()) {
effects_worn.push_back((art_effect_passive)ja.next_int());
}
}
示例5: while
VehicleFacings::VehicleFacings(JsonObject &jo, const std::string &key)
{
if(jo.has_array(key)) {
JsonArray jpos = jo.get_array(key);
while (jpos.has_more()) {
values.push_back(jpos.next_int());
}
}
else {
values.push_back(jo.get_int(key));
}
}
示例6: LoadMonsterGroup
void MonsterGroupManager::LoadMonsterGroup(JsonObject &jo)
{
MonsterGroup g;
g.name = jo.get_string("name");
g.defaultMonster = jo.get_string("default");
if (jo.has_array("monsters")) {
JsonArray monarr = jo.get_array("monsters");
while (monarr.has_more()) {
JsonObject mon = monarr.next_object();
std::string name = mon.get_string("monster");
int freq = mon.get_int("freq");
int cost = mon.get_int("cost_multiplier");
int pack_min = 1;
int pack_max = 1;
if(mon.has_member("pack_size")) {
JsonArray packarr = mon.get_array("pack_size");
pack_min = packarr.next_int();
pack_max = packarr.next_int();
}
int starts = 0;
int ends = 0;
if(mon.has_member("starts")) {
starts = mon.get_int("starts") * ACTIVE_WORLD_OPTIONS["MONSTER_GROUP_DIFFICULTY"];
}
if(mon.has_member("ends")) {
ends = mon.get_int("ends") * ACTIVE_WORLD_OPTIONS["MONSTER_GROUP_DIFFICULTY"];
}
MonsterGroupEntry new_mon_group = MonsterGroupEntry(name, freq, cost, pack_min, pack_max, starts,
ends);
if(mon.has_member("conditions")) {
JsonArray conditions_arr = mon.get_array("conditions");
while(conditions_arr.has_more()) {
new_mon_group.conditions.push_back(conditions_arr.next_string());
}
}
g.monsters.push_back(new_mon_group);
}
}
g.replace_monster_group = jo.get_bool("replace_monster_group", false);
g.new_monster_group = jo.get_string("new_monster_group_id", "NULL");
g.monster_group_time = jo.get_int("replacement_time", 0);
monsterGroupMap[g.name] = g;
}
示例7: LoadMonsterGroup
void MonsterGroupManager::LoadMonsterGroup(JsonObject &jo)
{
MonsterGroup g;
g.name = jo.get_string("name");
g.defaultMonster = jo.get_string("default");
if (jo.has_array("monsters")){
JsonArray monarr = jo.get_array("monsters");
while (monarr.has_more()) {
JsonObject mon = monarr.next_object();
std::string name = mon.get_string("monster");
int freq = mon.get_int("freq");
int cost = mon.get_int("cost_multiplier");
int pack_min = 1;
int pack_max = 1;
if(mon.has_member("pack_size")){
JsonArray packarr = mon.get_array("pack_size");
pack_min = packarr.next_int();
pack_max = packarr.next_int();
}
int starts = 0;
int ends = 0;
if(mon.has_member("starts")){
starts = mon.get_int("starts");
}
if(mon.has_member("ends")){
ends = mon.get_int("ends");
}
MonsterGroupEntry new_mon_group = MonsterGroupEntry(name,freq,cost,pack_min,pack_max,starts,ends);
if(mon.has_member("conditions")){
JsonArray conditions_arr = mon.get_array("conditions");
while(conditions_arr.has_more()){
new_mon_group.conditions.push_back(conditions_arr.next_string());
}
}
g.monsters.push_back(new_mon_group);
}
}
monsterGroupMap[g.name] = g;
}
示例8: json_load_invcache
/*
* Invlet cache: player specific, thus not wrapped in inventory::json_load/save
*/
void inventory::json_load_invcache(JsonIn &jsin)
{
try {
JsonArray ja = jsin.get_array();
while ( ja.has_more() ) {
JsonObject jo = ja.next_object();
std::set<std::string> members = jo.get_member_names();
for (std::set<std::string>::iterator it = members.begin();
it != members.end(); ++it) {
std::vector<char> vect;
JsonArray pvect = jo.get_array(*it);
while ( pvect.has_more() ) {
vect.push_back( pvect.next_int() );
}
invlet_cache[*it] = vect;
}
}
} catch (std::string jsonerr) {
debugmsg("bad invcache json:\n%s", jsonerr.c_str() );
}
}
示例9: LoadMonsterGroup
void MonsterGroupManager::LoadMonsterGroup( JsonObject &jo )
{
float mon_upgrade_factor = get_option<float>( "MONSTER_UPGRADE_FACTOR" );
MonsterGroup g;
g.name = mongroup_id( jo.get_string( "name" ) );
bool extending = false; //If already a group with that name, add to it instead of overwriting it
if( monsterGroupMap.count( g.name ) != 0 && !jo.get_bool( "override", false ) ) {
g = monsterGroupMap[g.name];
extending = true;
}
if( !extending
|| jo.has_string( "default" ) ) { //Not mandatory to specify default if extending existing group
g.defaultMonster = mtype_id( jo.get_string( "default" ) );
}
g.is_animal = jo.get_bool( "is_animal", false );
if( jo.has_array( "monsters" ) ) {
JsonArray monarr = jo.get_array( "monsters" );
while( monarr.has_more() ) {
JsonObject mon = monarr.next_object();
const mtype_id name = mtype_id( mon.get_string( "monster" ) );
int freq = mon.get_int( "freq" );
int cost = mon.get_int( "cost_multiplier" );
int pack_min = 1;
int pack_max = 1;
if( mon.has_member( "pack_size" ) ) {
JsonArray packarr = mon.get_array( "pack_size" );
pack_min = packarr.next_int();
pack_max = packarr.next_int();
}
static const time_duration tdfactor = 1_hours;
time_duration starts = 0_turns;
time_duration ends = 0_turns;
if( mon.has_member( "starts" ) ) {
starts = tdfactor * mon.get_int( "starts" ) * ( mon_upgrade_factor > 0 ? mon_upgrade_factor : 1 );
}
if( mon.has_member( "ends" ) ) {
ends = tdfactor * mon.get_int( "ends" ) * ( mon_upgrade_factor > 0 ? mon_upgrade_factor : 1 );
}
MonsterGroupEntry new_mon_group = MonsterGroupEntry( name, freq, cost, pack_min, pack_max, starts,
ends );
if( mon.has_member( "conditions" ) ) {
JsonArray conditions_arr = mon.get_array( "conditions" );
while( conditions_arr.has_more() ) {
new_mon_group.conditions.push_back( conditions_arr.next_string() );
}
}
g.monsters.push_back( new_mon_group );
}
}
g.replace_monster_group = jo.get_bool( "replace_monster_group", false );
g.new_monster_group = mongroup_id( jo.get_string( "new_monster_group_id",
mongroup_id::NULL_ID().str() ) );
assign( jo, "replacement_time", g.monster_group_time, false, 1_days );
g.is_safe = jo.get_bool( "is_safe", false );
g.freq_total = jo.get_int( "freq_total", ( extending ? g.freq_total : 1000 ) );
if( jo.get_bool( "auto_total", false ) ) { //Fit the max size to the sum of all freqs
int total = 0;
for( MonsterGroupEntry &mon : g.monsters ) {
total += mon.frequency;
}
g.freq_total = total;
}
monsterGroupMap[g.name] = g;
}
示例10: load
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.starts_active = jsobj.get_bool("starts_active", false);
new_mut.destroys_gear = jsobj.get_bool("destroys_gear", false);
new_mut.allow_soft_gear = jsobj.get_bool("allow_soft_gear", 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);
for( auto & s : jsobj.get_string_array( "initial_ma_styles" ) ) {
new_mut.initial_ma_styles.push_back( matype_id( s ) );
}
JsonArray bodytemp_array = jsobj.get_array( "bodytemp_modifiers" );
if( bodytemp_array.has_more() ) {
new_mut.bodytemp_min = bodytemp_array.get_int( 0 );
new_mut.bodytemp_max = bodytemp_array.get_int( 1 );
}
new_mut.bodytemp_sleep = jsobj.get_int( "bodytemp_sleep", 0 );
new_mut.threshold = jsobj.get_bool("threshold", false);
new_mut.profession = jsobj.get_bool("profession", false);
auto vr = jsobj.get_array( "vitamin_rates" );
while( vr.has_more() ) {
auto pair = vr.next_array();
new_mut.vitamin_rates[ vitamin_id( pair.get_string( 0 ) ) ] = pair.get_int( 1 );
}
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" );
new_mut.flags = jsobj.get_tags( "flags" );
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[get_body_part_token( part_id )] = protect;
}
jsarr = jsobj.get_array("encumbrance_always");
while (jsarr.has_more()) {
JsonArray jo = jsarr.next_array();
std::string part_id = jo.next_string();
int enc = jo.next_int();
new_mut.encumbrance_always[get_body_part_token( part_id )] = enc;
}
jsarr = jsobj.get_array("encumbrance_covered");
while (jsarr.has_more()) {
JsonArray jo = jsarr.next_array();
std::string part_id = jo.next_string();
int enc = jo.next_int();
new_mut.encumbrance_covered[get_body_part_token( part_id )] = enc;
}
jsarr = jsobj.get_array("restricts_gear");
while( jsarr.has_more() ) {
new_mut.restricts_gear.insert( get_body_part_token( jsarr.next_string() ) );
}
jsarr = jsobj.get_array( "armor" );
//.........这里部分代码省略.........
示例11: load
//.........这里部分代码省略.........
optional( jo, was_loaded, "weight_capacity_modifier", weight_capacity_modifier, 1.0f );
optional( jo, was_loaded, "hearing_modifier", hearing_modifier, 1.0f );
optional( jo, was_loaded, "noise_modifier", noise_modifier, 1.0f );
optional( jo, was_loaded, "metabolism_modifier", metabolism_modifier, 0.0f );
optional( jo, was_loaded, "thirst_modifier", thirst_modifier, 0.0f );
optional( jo, was_loaded, "fatigue_modifier", fatigue_modifier, 0.0f );
optional( jo, was_loaded, "fatigue_regen_modifier", fatigue_regen_modifier, 0.0f );
optional( jo, was_loaded, "stamina_regen_modifier", stamina_regen_modifier, 0.0f );
optional( jo, was_loaded, "overmap_sight", overmap_sight, 0.0f );
optional( jo, was_loaded, "overmap_multiplier", overmap_multiplier, 1.0f );
if( jo.has_object( "social_modifiers" ) ) {
JsonObject sm = jo.get_object( "social_modifiers" );
social_mods = load_mutation_social_mods( sm );
}
load_mutation_mods( jo, "passive_mods", mods );
/* Not currently supported due to inability to save active mutation state
load_mutation_mods(jsobj, "active_mods", new_mut.mods); */
optional( jo, was_loaded, "prereqs", prereqs );
optional( jo, was_loaded, "prereqs2", prereqs2 );
optional( jo, was_loaded, "threshreq", threshreq );
optional( jo, was_loaded, "cancels", cancels );
optional( jo, was_loaded, "changes_to", replacements );
optional( jo, was_loaded, "leads_to", additions );
optional( jo, was_loaded, "flags", flags );
optional( jo, was_loaded, "types", types );
auto jsarr = jo.get_array( "category" );
while( jsarr.has_more() ) {
std::string s = jsarr.next_string();
category.push_back( s );
mutations_category[s].push_back( trait_id( id ) );
}
jsarr = jo.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 );
protection[get_body_part_token( part_id )] = protect;
}
jsarr = jo.get_array( "encumbrance_always" );
while( jsarr.has_more() ) {
JsonArray jo = jsarr.next_array();
std::string part_id = jo.next_string();
int enc = jo.next_int();
encumbrance_always[get_body_part_token( part_id )] = enc;
}
jsarr = jo.get_array( "encumbrance_covered" );
while( jsarr.has_more() ) {
JsonArray jo = jsarr.next_array();
std::string part_id = jo.next_string();
int enc = jo.next_int();
encumbrance_covered[get_body_part_token( part_id )] = enc;
}
jsarr = jo.get_array( "restricts_gear" );
while( jsarr.has_more() ) {
restricts_gear.insert( get_body_part_token( jsarr.next_string() ) );
}
jsarr = jo.get_array( "armor" );
while( jsarr.has_more() ) {
JsonObject jo = jsarr.next_object();
auto parts = jo.get_tags( "parts" );
std::set<body_part> bps;
for( const std::string &part_string : parts ) {
if( part_string == "ALL" ) {
// Shorthand, since many mutations protect whole body
bps.insert( all_body_parts.begin(), all_body_parts.end() );
} else {
bps.insert( get_body_part_token( part_string ) );
}
}
resistances res = load_resistances_instance( jo );
for( body_part bp : bps ) {
armor[ bp ] = res;
}
}
if( jo.has_array( "attacks" ) ) {
jsarr = jo.get_array( "attacks" );
while( jsarr.has_more() ) {
JsonObject jo = jsarr.next_object();
attacks_granted.emplace_back( load_mutation_attack( jo ) );
}
} else if( jo.has_object( "attacks" ) ) {
JsonObject attack = jo.get_object( "attacks" );
attacks_granted.emplace_back( load_mutation_attack( attack ) );
}
}