mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 17:43:23 -08:00
[Refactor] Build Command_MoveCard in game/ instead of the zone views (#7417)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
4972ebcb97
commit
563833a88a
8 changed files with 98 additions and 78 deletions
|
|
@ -19,7 +19,6 @@
|
|||
#include <QPoint>
|
||||
#include <QRectF>
|
||||
#include <QString>
|
||||
#include <libcockatrice/protocol/pb/command_move_card.pb.h>
|
||||
#include <qnumeric.h>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -79,25 +78,15 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
|
|||
}
|
||||
}
|
||||
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_player_id(startZone->getPlayer()->getPlayerInfo()->getId());
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(getLogic()->getPlayer()->getPlayerInfo()->getId());
|
||||
cmd.set_target_zone(getLogic()->getName().toStdString());
|
||||
cmd.set_x(index);
|
||||
cmd.set_y(0);
|
||||
|
||||
QList<CardMoveRequest> cards;
|
||||
cards.reserve(dragItems.size());
|
||||
for (const CardDragItem *item : dragItems) {
|
||||
if (item) {
|
||||
auto *cardToMove = cmd.mutable_cards_to_move()->add_card();
|
||||
cardToMove->set_card_id(item->getId());
|
||||
if (item->isForceFaceDown()) {
|
||||
cardToMove->set_face_down(true);
|
||||
}
|
||||
cards.append(CardMoveRequest{item->getId(), item->isForceFaceDown()});
|
||||
}
|
||||
}
|
||||
|
||||
getLogic()->getPlayer()->getPlayerActions()->sendGameCommand(cmd);
|
||||
getLogic()->getPlayer()->getPlayerActions()->moveCards(startZone, getLogic(), index, 0, cards);
|
||||
}
|
||||
|
||||
void StackZone::setHeight(qreal newHeight)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue