From e2a70bce09ad6b2bb6d832f61916bf61b5ae8385 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sat, 20 Sep 2025 00:29:22 +0200 Subject: [PATCH] implement client side with static 4 phases --- cockatrice/src/game/board/arrow_item.cpp | 7 +++++-- cockatrice/src/game/board/arrow_item.h | 3 ++- cockatrice/src/game/board/card_item.cpp | 13 +++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/game/board/arrow_item.cpp b/cockatrice/src/game/board/arrow_item.cpp index 22e3ceb50..aba5b60e9 100644 --- a/cockatrice/src/game/board/arrow_item.cpp +++ b/cockatrice/src/game/board/arrow_item.cpp @@ -151,8 +151,8 @@ void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -ArrowDragItem::ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color) - : ArrowItem(_owner, -1, _startItem, 0, _color) +ArrowDragItem::ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase) + : ArrowItem(_owner, -1, _startItem, 0, _color), deleteInPhase(_deleteInPhase) { } @@ -245,6 +245,9 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) else cmd.set_start_zone(SettingsCache::instance().getPlayToStack() ? "stack" : "table"); } + if (deleteInPhase != 0) { + cmd.set_delete_in_phase(deleteInPhase); + } player->getPlayerActions()->sendGameCommand(cmd); } delArrow(); diff --git a/cockatrice/src/game/board/arrow_item.h b/cockatrice/src/game/board/arrow_item.h index 8405083fe..cb78ee066 100644 --- a/cockatrice/src/game/board/arrow_item.h +++ b/cockatrice/src/game/board/arrow_item.h @@ -82,10 +82,11 @@ class ArrowDragItem : public ArrowItem { Q_OBJECT private: + int deleteInPhase; QList childArrows; public: - ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color); + ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase); void addChildArrow(ArrowDragItem *childArrow); protected: diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index 52e237897..0a4fe5396 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -275,9 +275,14 @@ void CardItem::drawArrow(const QColor &arrowColor) if (owner->getGame()->getPlayerManager()->isSpectator()) return; - Player *arrowOwner = - owner->getGame()->getPlayerManager()->getActiveLocalPlayer(owner->getGame()->getGameState()->getActivePlayer()); - ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor); + auto *game = owner->getGame(); + Player *arrowOwner = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); + int phase = 0; // do not set phase + if (SettingsCache::instance().getDoNotDeleteArrowsInSubPhases()) { + int currentPhase = game->getGameState()->getCurrentPhase(); + phase = currentPhase + 4; + } + ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor, phase); scene()->addItem(arrow); arrow->grabMouse(); @@ -288,7 +293,7 @@ void CardItem::drawArrow(const QColor &arrowColor) if (card->getZone() != zone) continue; - ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, card, arrowColor); + ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, card, arrowColor, phase); scene()->addItem(childArrow); arrow->addChildArrow(childArrow); }