MCPcopy Index your code
hub / github.com/NetHack/NetHack / artifact_score

Function artifact_score

src/end.c:906–940  ·  view source on GitHub ↗

called twice; first to calculate total, then to list relevant items */

Source from the content-addressed store, hash-verified

904
905/* called twice; first to calculate total, then to list relevant items */
906staticfn void
907artifact_score(
908 struct obj *list,
909 boolean counting, /* true => add up points; false => display them */
910 winid endwin)
911{
912 char pbuf[BUFSZ];
913 struct obj *otmp;
914 long value, points;
915
916 for (otmp = list; otmp; otmp = otmp->nobj) {
917 if (otmp->oartifact || otmp->otyp == BELL_OF_OPENING
918 || otmp->otyp == SPE_BOOK_OF_THE_DEAD
919 || otmp->otyp == CANDELABRUM_OF_INVOCATION) {
920 value = arti_cost(otmp); /* zorkmid value */
921 points = value * 5 / 2; /* score value */
922 if (counting) {
923 u.urexp = nowrap_add(u.urexp, points);
924 } else {
925 discover_object(otmp->otyp, TRUE, TRUE, FALSE);
926 /* not observe_object; dead characters don't observe */
927 otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1;
928 /* assumes artifacts don't have quan > 1 */
929 Sprintf(pbuf, "%s%s (worth %ld %s and %ld points)",
930 the_unique_obj(otmp) ? "The " : "",
931 otmp->oartifact ? artiname(otmp->oartifact)
932 : OBJ_NAME(objects[otmp->otyp]),
933 value, currency(value), points);
934 putstr(endwin, 0, pbuf);
935 }
936 }
937 if (Has_contents(otmp))
938 artifact_score(otmp->cobj, counting, endwin);
939 }
940}
941
942/* when dying while running the debug fuzzer, [almost] always keep going;
943 True: forced survival; False: doomed unless wearing life-save amulet */

Callers 1

really_doneFunction · 0.85

Calls 5

arti_costFunction · 0.85
discover_objectFunction · 0.85
the_unique_objFunction · 0.85
artinameFunction · 0.85
currencyFunction · 0.85

Tested by

no test coverage detected