MCPcopy Create free account
hub / github.com/EasyRPG/Player / GetFatigue

Method GetFatigue

src/game_party.cpp:657–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657int Game_Party::GetFatigue() {
658 const auto& actors = GetActors();
659
660 if (actors.empty()) {
661 return 0;
662 }
663
664 int hp = 0;
665 int total_hp = 0;
666 int sp = 0;
667 int total_sp = 0;
668 for (auto* a : actors) {
669 hp += a->GetHp();
670 total_hp += a->GetMaxHp();
671 sp += a->GetSp();
672 total_sp += a->GetMaxSp();
673 }
674
675 // SP is always 33.3% of fatigue, which means a 0 SP actor is never above 66%
676 if (total_sp == 0) {
677 total_sp = 1;
678 }
679
680 auto p = Utils::RoundTo<int>(100.0f * ((static_cast<double>(hp) / total_hp * 2.0 + static_cast<double>(sp) / total_sp) / 3.0f));
681 return 100 - p;
682}
683
684void Game_Party::RemoveInvalidData() {
685 // Remove non existing actors

Callers 3

IsActionValidFunction · 0.80
AreConditionsMetMethod · 0.80
enemyai.cppFile · 0.80

Calls 5

GetMaxHpMethod · 0.80
GetMaxSpMethod · 0.80
emptyMethod · 0.45
GetHpMethod · 0.45
GetSpMethod · 0.45

Tested by

no test coverage detected