本文整理汇总了C++中json_spirit::Object::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::push_back方法的具体用法?C++ Object::push_back怎么用?C++ Object::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json_spirit::Object
的用法示例。
在下文中一共展示了Object::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillJSONObject
void PrinterState::fillJSONObject(json_spirit::Object &obj) {
using namespace json_spirit;
mutex::scoped_lock l(mutex);
obj.push_back(Pair("activeExtruder",activeExtruder));
obj.push_back(Pair("x",x));
obj.push_back(Pair("y",y));
obj.push_back(Pair("z",z));
obj.push_back(Pair("fanOn",fanOn));
obj.push_back(Pair("fanVoltage",fanVoltage));
obj.push_back(Pair("powerOn",powerOn));
obj.push_back(Pair("debugLevel",debugLevel));
obj.push_back(Pair("hasXHome",hasXHome));
obj.push_back(Pair("hasYHome",hasYHome));
obj.push_back(Pair("hasZHome",hasZHome));
obj.push_back(Pair("layer",layer));
obj.push_back(Pair("sdcardMounted",sdcardMounted));
obj.push_back(Pair("bedTempSet",bed.tempSet));
obj.push_back(Pair("bedTempRead",bed.tempRead));
obj.push_back(Pair("speedMultiply",speedMultiply));
obj.push_back(Pair("flowMultiply",flowMultiply));
obj.push_back(Pair("numExtruder",printer->extruderCount));
obj.push_back(Pair("firmware",firmware));
obj.push_back(Pair("firmwareURL",firmwareURL));
Array ea;
for(int i=0;i<printer->extruderCount;i++) {
Object e;
e.push_back(Pair("tempSet",extruder[i].tempSet));
e.push_back(Pair("tempRead",extruder[i].tempRead));
e.push_back(Pair("output",extruder[i].output));
ea.push_back(e);
}
obj.push_back(Pair("extruder",ea));
}
示例2: openSlotItm
//打开物品
int CharData::openSlotItm(int slot, int nums, json_spirit::Object& robj)
{
boost::shared_ptr<iItem> itm = m_bag.getItem(slot);
if (!itm.get())
{
return HC_ERROR;
}
if (itm->getType() != iItem_type_gem)
{
return HC_ERROR;
}
int use_num = itm->getCount();
if (nums > 0 && itm->getCount() > nums)
{
use_num = nums;
}
Gem* pg = dynamic_cast<Gem*>(itm.get());
robj.push_back( Pair("use", pg->getUsage()) );
switch (pg->getUsage())
{
//变身卡
case ITEM_USAGE_CHANGE_CARD:
{
m_change_spic = itm->getSubtype() - 499;
m_change_spic_time = time(NULL) + 7200;
m_bag.removeItem(slot);
itm->Clear();
itm->Save();
//robj.push_back( Pair("refresh", 1) );
setExtraData(char_data_type_normal, char_data_change_spic, m_change_spic);
setExtraData(char_data_type_normal, char_data_change_spic_time, m_change_spic_time);
return HC_SUCCESS;
}
//兑换货币
case ITEM_USAGE_SILVER_CARD:
{
int total = pg->getValue() * use_num;
addSilver(total);
//银币统计
add_statistics_of_silver_get(m_id,m_ip_address,total,silver_get_by_treasure, m_union_id, m_server_id);
json_spirit::Object obj;
obj.push_back( Pair("type", item_type_silver) );
obj.push_back( Pair("count", total) );
obj.push_back( Pair("id", 0) );
obj.push_back( Pair("fac", 0) );
obj.push_back( Pair("name", strSilver) );
robj.push_back( Pair("get", obj) );
if (itm->getCount() > use_num)
{
itm->addCount(-use_num);
}
else
{
m_bag.removeItem(slot);
itm->Clear();
}
itm->Save();
NotifyCharData();
return HC_SUCCESS;
}
case ITEM_USAGE_GOLD_CARD:
{
int total = pg->getValue() * use_num;
addGold(total);
//金币获得统计
add_statistics_of_gold_get(m_id,m_ip_address,total,gold_get_treasure, m_union_id, m_server_id);
json_spirit::Object obj;
obj.push_back( Pair("type", item_type_gold) );
obj.push_back( Pair("count", total) );
obj.push_back( Pair("id", 0) );
obj.push_back( Pair("fac", 0) );
obj.push_back( Pair("name", strGold) );
robj.push_back( Pair("get", obj) );
if (itm->getCount() > use_num)
{
itm->addCount(-use_num);
}
else
{
m_bag.removeItem(slot);
itm->Clear();
}
itm->Save();
NotifyCharData();
return HC_SUCCESS;
}
case ITEM_USAGE_YUSHI_CARD:
{
int total = pg->getValue() * use_num;
addTreasure(treasure_type_yushi, total);
json_spirit::Object obj;
obj.push_back( Pair("type", item_type_treasure) );
obj.push_back( Pair("count", total) );
obj.push_back( Pair("id", treasure_type_yushi) );
obj.push_back( Pair("fac", 0) );
boost::shared_ptr<baseTreasure> tr = GeneralDataMgr::getInstance()->GetBaseTreasure(treasure_type_yushi);
if (tr.get())
{
//.........这里部分代码省略.........
示例3: upgradeEquipment
//升级装备
int CharData::upgradeEquipment(int eid, bool cost_gold, json_spirit::Object& robj)
{
if (cost_gold && gold() < 50)
{
return HC_ERROR_NOT_ENOUGH_GOLD;
}
//cout<<"upgradeEquipment(), eid "<<eid<<endl;
equipment_scroll* sp = NULL;
EquipmentData* src_eq = m_bag.getEquipById(eid);
if (!src_eq)
{
src_eq = m_generals.getEquipById(eid);
}
if (src_eq)
{
//cout<<"find scroll by src_id "<<src_eq->baseid<<endl;
sp = Singleton<equipment_scroll_mgr>::Instance().getScrollBySrcId(src_eq->baseid);
if (!sp)
{
//cout<<"not find"<<endl;
return HC_ERROR;
}
}
else
{
//cout<<"wrong eid"<<endl;
return HC_ERROR;
}
Bag* pbag = src_eq->getContainer();
//武将身上,判断等级是否够
if (pbag != &m_bag && pbag && pbag->gd.get() && pbag->gd->m_level < sp->m_equipment->needLevel)
{
return HC_ERROR_NOT_ENOUGH_GENERAL_LEVEL;
}
if (m_bag.getGemCount(sp->m_gem_id) <= 0)
{
//cout<<"no scroll,gem id: "<<sp->m_gem_id<<endl;
return HC_ERROR;
}
//扣材料
bool success = trySubMaterial(sp, m_bag);
if (!success)
{
//cout<<"trySubMaterial() return false"<<endl;
return HC_ERROR;
}
//扣卷轴
int err_code = 0;
m_bag.addGem(sp->m_gem_id, -1, err_code);
if (cost_gold)
{
if (addGold(-iUpgradeEquiptmentKeepLevelGold) < 0)
{
return HC_ERROR_NOT_ENOUGH_GOLD;
}
//金币消耗统计
add_statistics_of_gold_cost(m_id, m_ip_address, iUpgradeEquiptmentKeepLevelGold, gold_cost_for_upgrade_equipment, m_union_id, m_server_id);
#ifdef QQ_PLAT
gold_cost_tencent(this,iUpgradeEquiptmentKeepLevelGold,gold_cost_for_upgrade_equipment);
#endif
NotifyCharData();
//act统计
act_to_tencent(this,act_new_equipt_make_special,src_eq->qLevel,src_eq->quality);
}
//升级装备
src_eq->upgrade(cost_gold);
if (src_eq->getContainer() != &m_bag)
{
m_weapon_attack_change = true;
if (pbag->gd.get())
{
pbag->gd->updateEquipmentEffect();
}
}
json_spirit::Object eq;
src_eq->toObj(eq);
robj.push_back( Pair("equipVO", eq) );
updateEnhanceCost();
updateEnhanceCDList();
if (src_eq->baseEq.get())
{
std::string link_name = strEquipLink;
str_replace(link_name, "$G", LEX_CAST_STR(src_eq->id));
str_replace(link_name, "$C", LEX_CAST_STR(m_id));
str_replace(link_name, "$N", src_eq->baseEq->name);
addColor(link_name, src_eq->quality);
//广播升级装备信息
std::string notify_msg = strEquiptMakeInfo;
str_replace(notify_msg, "$N", MakeCharNameLink(m_name));
str_replace(notify_msg, "$G", link_name);
GeneralDataMgr::getInstance()->broadCastSysMsg(notify_msg, -1);
}
//七日目标
Singleton<seven_Goals_mgr>::Instance().updateGoals(*this,queryCreateDays(),goals_type_equipt,src_eq->baseid);
//.........这里部分代码省略.........
示例4: getUpgradeEquipmentInfo
//获取装备升级信息
int CharData::getUpgradeEquipmentInfo(int eid, int type, json_spirit::Object& robj)
{
equipment_scroll* sp = NULL;
EquipmentData* src_eq = m_bag.getEquipById(eid);
if (!src_eq)
{
src_eq = m_generals.getEquipById(eid);
}
if (src_eq)
{
sp = Singleton<equipment_scroll_mgr>::Instance().getScrollBySrcId(src_eq->baseid);
if (!sp)
{
return HC_ERROR;
}
}
else
{
return HC_ERROR;
}
if (sp->m_equipment->needLevel > m_level)
{
robj.push_back( Pair("needLevel", sp->m_equipment->needLevel) );
return HC_SUCCESS;
}
//直接制造结果
json_spirit::Object eq = sp->m_eqobj;
int nextqLevel = equipmentUpgrade::getInstance()->convertUpgradeLevel(src_eq->quality, src_eq->type, src_eq->qLevel);
int nextAdd = 0;
int nextAdd2 = 0;
upgradeValue(sp->m_equipment->up_quality, src_eq->type, nextqLevel, nextAdd, nextAdd2);
eq.push_back( Pair("level", nextqLevel) );
eq.push_back( Pair("addNums", sp->m_equipment->baseValue + nextAdd) );
eq.push_back( Pair("needLevel", sp->m_equipment->needLevel) );
if (nextAdd2 > 0)
{
eq.push_back( Pair("addNums2", sp->m_equipment->baseValue2 + nextAdd2) );
}
//保留等级制造结果
int nextqLevel_gold = src_eq->qLevel;
nextAdd = 0;
nextAdd2 = 0;
upgradeValue(sp->m_equipment->up_quality, src_eq->type, nextqLevel_gold, nextAdd, nextAdd2);
eq.push_back( Pair("level_gold", nextqLevel_gold) );
eq.push_back( Pair("addNums_gold", sp->m_equipment->baseValue + nextAdd) );
if (nextAdd2 > 0)
{
eq.push_back( Pair("addNums2_gold", sp->m_equipment->baseValue2 + nextAdd2) );
}
robj.push_back( Pair("eq", eq) );
robj.push_back( Pair("eid", src_eq->id) );
bool canMake = true;
json_spirit::Array mlist;
//type=1显示装备type=2显示卷轴
if (type == 1)
{
json_spirit::Object o;
o.push_back( Pair("name", sp->m_equipment_src->name) );
o.push_back( Pair("type", iItem_type_equipment) );
o.push_back( Pair("id", sp->m_equipment_src->baseid) );
o.push_back( Pair("spic", sp->m_equipment_src->baseid) );
o.push_back( Pair("quality", sp->m_equipment_src->quality) );
o.push_back( Pair("need", 1) );
o.push_back( Pair("num", 1) );
if (sp->m_equipment_src->m_place.get())
{
o.push_back( Pair("info", sp->m_equipment_src->m_place->info) );
}
mlist.push_back(o);
}
//检查材料是否足够
canMake &= checkMaterial(sp, *this, m_bag, mlist, type);
robj.push_back( Pair("mlist", mlist) );
robj.push_back( Pair("canMake", canMake) );
return HC_SUCCESS;
}
示例5: toObj
void EquipmentData::toObj(json_spirit::Object& eq)
{
eq.push_back( Pair("id", id) );
eq.push_back( Pair("name", name()) );
eq.push_back( Pair("spic", baseid) );
eq.push_back( Pair("type", type) );
eq.push_back( Pair("level", qLevel) );
eq.push_back( Pair("maxLevel", quality*20) );
int cur = getvalue();
int add2 = 0;
int add = equipmentUpgrade::getInstance()->getUpgradeValue(up_quality, type, qLevel + 1, add2);
eq.push_back( Pair("addNums", cur) );
eq.push_back( Pair("nextNums", cur + add) );
if (add2 > 0)
{
int cur2 = getvalue2();
eq.push_back( Pair("addNums2", cur2) );
eq.push_back( Pair("nextNums2", cur2 + add2) );
}
eq.push_back( Pair("quality", quality) );
eq.push_back( Pair("up_quality", up_quality) );
eq.push_back( Pair("price", sellPrice()) );
eq.push_back( Pair("memo", memo()) );
if (baseEq.get())
{
eq.push_back( Pair("needLevel", baseEq->needLevel) );
}
}