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());
    }
}
Exemple #2
0
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" );
    }
}