示例#1
0
	JSONObject SpellData::ToJSON()
	{
		JSONObject object;

		object.set("id", mId);
		object.set("name", mName);
		object.set("cast_time", mCastTime);
		object.set("cooldown", mCooldown);
		object.set("spell_type", (int) mType);
		object.set("cast_type", (int) mCastType);
		object.set("spell_radius", mRadius);
		object.set("spell_range", mRange);
		object.set("shape", (int) mShape);

		JSONArray effects;
		for (auto &effectData : mEffects) {
			JSONObject effect;
			effect.set("id", effectData.id);
			effect.set("spell_id", effectData.spellId);
			effect.set("effect_type", (int) effectData.effectType);
			effect.set("percent_source_min", effectData.percentSourceMin);
			effect.set("school", effectData.school);
			effect.set("duration", effectData.duration);

			effects.add(effect);
		}

		object.set("effects", effects);

		JSONArray triggers;
		for (auto &triggerData : mTriggers) {
			JSONObject trigger;
			trigger.set("id", triggerData.id);
			trigger.set("spell_id", triggerData.spellId);
			trigger.set("trigger_spell_id", triggerData.triggerSpellId);
			trigger.set("chance", triggerData.chance);
			trigger.set("trigger_type", (int) triggerData.triggerType);

			triggers.add(trigger);
		}

		object.set("triggers", triggers);

		return object;
	}
示例#2
0
JSONArray* JSONArray::deepCopy() const {
  JSONArray* result = new JSONArray();

  const int size = this->size();
  for (int i = 0; i < size; i++) {
    result->add( JSONBaseObject::deepCopy( get(i) ) );
  }

  return result;
}
bool Round::SystemGetNetworkInfoResponse::setClusters(LocalNode *node) {
  JSONArray *clusterArray = getResultClusterArray();

  JSONDictionary *jsonDict = new JSONDictionary();
  SystemClusterInfoDict clusterInfoDict(jsonDict);
  clusterInfoDict.setCluster(node);
  
  clusterArray->add(jsonDict);
  
  return true;
}