* Spend energy if it can. Return false if it can't. * @param tu * @return flag if it could spend the time units or not. */
| 1173 | * @return flag if it could spend the time units or not. |
| 1174 | */ |
| 1175 | bool 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. |