Compare commits

...

8 Commits

@ -0,0 +1,33 @@
用例名eat
执行者:玩家
目标:通过吃东西来补充角色的饥饿值
前置条件:
玩家拥有至少一个可食用物品
玩家处于可以吃东西的状态(例如,非战斗状态)
玩家饥饿值未满
后置条件:
食物使用后,玩家的饥饿值恢复
玩家的状态可能因食物效果而改变
主要场景:
玩家选择一个食物。
玩家点击“使用”选项。
游戏判断玩家是否满足使用该道具的条件(例如,是否饥饿,是否非战斗)。
如果满足条件,游戏将吃掉食物,并恢复饥饿值。
如果为特殊食物,赋予特殊效果
使用后食物消失
玩家可以查看食物使用后的效果和状态变化。
交互动作:
1玩家遇到特殊情况后下达命令cmd.c并apply.c执行来选择使用食物
2检查是否饥饿若饥饿则使用食物
3根据食物使用更新内存分配alloc.c并记录时间date.c参数若食物有效果则用apply.c应用效果
用例交互图
玩家
| | 选择食物 |---------->| 判断条件饥饿值是否小于90 |---------->| 显示效果 |---------->| 恢复饥饿值更新状态 |---------->| 更新UI |---------->| 反馈 |
游戏系统
| | 触发条件 |---------->| 验证玩家 |---------->| 获取道具信息|---------->| 执行效果|---------->| 更新UI |---------->| 返回结果 |

@ -13,7 +13,7 @@
#define TEXT_TOMBSTONE #define TEXT_TOMBSTONE
#endif #endif
#if defined(mac) || defined(__BEOS__) #if defined(mac) || defined(__BEOS__)
#ifndef TEXT_TOMBSTONE #ifndef TEXT_TOMBSTONE//墓碑文档定义
#define TEXT_TOMBSTONE #define TEXT_TOMBSTONE
#endif #endif
#endif #endif
@ -70,7 +70,7 @@ static const char *const rip_txt[] = {
#define DEATH_LINE 8 /* *char[] line # for death description */ #define DEATH_LINE 8 /* *char[] line # for death description */
#define YEAR_LINE 12 /* *char[] line # for year */ #define YEAR_LINE 12 /* *char[] line # for year */
static void static void//将给定的文本字符串居中并放置在特定的位置。
center(int line, char *text) center(int line, char *text)
{ {
register char *ip, *op; register char *ip, *op;
@ -81,7 +81,7 @@ center(int line, char *text)
} }
void void
genl_outrip(winid tmpwin, int how, time_t when) genl_outrip(winid tmpwin, int how, time_t when)//在游戏中生成并显示一个“墓碑”文本
{ {
register char **dp; register char **dp;
register char *dpx; register char *dpx;

@ -67,7 +67,7 @@ static FILE *bw_FILE[MAXFD] = {0,0,0,0,0};
*/ */
static int static int
getidx(int fd, int flg) getidx(int fd, int flg)//保存给定的文件描述符 fd。
{ {
int i, retval = -1; int i, retval = -1;
@ -87,7 +87,7 @@ getidx(int fd, int flg)
/* Let caller know that bclose() should handle it (TRUE) */ /* Let caller know that bclose() should handle it (TRUE) */
boolean boolean
close_check(int fd) close_check(int fd)//检查给定的文件描述符 fd 是否已经存在于 bw_sticky 数组中。
{ {
int idx = getidx(fd, NOSLOT); int idx = getidx(fd, NOSLOT);
boolean retval = FALSE; boolean retval = FALSE;
@ -98,7 +98,7 @@ close_check(int fd)
} }
void void
bufon(int fd) bufon(int fd)//启用缓冲IO并将给定的文件描述符 fd 关联到一个 bw_sticky 数组中的索引。
{ {
int idx = getidx(fd, NOFLG); int idx = getidx(fd, NOFLG);
@ -119,7 +119,7 @@ bufon(int fd)
} }
void void
bufoff(int fd) bufoff(int fd)//关闭与给定文件描述符 fd 关联的缓冲IO。
{ {
int idx = getidx(fd, NOFLG); int idx = getidx(fd, NOFLG);
@ -130,7 +130,7 @@ bufoff(int fd)
} }
void void
bclose(int fd) bclose(int fd)//关闭与给定文件描述符 fd 关联的文件,并释放相关的资源。
{ {
int idx = getidx(fd, NOSLOT); int idx = getidx(fd, NOSLOT);
@ -150,7 +150,7 @@ bclose(int fd)
} }
void void
bflush(int fd) bflush(int fd)//刷新与给定文件描述符 fd 关联的缓冲区。
{ {
int idx = getidx(fd, NOFLG); int idx = getidx(fd, NOFLG);

@ -18,7 +18,7 @@
struct sysopt sysopt; struct sysopt sysopt;
void void
sys_early_init(void) sys_early_init(void)//初始化
{ {
sysopt.support = (char *) 0; sysopt.support = (char *) 0;
sysopt.recover = (char *) 0; sysopt.recover = (char *) 0;
@ -90,7 +90,7 @@ sys_early_init(void)
} }
void void
sysopt_release(void) sysopt_release(void)//系统释放
{ {
if (sysopt.support) if (sysopt.support)
free((genericptr_t) sysopt.support), sysopt.support = (char *) 0; free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;

@ -12,14 +12,14 @@ static NEARDATA int utcnt, utpnt;
static NEARDATA coord utrack[UTSZ]; static NEARDATA coord utrack[UTSZ];
void void
initrack(void) initrack(void)//初始化路径
{ {
utcnt = utpnt = 0; utcnt = utpnt = 0;
} }
/* add to track */ /* add to track */
void void
settrack(void) settrack(void)//添加路径
{ {
if (utcnt < UTSZ) if (utcnt < UTSZ)
utcnt++; utcnt++;
@ -31,7 +31,7 @@ settrack(void)
} }
coord * coord *
gettrack(coordxy x, coordxy y) gettrack(coordxy x, coordxy y)//寻找路径.
{ {
register int cnt, ndist; register int cnt, ndist;
register coord *tc; register coord *tc;

@ -15,10 +15,10 @@ static void insert_rtoption(char *);
/* fill buffer with short version (so caller can avoid including date.h) */ /* fill buffer with short version (so caller can avoid including date.h) */
char * char *
version_string(char *buf, size_t bufsz) version_string(char *buf, size_t bufsz)//获取一个版本字符串并将其存储在提供的缓冲区
{ {
Snprintf(buf, bufsz, "%s", Snprintf(buf, bufsz, "%s",
((nomakedefs.version_string && nomakedefs.version_string[0]) ((nomakedefs.version_string && nomakedefs.version_string[0])//确定要复制哪个版本字符串。检查nomakedefs.version_string是否存在并且是否非空
? nomakedefs.version_string ? nomakedefs.version_string
/* in case we try to write a paniclog entry after releasing /* in case we try to write a paniclog entry after releasing
the 'nomakedefs' data */ the 'nomakedefs' data */
@ -28,7 +28,7 @@ version_string(char *buf, size_t bufsz)
/* fill and return the given buffer with the long nethack version string */ /* fill and return the given buffer with the long nethack version string */
char * char *
getversionstring(char *buf, size_t bufsz) getversionstring(char *buf, size_t bufsz)//获取并格式化一个版本字符串
{ {
Strcpy(buf, nomakedefs.version_id); Strcpy(buf, nomakedefs.version_id);
@ -209,7 +209,7 @@ doextversion(void)
} }
void void
early_version_info(boolean pastebuf) early_version_info(boolean pastebuf)//获取并打印程序版本信息
{ {
char buf1[BUFSZ], buf2[BUFSZ]; char buf1[BUFSZ], buf2[BUFSZ];
char *buf, *tmp; char *buf, *tmp;
@ -295,7 +295,7 @@ comp_times(long filetime)
#endif #endif
boolean boolean
check_version( check_version(//检查给定的文件版本信息是否与预期的版本和配置兼容
struct version_info *version_data, struct version_info *version_data,
const char *filename, const char *filename,
boolean complain, boolean complain,
@ -337,7 +337,7 @@ check_version(
/* this used to be based on file date and somewhat OS-dependant, /* this used to be based on file date and somewhat OS-dependant,
but now examines the initial part of the file's contents */ but now examines the initial part of the file's contents */
boolean boolean
uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags) uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)//检查给定的文件是否与预期的版本和配置兼容。
{ {
ssize_t rlen = 0; ssize_t rlen = 0;
int cmc = 0, filecmc = 0; int cmc = 0, filecmc = 0;
@ -376,7 +376,7 @@ uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)
} }
void void
store_formatindicator(NHFILE *nhfp) store_formatindicator(NHFILE *nhfp)//在给定的文件上存储格式指示符。
{ {
char indicate = 'u'; char indicate = 'u';
int cmc = 0; int cmc = 0;
@ -391,7 +391,7 @@ store_formatindicator(NHFILE *nhfp)
} }
void void
store_version(NHFILE *nhfp) store_version(NHFILE *nhfp)//在给定的文件上存储版本信息。
{ {
struct version_info version_data = { struct version_info version_data = {
0UL, 0UL, 0UL, 0UL, 0UL 0UL, 0UL, 0UL, 0UL, 0UL
@ -424,7 +424,7 @@ const char amiga_version_string[] = AMIGA_VERSION_STRING;
#endif #endif
unsigned long unsigned long
get_feature_notice_ver(char *str) get_feature_notice_ver(char *str)//从给定的字符串中解析并提取版本号。
{ {
char buf[BUFSZ]; char buf[BUFSZ];
int ver_maj, ver_min, patch; int ver_maj, ver_min, patch;

@ -6,16 +6,16 @@
#include "hack.h" #include "hack.h"
void void
were_change(struct monst *mon) were_change(struct monst *mon)//处理角色在满月之夜变形成野兽,以及在非满月之夜变回人类的过程,并在这个过程中播放动物的叫声,唤醒附近的怪物等
{ {
if (!is_were(mon->data)) if (!is_were(mon->data))//检查角色是否具有变身能力
return; return;
if (is_human(mon->data)) { if (is_human(mon->data)) {//检查角色是否处于人类形态
if (!Protection_from_shape_changers if (!Protection_from_shape_changers//判断是否应该变身
&& !rn2(night() ? (flags.moonphase == FULL_MOON ? 3 : 30) && !rn2(night() ? (flags.moonphase == FULL_MOON ? 3 : 30)
: (flags.moonphase == FULL_MOON ? 10 : 50))) { : (flags.moonphase == FULL_MOON ? 10 : 50))) {
new_were(mon); /* change into animal form */ new_were(mon); /* 变身为野兽 */
if (!Deaf && !canseemon(mon)) { if (!Deaf && !canseemon(mon)) {
const char *howler; const char *howler;
@ -33,12 +33,12 @@ were_change(struct monst *mon)
if (howler) { if (howler) {
Soundeffect(se_canine_howl, 50); Soundeffect(se_canine_howl, 50);
You_hear("a %s howling at the moon.", howler); You_hear("a %s howling at the moon.", howler);
wake_nearto(mon->mx, mon->my, 4 * 4); wake_nearto(mon->mx, mon->my, 4 * 4);//播放动物的叫声并唤醒附近的怪物
} }
} }
} }
} else if (!rn2(30) || Protection_from_shape_changers) { } else if (!rn2(30) || Protection_from_shape_changers) {//检查是否应该变回人类
new_were(mon); /* change back into human form */ new_were(mon); /* 变回人类 */
} }
/* update innate intrinsics (mainly Drain_resistance) */ /* update innate intrinsics (mainly Drain_resistance) */
set_uasmon(); /* new_were() doesn't do this */ set_uasmon(); /* new_were() doesn't do this */

Loading…
Cancel
Save