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

Method spendEnergy

src/Savegame/BattleUnit.cpp:1175–1188  ·  view source on GitHub ↗

* Spend energy if it can. Return false if it can't. * @param tu * @return flag if it could spend the time units or not. */

Source from the content-addressed store, hash-verified

1173 * @return flag if it could spend the time units or not.
1174 */
1175bool BattleUnit::spendEnergy(int tu)
1176{
1177 int eu = tu / 2;
1178
1179 if (eu <= _energy)
1180 {
1181 _energy -= eu;
1182 return true;
1183 }
1184 else
1185 {
1186 return false;
1187 }
1188}
1189
1190/**
1191 * Set a specific number of timeunits.

Callers 1

thinkMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected