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

Function artifact_name

src/artifact.c:328–353  ·  view source on GitHub ↗

* Returns the full name (with articles and correct capitalization) of an * artifact named "name" if one exists, or NULL, it not. * The given name must be rather close to the real name for it to match. * The object type of the artifact is returned in otyp if the return value * is non-NULL. */

Source from the content-addressed store, hash-verified

326 * is non-NULL.
327 */
328const char *
329artifact_name(
330 const char *name, /* string from player that might be an artifact name */
331 short *otyp_p, /* secondary output */
332 boolean fuzzy) /* whether to allow extra or omitted spaces or dashes */
333{
334 const struct artifact *a;
335 const char *aname;
336
337 if (!strncmpi(name, "the ", 4))
338 name += 4;
339
340 for (a = artilist + 1; a->otyp; a++) {
341 aname = a->name;
342 if (!strncmpi(aname, "the ", 4))
343 aname += 4;
344 if (!fuzzy ? !strcmpi(name, aname)
345 : fuzzymatch(name, aname, " -", TRUE)) {
346 if (otyp_p)
347 *otyp_p = a->otyp;
348 return a->name;
349 }
350 }
351
352 return (char *) 0;
353}
354
355boolean
356exist_artifact(int otyp, const char *name)

Callers 5

do_onameFunction · 0.85
doname_baseFunction · 0.85
theFunction · 0.85
readobjnam_postparse3Function · 0.85
readobjnamFunction · 0.85

Calls 2

fuzzymatchFunction · 0.85
strncmpiFunction · 0.70

Tested by

no test coverage detected