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

Function is_magic_key

src/artifact.c:2774–2786  ·  view source on GitHub ↗

Master Key is magic key if its bless/curse state meets our criteria: not cursed for rogues or blessed for non-rogues */

Source from the content-addressed store, hash-verified

2772/* Master Key is magic key if its bless/curse state meets our criteria:
2773 not cursed for rogues or blessed for non-rogues */
2774boolean
2775is_magic_key(struct monst *mon, /* if null, non-rogue is assumed */
2776 struct obj *obj)
2777{
2778 if (is_art(obj, ART_MASTER_KEY_OF_THIEVERY)) {
2779 if ((mon == &gy.youmonst) ? Role_if(PM_ROGUE)
2780 : (mon && mon->data == &mons[PM_ROGUE]))
2781 return !obj->cursed; /* a rogue; non-cursed suffices for magic */
2782 /* not a rogue; key must be blessed to behave as a magic one */
2783 return obj->blessed;
2784 }
2785 return FALSE;
2786}
2787
2788/* figure out whether 'mon' (usually youmonst) is carrying the magic key */
2789struct obj *

Callers 3

has_magic_keyFunction · 0.85
autokeyFunction · 0.85
pick_lockFunction · 0.85

Calls 1

is_artFunction · 0.85

Tested by

no test coverage detected