Exemple #1
0
vector<UserSkillInfo> UserSkill::createUserSkillDataFromJson(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>& value)
{
	vector<UserSkillInfo> vInfo;
	vector<UserSkillInfo> pInfo;
	UserSkillInfo info;
	for (int i = 0; i < value.Size(); i++)
	{
		info.mst_skill_id = DataUtils::stringToFloat(value[i]["mst_skill_id"].GetString());
		info.name = value[i]["name"].GetString();
		info.skill_type = DataUtils::stringToFloat(value[i]["skill_type"].GetString());
		info.mp_cost = DataUtils::stringToFloat(value[i]["mp_cost"].GetString());
		info.cooldown_time = DataUtils::stringToFloat(value[i]["cooldown_time"].GetString());
		info.range_type = DataUtils::stringToFloat(value[i]["range_type"].GetString());
		info.range_distance = DataUtils::stringToFloat(value[i]["range_distance"].GetString());
		info.multi_effect = DataUtils::stringToFloat(value[i]["multi_effect"].GetString());
		info.target_type = DataUtils::stringToFloat(value[i]["target_type"].GetString());
		info.effect_type = DataUtils::stringToFloat(value[i]["effect_type"].GetString());
		info.buff_effect_type = DataUtils::stringToFloat(value[i]["buff_effect_type"].GetString());
		info.duration = DataUtils::stringToFloat(value[i]["effect_duration"].GetString());
		info.correct_type = DataUtils::stringToFloat(value[i]["correct_type"].GetString());
		info.corrett_value = DataUtils::stringToFloat(value[i]["corrett_value"].GetString());
		info.skill_des = value[i]["description"].GetString();
		info.image_path = value[i]["image_path"].GetString();
		info.skill_icon_path = value[i]["skill_icon_path"].GetString();

		vInfo.push_back(info);
		if (info.skill_type == 1) {
			pInfo.push_back(info);
		}
		log("skill %d name: %s", i+1, value[i]["name"].GetString());
	}
	setUserSkillList(vInfo);
	setPlayerSkillsList(pInfo);
	return getUserSkillList();
}
Exemple #2
0
void JSObject::FillRecursive(const rapidjson::GenericValue<rapidjson::UTF8<wchar_t>> &val)
{
  using namespace rapidjson;
  /**/
  switch(val.GetType())
  {
  case kNullType:		//!< null
    value = JSValue();
    break;
  case kFalseType:		//!< false
    value = JSValue(false);
    break;
  case kTrueType:		//!< true
    value = JSValue(true);
    break;
  case kObjectType:	//!< object
    value.type = JSTypeObject;
    for(GenericValue<UTF8<wchar_t>>::ConstMemberIterator itr2 = val.MemberBegin(); itr2 != val.MemberEnd(); ++itr2)
    {
      children.push_back(std::make_pair(itr2->name.GetString(), JSObject()));
      children.back().second.FillRecursive(itr2->value);
    }
    break;
  case kArrayType:		//!< array 
    value.type = JSTypeObject;
    children.resize(val.Size());
    for(SizeType i = 0; i < val.Size(); i++)
    {
      children[i].second.FillRecursive(val[i]);
    }
    break;
  case kStringType:	//!< string
    value.str = val.GetString();
    value.type = JSTypeString;
    break;
  case kNumberType:	//!< number
    value = val.GetDouble();
    break;
  }

}