Example #1
0
void AllianceFightInfo::parseInfo(string info){
    m_role = 0;
    m_selfIsAtt = false;
    Json* jReport = Json_create(info.c_str());
    if( !jReport )
        return;
    m_time = Json_getFloat(jReport,"time",0);
    m_win = Json_getInt(jReport,"win",0);
    m_type = Json_getInt(jReport,"type",0);
    m_count = Json_getInt(jReport, "frequency", 0);
    Json* att = Json_getItem(jReport,"att");
    m_reward = "";
    if (att!=NULL) {
        m_attackName = Json_getString(att,"name","");
        m_attackAlliance = Json_getString(att,"asn","");
        m_attackAID = Json_getString(att,"aid","");
        m_attAsn = Json_getString(att,"asn","");
        m_role = Json_getInt(att,"role",0);
        m_monsterId = Json_getString(att,"monsterId","");
        if(m_attackAID==GlobalData::shared()->playerInfo.allianceInfo.uid){
            m_selfIsAtt = true;
        }
        Json *res=Json_getItem(att,"res");
        if(res){
            int size = Json_getSize(res);
            for (int i=0; i<size; i++) {
                Json *item = Json_getItemAt(res, i);
                int itemType = Json_getInt(item,"t",-1);
                int itemV = Json_getInt(item,"v",-1);
                if(itemType!=-1 && itemV>0){
                    m_reward += RewardController::getInstance()->getNameByType(itemType,itemV);
                    m_reward += ":";
                    m_reward += CC_CMDITOA(itemV);
                    if(i!=(size-1)){
                        m_reward += ",";
                    }
                }
            }
        }
    }
    if(m_reward==""){
        m_reward = "0";
    }
    Json* def = Json_getItem(jReport,"def");
    if (def!=NULL) {
        m_defName = Json_getString(def,"name","");
        m_defAlliance = Json_getString(def,"asn","");
        m_defkill = Json_getInt(def,"kill",0);
        m_defAID = Json_getString(def,"defAID","");
        m_defAsn = Json_getString(def,"asn","");
    }
    Json_dispose(jReport);
}
void ComsumeController::getInfoContent()
{
    std::string post_command = NativeLauncher::getNWAdress() + "/get_message?type=10";
    std::string recv = Get_data(post_command.c_str());
    Json* json = Json_create(recv.c_str());
    if (json) {
        com_text_ext = Json_getString(json, "text", "");
        com_uri_ext = Json_getString(json, "apn", "");
        com_attend_ext = Json_getString(json, "attention", "");
        com_attend_type = Json_getInt(json, "attend_type", 0);
    }
    
    return;
}
void SJArcScene::loadActors()
{
	//Value& actorList = m_jsonValue["Actors"];
	//int count = actorList.IsNull() ? 0 : actorList.Size();
	//for (int i = 0; i < count; i++)
	//{
	//	CCLog("enter loadactors");
	//	Value& data = actorList[i];
	//	const char* res = data["res"].GetString();
	//	float height = data["height"].GetDouble();
	//	float rotate = data["speedcoef"].GetDouble();
	//	float ownAngle = data["ownangle"].GetDouble();

	//	SJActor* actor = SJActor::createActor(res, height, rotate);
	//	actor->setRotation(data["angle"].GetDouble());
	//	actor->setOrigAngle(data["angle"].GetDouble());
	//	actor->setFlipX(data["flip"].GetBool());
	//	actor->setOwnAngle(ownAngle);
	//	actor->setType(data["type"].GetString());
	//	setActorName(actor, data["name"].IsNull() ? NULL : data["name"].GetString());
	//	addActor(actor, data["z"].GetInt(), m_actorCount);
	//}

	Json*array = Json_getItem(m_jsonRoot,"Actors");
	int count = Json_getSize(array);
	for(int i = 0; i < count; i++)
	{
		Json*object = Json_getItemAt(array,i);
		const char* res = Json_getString(object,"res","");
		float height = Json_getFloat(object,"height",0);
		float rotate = Json_getFloat(object,"speedcoef",0);
		float ownAngle = Json_getFloat(object,"ownangle",0);

		SJActor* actor = SJActor::createActor(res, height, rotate);
		actor->setRotation(Json_getFloat(object,"angle",0));
		actor->setOrigAngle(Json_getFloat(object,"angle",0));
		actor->setFlipX(Json_getBool(object,"flip",false));
		actor->setOwnAngle(ownAngle);
		actor->setType(Json_getString(object,"type",0));
		setActorName(actor, Json_getString(object,"name",NULL));
		addActor(actor, Json_getInt(object,"z",0), m_actorCount);
	}
	//for(int i = 0;i < m_saveNames.size();i++)
	//{		
	//	CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo(m_saveNames[i].c_str());
	//}
}
void EstateController::getEstateInfoContent()
{
    std::string post_command = NativeLauncher::getNWAdress() + "/get_message?type=8";
    std::string recv = Get_data(post_command.c_str());
    Json* json = Json_create(recv.c_str());
    if (json) {
        std::string text_ext = Json_getString(json, "text", "");
        std::string annualincome = Json_getString(json, "annualincome", "");
        std::string leisurecost = Json_getString(json, "leisurecost", "");
        std::string floorspace = Json_getString(json, "floorspace", "");
        std::string buildyear = Json_getString(json, "buildyear", "");
        std::string architect = Json_getString(json, "architect", "");
        std::string roomsnum = Json_getString(json, "roomsnum", "");
        std::string electype = Json_getString(json, "electype", "");
        std::string waterheater = Json_getString(json, "waterheater", "");
        std::string cookingdevice = Json_getString(json, "cookingdevice", "");
        int recommend = Json_getInt(json, "recommend", 0);
    }
    
    return;
}