MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getReactor

Method getReactor

src/Battlescape/TileEngine.cpp:875–901  ·  view source on GitHub ↗

* Gets the unit with the highest reaction score from the spotter vector. * @param spotters The vector of spotting units. * @param unit The unit to check scores against. * @return The unit with the highest reactions. */

Source from the content-addressed store, hash-verified

873 * @return The unit with the highest reactions.
874 */
875BattleUnit* TileEngine::getReactor(std::vector<BattleUnit *> spotters, BattleUnit *unit)
876{
877 int bestScore = -1;
878 BattleUnit *bu = 0;
879 for (std::vector<BattleUnit *>::iterator i = spotters.begin(); i != spotters.end(); ++i)
880 {
881 if (!(*i)->isOut() &&
882 canMakeSnap(*i, unit) &&
883 (*i)->getReactionScore() > bestScore)
884 {
885 bestScore = (*i)->getReactionScore();
886 bu = *i;
887 }
888 }
889 if (unit->getReactionScore() <= bestScore)
890 {
891 if (bu->getOriginalFaction() == FACTION_PLAYER)
892 {
893 bu->addReactionExp();
894 }
895 }
896 else
897 {
898 bu = unit;
899 }
900 return bu;
901}
902
903/**
904 * Checks the validity of a snap shot performed here.

Callers

nothing calls this directly

Calls 4

isOutMethod · 0.80
getReactionScoreMethod · 0.80
getOriginalFactionMethod · 0.80
addReactionExpMethod · 0.80

Tested by

no test coverage detected