Split can-engrave checks out of engraving function

This commit is contained in:
Pasi Kallinen
2021-07-07 16:41:58 +03:00
parent 216c26aaef
commit 2f1b3a34ad

View File

@@ -6,6 +6,7 @@
#include "hack.h"
static int stylus_ok(struct obj *);
static boolean u_can_engrave(void);
static int engrave(void);
static const char *blengr(void);
@@ -444,6 +445,42 @@ stylus_ok(struct obj *obj)
return GETOBJ_EXCLUDE;
}
/* can hero engrave at all (at their location)? */
static boolean
u_can_engrave(void)
{
if (u.uswallow) {
if (is_animal(u.ustuck->data)) {
pline("What would you write? \"Jonah was here\"?");
return FALSE;
} else if (is_whirly(u.ustuck->data)) {
cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
return FALSE;
}
} else if (is_lava(u.ux, u.uy)) {
You_cant("write on the %s!", surface(u.ux, u.uy));
return FALSE;
} else if (is_pool(u.ux, u.uy) || IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
You_cant("write on the %s!", surface(u.ux, u.uy));
return FALSE;
}
if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) /* in bubble */) {
You_cant("write in thin air!");
return FALSE;
} else if (!accessible(u.ux, u.uy)) {
/* stone, tree, wall, secret corridor, pool, lava, bars */
You_cant("write here.");
return FALSE;
}
if (cantwield(g.youmonst.data)) {
You_cant("even hold anything!");
return FALSE;
}
if (check_capacity((char *) 0))
return FALSE;
return TRUE;
}
/* Mohs' Hardness Scale:
* 1 - Talc 6 - Orthoclase
* 2 - Gypsum 7 - Quartz
@@ -511,37 +548,11 @@ doengrave(void)
type = ENGR_BLOOD;
/* Can the adventurer engrave at all? */
if (!u_can_engrave())
return 0;
if (u.uswallow) {
if (is_animal(u.ustuck->data)) {
pline("What would you write? \"Jonah was here\"?");
return 0;
} else if (is_whirly(u.ustuck->data)) {
cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
return 0;
} else
jello = TRUE;
} else if (is_lava(u.ux, u.uy)) {
You_cant("write on the %s!", surface(u.ux, u.uy));
return 0;
} else if (is_pool(u.ux, u.uy) || IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
You_cant("write on the %s!", surface(u.ux, u.uy));
return 0;
}
if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) /* in bubble */) {
You_cant("write in thin air!");
return 0;
} else if (!accessible(u.ux, u.uy)) {
/* stone, tree, wall, secret corridor, pool, lava, bars */
You_cant("write here.");
return 0;
}
if (cantwield(g.youmonst.data)) {
You_cant("even hold anything!");
return 0;
}
if (check_capacity((char *) 0))
return 0;
jello = (u.uswallow && !(is_animal(u.ustuck->data)
|| is_whirly(u.ustuck->data)));
/* One may write with finger, or weapon, or wand, or..., or...
* Edited by GAN 10/20/86 so as not to change weapon wielded.