[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:
BruebachL 2026-10-31 18:44:09 +01:00 • committed by GitHub
parent 4972ebcb97
commit 563833a88a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 78 deletions

View file

@ -24,7 +24,6 @@
#include <QString>
#include <QTransform>
#include <QtGlobal>
#include <libcockatrice/protocol/pb/command_move_card.pb.h>
#include <libcockatrice/settings/cards_display_settings.h>
#include <qnamespace.h>
#include <string>
@ -80,23 +79,13 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*optio
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZoneLogic *startZone, const QPoint &)
{
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(0);
cmd.set_y(0);
for (int i = 0; i < dragItems.size(); ++i) {
auto cardToMove = cmd.mutable_cards_to_move()->add_card();
cardToMove->set_card_id(dragItems[i]->getId());
if (dragItems[i]->isForceFaceDown()) {
cardToMove->set_face_down(true);
}
QList<CardMoveRequest> cards;
cards.reserve(dragItems.size());
for (const CardDragItem *item : dragItems) {
cards.append(CardMoveRequest{item->getId(), item->isForceFaceDown()});
}
getLogic()->getPlayer()->getPlayerActions()->sendGameCommand(cmd);
getLogic()->getPlayer()->getPlayerActions()->moveCards(startZone, getLogic(), 0, 0, cards);
}
void PileZone::reorganizeCards()