MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / to_json

Method to_json

AgentBench.old/src/tasks/card_game/logic/src/fish.cpp:110–132  ·  view source on GitHub ↗

按照成员变量定义顺序转成 JSON 样例: { "hp": hp, "atk": atk, "def": def, "type": type, "id": id, "state": state, "is_expose": is_expose } */

Source from the content-addressed store, hash-verified

108 }
109*/
110Json::Value Fish::to_json() const
111{
112 Json::Value json;
113 json["hp"] = hp;
114 int now_atk = atk;
115 int now_id = id;
116 if (auto imitate = dynamic_cast<const Imitator *>(this))
117 if (imitate->avatar)
118 now_id = imitate->avatar->id;
119 if (now_id == 10 && hp * 5 < max_hp) now_atk += 15;
120 json["atk"] = now_atk;
121 json["def"] = def;
122 json["pos"] = pos;
123 if (ally != nullptr)
124 json["player"] = ally->player_id;
125 json["id"] = id;
126 json["state"] = state;
127 json["is_expose"] = is_expose;
128 if (auto imitate = dynamic_cast<const Imitator *>(this))
129 if (imitate->avatar)
130 json["imitate"] = imitate->avatar->id;
131 return json;
132}
133
134int Fish::heal_hp(int num){
135 int hurt = max_hp - hp;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected