示例#1
0
void KReversiView::setGame(KReversiGame *game)
{
    // disconnect signals from previous game if they exist,
    // we are not interested in them anymore
    if (m_game) {
        disconnect(m_game, SIGNAL(boardChanged()), this, SLOT(updateBoard()));
        disconnect(m_game, SIGNAL(moveFinished()), this, SLOT(gameMoveFinished()));
        disconnect(m_game, SIGNAL(gameOver()), this, SLOT(gameOver()));
        disconnect(m_game, SIGNAL(whitePlayerCantMove()), this, SLOT(whitePlayerCantMove()));
        disconnect(m_game, SIGNAL(blackPlayerCantMove()), this, SLOT(blackPlayerCantMove()));
        delete m_game;
    }

    m_game = game;

    if (m_game) {
        connect(m_game, SIGNAL(boardChanged()), this, SLOT(updateBoard()));
        connect(m_game, SIGNAL(moveFinished()), this, SLOT(gameMoveFinished()));
        connect(m_game, SIGNAL(gameOver()), this, SLOT(gameOver()));
        connect(m_game, SIGNAL(whitePlayerCantMove()), this, SLOT(whitePlayerCantMove()));
        connect(m_game, SIGNAL(blackPlayerCantMove()), this, SLOT(blackPlayerCantMove()));

        m_game->setDelay(m_delay);
    }

    m_hint = KReversiMove();

    updateBoard();
}
示例#2
0
int Settings::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: refreshViews(); break;
        case 1: preInitialize(); break;
        case 2: initialize(); break;
        case 3: load(); break;
        case 4: createGUI(); break;
        case 5: lexiconChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: alphabetChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 7: boardChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 8: addBoard(); break;
        case 9: editBoard(); break;
        case 10: deleteBoard(); break;
        case 11: setQuackleToUseLexiconName((*reinterpret_cast< const string(*)>(_a[1]))); break;
        case 12: setQuackleToUseAlphabetName((*reinterpret_cast< const string(*)>(_a[1]))); break;
        case 13: setQuackleToUseBoardName((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        }
        _id -= 14;
    }
    return _id;
}
void BoardController::clearBoard()
{
    m_figures.clear();

    for(int i = 0; i < board_items_count; ++i)
        m_figures.append(new Figure(this, Figure::Type::NONE, Figure::Side::UNDEF));

    emit boardChanged(board());
}
示例#4
0
/**
 * @param info new session info
 */
void SessionState::update(const Session& info)
{
    Session old = info_;
    info_ = info;
    // Locking warrants its own signal
    if(old.lock() != info.lock())
        emit sessionLocked(info.lock());
    emit boardChanged();
}
void BoardController::_moveFigure(int from, int to, Figure::Type displacer_type, Figure::Side displacer_side)
{
    std::swap(m_figures[from], m_figures[to]);
    auto displacer = m_figures[from];
    displacer->setType(displacer_type);
    displacer->setSide(displacer_side);

    qDebug() << "Move from " << from  << " to " << to;

    emit boardChanged(board());
}
示例#6
0
void Game::setBoard(Board *board) {
    if (board == m_board)
        return;

    m_board = board;

    connect(m_board, SIGNAL(boardIsFull()), SLOT(onBoardIsFull()));

    if (m_board != NULL)
        m_board->setParent(this);

    m_board->m_startTime = QDateTime::currentMSecsSinceEpoch();

    emit boardChanged();
}
void Gamemaster::cleanup()
{
    _initialised = false;
    if(_player[0] != NULL)
    {
        delete _player[0];
        _player[0] = NULL;
    }
    if(_player[1] != NULL)
    {
        delete _player[1];
        _player[1] = NULL;
    }
    if(_board != NULL)
    {
        QObject::disconnect(_board,SIGNAL(boardChanged()),this,SLOT(getBoardChanged()));
        delete _board;
        _board = NULL;
    }
}
bool Gamemaster::initialise(QString player1, QString player2, int bonus)
{
    cleanup();
    //Player 1
    if(player1 == "Human")
    {
        _player[0] = new HumanPlayer(this);
    }
    else if(player1 == "Random AI")
    {
        _player[0] = new RandomAIPlayer(this);
    }
    else if(player1 == "Greedy AI")
    {
        _player[0] = new GreedyAIPlayer(this);
    }
    else if(player1 == "Tree AI")
    {
        _player[0] = new TreeAIPlayer(this);
    }
    else if(player1 == "Balanced AI")
    {
        _player[0] = new BalancedAIPlayer(this);
    }
    else if(player1 == "Static Rule AI")
    {
        _player[0] = new StaticRuleAIPlayer(this);
    }
    else if(player1 == "Tutorial")
    {
        _player[0] = new TutorialPlayer(this);
    }
    else if(player1 == "Adaptive Tree AI")
    {
        _player[0] = new AdaptiveTreeAIPlayer(this);
    }
    else if(player1 == "Control AI")
    {
        _player[0] = new ControlAIPlayer(this);
    }
    else if(player1 == "Assembly AI")
    {
        _player[0] = new AssemblyAIPlayer(this);
    }
    else if(player1 == "Neural Network AI")
    {
        _player[0] = new NeuralNetworkAIPlayer(this);
    }
    else
    {
        return false;
    }
    QObject::connect(_player[0], SIGNAL(awaitsHuman()), this, SLOT(awaitsHuman()));
    QObject::connect(_player[0], SIGNAL(sendMessage(QString)), this, SLOT(message(QString)));
    QObject::connect(_player[0], SIGNAL(turn(int,int)), this, SLOT(turn(int,int)));
    QObject::connect(this,SIGNAL(humanInput(int,int)),_player[0],SLOT(humanInput(int,int)));

    //Player 2
    if(player2 == "Human")
    {
        _player[1] = new HumanPlayer(this);
    }
    else if(player2 == "Random AI")
    {
        _player[1] = new RandomAIPlayer(this);
    }
    else if(player2 == "Greedy AI")
    {
        _player[1] = new GreedyAIPlayer(this);
    }
    else if(player2 == "Tree AI")
    {
        _player[1] = new TreeAIPlayer(this);
    }
    else if(player2 == "Balanced AI")
    {
        _player[1] = new BalancedAIPlayer(this);
    }
    else if(player2 == "Static Rule AI")
    {
        _player[1] = new StaticRuleAIPlayer(this);
    }
    else if(player2 == "Tutorial")
    {
        _player[1] = new TutorialPlayer(this);
    }
    else if(player2 == "Adaptive Tree AI")
    {
        _player[1] = new AdaptiveTreeAIPlayer(this);
    }
    else if(player2 == "Control AI")
    {
        _player[1] = new ControlAIPlayer(this);
    }
    else if(player2 == "Assembly AI")
    {
        _player[1] = new AssemblyAIPlayer(this);
    }
    else if(player2 == "Neural Network AI")
    {
        _player[1] = new NeuralNetworkAIPlayer(this);
    }
    else
    {
        cleanup();
        return false;
    }
    QObject::connect(_player[1], SIGNAL(awaitsHuman()), this, SLOT(awaitsHuman()));
    QObject::connect(_player[1], SIGNAL(sendMessage(QString)), this, SLOT(message(QString)));
    QObject::connect(_player[1], SIGNAL(turn(int,int)), this, SLOT(turn(int,int)));
    QObject::connect(this,SIGNAL(humanInput(int,int)),_player[1],SLOT(humanInput(int,int)));

    _bonus = bonus;

    _board = new Gameboard(this);
    QObject::connect(_board, SIGNAL(boardChanged()),this,SLOT(getBoardChanged()));

    _initialised = true;
    return true;
}
void Gamemaster::getBoardChanged()
{
    emit boardChanged();
}
示例#10
0
void BoardController::resetBoard()
{
    _initBoard();
    emit boardChanged(board());
}