From 97edd4b84530fa757659d9ff50cab628c5d1cea1 Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sat, 20 May 2023 04:16:49 +0900 Subject: [PATCH] split offering fake amulet into separate function --- src/pray.c | 57 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/pray.c b/src/pray.c index 6d12477ca..7d9d5391f 100644 --- a/src/pray.c +++ b/src/pray.c @@ -23,6 +23,7 @@ static void consume_offering(struct obj *); static void offer_too_soon(aligntyp); static void desecrate_high_altar(aligntyp); static void offer_real_amulet(struct obj *, aligntyp); /* NORETURN */ +static void offer_fake_amulet(struct obj *, boolean, aligntyp); static void offer_different_alignment_altar(struct obj *, aligntyp); static int bestow_artifact(void); static boolean pray_revive(void); @@ -1548,6 +1549,39 @@ offer_real_amulet(struct obj *otmp, aligntyp altaralign) /*NOTREACHED*/ } +static void +offer_fake_amulet( + struct obj *otmp, + boolean highaltar, + aligntyp altaralign) +{ + if (!highaltar && !otmp->known) { + offer_too_soon(altaralign); + return; + } + Soundeffect(se_thunderclap, 100); + You_hear("a nearby thunderclap."); + if (!otmp->known) { + You("realize you have made a %s.", + Hallucination ? "boo-boo" : "mistake"); + otmp->known = TRUE; + change_luck(-1); + } else { + /* don't you dare try to fool the gods */ + if (Deaf) + pline("Oh, no."); /* didn't hear thunderclap */ + change_luck(-3); + adjalign(-1); + u.ugangr += 3; + /* value = -3; */ + if (altaralign != u.ualign.type && highaltar) { + desecrate_high_altar(altaralign); + } else { /* value < 0 */ + gods_upset(altaralign); + } + } +} + /* possibly convert an altar's alignment or the hero's alignment */ static void offer_different_alignment_altar( @@ -1864,27 +1898,8 @@ dosacrifice(void) } /* real Amulet */ if (otmp->otyp == FAKE_AMULET_OF_YENDOR) { - if (!highaltar && !otmp->known) { - offer_too_soon(altaralign); - return ECMD_TIME; - } - Soundeffect(se_thunderclap, 100); - You_hear("a nearby thunderclap."); - if (!otmp->known) { - You("realize you have made a %s.", - Hallucination ? "boo-boo" : "mistake"); - otmp->known = TRUE; - change_luck(-1); - return ECMD_TIME; - } else { - /* don't you dare try to fool the gods */ - if (Deaf) - pline("Oh, no."); /* didn't hear thunderclap */ - change_luck(-3); - adjalign(-1); - u.ugangr += 3; - value = -3; - } + offer_fake_amulet(otmp, highaltar, altaralign); + return ECMD_TIME; } /* fake Amulet */ if (value == 0) {