本文整理汇总了C++中JsonObject::get_tags方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::get_tags方法的具体用法?C++ JsonObject::get_tags怎么用?C++ JsonObject::get_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::get_tags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_technique
void load_technique(JsonObject &jo)
{
ma_technique tec;
tec.id = jo.get_string("id");
tec.name = jo.get_string("name", "");
if (!tec.name.empty()) {
tec.name = _(tec.name.c_str());
}
JsonArray jsarr = jo.get_array("messages");
while (jsarr.has_more()) {
tec.messages.push_back(_(jsarr.next_string().c_str()));
}
tec.reqs.unarmed_allowed = jo.get_bool("unarmed_allowed", false);
tec.reqs.melee_allowed = jo.get_bool("melee_allowed", false);
tec.reqs.min_melee = jo.get_int("min_melee", 0);
tec.reqs.min_unarmed = jo.get_int("min_unarmed", 0);
tec.reqs.min_bashing = jo.get_int("min_bashing", 0);
tec.reqs.min_cutting = jo.get_int("min_cutting", 0);
tec.reqs.min_stabbing = jo.get_int("min_stabbing", 0);
tec.reqs.min_bashing_damage = jo.get_int("min_bashing_damage", 0);
tec.reqs.min_cutting_damage = jo.get_int("min_cutting_damage", 0);
tec.reqs.req_buffs = jo.get_tags("req_buffs");
tec.reqs.req_flags = jo.get_tags("req_flags");
tec.crit_tec = jo.get_bool("crit_tec", false);
tec.defensive = jo.get_bool("defensive", false);
tec.disarms = jo.get_bool("disarms", false);
tec.dodge_counter = jo.get_bool("dodge_counter", false);
tec.block_counter = jo.get_bool("block_counter", false);
tec.miss_recovery = jo.get_bool("miss_recovery", false);
tec.grab_break = jo.get_bool("grab_break", false);
tec.flaming = jo.get_bool("flaming", false);
tec.hit = jo.get_int("pain", 0);
tec.bash = jo.get_int("bash", 0);
tec.cut = jo.get_int("cut", 0);
tec.pain = jo.get_int("pain", 0);
tec.weighting = jo.get_int("weighting", 1);
tec.bash_mult = jo.get_float("bash_mult", 1.0);
tec.cut_mult = jo.get_float("cut_mult", 1.0);
tec.speed_mult = jo.get_float("speed_mult", 1.0);
tec.down_dur = jo.get_int("down_dur", 0);
tec.stun_dur = jo.get_int("stun_dur", 0);
tec.knockback_dist = jo.get_int("knockback_dist", 0);
tec.knockback_spread = jo.get_int("knockback_spread", 0);
tec.aoe = jo.get_string("aoe", "");
tec.flags = jo.get_tags("flags");
ma_techniques[tec.id] = tec;
}
示例2: load_species
void MonsterGenerator::load_species(JsonObject &jo)
{
// id, flags, triggers (anger, placate, fear)
std::string sid;
if (jo.has_member("id")) {
sid = jo.get_string("id");
int species_num = mon_species.size();
if (mon_species.count(sid) > 0) {
species_num = mon_species[sid]->short_id; // Keep it or weird things may happen
delete mon_species[sid];
}
std::set<std::string> sflags, sanger, sfear, splacate;
sflags = jo.get_tags("flags");
sanger = jo.get_tags("anger_triggers");
sfear = jo.get_tags("fear_triggers");
splacate = jo.get_tags("placate_triggers");
std::set<m_flag> flags = get_set_from_tags(sflags, flag_map, MF_NULL);
std::set<monster_trigger> anger, fear, placate;
anger = get_set_from_tags(sanger, trigger_map, MTRIG_NULL);
fear = get_set_from_tags(sfear, trigger_map, MTRIG_NULL);
placate = get_set_from_tags(splacate, trigger_map, MTRIG_NULL);
species_type *new_species = new species_type(species_num, sid, flags, anger, fear, placate);
mon_species[sid] = new_species;
}
}
示例3: load_monster_faction
void monfactions::load_monster_faction( JsonObject &jo )
{
// Factions inherit values from their parent factions - this is set during finalization
std::set< std::string > by_mood, neutral, friendly;
by_mood = jo.get_tags( "by_mood" );
neutral = jo.get_tags( "neutral" );
friendly = jo.get_tags( "friendly" );
// Need to make sure adding new factions won't invalidate our current faction's reference
// That +1 is for base faction
faction_list.reserve( faction_list.size() + by_mood.size() + neutral.size() + friendly.size() + 1 );
prealloc( by_mood );
prealloc( neutral );
prealloc( friendly );
std::string name = jo.get_string( "name" );
mfaction_id cur_id = get_or_add_faction( mfaction_str_id( name ) );
std::string base_faction = jo.get_string( "base_faction", "" );
mfaction_id base_id = get_or_add_faction( mfaction_str_id( base_faction ) );
// Don't get the reference until here (to avoid vector reallocation messing it up)
monfaction &faction = faction_list[cur_id];
faction.base_faction = base_id;
add_to_attitude_map( by_mood, faction.attitude_map, MFA_BY_MOOD );
add_to_attitude_map( neutral, faction.attitude_map, MFA_NEUTRAL );
add_to_attitude_map( friendly, faction.attitude_map, MFA_FRIENDLY );
}
示例4: load_gun
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);
}
示例5: 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");
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");
covers = jo.get_int("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());
}
}
示例6: load_martial_art
void load_martial_art(JsonObject &jo)
{
martialart ma;
JsonArray jsarr;
ma.id = jo.get_string("id");
ma.name = _(jo.get_string("name").c_str());
ma.description = _(jo.get_string("description").c_str());
jsarr = jo.get_array("static_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.static_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("onmove_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.onmove_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("onhit_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.onhit_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("onattack_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.onattack_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("ondodge_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.ondodge_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("onblock_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.onblock_buffs.push_back(load_buff(jsobj));
}
jsarr = jo.get_array("ongethit_buffs");
while (jsarr.has_more()) {
JsonObject jsobj = jsarr.next_object();
ma.onblock_buffs.push_back(load_buff(jsobj));
}
ma.techniques = jo.get_tags("techniques");
ma.leg_block = jo.get_int("leg_block", -1);
ma.arm_block = jo.get_int("arm_block", -1);
martialarts[ma.id] = ma;
}
示例7: remove_special_attacks
void mtype::remove_special_attacks( JsonObject &jo, const std::string &member_name )
{
for( const std::string &name : jo.get_tags( member_name ) ) {
special_attacks.erase( name );
const auto iter = std::find( special_attacks_names.begin(), special_attacks_names.end(), name );
if( iter != special_attacks_names.end() ) {
special_attacks_names.erase( iter );
}
}
}
示例8: load_overlay_ordering_into_array
void load_overlay_ordering_into_array( JsonObject &jsobj, std::map<std::string, int> &orderarray )
{
JsonArray jarr = jsobj.get_array( "overlay_ordering" );
while( jarr.has_more() ) {
JsonObject ordering = jarr.next_object();
int order = ordering.get_int( "order" );
for( auto &id : ordering.get_tags( "id" ) ) {
orderarray[id] = order;
}
}
}
示例9: load_location
void start_location::load_location( JsonObject &jsonobj )
{
start_location new_location;
new_location._ident = jsonobj.get_string("ident");
new_location._name = jsonobj.get_string("name");
new_location._target = jsonobj.get_string("target");
new_location._flags = jsonobj.get_tags("flags");
_locations[new_location._ident] = new_location;
}
示例10: load
void mission_type::load( JsonObject &jo, const std::string & )
{
mandatory( jo, was_loaded, "name", name, translated_string_reader );
mandatory( jo, was_loaded, "difficulty", difficulty );
mandatory( jo, was_loaded, "value", value );
auto djo = jo.get_object( "dialogue" );
// @todo There should be a cleaner way to do it
mandatory( djo, was_loaded, "describe", dialogue[ "describe" ] );
mandatory( djo, was_loaded, "offer", dialogue[ "offer" ] );
mandatory( djo, was_loaded, "accepted", dialogue[ "accepted" ] );
mandatory( djo, was_loaded, "rejected", dialogue[ "rejected" ] );
mandatory( djo, was_loaded, "advice", dialogue[ "advice" ] );
mandatory( djo, was_loaded, "inquire", dialogue[ "inquire" ] );
mandatory( djo, was_loaded, "success", dialogue[ "success" ] );
mandatory( djo, was_loaded, "success_lie", dialogue[ "success_lie" ] );
mandatory( djo, was_loaded, "failure", dialogue[ "failure" ] );
optional( jo, was_loaded, "urgent", urgent );
optional( jo, was_loaded, "item", item_id );
optional( jo, was_loaded, "count", item_count, 1 );
goal = jo.get_enum_value<decltype(goal)>( "goal" );
assign_function( jo, "place", place, tripoint_function_map );
assign_function( jo, "start", start, mission_function_map );
assign_function( jo, "end", end, mission_function_map );
assign_function( jo, "fail", fail, mission_function_map );
if( jo.has_int( "deadline_low" ) ) {
deadline_low = DAYS( jo.get_int( "deadline_low" ) );
}
if( jo.has_int( "deadline_high" ) ) {
deadline_high = DAYS( jo.get_int( "deadline_high" ) );
}
if( jo.has_member( "origins" ) ) {
origins.clear();
for( auto &m : jo.get_tags( "origins" ) ) {
origins.emplace_back( io::string_to_enum_look_up( io::origin_map, m ) );
}
}
if( jo.has_member( "followup" ) ) {
follow_up = mission_type_id( jo.get_string( "followup" ) );
}
if( jo.has_member( "destination" ) ) {
target_id = oter_id( jo.get_string( "destination" ) );
}
}
示例11: 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());
}
}
示例12: load_monster
void MonsterGenerator::load_monster(JsonObject &jo)
{
// id
std::string mid;
if (jo.has_member("id")){
mid = jo.get_string("id");
if (mon_templates.count(mid) > 0) {
delete mon_templates[mid];
}
mtype *newmon = new mtype;
newmon->id = mid;
newmon->name = _(jo.get_string("name","").c_str());
newmon->description = _(jo.get_string("description").c_str());
newmon->mat = jo.get_string("material");
newmon->species = jo.get_tags("species");
newmon->categories = jo.get_tags("categories");
newmon->sym = jo.get_string("symbol")[0]; // will fail here if there is no symbol
newmon->color = color_from_string(jo.get_string("color"));
newmon->size = get_from_string(jo.get_string("size", "MEDIUM"), size_map, MS_MEDIUM);
newmon->phase = get_from_string(jo.get_string("phase", "SOLID"), phase_map, SOLID);
newmon->difficulty = jo.get_int("diff", 0);
newmon->agro = jo.get_int("aggression", 0);
newmon->morale = jo.get_int("morale", 0);
newmon->speed = jo.get_int("speed", 0);
newmon->melee_skill = jo.get_int("melee_skill", 0);
newmon->melee_dice = jo.get_int("melee_dice", 0);
newmon->melee_sides = jo.get_int("melee_dice_sides", 0);
newmon->melee_cut = jo.get_int("melee_cut", 0);
newmon->sk_dodge = jo.get_int("dodge", 0);
newmon->armor_bash = jo.get_int("armor_bash", 0);
newmon->armor_cut = jo.get_int("armor_cut", 0);
newmon->item_chance = jo.get_int("item_chance", 0);
newmon->hp = jo.get_int("hp", 0);
newmon->sp_freq = jo.get_int("special_freq", 0);
newmon->luminance = jo.get_float("luminance", 0);
newmon->dies = get_death_functions(jo, "death_function");
newmon->sp_attack = get_attack_function(jo, "special_attack");
std::set<std::string> flags, anger_trig, placate_trig, fear_trig, cats;
flags = jo.get_tags("flags");
anger_trig = jo.get_tags("anger_triggers");
placate_trig = jo.get_tags("placate_triggers");
fear_trig = jo.get_tags("fear_triggers");
newmon->flags = get_set_from_tags(flags, flag_map, MF_NULL);
newmon->anger = get_set_from_tags(anger_trig, trigger_map, MTRIG_NULL);
newmon->fear = get_set_from_tags(fear_trig, trigger_map, MTRIG_NULL);
newmon->placate = get_set_from_tags(placate_trig, trigger_map, MTRIG_NULL);
mon_templates[mid] = newmon;
}
}
示例13: load_species
void MonsterGenerator::load_species(JsonObject &jo)
{
const species_id sid( jo.get_string( "id" ) );
if (mon_species.count(sid) > 0) {
delete mon_species[sid];
}
std::set<std::string> sflags, sanger, sfear, splacate;
sflags = jo.get_tags("flags");
sanger = jo.get_tags("anger_triggers");
sfear = jo.get_tags("fear_triggers");
splacate = jo.get_tags("placate_triggers");
std::set<m_flag> flags = get_set_from_tags(sflags, flag_map, MF_NULL);
std::set<monster_trigger> anger, fear, placate;
anger = get_set_from_tags(sanger, trigger_map, MTRIG_NULL);
fear = get_set_from_tags(sfear, trigger_map, MTRIG_NULL);
placate = get_set_from_tags(splacate, trigger_map, MTRIG_NULL);
species_type *new_species = new species_type(sid, flags, anger, fear, placate);
mon_species[sid] = new_species;
}
示例14: load_species
void MonsterGenerator::load_species(JsonObject &jo)
{
// id, flags, triggers (anger, placate, fear)
std::string sid;
if (jo.has_member("id")){
sid = jo.get_string("id");
std::set<std::string> sflags, sanger, sfear, splacate;
sflags = jo.get_tags("flags");
sanger = jo.get_tags("anger_triggers");
sfear = jo.get_tags("fear_triggers");
splacate = jo.get_tags("placate_triggers");
std::set<m_flag> flags = get_set_from_tags(sflags, flag_map, MF_NULL);
std::set<monster_trigger> anger, fear, placate;
anger = get_set_from_tags(sanger, trigger_map, MTRIG_NULL);
fear = get_set_from_tags(sfear, trigger_map, MTRIG_NULL);
placate = get_set_from_tags(splacate, trigger_map, MTRIG_NULL);
species_type *new_species = new species_type(sid, flags, anger, fear, placate);
mon_species[sid] = new_species;
}
}
示例15:
std::vector<void (mdeath::*)(monster*)> MonsterGenerator::get_death_functions(JsonObject& jo, std::string member)
{
std::vector<void (mdeath::*)(monster*)> deaths;
std::set<std::string> death_flags = jo.get_tags(member);
std::set<std::string>::iterator it = death_flags.begin();
for (; it != death_flags.end(); ++it) {
deaths.push_back(death_map[*it]);
}
if (deaths.size() == 0)
deaths.push_back(death_map["NORMAL"]);
return deaths;
}