コード例 #1
0
ファイル: moveengine.cpp プロジェクト: opieproject/opie
void MoveEngine::diceroll(const int& newplayer,const int& face1,const int& face2,const int& face3,const int& face4,bool computer)
{
    checkstate();
    player=newplayer;
    otherplayer=(player==1) ? 2 : 1;
    dice[0]=face1;
    dice[1]=face2;
    dice[2]=face3;
    dice[3]=face4;
    marker_current=-1;
    if(getPossibleMoves()==0)
    {
        emit nomove();
        return; // player will be changed
    }
    if(!computer)
        return; //human intervention required

    QTimer::singleShot(2000,this,SLOT(automove()));
}
コード例 #2
0
ファイル: move.c プロジェクト: ajinkya93/netbsd-src
/*
 * get_move:
 *	Get and execute a move from the player
 */
void
get_move(void)
{
	int c;
#ifdef FANCY
	int lastmove;
#endif /*FANCY*/

	if (Waiting)
		return;

#ifdef FANCY
	if (Pattern_roll) {
		if (Next_move >= Move_list)
			lastmove = *Next_move;
		else
			lastmove = -1;	/* flag for "first time in" */
	} else
		lastmove = 0; /* Shut up gcc */
#endif
	for (;;) {
		if (Teleport && must_telep())
			goto teleport;
		if (Running)
			c = Run_ch;
		else if (Count != 0)
			c = Cnt_move;
#ifdef FANCY
		else if (Num_robots > 1 && Stand_still)
			c = '>';
		else if (Num_robots > 1 && Pattern_roll) {
			if (*++Next_move == '\0') {
				if (lastmove < 0)
					goto over;
				Next_move = Move_list;
			}
			c = *Next_move;
			mvaddch(0, 0, c);
			if (c == lastmove)
				goto over;
		}
#endif
		else {
over:
			if (Auto_bot) {
				c = automove();
				if (!Jump) {
					usleep(10000);
					refresh();
				}
			} else
				c = getchar();
			if (isdigit(c)) {
				Count = (c - '0');
				while (isdigit(c = getchar()))
					Count = Count * 10 + (c - '0');
				if (c == ESC)
					goto over;
				Cnt_move = c;
				if (Count)
					leaveok(stdscr, TRUE);
			}
		}

		switch (c) {
		  case ' ':
		  case '.':
			if (do_move(0, 0))
				goto ret;
			break;
		  case 'y':
			if (do_move(-1, -1))
				goto ret;
			break;
		  case 'k':
			if (do_move(-1, 0))
				goto ret;
			break;
		  case 'u':
			if (do_move(-1, 1))
				goto ret;
			break;
		  case 'h':
			if (do_move(0, -1))
				goto ret;
			break;
		  case 'l':
			if (do_move(0, 1))
				goto ret;
			break;
		  case 'b':
			if (do_move(1, -1))
				goto ret;
			break;
		  case 'j':
			if (do_move(1, 0))
				goto ret;
			break;
		  case 'n':
			if (do_move(1, 1))
				goto ret;
			break;
		  case 'Y': case 'U': case 'H': case 'J':
		  case 'K': case 'L': case 'B': case 'N':
		  case '>':
			Running = true;
			if (c == '>')
				Run_ch = ' ';
			else
				Run_ch = tolower(c);
			leaveok(stdscr, TRUE);
			break;
		  case 'q':
		  case 'Q':
			if (query("Really quit?"))
				quit(0);
			refresh();
			break;
		  case 'w':
		  case 'W':
			Waiting = true;
			leaveok(stdscr, TRUE);
			goto ret;
		  case 't':
		  case 'T':
teleport:
			Running = false;
			mvaddch(My_pos.y, My_pos.x, ' ');
			My_pos = *rnd_pos();
			telmsg(1);
			refresh();
			sleep(1);
			telmsg(0);
			mvaddch(My_pos.y, My_pos.x, PLAYER);
			leaveok(stdscr, FALSE);
			refresh();
			flush_in();
			goto ret;
		  case CTRL('L'):
			refresh();
			break;
		  case EOF:
			break;
		  default:
			putchar(CTRL('G'));
			reset_count();
			fflush(stdout);
			break;
		}
	}
ret:
	if (Count > 0)
		if (--Count == 0)
			leaveok(stdscr, FALSE);
}