MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / getCapacityUsed

Method getCapacityUsed

game/state/city/base.cpp:444–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444int Base::getCapacityUsed(GameState &state, FacilityType::Capacity type) const
445{
446 int total = 0;
447 switch (type)
448 {
449 case FacilityType::Capacity::Repair:
450 for (auto &v : state.vehicles)
451 {
452 if (v.second->homeBuilding == building &&
453 v.second->getMaxHealth() > v.second->getHealth())
454 {
455 total += v.second->getMaxHealth() - v.second->getHealth();
456 }
457 }
458 // Show percentage of repair bay used if it can repair in one hour, or 100% if can't
459 if (total > 0)
460 {
461 int max = getCapacityTotal(type);
462 return std::min(total, max);
463 }
464 break;
465 case FacilityType::Capacity::Medical:
466 for (auto &a : state.agents)
467 {
468 if (a.second->homeBuilding == building)
469 {
470 if (a.second->modified_stats.health < a.second->current_stats.health)
471 {
472 total++;
473 }
474 }
475 }
476 break;
477 case FacilityType::Capacity::Training:
478 for (auto &a : state.agents)
479 {
480 if (a.second->homeBuilding == building &&
481 a.second->trainingAssignment == TrainingAssignment::Physical)
482 {
483 total++;
484 }
485 }
486 break;
487 case FacilityType::Capacity::Psi:
488 for (auto &a : state.agents)
489 {
490 if (a.second->homeBuilding == building &&
491 a.second->trainingAssignment == TrainingAssignment::Psi)
492 {
493 total++;
494 }
495 }
496 break;
497 case FacilityType::Capacity::Chemistry:
498 [[fallthrough]];
499 case FacilityType::Capacity::Physics:
500 [[fallthrough]];
501 case FacilityType::Capacity::Workshop:

Callers

nothing calls this directly

Calls 5

endMethod · 0.80
getMaxHealthMethod · 0.45
getHealthMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected