| 5199 | } |
| 5200 | |
| 5201 | void |
| 5202 | drain_en(int n, boolean max_already_drained) |
| 5203 | { |
| 5204 | const char *mesg; |
| 5205 | char punct = max_already_drained ? '!' : '.'; |
| 5206 | |
| 5207 | /* |
| 5208 | * FIXME? |
| 5209 | * u.uenmax should probably have a higher minimum than 0; |
| 5210 | * perhaps u.ulevel or (u.ulevel + 1) / 2 |
| 5211 | */ |
| 5212 | if (u.uenmax < 1) { |
| 5213 | /* energy is completely gone */ |
| 5214 | if (u.uen || u.uenmax) { /* paranoia */ |
| 5215 | u.uen = u.uenmax = 0; |
| 5216 | disp.botl = TRUE; |
| 5217 | } |
| 5218 | mesg = "momentarily lethargic"; |
| 5219 | } else { |
| 5220 | /* throttle further loss a bit when there's not much left to lose */ |
| 5221 | if (n > (u.uen + u.uenmax) / 3) |
| 5222 | n = rnd(n); |
| 5223 | |
| 5224 | mesg = "your magical energy drain away"; |
| 5225 | if (n > u.uen) |
| 5226 | punct = '!'; |
| 5227 | |
| 5228 | u.uen -= n; |
| 5229 | if (u.uen < 0) { |
| 5230 | u.uenmax -= rnd(-u.uen); |
| 5231 | if (u.uenmax < 0) |
| 5232 | u.uenmax = 0; |
| 5233 | u.uen = 0; |
| 5234 | } else if (u.uen > u.uenmax) { |
| 5235 | /* uen might be greater than uenmax if caller reduced uenmax |
| 5236 | and then we throttled the loss being applied to current */ |
| 5237 | u.uen = u.uenmax; |
| 5238 | } |
| 5239 | disp.botl = TRUE; |
| 5240 | } |
| 5241 | /* after manipulating u.uen,uenmax and setting context.botl, so |
| 5242 | that You_feel() -> pline() will update status before the message */ |
| 5243 | You_feel("%s%c", mesg, punct); |
| 5244 | } |
| 5245 | |
| 5246 | /* the #untrap command - disarm a trap */ |
| 5247 | int |
no test coverage detected