bool Round::SystemGetNetworkInfoResponse::getClusters(ClusterList *clusterList) {
  JSONArray *clusterArray = getResultClusterArray();
  size_t clusterCnt = clusterArray->size();
  for (size_t n=0; n<clusterCnt; n++) {
    JSONDictionary *jsonDict = dynamic_cast<JSONDictionary *>(clusterArray->getObject(n));
    if (!jsonDict)
      continue;
    
    SystemClusterInfoDict clusterInfoDict(jsonDict);
    Cluster *cluster = new Cluster();
    if (!clusterInfoDict.getCluster(cluster)) {
      delete cluster;
      continue;
    }
    
    clusterList->addCluster(cluster);
  }
  
  return true;
}
Esempio n. 2
0
	void SpellData::FromJSON(JSONObject *object)
	{
		mId = UUID(object->getValue<std::string>("id"));
		mName = object->getValue<std::string>("name");
		mCastTime = object->getValue<int>("cast_time");
		mCooldown = object->getValue<int>("cooldown");
		mType = (SpellType) object->getValue<int>("spell_type");
		mCastType = (SpellCastType) object->getValue<int>("cast_type");
		mRadius = object->getValue<double>("spell_radius");
		mRange = object->getValue<double>("spell_range");
		mShape = (SpellShape) object->getValue<int>("shape");

		if (object->has("icon_url"))
		mIconURL = object->getValue<std::string>("icon_url");

		if (object->has("slot")) {
			mSlot = object->getValue<std::string>("slot");
		}

		if (object->has("class_id")) {
			int classId = object->getValue<int>("class_id");
			mCharClass.classId = classId;
			mCharClass.name = GetCharacterClassName((CharacterClass)classId);
		}

		JSONArray *effects = object->getArray("effects");
		for (int i = 0; i < effects->size(); i++) {
			JSONObject *effect = effects->getObject(i);
			SpellEffectData effectData;
			effectData.id = UUID(effect->getValue<std::string>("id"));
			effectData.spellId = UUID(effect->getValue<std::string>("spell_id"));
			effectData.effectType = (SpellEffectType) effect->getValue<int>("effect_type");
			effectData.percentSourceMin = effect->getValue<int>("percent_source_min");
			effectData.percentSourceMax = effect->getValue<int>("percent_source_max");
			effectData.flatAmountMin = effect->getValue<int>("flat_amount_min");
			effectData.flatAmountMax = effect->getValue<int>("flat_amount_max");
			effectData.dotDuration = effect->getValue<int>("dot_duration");
			effectData.dotTick = effect->getValue<int>("dot_tick");
			effectData.buffDuration = effect->getValue<int>("buff_duration");
			effectData.damageSource = (SpellDamageSource)effect->getValue<int>("damage_source");
			effectData.buffSource = (CharacterStatType)effect->getValue<int>("buff_source");
			effectData.mechanic = (SpellMechanic)effect->getValue<int>("mechanic");
			effectData.school = (SpellSchool) effect->getValue<int>("school");
			effectData.maxStacks = effect->getValue<int>("max_stacks");

			mEffects.push_back(effectData);
		}

		JSONArray *triggers = object->getArray("triggers");
		for (int i = 0; i < triggers->size(); i++) {
			JSONObject *trigger = triggers->getObject(i);
			SpellTriggerData triggerData;

			triggerData.id = UUID(trigger->getValue<std::string>("id"));
			triggerData.spellId = UUID(trigger->getValue<std::string>("spell_id"));
			triggerData.triggerSpellId = UUID(trigger->getValue<std::string>("trigger_spell_id"));
			triggerData.chance = trigger->getValue<double>("chance");
			triggerData.triggerType = (TriggerType) trigger->getValue<int>("trigger_type");
			
			mTriggers.push_back(triggerData);
		}

	}