MCPcopy Create free account
hub / github.com/NetHack/NetHack / charge_ok

Function charge_ok

src/read.c:688–724  ·  view source on GitHub ↗

getobj callback for object to charge */

Source from the content-addressed store, hash-verified

686
687/* getobj callback for object to charge */
688int
689charge_ok(struct obj *obj)
690{
691 if (!obj)
692 return GETOBJ_EXCLUDE;
693
694 if (obj->oclass == WAND_CLASS)
695 return GETOBJ_SUGGEST;
696
697 if (obj->oclass == RING_CLASS && objects[obj->otyp].oc_charged
698 && obj->dknown && objects[obj->otyp].oc_name_known)
699 return GETOBJ_SUGGEST;
700
701 if (is_weptool(obj)) /* specific check before general tools */
702 return GETOBJ_EXCLUDE;
703
704 if (obj->oclass == TOOL_CLASS) {
705 /* suggest tools that aren't oc_charged but can still be recharged */
706 if (obj->otyp == BRASS_LANTERN
707 || (obj->otyp == OIL_LAMP)
708 /* only list magic lamps if they are not identified yet */
709 || (obj->otyp == MAGIC_LAMP
710 && !objects[MAGIC_LAMP].oc_name_known)) {
711 return GETOBJ_SUGGEST;
712 }
713 /* suggest chargeable tools only if discovered, to prevent leaking
714 info (e.g. revealing if an unidentified 'flute' is magic or not) */
715 if (objects[obj->otyp].oc_charged) {
716 return (obj->dknown && objects[obj->otyp].oc_name_known)
717 ? GETOBJ_SUGGEST : GETOBJ_DOWNPLAY;
718 }
719 return GETOBJ_EXCLUDE;
720 }
721 /* why are weapons/armor considered charged anyway?
722 * make them selectable even so for "feeling of loss" message */
723 return GETOBJ_EXCLUDE_SELECTABLE;
724}
725
726/* recharge an object; curse_bless is -1 if the recharging implement
727 was cursed, +1 if blessed, 0 otherwise. */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected