wanghao_branch
jiehaoxuan 1 year ago
parent b9617c21de
commit 396fd2b00c

@ -1,3 +1,4 @@
//2023/12/3 大致阅读改代码,并对没有英文注释的代码加上了汉文注释
/* NetHack 3.7 write.c $NHDT-Date: 1596498232 2020/08/03 23:43:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.26 $ */
/* NetHack may be freely redistributed. See license for details. */
@ -62,6 +63,7 @@ cost(struct obj *otmp)
the discoveries list and aren't present in current inventory,
so some scrolls with ought to yield True will end up False */
static boolean
//判断一个玩家是否知道某个卷轴的名称
label_known(int scrolltype, struct obj *objlist)
{
struct obj *otmp;
@ -69,24 +71,30 @@ label_known(int scrolltype, struct obj *objlist)
/* only scrolls */
if (objects[scrolltype].oc_class != SCROLL_CLASS)
return FALSE;
/* type known implies full discovery; otherwise,
user-assigned name implies partial discovery */
if (objects[scrolltype].oc_name_known || objects[scrolltype].oc_uname)
return TRUE;
/* check inventory, including carried containers with known contents */
for (otmp = objlist; otmp; otmp = otmp->nobj) {
if (otmp->otyp == scrolltype && otmp->dknown)
if (otmp->otyp == scrolltype && otmp->dknown) // 检查物品种类和标记为已识别的卷轴
return TRUE;
if (Has_contents(otmp) && otmp->cknown
&& label_known(scrolltype, otmp->cobj))
if (Has_contents(otmp) && otmp->cknown // 检查物品是否是容器且已知其内容
&& label_known(scrolltype, otmp->cobj)) // 递归地检查容器内的物品
return TRUE;
}
/* not found */
return FALSE;
}
/* getobj callback for object to write on */
static int
//用于确定物品是否可以写入(即在其上书写符文或咒语)
write_ok(struct obj *obj)
{
if (!obj || (obj->oclass != SCROLL_CLASS && obj->oclass != SPBOOK_CLASS))
@ -237,28 +245,32 @@ dowrite(struct obj *pen)
found:
if (i == SCR_BLANK_PAPER || i == SPE_BLANK_PAPER) {
You_cant("write that!");
pline("It's obscene!");
return ECMD_TIME;
} else if (i == SPE_NOVEL) {
boolean fanfic = !rn2(3), tearup = !rn2(3);
// 如果玩家尝试在空白卷轴或空白法术书上书写
You_cant("write that!"); // 提示玩家无法这样做
pline("It's obscene!"); // 发出警告
return ECMD_TIME; // 返回时间消耗
} else if (i == SPE_NOVEL) {
// 如果玩家尝试在小说上书写
boolean fanfic = !rn2(3), tearup = !rn2(3);
if (!fanfic) {
You("%s to write the Great Yendorian Novel, but %s inspiration.",
!tearup ? "prepare" : "try",
!Hallucination ? "lack" : "have too much");
} else {
You("%sproduce really %s fan-fiction.",
!tearup ? "start to " : "",
!Hallucination ? "lame" : "awesome");
}
if (!tearup) {
You("give up on the idea.");
} else {
You("tear it up.");
useup(paper); // 销毁使用的纸张
}
return ECMD_TIME; // 返回时间消耗
}
if (!fanfic) {
You("%s to write the Great Yendorian Novel, but %s inspiration.",
!tearup ? "prepare" : "try",
!Hallucination ? "lack" : "have too much");
} else {
You("%sproduce really %s fan-fiction.",
!tearup ? "start to " : "",
!Hallucination ? "lame" : "awesome");
}
if (!tearup) {
You("give up on the idea.");
} else {
You("tear it up.");
useup(paper);
}
return ECMD_TIME;
} else if (i == SPE_BOOK_OF_THE_DEAD) {
pline("No mere dungeon adventurer could write that.");
return ECMD_TIME;

Loading…
Cancel
Save