当前位置: 首页>>代码示例>>C++>>正文


C++ JsonObject::get_long方法代码示例

本文整理汇总了C++中JsonObject::get_long方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::get_long方法的具体用法?C++ JsonObject::get_long怎么用?C++ JsonObject::get_long使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonObject的用法示例。


在下文中一共展示了JsonObject::get_long方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
    }
}
开发者ID:Hadesfire27,项目名称:Cataclysm-DDA,代码行数:48,代码来源:artifact.cpp

示例2: 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");
    // 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));
        }
    }
    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());
    }

    if( item_tags.count( "CHOP" ) > 0 ) {
        item_tags.insert( "SHEATH_SWORD" );
    }
    if( item_tags.count( "STAB" ) > 0 ) {
        item_tags.insert( "SHEATH_KNIFE" );
    }
}
开发者ID:Suseika,项目名称:Cataclysm-DDA,代码行数:71,代码来源:artifact.cpp


注:本文中的JsonObject::get_long方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。