called twice; first to calculate total, then to list relevant items */
| 904 | |
| 905 | /* called twice; first to calculate total, then to list relevant items */ |
| 906 | staticfn void |
| 907 | artifact_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 */ |
no test coverage detected