Using ^ to denote stats that are in templates, and as such do not change. Using : to denote stats that come from structure specializations.
| 353 | // Using ^ to denote stats that are in templates, and as such do not change. |
| 354 | // Using : to denote stats that come from structure specializations. |
| 355 | nlohmann::ordered_json componentToString(const COMPONENT_STATS *psStats, int player) |
| 356 | { |
| 357 | nlohmann::ordered_json key = nlohmann::ordered_json::object(); |
| 358 | |
| 359 | key["Name"] = getStatsName(psStats); |
| 360 | key["NameLocalized"] = getLocalizedStatsName(psStats); |
| 361 | key["^Id"] = psStats->id.toUtf8(); |
| 362 | key["^Power"] = psStats->buildPower; |
| 363 | key["^Build Points"] = psStats->buildPoints; |
| 364 | key["^Weight"] = psStats->weight; |
| 365 | key["^Hit points"] = psStats->getUpgrade(player).hitpoints; |
| 366 | key["^Hit points +% of total"] = psStats->getUpgrade(player).hitpointPct; |
| 367 | key["^Designable"] = psStats->designable; |
| 368 | switch (psStats->compType) |
| 369 | { |
| 370 | case COMP_BODY: |
| 371 | { |
| 372 | const BODY_STATS *psBody = (const BODY_STATS *)psStats; |
| 373 | key["^Size"] = psBody->size; |
| 374 | key["^Max weapons"] = psBody->weaponSlots; |
| 375 | key["^Body class"] = psBody->bodyClass.toUtf8(); |
| 376 | break; |
| 377 | } |
| 378 | case COMP_PROPULSION: |
| 379 | { |
| 380 | const PROPULSION_STATS *psProp = (const PROPULSION_STATS *)psStats; |
| 381 | key["^Hit points +% of body"] = psProp->upgrade[player].hitpointPctOfBody; |
| 382 | key["^Max speed"] = psProp->maxSpeed; |
| 383 | key["^Propulsion type"] = psProp->propulsionType; |
| 384 | key["^Turn speed"] = psProp->turnSpeed; |
| 385 | key["^Spin speed"] = psProp->spinSpeed; |
| 386 | key["^Spin angle"] = psProp->spinAngle; |
| 387 | key["^Skid decelaration"] = psProp->skidDeceleration; |
| 388 | key["^Deceleration"] = psProp->deceleration; |
| 389 | key["^Acceleration"] = psProp->acceleration; |
| 390 | break; |
| 391 | } |
| 392 | case COMP_BRAIN: |
| 393 | { |
| 394 | const BRAIN_STATS *psBrain = (const BRAIN_STATS *)psStats; |
| 395 | std::string ranks; |
| 396 | for (const std::string &s : psBrain->rankNames) |
| 397 | { |
| 398 | if (!ranks.empty()) |
| 399 | { |
| 400 | ranks += ", "; |
| 401 | } |
| 402 | ranks += s; |
| 403 | } |
| 404 | std::string thresholds; |
| 405 | for (int t : psBrain->upgrade[player].rankThresholds) |
| 406 | { |
| 407 | if (!thresholds.empty()) |
| 408 | { |
| 409 | thresholds += ", "; |
| 410 | } |
| 411 | thresholds += WzString::number(t).toUtf8(); |
| 412 | } |
no test coverage detected