Example #1
0
void Swan::move(Floor& floor){
	location deltaPos, current, next;
	int input;
	current = getPos();
	
	do{
		deltaPos.r = 0;
		deltaPos.c = 0;
		next = current;
		input = rand()%4;
		if(input == 0){
			deltaPos.r--;
		}
		else if(input == 1){
			deltaPos.c--;
		}
		else if(input == 2){
			deltaPos.r++;
		}
		else if(input == 3){
			deltaPos.c++;
		}

		next.r += deltaPos.r;
		next.c += deltaPos.c;
	}while(invalidMove(next, floor));

	floor.setTile(current.r, current.c, getTileBelow());
	if(getTileBelow() == 'P')
		floor.setTile(current.r, current.c, ' ');
	setTileBelow(floor.getTile(next.r, next.c));

	setPos(next);
	floor.setTile(next.r, next.c, 'S');
}
Example #2
0
void GPControlView::on_abortbutton_clicked()
{
    gpControl->disconnect(SIGNAL(end(QString)));
    gpControl->disconnect(SIGNAL(carMoved()));
    gpControl->disconnect(SIGNAL(carMovedWithBoost()));
    gpControl->disconnect(SIGNAL(invalidMove()));
    gpControl->disconnect(SIGNAL(syntaxError()));
    gpControl->disconnect(SIGNAL(driverTimeout()));

    newGPControl();
    enableControls();
}
Example #3
0
void GPControlView::on_runbutton_clicked()
{
    emit start();
    for (int noCar = 0; noCar < gpControl->getNbCars(); noCar++) {
        gpControl->setDriverPath(noCar, driverSelectors[noCar].getDriverPath());
    }
    disableControls();
    QObject::connect(gpControl, SIGNAL(end(QString)),
                     this, SLOT(gpControl_end(QString)));
    QObject::connect(gpControl, SIGNAL(carMoved()),
                     this, SLOT(gpControl_carMoved()));
    QObject::connect(gpControl, SIGNAL(carMovedWithBoost()),
                     this, SLOT(gpControl_carMovedWithBoost()));
    QObject::connect(gpControl, SIGNAL(invalidMove()),
                     this, SLOT(gpControl_invalidMove()));
    QObject::connect(gpControl, SIGNAL(syntaxError()),
                     this, SLOT(gpControl_syntaxError()));
    QObject::connect(gpControl, SIGNAL(driverTimeout()),
                     this, SLOT(gpControl_driverTimeout()));

    gpControl->nextMove();
}
Example #4
0
BoardSetupDialog::BoardSetupDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f),
    m_wheelCurrentDelta(0), m_selectedPiece(Empty), inDrag(false)
{
    setObjectName("BoardSetupDialog");
    ui.setupUi(this);

    QPushButton *pasteButton = ui.buttonBox->addButton(tr("Paste FEN"), QDialogButtonBox::ActionRole);
    copyButton = ui.buttonBox->addButton(tr("Copy FEN"), QDialogButtonBox::ApplyRole);
    btCopyText = ui.buttonBox->addButton(tr("Copy Text"), QDialogButtonBox::ApplyRole);

    restoreLayout();

    ui.boardView->configure();
    ui.boardView->setFlags(BoardView::IgnoreSideToMove | BoardView::SuppressGuessMove | BoardView::AllowCopyPiece);
    ui.boardView->showMoveIndicator(false);
    ui.boardView->showCoordinates(true);

    m_minDeltaWheel = AppSettings->getValue("/Board/minWheelCount").toInt();

    for(int piece = Empty; piece <= BlackPawn; piece++)
    {
        BoardSetupToolButton* button = new BoardSetupToolButton(this);
        button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
        button->setMinimumSize(QSize(10, 10));
        button->m_piece = (Piece)piece;
        if(piece == Empty)
        {
            button->m_pixmap = QPixmap(0, 0);
            ui.buttonLayout->addWidget(button, 6, 0);
        }
        else
        {
            button->m_pixmap = ui.boardView->theme().piece(Piece(piece));
            ui.buttonLayout->addWidget(button, (piece - 1) % 6, piece >= BlackKing);
        }
        connect(button, SIGNAL(signalDragStarted(QWidget*, QMouseEvent*)), this, SLOT(startDrag(QWidget*, QMouseEvent*)));
        connect(button, SIGNAL(signalClicked(Piece)), this, SLOT(labelClicked(Piece)));
        connect(this, SIGNAL(signalClearBackground(Piece)), button, SLOT(slotClearBackground(Piece)));
    }

    emit signalClearBackground(Empty);

    ui.buttonBoxTools->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Clear"));
    connect(ui.buttonBoxTools->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(slotClear()));
    connect(ui.buttonBoxTools->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(slotReset()));

    connect(ui.boardView, SIGNAL(clicked(Square, int, QPoint, Square)), SLOT(slotSelected(Square, int)));
    connect(ui.boardView, SIGNAL(moveMade(Square, Square, int)), SLOT(slotMovePiece(Square, Square)));
    connect(ui.boardView, SIGNAL(copyPiece(Square, Square)), SLOT(slotCopyPiece(Square, Square)));
    connect(ui.boardView, SIGNAL(invalidMove(Square)), SLOT(slotInvalidMove(Square)));
    connect(ui.boardView, SIGNAL(wheelScrolled(int)), SLOT(slotChangePiece(int)));
    connect(ui.boardView, SIGNAL(pieceDropped(Square, Piece)), SLOT(slotDroppedPiece(Square, Piece)));
    connect(ui.toMoveButton, SIGNAL(clicked()), SLOT(slotToggleSide()));
    connect(ui.wkCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights()));
    connect(ui.wqCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights()));
    connect(ui.bkCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights()));
    connect(ui.bqCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights()));
    connect(ui.epCombo, SIGNAL(currentIndexChanged(int)), SLOT(slotEnPassantSquare()));
    connect(ui.halfmoveSpin, SIGNAL(valueChanged(int)), SLOT(slotHalfmoveClock()));
    connect(ui.moveSpin, SIGNAL(valueChanged(int)), SLOT(slotMoveNumber()));
    connect(ui.btFlipBoard, SIGNAL(clicked()), ui.boardView, SLOT(flip()));
    ui.btFlipBoard->setCheckable(true);

    connect(copyButton, SIGNAL(clicked()), SLOT(slotCopyFen()));
    connect(pasteButton, SIGNAL(clicked()), SLOT(slotPasteFen()));
    connect(btCopyText, SIGNAL(clicked()), SLOT(slotCopyText()));

    connect(ui.btFlipVertical, SIGNAL(clicked()), SLOT(mirrorVertical()));
    connect(ui.btFlipHorizontal, SIGNAL(clicked()), SLOT(mirrorHorizontal()));
    connect(ui.btSwapColor, SIGNAL(clicked()), SLOT(swapColors()));

    ui.tabWidget->setCurrentIndex(0);
}
Example #5
0
void GPControlView::gpControl_syntaxError()
{
    emit invalidMove(tr("Driver %1: syntax error").arg(gpControl->getCurrentCar() + 1));
}
Example #6
0
void GPControlView::gpControl_invalidMove()
{
 	int curCar = gpControl->getCurrentCar();
    emit invalidMove(tr("Driver %1: invalid move %2 carburant").arg(gpControl->getCurrentCar() + 1).arg(gpControl->getCarburant(curCar)));
    updateDriverInfo();
}