Ejemplo n.º 1
0
void CardZone::removeCard(CardItem *card)
{
    cards.removeAt(cards.indexOf(card));
    reorganizeCards();
    emit cardCountChanged();
    player->deleteCard(card);
}
Ejemplo n.º 2
0
CardItem *CardZone::takeCard(int position, int cardId, bool /*canResize*/)
{
    if (position == -1) {
        // position == -1 means either that the zone is indexed by card id
        // or that it doesn't matter which card you take.
        for (int i = 0; i < cards.size(); ++i)
            if (cards[i]->getId() == cardId) {
                position = i;
                break;
            }
        if (position == -1)
            position = 0;
    }
    if (position >= cards.size())
        return 0;

    CardItem *c = cards.takeAt(position);

    if (view)
        view->removeCard(position);

    c->setId(cardId);

    reorganizeCards();
    emit cardCountChanged();
    return c;
}
Ejemplo n.º 3
0
void HandZone::setWidth(qreal _width)
{
    if (settingsCache->getHorizontalHand()) {
        prepareGeometryChange();
        width = _width;
        reorganizeCards();
    }
}
Ejemplo n.º 4
0
void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
{
    if (view)
        if ((x <= view->getCards().size()) || (view->getNumberCards() == -1))
            view->addCard(new CardItem(player, card->getName(), card->getId()), reorganize, x, y);

    card->setZone(this);
    addCardImpl(card, x, y);

    if (reorganize)
        reorganizeCards();
    
    emit cardCountChanged();
}
Ejemplo n.º 5
0
void ZoneViewZone::initializeCards(const QList<const ServerInfo_Card *> &cardList)
{
    if (!cardList.isEmpty()) {
        for (int i = 0; i < cardList.size(); ++i)
            addCard(new CardItem(player, QString::fromStdString(cardList[i]->name()), cardList[i]->id(), revealZone, this), false, i);
        reorganizeCards();
    } else if (!origZone->contentsKnown()) {
        Command_DumpZone cmd;
        cmd.set_player_id(player->getId());
        cmd.set_zone_name(name.toStdString());
        cmd.set_number_cards(numberCards);
        
        PendingCommand *pend = player->prepareGameCommand(cmd);
        connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(zoneDumpReceived(const Response &)));
        player->sendGameCommand(pend);
    } else {
Ejemplo n.º 6
0
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
    : SelectZone(_p, "table", true, false, true, parent), active(false)
{
    connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
    connect(settingsCache, SIGNAL(invertVerticalCoordinateChanged()), this, SLOT(reorganizeCards()));
    updateBgPixmap();

    height = 2 * boxLineWidth + 3 * (CARD_HEIGHT + 20) + 2 * paddingY;
    width = minWidth + 2 * marginX + 2 * boxLineWidth;
    currentMinimumWidth = minWidth;

    setCacheMode(DeviceCoordinateCache);
#if QT_VERSION < 0x050000
    setAcceptsHoverEvents(true);
#else
    setAcceptHoverEvents(true);
#endif
}
Ejemplo n.º 7
0
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
    : SelectZone(_p, "table", true, false, true, parent), active(false)
{
    connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
    connect(settingsCache, SIGNAL(invertVerticalCoordinateChanged()), this, SLOT(reorganizeCards()));

    updateBgPixmap();

    height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS-1) * PADDING_Y;
    width = MIN_WIDTH;
    currentMinimumWidth = width;

    setCacheMode(DeviceCoordinateCache);
#if QT_VERSION < 0x050000
    setAcceptsHoverEvents(true);
#else
    setAcceptHoverEvents(true);
#endif
}
Ejemplo n.º 8
0
void HandZone::updateOrientation()
{
    prepareGeometryChange();
    reorganizeCards();
}