예제 #1
0
void CheckersGameWidget::start(){
	if(player != white_player ){
		moveComputer();
	}	
	/*vector<QtBoard::State> st(32,QtBoard::NONE) ;
	st[3] = QtBoard::WHITE;
	qt_board->draw(st); */
	/*if(white_player != player){
		Move m = computer.getMove(board);
	}*/
}
예제 #2
0
int updateGame(void) {
	int coins;
	
	coins = movePlayer();
	numOfCoins = numOfCoins - coins;
	if (numOfCoins == 0) {
		return YES;	
	} 
	coins = moveComputer();
	numOfCoins = numOfCoins - coins;
	if (numOfCoins == 0) {
		return YES;	
	} 
	return NO;
}
예제 #3
0
void clickedButton(GtkWidget *widget, GtkWidget **buttons) {
    if(strlen(gtk_button_get_label(GTK_BUTTON(widget))) != 1) {
        gtk_button_set_label(GTK_BUTTON(widget), "X");

        GtkWidget *i = 0;
        whoWon(buttons);

        while(1) {
            i = moveComputer(buttons);
            if(strlen(gtk_button_get_label(GTK_BUTTON(i))) != 1) {
                gtk_button_set_label(GTK_BUTTON(i), "O");
                break;
            }
        }
    }
    whoWon(buttons);
}
예제 #4
0
void CheckersGameWidget::figureSelected(int index){
	qDebug()<<index<<"ssss";
	if(!is_player_moving){	
		if(Figures::playerOf(board[index]) == player){
			PossibleMoves::getAllForIndex(&board,index,&possible_moves);
			is_player_moving = true;
			qDebug()<<"moving";
		}
	}else{
		list<Move>::iterator it = possible_moves.begin();
		for(;it != possible_moves.end(); ){
			if(index == it->to()){
				break;
			}
			Move::capturing_iterator cap_it = it->beginCapturing();
			for( ; cap_it != it->endCapturing() ;++cap_it){
				if(index == cap_it->to){
					break;
				}
			}
			if(cap_it == it->endCapturing() ){
				it = possible_moves.erase(it);
			}else{
				++it;
			}
		}
		if(possible_moves.empty()){
			is_player_moving =false;
			qDebug()<<"disable";
		}
		if(it != possible_moves.end()){
			is_player_moving = false;
			Move m(*it);
			possible_moves.clear();
			move(m);
			moveComputer(); 
		}
		
	}
}