* Decide whether an object being placed into a magic bag will cause * it to explode. If the object is a bag itself, check recursively. */
| 2485 | * it to explode. If the object is a bag itself, check recursively. |
| 2486 | */ |
| 2487 | staticfn boolean |
| 2488 | mbag_explodes(struct obj *obj, int depthin) |
| 2489 | { |
| 2490 | /* these won't cause an explosion when they're empty */ |
| 2491 | if ((obj->otyp == WAN_CANCELLATION || obj->otyp == BAG_OF_TRICKS) |
| 2492 | && obj->spe <= 0) |
| 2493 | return FALSE; |
| 2494 | |
| 2495 | /* odds: 1/1, 2/2, 3/4, 4/8, 5/16, 6/32, 7/64, 8/128, 9/128, 10/128,... */ |
| 2496 | if ((Is_mbag(obj) || obj->otyp == WAN_CANCELLATION) |
| 2497 | && (rn2(1 << (depthin > 7 ? 7 : depthin)) <= depthin)) |
| 2498 | return TRUE; |
| 2499 | else if (Has_contents(obj)) { |
| 2500 | struct obj *otmp; |
| 2501 | |
| 2502 | for (otmp = obj->cobj; otmp; otmp = otmp->nobj) |
| 2503 | if (mbag_explodes(otmp, depthin + 1)) |
| 2504 | return TRUE; |
| 2505 | } |
| 2506 | return FALSE; |
| 2507 | } |
| 2508 | |
| 2509 | staticfn boolean |
| 2510 | is_boh_item_gone(void) |
no test coverage detected