address github issue #303 - paranoid_confirm:pray

An issue from nearly three years ago, reported by Anerag:  asking
player whether to really pray isn't paranoid enough because it
accepts 'y' rather than requring "yes".

This changes it to require "yes" followed by <return> or <enter> if
paranoid_confirm:Confirm is also set.  (A side-effect of that is
explicit "no<return|enter>" is required instead of just 'n' to
decline--for all the paranoid confirmations, not just for prayer.)
This extension of paranoid:Confirm applies to paranoid:AutoAll too.

A comment asks why paranoid_confirm:pray is different from the other
paranoid questions in the first place.  The answer is that when it
isn't set, no confirmation prompt is issued at all.  The others all
have y/n confirmation prompts when the corresponding paranoid option
isn't set.

Once upon a time there was a boolean option called 'prayconfirm' that
issued "really pray?" prompt when True.  It was added after players
whinged about typing Alt+p when they meant to type Alt+o.  When the
more advanced 'paranoid_confirmation' was introduced, paranoid:pray
superseded prayconfirm, but it still only issues a confirmation
prompt where there normally wouldn't be one rather than change an
existing one to require "yes<return|enter>" instead of 'y'.

Closes #303
This commit is contained in:
PatR
2023-06-24 16:12:54 -07:00
parent 456a87fdc6
commit b1d30fbce9
3 changed files with 36 additions and 12 deletions

View File

@@ -211,9 +211,10 @@ packorder a list of default symbols for kinds of [")[%?+!=/(*`0_]
some other things) gets shown if the 'sortpack' option is on
(If you specify only some kinds of items, the others from the
default order will be appended to the end.)
paranoid_confirmation space separated list [paranoid_confirmation:pray]
paranoid_confirmation space separated list [paranoid_confirm:pray swim]
of situations where alternate prompting is desired
Confirm -- when requiring "yes", also require "no" to reject
Confirm -- when requiring "yes", also require "no" to reject;
also requires yes rather than y for pray, Autoall
quit -- yes vs y to confirm quitting or to enter explore mode
die -- yes vs y to confirm dying (for explore or debug mode)
bones -- yes vs y to confirm saving bones data in debug mode
@@ -223,10 +224,10 @@ paranoid_confirmation space separated list [paranoid_confirmation:pray]
Were-change -- yes vs y to confirm changing form due to
lycanthropy when hero has polymorph control;
pray -- y to confirm an attempt to pray; on by default
swim -- y to confirm an attempt to move into water or lava
when hero can see it and isn't impaired; on by default
swim -- require m prefix to move into water or lava when
hero has seen it and isn't impaired; on by default;
AutoAll -- y to confirm if using menustyle:Full and choice 'A'
in the object class filtering menu is selected
in the object class filtering menu is selected;
Remove -- always pick from inventory for 'R' and 'T' even when
wearing just one applicable item to remove or take off
pickup_burden when you pick up an item that exceeds this encumbrance [S]

View File

@@ -1361,7 +1361,11 @@ query_category(
for (i = 0; i < n; ++i)
if ((*pick_list)[i].item.a_int == 'A') {
if (y_n("Really autoselect All?") != 'y') {
/* ParanoidAutoAll is set (otherwise verify_All is false);
if ParanoidConfirm is also set, require "yes" rather than
just "y" to accept (and "no" rather than "n" to decline) */
if (paranoid_query(ParanoidConfirm,
"Really autoselect All?")) {
/* answer is "no", so take 'A' out of the list;
if it is the only entry, we'll return nothing,
otherwise go on to next menu without autoselect */

View File

@@ -2057,14 +2057,24 @@ pray_revive(void)
int
dopray(void)
{
boolean ok;
/*
* If ParanoidPray is set, confirm prayer to avoid accidental slips
* of Alt+p.
* YN(): don't save response in do-again buffer since if it is 'y',
* ^A would bypass confirmation, or if 'n', ^A would be pointless.
* of Alt+p. If ParanoidConfirm is also set, require "yes" rather
* than just "y" (will also require "no" to decline).
*/
if (ParanoidPray && YN("Are you sure you want to pray?") != 'y')
if (ParanoidPray) {
ok = paranoid_query(ParanoidConfirm, "Are you sure you want to pray?");
/* clear command recall buffer; otherwise ^A to repeat p(ray) would
do so without confirmation (if 'ok') or do nothing (if '!ok') */
cmdq_clear(CQ_REPEAT);
cmdq_add_ec(CQ_REPEAT, dopray);
if (!ok) /* declined the "are you sure?" confirmation */
return ECMD_OK;
}
if (!u.uconduct.gnostic++)
/* breaking conduct should probably occur in can_pray() at
@@ -2085,7 +2095,16 @@ dopray(void)
from the do-again buffer, so need to suppress this response too;
otherwise subsequent ^A would use this answer for "are you sure?"
and bypass confirmation */
if ((ParanoidPray ? YN(forcesuccess) : y_n(forcesuccess)) == 'y') {
if (ParanoidPray) {
boolean save_doagain = gi.in_doagain;
gi.in_doagain = FALSE;
ok = (YN(forcesuccess) == 'y');
gi.in_doagain = save_doagain;
} else {
ok = (y_n(forcesuccess) == 'y');
}
if (ok) {
u.ublesscnt = 0;
if (u.uluck < 0)
u.uluck = 0;