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

@@ -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')
return ECMD_OK;
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;