按照成员变量定义顺序转成 JSON 样例: { "hp": hp, "atk": atk, "def": def, "type": type, "id": id, "state": state, "is_expose": is_expose } */
| 108 | } |
| 109 | */ |
| 110 | Json::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 | |
| 134 | int Fish::heal_hp(int num){ |
| 135 | int hurt = max_hp - hp; |
nothing calls this directly
no outgoing calls
no test coverage detected