1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
|
/* OutfitInfoDisplay.cpp
Copyright (c) 2014 by Michael Zahniser
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "OutfitInfoDisplay.h"
#include "Depreciation.h"
#include "text/Format.h"
#include "GameData.h"
#include "Outfit.h"
#include "PlayerInfo.h"
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <sstream>
using namespace std;
namespace {
const vector<pair<double, string>> SCALE_LABELS = {
make_pair(60., ""),
make_pair(60. * 60., ""),
make_pair(60. * 100., ""),
make_pair(100., "%"),
make_pair(100., ""),
make_pair(1. / 60., "s")
};
const map<string, int> SCALE = {
{"active cooling", 0},
{"afterburner shields", 0},
{"afterburner hull", 0},
{"afterburner energy", 0},
{"afterburner fuel", 0},
{"afterburner heat", 0},
{"burn resistance energy", 0},
{"burn resistance fuel", 0},
{"burn resistance heat", 0},
{"cloak", 0},
{"cloaking energy", 0},
{"cloaking fuel", 0},
{"cloaking heat", 0},
{"cloaking shields", 0},
{"cloaked firing", 0},
{"cooling", 0},
{"cooling energy", 0},
{"corrosion resistance energy", 0},
{"corrosion resistance fuel", 0},
{"corrosion resistance heat", 0},
{"discharge resistance energy", 0},
{"discharge resistance fuel", 0},
{"discharge resistance heat", 0},
{"disruption resistance energy", 0},
{"disruption resistance fuel", 0},
{"disruption resistance heat", 0},
{"energy consumption", 0},
{"energy generation", 0},
{"fuel consumption", 0},
{"fuel energy", 0},
{"fuel generation", 0},
{"fuel heat", 0},
{"heat generation", 0},
{"heat dissipation", 0},
{"hull repair rate", 0},
{"hull energy", 0},
{"hull fuel", 0},
{"hull heat", 0},
{"delayed hull repair rate", 0},
{"delayed hull energy", 0},
{"delayed hull fuel", 0},
{"delayed hull heat", 0},
{"ion resistance energy", 0},
{"ion resistance fuel", 0},
{"ion resistance heat", 0},
{"scramble resistance energy", 0},
{"scramble resistance fuel", 0},
{"scramble resistance heat", 0},
{"jump speed", 0},
{"leak resistance energy", 0},
{"leak resistance fuel", 0},
{"leak resistance heat", 0},
{"overheat damage rate", 0},
{"reverse thrusting shields", 0},
{"reverse thrusting hull", 0},
{"reverse thrusting energy", 0},
{"reverse thrusting fuel", 0},
{"reverse thrusting heat", 0},
{"scram drive", 0},
{"shield generation", 0},
{"shield energy", 0},
{"shield fuel", 0},
{"shield heat", 0},
{"delayed shield generation", 0},
{"delayed shield energy", 0},
{"delayed shield fuel", 0},
{"delayed shield heat", 0},
{"slowing resistance energy", 0},
{"slowing resistance fuel", 0},
{"slowing resistance heat", 0},
{"solar collection", 0},
{"solar heat", 0},
{"thrusting shields", 0},
{"thrusting hull", 0},
{"thrusting energy", 0},
{"thrusting fuel", 0},
{"thrusting heat", 0},
{"turn", 0},
{"turning shields", 0},
{"turning hull", 0},
{"turning energy", 0},
{"turning fuel", 0},
{"turning heat", 0},
{"thrust", 1},
{"reverse thrust", 1},
{"afterburner thrust", 1},
{"afterburner discharge", 2},
{"afterburner corrosion", 2},
{"afterburner ion", 2},
{"afterburner scramble", 2},
{"afterburner leakage", 2},
{"afterburner burn", 2},
{"afterburner slowing", 2},
{"afterburner disruption", 2},
{"reverse thrusting discharge", 2},
{"reverse thrusting corrosion", 2},
{"reverse thrusting ion", 2},
{"reverse thrusting scramble", 2},
{"reverse thrusting leakage", 2},
{"reverse thrusting burn", 2},
{"reverse thrusting slowing", 2},
{"reverse thrusting disruption", 2},
{"thrusting discharge", 2},
{"thrusting corrosion", 2},
{"thrusting ion", 2},
{"thrusting scramble", 2},
{"thrusting leakage", 2},
{"thrusting burn", 2},
{"thrusting slowing", 2},
{"thrusting disruption", 2},
{"turning discharge", 2},
{"turning corrosion", 2},
{"turning ion", 2},
{"turning scramble", 2},
{"turning leakage", 2},
{"turning burn", 2},
{"turning slowing", 2},
{"turning disruption", 2},
{"ion resistance", 2},
{"scramble resistance", 2},
{"disruption resistance", 2},
{"slowing resistance", 2},
{"discharge resistance", 2},
{"corrosion resistance", 2},
{"leak resistance", 2},
{"burn resistance", 2},
{"cloak by mass", 3},
{"shield multiplier", 3},
{"hull multiplier", 3},
{"hull repair multiplier", 3},
{"hull energy multiplier", 3},
{"hull fuel multiplier", 3},
{"hull heat multiplier", 3},
{"piercing resistance", 3},
{"shield generation multiplier", 3},
{"shield energy multiplier", 3},
{"shield fuel multiplier", 3},
{"shield heat multiplier", 3},
{"threshold percentage", 3},
{"overheat damage threshold", 3},
{"high shield permeability", 3},
{"low shield permeability", 3},
{"cloaked shield permeability", 3},
{"cloaked regen multiplier", 3},
{"cloaked repair multiplier", 3},
{"acceleration multiplier", 3},
{"turn multiplier", 3},
{"turret turn multiplier", 3},
{"burn protection", 4},
{"corrosion protection", 4},
{"discharge protection", 4},
{"disruption protection", 4},
{"drag reduction", 4},
{"energy protection", 4},
{"force protection", 4},
{"fuel protection", 4},
{"heat protection", 4},
{"hull protection", 4},
{"inertia reduction", 4},
{"ion protection", 4},
{"scramble protection", 4},
{"leak protection", 4},
{"piercing protection", 4},
{"shield protection", 4},
{"slowing protection", 4},
{"cloak hull protection", 4},
{"cloak shield protection", 4},
{"repair delay", 5},
{"cloaking repair delay", 5},
{"disabled repair delay", 5},
{"shield delay", 5},
{"cloaking shield delay", 5},
{"depleted shield delay", 5},
{"disabled recovery time", 5}
};
const map<string, string> BOOLEAN_ATTRIBUTES = {
{"unplunderable", "This outfit cannot be plundered."},
{"installable", "This is not an installable item."},
{"hyperdrive", "Allows you to make hyperjumps."},
{"jump drive", "Lets you jump to any nearby system."},
{"minable", "This item is mined from asteroids."},
{"map minables", "This map reveals minables."},
{"atrocity", "This outfit is considered an atrocity."},
{"unique", "This item is unique."},
{"cloaked afterburner", "You may use afterburners while cloaked."},
{"cloaked boarding", "You may board while cloaked."},
{"cloaked communication", "You may make hails while cloaked."},
{"cloaked deployment", "You may deploy from bays while cloaked."},
{"cloaked pickup", "You may pick up flotsam while cloaked."},
{"cloaked scanning", "You may scan other ships while cloaked."}
};
bool IsNotRequirement(const string &label)
{
return label == "automaton" ||
SCALE.find(label) != SCALE.end() ||
BOOLEAN_ATTRIBUTES.find(label) != BOOLEAN_ATTRIBUTES.end();
}
}
OutfitInfoDisplay::OutfitInfoDisplay(const Outfit &outfit, const PlayerInfo &player,
bool canSell, bool descriptionCollapsed)
{
Update(outfit, player, canSell, descriptionCollapsed);
}
// Call this every time the ship changes.
void OutfitInfoDisplay::Update(const Outfit &outfit, const PlayerInfo &player, bool canSell, bool descriptionCollapsed)
{
UpdateDescription(outfit.Description(), outfit.Licenses(), false);
UpdateRequirements(outfit, player, canSell, descriptionCollapsed);
UpdateAttributes(outfit);
maximumHeight = max(descriptionHeight, max(requirementsHeight, attributesHeight));
}
int OutfitInfoDisplay::RequirementsHeight() const
{
return requirementsHeight;
}
void OutfitInfoDisplay::DrawRequirements(const Point &topLeft) const
{
Draw(topLeft, requirementLabels, requirementValues);
}
void OutfitInfoDisplay::UpdateRequirements(const Outfit &outfit, const PlayerInfo &player,
bool canSell, bool descriptionCollapsed)
{
requirementLabels.clear();
requirementValues.clear();
requirementsHeight = 20;
int day = player.GetDate().DaysSinceEpoch();
int64_t cost = outfit.Cost();
int64_t buyValue = player.StockDepreciation().Value(&outfit, day);
int64_t sellValue = player.FleetDepreciation().Value(&outfit, day);
for(const string &license : outfit.Licenses())
{
if(player.HasLicense(license))
continue;
const auto &licenseOutfit = GameData::Outfits().Find(license + " License");
if(descriptionCollapsed || (licenseOutfit && licenseOutfit->Cost()))
{
requirementLabels.push_back("license:");
requirementValues.push_back(license);
requirementsHeight += 20;
}
}
if(buyValue == cost)
requirementLabels.push_back("cost:");
else
{
ostringstream out;
out << "cost (" << (100 * buyValue) / cost << "%):";
requirementLabels.push_back(out.str());
}
requirementValues.push_back(buyValue ? Format::Credits(buyValue) : "free");
requirementsHeight += 20;
if(canSell && sellValue != buyValue)
{
if(sellValue == cost)
requirementLabels.push_back("sells for:");
else
{
ostringstream out;
out << "sells for (" << (100 * sellValue) / cost << "%):";
requirementLabels.push_back(out.str());
}
requirementValues.push_back(Format::Credits(sellValue));
requirementsHeight += 20;
}
if(outfit.Mass())
{
requirementLabels.emplace_back("mass:");
requirementValues.emplace_back(Format::Number(outfit.Mass()));
requirementsHeight += 20;
}
requirementLabels.emplace_back();
requirementValues.emplace_back();
requirementsHeight += 10;
bool hasContent = false;
static const vector<string> BEFORE = {"outfit space", "weapon capacity", "engine capacity"};
for(const auto &attr : BEFORE)
{
if(outfit.Get(attr) < 0)
{
AddRequirementAttribute(attr, outfit.Get(attr));
hasContent = true;
}
}
if(hasContent)
{
requirementLabels.emplace_back();
requirementValues.emplace_back();
requirementsHeight += 10;
}
for(const pair<const char *, double> &it : outfit.Attributes())
if(!count(BEFORE.begin(), BEFORE.end(), it.first))
AddRequirementAttribute(it.first, it.second);
}
// Any attribute with a negative value is considered a requirement.
// Any exceptions to that rule would require in-game code to handle
// their unique properties, so when code is added to handle a new
// attribute, this code also should also be updated.
void OutfitInfoDisplay::AddRequirementAttribute(string label, double value)
{
// These attributes have negative values but are not requirements
if(IsNotRequirement(label))
return;
// Special case for 'required crew' - use positive values as a requirement.
if(label == "required crew")
{
if(value > 0)
{
requirementLabels.push_back(label + ":");
requirementValues.push_back(Format::Number(value));
requirementsHeight += 20;
return;
}
else
value *= -1;
}
if(value >= 0)
return;
requirementLabels.push_back(label + " needed:");
requirementValues.push_back(Format::Number(-value));
requirementsHeight += 20;
}
void OutfitInfoDisplay::UpdateAttributes(const Outfit &outfit)
{
attributeLabels.clear();
attributeValues.clear();
attributesHeight = 20;
bool hasNormalAttributes = false;
// These attributes are regularly negative on outfits, so when positive,
// tag them with "added" and show them first. They conveniently
// don't use SCALE or BOOLEAN_ATTRIBUTES.
static const vector<string> EXPECTED_NEGATIVE = {
"outfit space", "weapon capacity", "engine capacity", "gun ports", "turret mounts"
};
for(const string &attr : EXPECTED_NEGATIVE)
{
double value = outfit.Get(attr);
if(value <= 0)
continue;
attributeLabels.emplace_back(attr + " added:");
attributeValues.emplace_back(Format::Number(value));
attributesHeight += 20;
hasNormalAttributes = true;
}
for(const pair<const char *, double> &it : outfit.Attributes())
{
if(count(EXPECTED_NEGATIVE.begin(), EXPECTED_NEGATIVE.end(), it.first))
continue;
// Only show positive values here, with some exceptions.
// Negative values are usually handled as a "requirement"
if(static_cast<string>(it.first) == "required crew")
{
// 'required crew' is inverted - positive values are requirements.
if(it.second > 0)
continue;
// A negative 'required crew' would be a benefit, so it is listed here.
}
// If this attribute is not a requirement, it is always listed here, though it may be negative.
else if(it.second < 0 && !IsNotRequirement(it.first))
continue;
auto sit = SCALE.find(it.first);
double scale = (sit == SCALE.end() ? 1. : SCALE_LABELS[sit->second].first);
string units = (sit == SCALE.end() ? "" : SCALE_LABELS[sit->second].second);
auto bit = BOOLEAN_ATTRIBUTES.find(it.first);
if(bit != BOOLEAN_ATTRIBUTES.end())
{
attributeLabels.emplace_back(bit->second);
attributeValues.emplace_back(" ");
attributesHeight += 20;
}
else
{
attributeLabels.emplace_back(static_cast<string>(it.first) + ":");
attributeValues.emplace_back(Format::Number(it.second * scale) + units);
attributesHeight += 20;
}
hasNormalAttributes = true;
}
if(!outfit.IsWeapon())
return;
// Insert padding if any normal attributes were listed above.
if(hasNormalAttributes)
{
attributeLabels.emplace_back();
attributeValues.emplace_back();
attributesHeight += 10;
}
if(outfit.Ammo())
{
attributeLabels.emplace_back("ammo:");
attributeValues.emplace_back(outfit.Ammo()->DisplayName());
attributesHeight += 20;
if(outfit.AmmoUsage() != 1)
{
attributeLabels.emplace_back("ammo usage:");
attributeValues.emplace_back(Format::Number(outfit.AmmoUsage()));
attributesHeight += 20;
}
}
double range = outfit.Range();
attributeLabels.emplace_back("range:");
attributeValues.emplace_back(Format::Number(range));
attributesHeight += 20;
attributeLabels.emplace_back("velocity:");
double velocity = outfit.WeightedVelocity();
if(velocity == range)
attributeValues.emplace_back("instantaneous");
else
attributeValues.emplace_back(Format::Number(velocity * 60.));
attributesHeight += 20;
// Identify the dropoff at range and inform the player.
double fullDropoff = outfit.MaxDropoff();
if(fullDropoff != 1.)
{
attributeLabels.emplace_back("dropoff modifier:");
attributeValues.emplace_back(Format::Number(100. * fullDropoff) + "%");
attributesHeight += 20;
// Identify the ranges between which the dropoff takes place.
attributeLabels.emplace_back("dropoff range:");
const pair<double, double> &ranges = outfit.DropoffRanges();
attributeValues.emplace_back(Format::Number(ranges.first)
+ " - " + Format::Number(ranges.second));
attributesHeight += 20;
}
static const vector<pair<string, string>> VALUE_NAMES = {
{"shield damage", ""},
{"hull damage", ""},
{"minable damage", ""},
{"fuel damage", ""},
{"heat damage", ""},
{"energy damage", ""},
{"ion damage", ""},
{"scrambling damage", ""},
{"slowing damage", ""},
{"disruption damage", ""},
{"discharge damage", ""},
{"corrosion damage", ""},
{"leak damage", ""},
{"burn damage", ""},
{"% shield damage", "%"},
{"% hull damage", "%"},
{"% minable damage", "%"},
{"% fuel damage", "%"},
{"% heat damage", "%"},
{"% energy damage", "%"},
{"firing energy", ""},
{"firing heat", ""},
{"firing fuel", ""},
{"firing hull", ""},
{"firing shields", ""},
{"firing ion", ""},
{"firing scramble", ""},
{"firing slowing", ""},
{"firing disruption", ""},
{"firing discharge", ""},
{"firing corrosion", ""},
{"firing leak", ""},
{"firing burn", ""},
{"% firing energy", "%"},
{"% firing heat", "%"},
{"% firing fuel", "%"},
{"% firing hull", "%"},
{"% firing shields", "%"}
};
vector<double> values = {
outfit.ShieldDamage(),
outfit.HullDamage(),
outfit.MinableDamage() != outfit.HullDamage() ? outfit.MinableDamage() : 0.,
outfit.FuelDamage(),
outfit.HeatDamage(),
outfit.EnergyDamage(),
outfit.IonDamage() * 100.,
outfit.ScramblingDamage() * 100.,
outfit.SlowingDamage() * 100.,
outfit.DisruptionDamage() * 100.,
outfit.DischargeDamage() * 100.,
outfit.CorrosionDamage() * 100.,
outfit.LeakDamage() * 100.,
outfit.BurnDamage() * 100.,
outfit.RelativeShieldDamage() * 100.,
outfit.RelativeHullDamage() * 100.,
outfit.RelativeMinableDamage() != outfit.RelativeHullDamage() ? outfit.RelativeMinableDamage() * 100. : 0.,
outfit.RelativeFuelDamage() * 100.,
outfit.RelativeHeatDamage() * 100.,
outfit.RelativeEnergyDamage() * 100.,
outfit.FiringEnergy(),
outfit.FiringHeat(),
outfit.FiringFuel(),
outfit.FiringHull(),
outfit.FiringShields(),
outfit.FiringIon() * 100.,
outfit.FiringScramble() * 100.,
outfit.FiringSlowing() * 100.,
outfit.FiringDisruption() * 100.,
outfit.FiringDischarge() * 100.,
outfit.FiringCorrosion() * 100.,
outfit.FiringLeak() * 100.,
outfit.FiringBurn() * 100.,
outfit.RelativeFiringEnergy() * 100.,
outfit.RelativeFiringHeat() * 100.,
outfit.RelativeFiringFuel() * 100.,
outfit.RelativeFiringHull() * 100.,
outfit.RelativeFiringShields() * 100.
};
// Add any per-second values to the table.
double reload = outfit.Reload();
if(reload)
{
static const string PER_SECOND = " / second:";
for(unsigned i = 0; i < values.size(); ++i)
if(values[i])
{
attributeLabels.emplace_back(VALUE_NAMES[i].first + PER_SECOND);
attributeValues.emplace_back(Format::Number(60. * values[i] / reload) + VALUE_NAMES[i].second);
attributesHeight += 20;
}
}
bool oneFrame = (outfit.TotalLifetime() == 1.);
bool isContinuous = (reload <= 1. && oneFrame);
bool isContinuousBurst = (outfit.BurstCount() > 1 && outfit.BurstReload() <= 1. && oneFrame);
attributeLabels.emplace_back("shots / second:");
if(isContinuous)
attributeValues.emplace_back("continuous");
else if(isContinuousBurst)
attributeValues.emplace_back("continuous (" + Format::Number(lround(outfit.BurstReload() * 100. / reload)) + "%)");
else
attributeValues.emplace_back(Format::Number(60. / reload));
attributesHeight += 20;
double turretTurn = outfit.TurretTurn() * 60.;
if(turretTurn)
{
attributeLabels.emplace_back("turret turn rate:");
attributeValues.emplace_back(Format::Number(turretTurn));
attributesHeight += 20;
}
double arc = outfit.Arc();
if(arc < 360.)
{
attributeLabels.emplace_back("arc:");
attributeValues.emplace_back(Format::Number(arc));
attributesHeight += 20;
}
if(outfit.Homing())
{
attributeLabels.emplace_back("homing type:");
attributeValues.emplace_back(outfit.Leading() ? "leading" : "direct");
attributesHeight += 20;
}
static const vector<string> PERCENT_NAMES = {
"tracking:",
"optical tracking:",
"infrared tracking:",
"radar tracking:",
"piercing:"
};
vector<double> percentValues = {
outfit.Tracking(),
outfit.OpticalTracking(),
outfit.InfraredTracking(),
outfit.RadarTracking(),
outfit.Piercing()
};
for(unsigned i = 0; i < PERCENT_NAMES.size(); ++i)
if(percentValues[i])
{
int percent = lround(100. * percentValues[i]);
attributeLabels.push_back(PERCENT_NAMES[i]);
attributeValues.push_back(Format::Number(percent) + "%");
attributesHeight += 20;
}
if(outfit.ThrottleControl())
{
attributeLabels.emplace_back("Projectiles can control thrust.");
attributeValues.emplace_back(" ");
attributesHeight += 20;
}
if(outfit.HasBlindspot())
{
attributeLabels.emplace_back("Cannot track targets behind it.");
attributeValues.emplace_back(" ");
attributesHeight += 20;
}
// Pad the table.
attributeLabels.emplace_back();
attributeValues.emplace_back();
attributesHeight += 10;
// Add per-shot values to the table. If the weapon fires continuously,
// the values have already been added.
if(!isContinuous && !isContinuousBurst)
{
static const string PER_SHOT = " / shot:";
for(unsigned i = 0; i < VALUE_NAMES.size(); ++i)
if(values[i])
{
attributeLabels.emplace_back(VALUE_NAMES[i].first + PER_SHOT);
attributeValues.emplace_back(Format::Number(values[i]) + VALUE_NAMES[i].second);
attributesHeight += 20;
}
}
static const vector<string> OTHER_NAMES = {
"inaccuracy:",
"blast radius:",
"missile strength:",
"anti-missile:",
"tractor beam:",
"mining precision:",
};
vector<double> otherValues = {
outfit.Inaccuracy(),
outfit.BlastRadius(),
static_cast<double>(outfit.MissileStrength()),
static_cast<double>(outfit.AntiMissile()),
outfit.TractorBeam() * 60.,
outfit.Prospecting() && outfit.MinableDamage() ? outfit.Prospecting() / outfit.MinableDamage() : 0.,
};
for(unsigned i = 0; i < OTHER_NAMES.size(); ++i)
if(otherValues[i])
{
attributeLabels.emplace_back(OTHER_NAMES[i]);
attributeValues.emplace_back(Format::Number(otherValues[i]));
attributesHeight += 20;
}
}
|