Remove a positive enchantment or charge from obj, * possibly carried by you or a monster */
| 1379 | * possibly carried by you or a monster |
| 1380 | */ |
| 1381 | boolean |
| 1382 | drain_item(struct obj *obj, boolean by_you) |
| 1383 | { |
| 1384 | boolean u_ring; |
| 1385 | |
| 1386 | /* Is this a charged/enchanted object? */ |
| 1387 | if (!obj |
| 1388 | || (!objects[obj->otyp].oc_charged && obj->oclass != WEAPON_CLASS |
| 1389 | && obj->oclass != ARMOR_CLASS && !is_weptool(obj)) |
| 1390 | || obj->spe <= 0) |
| 1391 | return FALSE; |
| 1392 | if (defends(AD_DRLI, obj) || defends_when_carried(AD_DRLI, obj) |
| 1393 | || obj_resists(obj, 10, 90)) |
| 1394 | return FALSE; |
| 1395 | |
| 1396 | /* Charge for the cost of the object */ |
| 1397 | if (by_you) |
| 1398 | costly_alteration(obj, COST_DRAIN); |
| 1399 | |
| 1400 | /* Drain the object and any implied effects */ |
| 1401 | obj->spe--; |
| 1402 | u_ring = (obj == uleft) || (obj == uright); |
| 1403 | switch (obj->otyp) { |
| 1404 | case RIN_GAIN_STRENGTH: |
| 1405 | if ((obj->owornmask & W_RING) && u_ring) { |
| 1406 | ABON(A_STR)--; |
| 1407 | disp.botl = TRUE; |
| 1408 | } |
| 1409 | break; |
| 1410 | case RIN_GAIN_CONSTITUTION: |
| 1411 | if ((obj->owornmask & W_RING) && u_ring) { |
| 1412 | ABON(A_CON)--; |
| 1413 | disp.botl = TRUE; |
| 1414 | } |
| 1415 | break; |
| 1416 | case RIN_ADORNMENT: |
| 1417 | if ((obj->owornmask & W_RING) && u_ring) { |
| 1418 | ABON(A_CHA)--; |
| 1419 | disp.botl = TRUE; |
| 1420 | } |
| 1421 | break; |
| 1422 | case RIN_INCREASE_ACCURACY: |
| 1423 | if ((obj->owornmask & W_RING) && u_ring) |
| 1424 | u.uhitinc--; |
| 1425 | break; |
| 1426 | case RIN_INCREASE_DAMAGE: |
| 1427 | if ((obj->owornmask & W_RING) && u_ring) |
| 1428 | u.udaminc--; |
| 1429 | break; |
| 1430 | case RIN_PROTECTION: |
| 1431 | if (u_ring) |
| 1432 | disp.botl = TRUE; /* bot() will recalc u.uac */ |
| 1433 | break; |
| 1434 | case HELM_OF_BRILLIANCE: |
| 1435 | if ((obj->owornmask & W_ARMH) && (obj == uarmh)) { |
| 1436 | ABON(A_INT)--; |
| 1437 | ABON(A_WIS)--; |
| 1438 | disp.botl = TRUE; |
no test coverage detected