allow placement below top X cards (#2666)

Close #2666
This commit is contained in:
Zach H 2017-04-27 20:32:24 -04:00 committed by Gavin Bisesi
parent 7c1a18da5e
commit 12c9e4b81a
4 changed files with 56 additions and 4 deletions

View file

@ -277,8 +277,10 @@ void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
finalStr = tr("%1 puts %2%3 on bottom of their library."); finalStr = tr("%1 puts %2%3 on bottom of their library.");
else if (attributes.newX == 0) else if (attributes.newX == 0)
finalStr = tr("%1 puts %2%3 on top of their library."); finalStr = tr("%1 puts %2%3 on top of their library.");
else else {
finalStr = tr("%1 puts %2%3 into their library at position %4."); attributes.newX++;
finalStr = tr("%1 puts %2%3 into their library %4 cards from the top.");
}
} else if (targetName == "sb") } else if (targetName == "sb")
finalStr = tr("%1 moves %2%3 to sideboard."); finalStr = tr("%1 moves %2%3 to sideboard.");
else if (targetName == "stack") { else if (targetName == "stack") {

View file

@ -95,6 +95,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
game(_parent), game(_parent),
shortcutsActive(false), shortcutsActive(false),
defaultNumberTopCards(1), defaultNumberTopCards(1),
defaultNumberTopCardsToPlaceBelow(1),
lastTokenDestroy(true), lastTokenDestroy(true),
lastTokenTableRow(0), lastTokenTableRow(0),
id(_id), id(_id),
@ -417,6 +418,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
aMoveToTopLibrary->setData(cmMoveToTopLibrary); aMoveToTopLibrary->setData(cmMoveToTopLibrary);
aMoveToBottomLibrary = new QAction(this); aMoveToBottomLibrary = new QAction(this);
aMoveToBottomLibrary->setData(cmMoveToBottomLibrary); aMoveToBottomLibrary->setData(cmMoveToBottomLibrary);
aMoveToXfromTopOfLibrary = new QAction(this);
aMoveToGraveyard = new QAction(this); aMoveToGraveyard = new QAction(this);
aMoveToHand = new QAction(this); aMoveToHand = new QAction(this);
aMoveToHand->setData(cmMoveToHand); aMoveToHand->setData(cmMoveToHand);
@ -425,6 +427,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
aMoveToExile->setData(cmMoveToExile); aMoveToExile->setData(cmMoveToExile);
connect(aMoveToTopLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction())); connect(aMoveToTopLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
connect(aMoveToBottomLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction())); connect(aMoveToBottomLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
connect(aMoveToXfromTopOfLibrary, SIGNAL(triggered()), this, SLOT(actMoveCardXCardsFromTop()));
connect(aMoveToHand, SIGNAL(triggered()), this, SLOT(cardMenuAction())); connect(aMoveToHand, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
connect(aMoveToGraveyard, SIGNAL(triggered()), this, SLOT(cardMenuAction())); connect(aMoveToGraveyard, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
connect(aMoveToExile, SIGNAL(triggered()), this, SLOT(cardMenuAction())); connect(aMoveToExile, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
@ -723,6 +726,7 @@ void Player::retranslateUi()
} }
aMoveToTopLibrary->setText(tr("&Top of library")); aMoveToTopLibrary->setText(tr("&Top of library"));
aMoveToXfromTopOfLibrary->setText(tr("X cards from the top..."));
aMoveToBottomLibrary->setText(tr("&Bottom of library")); aMoveToBottomLibrary->setText(tr("&Bottom of library"));
aMoveToHand->setText(tr("&Hand")); aMoveToHand->setText(tr("&Hand"));
aMoveToGraveyard->setText(tr("&Graveyard")); aMoveToGraveyard->setText(tr("&Graveyard"));
@ -1972,6 +1976,49 @@ bool Player::clearCardsToDelete()
return true; return true;
} }
void Player::actMoveCardXCardsFromTop()
{
bool ok;
int number = QInputDialog::getInt(0, tr("Place card X cards from top library"), tr("How many cards from the top of the deck should this card be placed:"), defaultNumberTopCardsToPlaceBelow, 1, 2000000000, 1, &ok);
number--;
if (!ok)
return;
defaultNumberTopCardsToPlaceBelow = number;
QList<QGraphicsItem *> sel = scene()->selectedItems();
QList<CardItem *> cardList;
while (!sel.isEmpty())
cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst()));
QList< const ::google::protobuf::Message * > commandList;
ListOfCardsToMove idList;
for (int i = 0; i < cardList.size(); ++i)
idList.add_card()->set_card_id(cardList[i]->getId());
if (cardList.isEmpty())
return;
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
QString startZone = cardList[0]->getZone()->getName();
Command_MoveCard *cmd = new Command_MoveCard;
cmd->set_start_player_id(startPlayerId);
cmd->set_start_zone(startZone.toStdString());
cmd->mutable_cards_to_move()->CopyFrom(idList);
cmd->set_target_player_id(getId());
cmd->set_target_zone("deck");
cmd->set_x(number);
cmd->set_y(0);
commandList.append(cmd);
if (local)
sendGameCommand(prepareGameCommand(commandList));
else
game->sendGameCommand(prepareGameCommand(commandList));
}
void Player::cardMenuAction() void Player::cardMenuAction()
{ {
QAction *a = static_cast<QAction *>(sender()); QAction *a = static_cast<QAction *>(sender());
@ -2406,6 +2453,7 @@ void Player::updateCardMenu(const CardItem *card)
else if (writeableCard) { else if (writeableCard) {
if (moveMenu->isEmpty()) { if (moveMenu->isEmpty()) {
moveMenu->addAction(aMoveToTopLibrary); moveMenu->addAction(aMoveToTopLibrary);
moveMenu->addAction(aMoveToXfromTopOfLibrary);
moveMenu->addAction(aMoveToBottomLibrary); moveMenu->addAction(aMoveToBottomLibrary);
moveMenu->addSeparator(); moveMenu->addSeparator();
moveMenu->addAction(aMoveToHand); moveMenu->addAction(aMoveToHand);

View file

@ -145,6 +145,7 @@ private slots:
void actCreateRelatedCard(); void actCreateRelatedCard();
void actCreateAllRelatedCards(); void actCreateAllRelatedCards();
void cardMenuAction(); void cardMenuAction();
void actMoveCardXCardsFromTop();
void actCardCounterTrigger(); void actCardCounterTrigger();
void actAttach(); void actAttach();
void actUnattach(); void actUnattach();
@ -182,10 +183,11 @@ private:
QAction *aPlay, *aPlayFacedown, QAction *aPlay, *aPlayFacedown,
*aHide, *aHide,
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone, *aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile; *aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary;
bool shortcutsActive; bool shortcutsActive;
int defaultNumberTopCards; int defaultNumberTopCards;
int defaultNumberTopCardsToPlaceBelow;
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation; QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
bool lastTokenDestroy; bool lastTokenDestroy;
int lastTokenTableRow; int lastTokenTableRow;

View file

@ -341,7 +341,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
if (((targetzone->getType() != ServerInfo_Zone::PublicZone) || !targetzone->hasCoords()) && (startzone->getPlayer() != targetzone->getPlayer())) if (((targetzone->getType() != ServerInfo_Zone::PublicZone) || !targetzone->hasCoords()) && (startzone->getPlayer() != targetzone->getPlayer()))
return Response::RespContextError; return Response::RespContextError;
if (!targetzone->hasCoords() && (x == -1)) if (!targetzone->hasCoords() && (x <= -1))
x = targetzone->getCards().size(); x = targetzone->getCards().size();
QList<QPair<Server_Card *, int> > cardsToMove; QList<QPair<Server_Card *, int> > cardsToMove;