gitpub issue #933: feedback for throwing w/ count
Issue reported by Meklon2007: typing arrow keys when a menu is open can end up with hidden counts. That's a Windows thing and this makes no attempt to address it. (That's also a user error since menus don't support arrow key use.) It shows up more for throwing that for other things because fetching an object from inventory for throwing attempts to enforce a count limit during item selection that other actions don't. But feedback could also be odd if you explicitly specify a count since the rejection wasn't attempting to distinguish throwing more than one from throwing more than you have. This changes things so that with invent of |$ - 3 gold pieces |a - a dagger |b - 3 darts t4$ now yields "You only have 3." instead of throwing all 3 t4a now yields "You only have 1." instead of "you can only throw one" t2b still yields "You can only throw one at a time." t4b now yields "You only have 2 and can only throw one at a time." In each case, it will reprompt rather than terminate the throw. "Only one at a time" was already in place when multi-shot throwing/ shooting was introduced and became iffy then, but the way to try to throw a specific amount is via a repeat count before t rather than by choosing a subset when selecting the inventory item for t. The count prefix method also works for f which doesn't otherwise provide an opportunity to specify count since inventory item is preselected via quiver. Someone might want to reopen the arrow behavior as a Windows issue but I'm not sure how that would be fixed other than by eliminating its attempt to be user-friendly in converting arrows into movement direction keystrokes. Closes #933
This commit is contained in:
20
src/invent.c
20
src/invent.c
@@ -1574,8 +1574,8 @@ getobj(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!otmp) /* didn't find what we were looking for, */
|
if (!otmp) /* didn't find what we were looking for, */
|
||||||
cmdq_clear(CQ_CANNED); /* so discard any other queued commands */
|
cmdq_clear(CQ_CANNED); /* so discard any other queued cmnds */
|
||||||
else if (cntgiven) {
|
else if (cntgiven) {
|
||||||
/* if stack is smaller than count, drop the whole stack */
|
/* if stack is smaller than count, drop the whole stack */
|
||||||
if (cnt < 1 || otmp->quan <= cnt)
|
if (cnt < 1 || otmp->quan <= cnt)
|
||||||
@@ -1791,15 +1791,23 @@ getobj(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cntgiven && !strcmp(word, "throw")) {
|
if (cntgiven && !strcmp(word, "throw")) {
|
||||||
|
static const char only_one[] = "can only throw one at a time";
|
||||||
|
boolean coins;
|
||||||
|
|
||||||
/* permit counts for throwing gold, but don't accept counts
|
/* permit counts for throwing gold, but don't accept counts
|
||||||
for other things since the throw code will split off a
|
for other things since the throw code will split off a
|
||||||
single item anyway; if populating quiver, 'word' will be
|
single item anyway; if populating quiver, 'word' will be
|
||||||
"ready" or "fire" and this restriction doesn't apply */
|
"ready" or "fire" and this restriction doesn't apply */
|
||||||
if (cnt == 0)
|
if (cnt == 0L || !otmp)
|
||||||
return (struct obj *) 0;
|
return (struct obj *) 0;
|
||||||
if (cnt > 1 && (ilet != def_oc_syms[COIN_CLASS].sym
|
coins = (otmp->oclass == COIN_CLASS);
|
||||||
&& !(otmp && otmp->oclass == COIN_CLASS))) {
|
if (cnt > 1L && (!coins || cnt > otmp->quan)) {
|
||||||
You("can only throw one item at a time.");
|
if (cnt > otmp->quan)
|
||||||
|
You("only have %ld%s%s.", otmp->quan,
|
||||||
|
(!coins && otmp->quan > 1L) ? " and " : "",
|
||||||
|
(!coins && otmp->quan > 1L) ? only_one : "");
|
||||||
|
else
|
||||||
|
You("%s.", only_one);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user