BUC patch

This adds the BUC-patch, except that it includes four separate choices for
blessed/cursed/uncursed/unknown.  The patch only applies to full menu styles.

--Ken A

(Incidentally, I have a suggestion: when deciding what's the first line for
purposes of mailing out messages, use the first nonblank line...)
This commit is contained in:
arromdee
2002-01-16 03:19:45 +00:00
parent 5bf430c3d3
commit 4361289ec3
6 changed files with 137 additions and 2 deletions

View File

@@ -608,6 +608,10 @@ int retry;
menu_item *pick_list;
boolean all_categories = TRUE;
boolean drop_everything = FALSE;
boolean drop_blessed = FALSE;
boolean drop_cursed = FALSE;
boolean drop_uncursed = FALSE;
boolean drop_buc_unknown = FALSE;
#ifndef GOLDOBJ
if (u.ugold) {
@@ -626,7 +630,8 @@ int retry;
all_categories = FALSE;
n = query_category("Drop what type of items?",
invent,
UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL,
UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL |
BUC_BLESSED | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN,
&pick_list, PICK_ANY);
if (!n) goto drop_done;
for (i = 0; i < n; i++) {
@@ -634,6 +639,14 @@ int retry;
all_categories = TRUE;
else if (pick_list[i].item.a_int == 'A')
drop_everything = TRUE;
else if (pick_list[i].item.a_int == 'B')
drop_blessed = TRUE;
else if (pick_list[i].item.a_int == 'C')
drop_cursed = TRUE;
else if (pick_list[i].item.a_int == 'U')
drop_uncursed = TRUE;
else if (pick_list[i].item.a_int == 'X')
drop_buc_unknown = TRUE;
else
add_valid_menu_class(pick_list[i].item.a_int);
}
@@ -653,6 +666,35 @@ int retry;
otmp2 = otmp->nobj;
n_dropped += drop(otmp);
}
} else if (drop_blessed) {
for(otmp = invent; otmp; otmp = otmp2) {
/* zw, gold is never blessed or cursed */
otmp2 = otmp->nobj;
if (otmp->oclass != GOLD_CLASS && otmp->bknown && otmp->blessed)
n_dropped += drop(otmp);
}
} else if (drop_cursed) {
for(otmp = invent; otmp; otmp = otmp2) {
/* zw, gold is never blessed or cursed */
otmp2 = otmp->nobj;
if (otmp->oclass != GOLD_CLASS && otmp->bknown && otmp->cursed)
n_dropped += drop(otmp);
}
} else if (drop_uncursed) {
for(otmp = invent; otmp; otmp = otmp2) {
/* zw, gold is never blessed or cursed */
otmp2 = otmp->nobj;
if (otmp->oclass != GOLD_CLASS &&
otmp->bknown && !otmp->blessed && !otmp->cursed)
n_dropped += drop(otmp);
}
} else if (drop_buc_unknown) {
for(otmp = invent; otmp; otmp = otmp2) {
/* zw, gold is never blessed or cursed */
otmp2 = otmp->nobj;
if (otmp->oclass != GOLD_CLASS && !otmp->bknown)
n_dropped += drop(otmp);
}
} else {
/* should coordinate with perm invent, maybe not show worn items */
n = query_objlist("What would you like to drop?", invent,

View File

@@ -1631,6 +1631,45 @@ count_unpaid(list)
return count;
}
/*
* Returns the number of items with b/u/c/unknown within the given list.
* This does NOT include contained objects.
*/
int
count_buc(list, type)
struct obj *list;
int type;
{
int count = 0;
while (list) {
switch(type) {
case BUC_BLESSED:
if (list->oclass != GOLD_CLASS && list->bknown && list->blessed)
count++;
break;
case BUC_CURSED:
if (list->oclass != GOLD_CLASS && list->bknown && list->cursed)
count++;
break;
case BUC_UNCURSED:
if (list->oclass != GOLD_CLASS &&
list->bknown && !list->blessed && !list->cursed)
count++;
break;
case BUC_UNKNOWN:
if (list->oclass != GOLD_CLASS && !list->bknown)
count++;
break;
default:
impossible("need count of curse status %d?", type);
return 0;
}
list = list->nobj;
}
return count;
}
STATIC_OVL void
dounpaid()
{

View File

@@ -716,14 +716,33 @@ int how; /* type of query */
char invlet;
int ccount;
boolean do_unpaid = FALSE;
boolean do_blessed = FALSE, do_cursed = FALSE, do_uncursed = FALSE,
do_buc_unknown = FALSE;
int num_buc_types = 0;
*pick_list = (menu_item *) 0;
if (!olist) return 0;
if ((qflags & UNPAID_TYPES) && count_unpaid(olist)) do_unpaid = TRUE;
if ((qflags & BUC_BLESSED) && count_buc(olist, BUC_BLESSED)) {
do_blessed = TRUE;
num_buc_types++;
}
if ((qflags & BUC_CURSED) && count_buc(olist, BUC_CURSED)) {
do_cursed = TRUE;
num_buc_types++;
}
if ((qflags & BUC_UNCURSED) && count_buc(olist, BUC_UNCURSED)) {
do_uncursed = TRUE;
num_buc_types++;
}
if ((qflags & BUC_UNKNOWN) && count_buc(olist, BUC_UNKNOWN)) {
do_buc_unknown = TRUE;
num_buc_types++;
}
ccount = count_categories(olist, qflags);
/* no point in actually showing a menu for a single category */
if (ccount == 1 && !do_unpaid && !(qflags & BILLED_TYPES)) {
if (ccount == 1 && !do_unpaid && num_buc_types <= 1 && !(qflags & BILLED_TYPES)) {
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if ((qflags & WORN_TYPES) &&
!(curr->owornmask & (W_ARMOR|W_RING|W_AMUL|W_TOOL|W_WEP|W_SWAPWEP|W_QUIVER)))
@@ -805,6 +824,35 @@ int how; /* type of query */
"Auto-select every item being worn" :
"Auto-select every item", MENU_UNSELECTED);
}
/* items with b/u/c/unknown if there are any */
if (do_blessed) {
invlet = 'B';
any.a_void = 0;
any.a_int = 'B';
add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
"Auto-select blessed items", MENU_UNSELECTED);
}
if (do_cursed) {
invlet = 'C';
any.a_void = 0;
any.a_int = 'C';
add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
"Auto-select cursed items", MENU_UNSELECTED);
}
if (do_uncursed) {
invlet = 'U';
any.a_void = 0;
any.a_int = 'U';
add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
"Auto-select known uncursed items", MENU_UNSELECTED);
}
if (do_buc_unknown) {
invlet = 'X';
any.a_void = 0;
any.a_int = 'X';
add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
"Auto-select un-b/u/c known items", MENU_UNSELECTED);
}
end_menu(win, qstr);
n = select_menu(win, how, pick_list);
destroy_nhwindow(win);