コード例 #1
0
void
wake_room(short rn, boolean entering, short row, short col)
{
	object *monster;
	short wake_percent;
	boolean in_room;

	wake_percent = (rn == party_room) ? PARTY_WAKE_PERCENT : WAKE_PERCENT;
	if (stealthy > 0) {
		wake_percent /= (STEALTH_FACTOR + stealthy);
	}

	monster = level_monsters.next_monster;

	while (monster) {
		in_room = (rn == get_room_number(monster->row, monster->col));
		if (in_room) {
			if (entering) {
				monster->trow = NO_ROOM;
			} else {
				monster->trow = row;
				monster->tcol = col;
			}
		}
		if ((monster->m_flags & WAKENS) &&
			(rn == get_room_number(monster->row, monster->col))) {
			if (rand_percent(wake_percent)) {
				wake_up(monster);
			}
		}
		monster = monster->next_monster;
	}
}
コード例 #2
0
ファイル: level.c プロジェクト: newdispatcher/minix
/*
 * try not to put in room NR
 */
void
put_player(short nr)
{
    short rn = nr, misses;
    short row, col;

    for (misses = 0; ((misses < 2) && (rn == nr)); misses++) {
        gr_row_col(&row, &col, (FLOOR | TUNNEL | OBJECT | STAIRS));
        rn = get_room_number(row, col);
    }
    rogue.row = row;
    rogue.col = col;

    if (dungeon[rogue.row][rogue.col] & TUNNEL) {
        cur_room = PASSAGE;
    } else {
        cur_room = rn;
    }
    if (cur_room != PASSAGE) {
        light_up_room(cur_room);
    } else {
        light_passage(rogue.row, rogue.col);
    }
    rn = get_room_number(rogue.row, rogue.col);
    wake_room(rn, 1, rogue.row, rogue.col);
    if (new_level_message) {
        messagef(0, "%s", new_level_message);
        new_level_message = NULL;
    }
    mvaddch(rogue.row, rogue.col, rogue.fchar);
}
コード例 #3
0
ファイル: spechit.c プロジェクト: naota/rogueclone2s-utf8
int
seek_gold(object *monster)
{
    short i, j, rn, s;

    if ((rn = get_room_number(monster->row, monster->col)) < 0) {
	return 0;
    }
    for (i = rooms[rn].top_row + 1; i < rooms[rn].bottom_row; i++) {
	for (j = rooms[rn].left_col + 1; j < rooms[rn].right_col; j++) {
	    if ((gold_at(i, j)) && !(dungeon[i][j] & MONSTER)) {
		monster->m_flags |= CAN_FLIT;
		s = mon_can_go(monster, i, j);
		monster->m_flags &= (~CAN_FLIT);
		if (s) {
		    move_mon_to(monster, i, j);
		    monster->m_flags |= ASLEEP;
		    monster->m_flags &= (~(WAKENS | SEEKS_GOLD));
		    return 1;
		}
		monster->m_flags &= (~SEEKS_GOLD);
		monster->m_flags |= CAN_FLIT;
		mv_monster(monster, i, j);
		monster->m_flags &= (~CAN_FLIT);
		monster->m_flags |= SEEKS_GOLD;
		return 1;
	    }
	}
    }
    return 0;
}
コード例 #4
0
ファイル: services.c プロジェクト: junbinxu/ChineseChess
void on_draw_game (int fd, struct message *msg)
{
	printf ("on_draw_game\n");
	msg->type = DRAW_GAME_FEEDBACK;
	if (accept_request ("对方请求和棋\n是否同意"))
	{
		sprintf (msg->buff, "%s 1", get_room_number ());
		/*  同意和棋 */
		game_draw ();
	}
	else
	{
		sprintf (msg->buff, "%s 0", get_room_number ());
	}
	send_message (msg);
}
コード例 #5
0
boolean
mon_sees(const object *monster, int row, int col)
{
	short rn, rdif, cdif, retval;

	rn = get_room_number(row, col);

	if (	(rn != NO_ROOM) &&
			(rn == get_room_number(monster->row, monster->col)) &&
			!(rooms[rn].is_room & R_MAZE)) {
		return(1);
	}
	rdif = row - monster->row;
	cdif = col - monster->col;

	retval = (rdif >= -1) && (rdif <= 1) && (cdif >= -1) && (cdif <= 1);
	return(retval);
}
コード例 #6
0
ファイル: monster.c プロジェクト: zerobandwidth-net/zerogue
int rogue_can_see(int row, int col)
{
    int retval;

    retval = !blind && (((get_room_number(row, col) == cur_room)
                         &&	!(rooms[cur_room].is_room & R_MAZE))
                        || rogue_is_around(row, col));

    return(retval);
}
コード例 #7
0
ファイル: services.c プロジェクト: junbinxu/ChineseChess
void on_regret (int fd, struct message *msg)
{
	printf ("on_regret\n");

	msg->type = REGRET_FEEDBACK;
	if (accept_request ("对方请求悔棋\n是否同意"))
	{
		sprintf (msg->buff, "%s 1", get_room_number ());
		/*  同意悔棋了,所以要把棋盘恢复到上一步的局面 */
		unset_turn ();
		restore_chessbord ();
		set_regret_flag (FALSE);
		min_step ();
	}
	else
	{
		sprintf (msg->buff, "%s 0", get_room_number ());
	}
	send_message (msg);
}
コード例 #8
0
ファイル: use.c プロジェクト: AhmadTux/DragonFlyBSD
void
tele(void)
{
	mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));

	if (cur_room >= 0) {
		darken_room(cur_room);
	}
	put_player(get_room_number(rogue.row, rogue.col));
	being_held = 0;
	bear_trap = 0;
}
コード例 #9
0
void
move_mon_to(object *monster, short row, short col)
{
	short c;
	int mrow, mcol;

	mrow = monster->row;
	mcol = monster->col;

	dungeon[mrow][mcol] &= ~MONSTER;
	dungeon[row][col] |= MONSTER;

	c = mvinch(mrow, mcol);

	if ((c >= 'A') && (c <= 'Z')) {
		if (!detect_monster) {
			mvaddch(mrow, mcol, monster->trail_char);
		} else {
			if (rogue_can_see(mrow, mcol)) {
				mvaddch(mrow, mcol, monster->trail_char);
			} else {
				if (monster->trail_char == '.') {
					monster->trail_char = ' ';
				}
				mvaddch(mrow, mcol, monster->trail_char);
			}
		}
	}
	monster->trail_char = mvinch(row, col);
	if (!blind && (detect_monster || rogue_can_see(row, col))) {
		if ((!(monster->m_flags & INVISIBLE) ||
			(detect_monster || see_invisible || r_see_invisible))) {
			mvaddch(row, col, gmc(monster));
		}
	}
	if ((dungeon[row][col] & DOOR) &&
		(get_room_number(row, col) != cur_room) &&
		(dungeon[mrow][mcol] == FLOOR) && !blind) {
			mvaddch(mrow, mcol, ' ');
	}
	if (dungeon[row][col] & DOOR) {
			dr_course(monster, ((dungeon[mrow][mcol] & TUNNEL) ? 1 : 0),
				row, col);
	} else {
		monster->row = row;
		monster->col = col;
	}
}
コード例 #10
0
ファイル: monster.c プロジェクト: AhmadTux/DragonFlyBSD
static void
aim_monster(object *monster)
{
	short i, rn, d, r;

	rn = get_room_number(monster->row, monster->col);
	r = get_rand(0, 12);

	for (i = 0; i < 4; i++) {
		d = (r + i) % 4;
		if (rooms[rn].doors[d].oth_room != NO_ROOM) {
			monster->trow = rooms[rn].doors[d].door_row;
			monster->tcol = rooms[rn].doors[d].door_col;
			break;
		}
	}
}
コード例 #11
0
ファイル: services.c プロジェクト: junbinxu/ChineseChess
void on_exit_room (int fd, struct message *msg)
{
	printf ("on_exit_room\n");
	if (get_color () == BLACK)
	{
		struct message msg;
		msg.type = EXIT_ROOM;
		sprintf (msg.buff, "%s", get_room_number ());
		send_message (&msg);

		show_message_dialog (GTK_MESSAGE_ERROR, "游戏已被房主解散");
		hide_room_dialog ();
		show_main_dialog ();
	}
	else
	{
		show_message_dialog (GTK_MESSAGE_ERROR, "对方已经退出房间");
		opp_exit_room ();
	}
}
コード例 #12
0
ファイル: rooms.c プロジェクト: cafuego/monolith
void
edit_room_field(room_t * QRedit, unsigned int forum_id, int fieldnum)
{
    int loop, i, j = 0;
    char *quad_name;

    switch (fieldnum) {

	case '1':
	    cprintf("%s%s%s%s",
		  "\1rPlease keep length of name to under 36 characters.\n",
		    "\1w                        ",
		    "|------------------------------------|\n",
		    "\1rEnter new quadrant name\1w: \1c");
	    quad_name = get_name(3);
	    if (strlen(quad_name) < 1) {
		cprintf("\1gOk, name not changed.\n");
		break;
	    }
	    if (get_room_number(quad_name) != -1) {
		cprintf("\1rThat name is already taken, sorry.\n");
	    } else {
		log_sysop_action("changed %ss name into %s.",
				 QRedit->name, quad_name);
		strcpy(QRedit->name, quad_name);
		mono_sql_f_rename_forum(forum_id, quad_name);
		/* if we rename a guessname, up the generation no */
	        if ( QRedit->flags & QR_GUESSNAME ) 
		    QRedit->generation++;
		need_rewrite = TRUE;
	    }

	    break;

/*-------------------------------------------------------------------*/

	case '3':		/* room type */

	    cprintf("\1g%s Type: \1w<\1r1\1w> \1gPublic \1w<\1r2\1w> \1rPrivate \1w: \1c", config.forum);
	    loop = get_single("12");

	    if (loop == '1') {
		cprintf("\1g%s set to PUBLIC.\n\n", config.forum);
		QRedit->flags &= ~QR_PRIVATE;
	    } else if (loop == '2') {
		cprintf("\1r%s set to INVITE ONLY.\n\n", config.forum);
		QRedit->flags |= QR_PRIVATE;
		cprintf("Kick out all users? ");
		if (yesno() == YES) {
		    QRedit->generation++;
		    if (QRedit->generation == 100)
			QRedit->generation = 10;
		    if (invite(who_am_i(NULL), curr_rm) == -1)
			cprintf("Error inviting yourself.\n");
		}
	    }
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '4':
	    cprintf("\1gPostType: \1w<\1y1\1w> \1gNormal \1w<\1y2\1w>\1pAnon-only \1w<\1y3\1w>\1pAnon-option \1w: \1c");

	    loop = get_single("123");

	    if (loop == '1') {	/* normal room, remove flags */
		QRedit->flags &= ~QR_ANONONLY;
		QRedit->flags &= ~QR_ANON2;
	    }
	    if (loop == '2') {	/* anononly room, set & unset proper flags */
		QRedit->flags |= QR_ANONONLY;
		QRedit->flags &= ~QR_ANON2;
	    }
	    if (loop == '3') {	/* anonopt room */
		QRedit->flags |= QR_ANON2;
		QRedit->flags &= ~QR_ANONONLY;
	    }
	    if (QRedit->flags & (QR_ANONONLY | QR_ANON2)) {
		cprintf("\1gShould the users be able to use Aliasnames? (y/n) ");
		if (yesno() == YES)
		    QRedit->flags |= QR_ALIASNAME;
		else
		    QRedit->flags &= ~QR_ALIASNAME;
	    } else
		QRedit->flags &= ~QR_ALIASNAME;

	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '5':
	    QRedit->flags ^= QR_SUBJECTLINE;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '6':
	    QRedit->flags ^= QR_DESCRIBED;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '7':
	    QRedit->flags ^= QR_READONLY;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '8':
	    QRedit->flags ^= QR_NOZAP;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '9':
	    QRedit->flags ^= QR_INUSE;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case '0':
	    QRedit->flags ^= QR_GUESSNAME;
	    need_rewrite = TRUE;
	    break;

/*--------------------------------------------------------------------*/

	case 'a':
	case 'A':
	    cprintf("\1rEnter the new maximum number of messages\1w(\1r%d\1w): \1c",
		    QRedit->maxmsg);
	    j = qc_get_pos_int('\0', 4);
	    if (j < 10) {
		cprintf("\1rDon't be daft! 10 messages is the minimum.\n");
		break;
	    } else if (j > 1000) {
		cprintf("\1rDon't be daft! 1000 messages is the maximum.\n");
		break;
	    } else {
		QRedit->maxmsg = j;
		need_rewrite = TRUE;
		break;
	    }

/*--------------------------------------------------------------------*/
	case 'b':
	case 'B':
	    cprintf("\1rEnter the new highest %s\1w: \1c", config.message);
	    j = qc_get_pos_int('\0', 7);
	    cprintf("\1f\1gAre you \1rSURE\1g you want to set the highest for `\1y%s\1g` to \1w%ld\1g? \1c", QRedit->name, j);
	    if (yesno() == YES) {
		QRedit->highest = j;
		cprintf("\1gIf you say so... done.\n");
		need_rewrite = TRUE;
	    }
	    break;
/*--------------------------------------------------------------------*/
	case 'c':
	case 'C':
	    cprintf("\1rEnter the new lowest %s\1w: \1c", config.message);
	    j = qc_get_pos_int('\0', 7);
	    cprintf("\1f\1gAre you \1rSURE\1g you want to set the lowest for `\1y%s\1g` to \1w%ld\1g? \1c", QRedit->name, j);
	    if (yesno() == YES) {
		QRedit->lowest = j;
		cprintf("\1gIf you say so... done.\n");
		need_rewrite = TRUE;
	    }
	    break;
/*--------------------------------------------------------------------*/
	case 'd':
	case 'D':

	    for (i = 0; i < CATEGORIES; i++)
		cprintf("\1w<\1r%2d\1w>\1g %s\n", i, fish[i]);

	    cprintf("\1gEnter the new category number\1w: \1c");

	    if ((i = qc_get_pos_int('\0', 2)) < 0)
		break;
	    else {
		if (i >= CATEGORIES) {
		    cprintf("\n\1r+++ OUT OF CHEESE ERROR - REDO FROM START +++\n\n");
		    break;
		} else {
		    strcpy(QRedit->category, fish[i]);
		    need_rewrite = TRUE;
		    break;
		}
		cprintf("\1r\1nUm, what?\n\n");
	    }
	    break;
/*--------------------------------------------------------------------*/

	default:
	    break;

    }				/* end switch */
}
コード例 #13
0
ファイル: rooms.c プロジェクト: cafuego/monolith
void
create_room()
{
    int number;
    char command, *quad_name;

    for (number = 0; number < MAXQUADS; number++)
	if (!(readquad(number).flags & QR_INUSE)) {
	    cprintf("\n\1f\1gFound an unused %s at slot \1y%d\1g.\n", config.forum, number);
	    cprintf("\1gStop searching and use this position? \1w(\1rY\1w/\1rn\1w): \1c");
	    if (yesno_default(YES) == YES) {
		cprintf("\1f\1gInstall %s into slot \1y%d\1g? \1w(\1rY\1w/\1rn\1w): \1c", config.forum, number);
		if (yesno_default(YES) == NO)
		    return;
		else
		    break;
	    } else
		continue;
	}
    if (number >= MAXQUADS) {
	cprintf("\1f\1rNo unused %s was found.\n", config.forum);
	return;
    }
    cprintf("\1f\1rPlease keep the length of the name under 36 characters.\n                      |------------------------------------|\n\1f\1gName for new %s\1w: \1c", config.forum);
    quad_name = get_name(3);

    if (strlen(quad_name) == 0)
	return;
    if (get_room_number(quad_name) != -1) {
	cprintf("\1rA %s named '%s' already exists.\n", config.forum, quad_name);
	return;
    }
    curr_rm = number;
    quickroom = readquad(curr_rm);

    strcpy(quickroom.name, quad_name);
    quickroom.generation++;
    quickroom.lowest = ++quickroom.highest;
    quickroom.maxmsg = 100;
    quickroom.flags = QR_INUSE;

    cprintf("\1f\1g%s%s ",
	    config.forum,
	    "Type: \1w<\1y1\1w> \1gPublic \1w<\1y2\1w> \1rPrivate : \1c");

    command = get_single("12");

    if (command == '1') {	/* public room */
	cprintf("\1rThe %s will be PUBLIC.\n\n", config.forum);
	quickroom.flags &= ~QR_PRIVATE;
    } else {			/* invite -- just private flag, guessname off */
	cprintf("\1rThe %s will be INVITE ONLY.\n\n", config.forum);
	quickroom.flags |= QR_PRIVATE;
	if (quickroom.generation >= 100)
	    quickroom.generation = 10;
    }

    write_quad(quickroom, curr_rm);
    gotocurr();			/* takes care of self invite.. no matter, sysop anyways */
    log_sysop_action("created %s: %s> ", config.forum, quickroom.name);

    editroom();
    change_forum_info();
    qc_edit_room();
}