/** * updates the Player card with animation from stack to the playerhand * @brief Playground::updatePlayerCard * @param fromCard * @param toCard * @param withAnimation */ void Playground::updatePlayerCard(CardItem& fromCard, CardItem& toCard, bool withAnimation) { fromCard.setPos(stack.getX(), stack.getY()); addItem(fromCard.createImg()); qreal x = toCard.getX(); qreal y = toCard.getY(); if (withAnimation) { QEventLoop pause; prepareNewAnimation(pause); addPositionAnimation(*fromCard.createImg(), *toCard.createImg()); startAnimation(); pause.exec(); } if ((&toCard) != NULL) { } toCard = CardItem(fromCard); toCard.setPos(x, y); toCard.createImg()->setZValue(zValue); zValue++; addItem(toCard.createImg()); update(sceneRect()); }
/** * An other player plays a card from his hand to the stack * @brief Playground::playerPlaysCard * @param player * @param playedCard */ void Playground::playerPlaysCard(PLAYER::Name player, const Card& playedCard) { PlayerItem* p = NULL; switch (player) { case PLAYER::Name::LEFT: { p = players.value(PlayerItem::direction::LEFT); break; } case PLAYER::Name::TOP: { p = players.value(PlayerItem::direction::TOP); break; } case PLAYER::Name::RIGHT: { p = players.value(PlayerItem::direction::RIGHT); break; } default: break; } p->setActive(); CardItem* dummyCard = p->findCard(playedCard, true); CardItem _playedCard(playedCard); history.write("another Player, plays a Card", _playedCard); addItem(_playedCard.createImg()); _playedCard.setPos(dummyCard->getX(), dummyCard->getY()); p->removeCard(playedCard); soundMgr.playCard(); updateDepotCard(_playedCard, depot); p->setUnactive(); p->rearrangePlayer(this->sceneRect().center().x(), this->sceneRect().center().y()); }
/** * updates the Depot Card * @brief Playground::updateDepotCard * @param fromCard * @param toCard * @param withAnimation with Animation or without */ void Playground::updateDepotCard(CardItem& fromCard, CardItem& toCard, bool withAnimation) { qreal x = toCard.getX(); qreal y = toCard.getY(); if (withAnimation) { QEventLoop pause; prepareNewAnimation(pause); addPositionAnimation(*fromCard.createImg(), *toCard.createImg()); startAnimation(); pause.exec(QEventLoop::AllEvents); } removeItem(toCard.createImg()); toCard = CardItem(fromCard.getCard()); toCard.setPos(x, y); toCard.createImg()->setZValue(zValue); zValue++; addItem(toCard.createImg()); update(sceneRect()); }