From 8ca693ef701f18da93414cf36ca925dab6d6c1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Tue, 9 Jun 2026 09:26:53 +0200 Subject: [PATCH] Adjust to rebase. Took 28 minutes Took 7 seconds Took 2 minutes Took 8 minutes Took 13 seconds --- cockatrice/CMakeLists.txt | 4 ++-- cockatrice/src/game/player/player_actions.cpp | 16 +++++++--------- cockatrice/src/game/player/player_actions.h | 10 +++++++--- .../src/game/player/player_event_handler.cpp | 6 +++--- cockatrice/src/game/player/player_logic.cpp | 10 +++++----- cockatrice/src/game/player/player_logic.h | 1 + cockatrice/src/game/zones/command_zone_logic.cpp | 2 +- .../board/commander_tax_counter.cpp | 2 +- .../board/commander_tax_counter.h | 0 .../src/game_graphics/player/menu/card_menu.cpp | 8 ++------ .../player/menu/command_zone_menu.cpp | 11 ++++++----- .../game_graphics/player/menu/player_menu.cpp | 5 +++-- .../src/game_graphics/player/menu/player_menu.h | 2 +- .../player/player_graphics_item.cpp | 6 +++--- .../zones/command_zone.cpp | 11 ++++++----- .../{game => game_graphics}/zones/command_zone.h | 4 ++-- 16 files changed, 50 insertions(+), 48 deletions(-) rename cockatrice/src/{game => game_graphics}/board/commander_tax_counter.cpp (97%) rename cockatrice/src/{game => game_graphics}/board/commander_tax_counter.h (100%) rename cockatrice/src/{game => game_graphics}/zones/command_zone.cpp (96%) rename cockatrice/src/{game => game_graphics}/zones/command_zone.h (97%) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 649cd49cd..608ac7a6a 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -87,7 +87,7 @@ set(cockatrice_SOURCES src/game_graphics/log/message_log_widget.cpp src/game/phase.cpp src/game_graphics/phases_toolbar.cpp - src/game_graphics/player/menu/card_menu. + src/game_graphics/player/menu/card_menu.cpp src/game_graphics/player/menu/command_zone_menu.cpp src/game_graphics/player/menu/custom_zone_menu.cpp src/game_graphics/player/menu/grave_menu.cpp @@ -112,7 +112,7 @@ set(cockatrice_SOURCES src/game_graphics/player/player_target.cpp src/game/replay.cpp src/game/zones/card_zone_logic.cpp - src/game/zones/command_zone.cpp + src/game_graphics/zones/command_zone.cpp src/game/zones/command_zone_logic.cpp src/game/zones/hand_zone_logic.cpp src/game/zones/pile_zone_logic.cpp diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index 3fc3e3ef7..1021629cc 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -7,7 +7,6 @@ #include "../../game_graphics/zones/table_zone.h" #include "../../interface/widgets/tabs/tab_game.h" #include "../../interface/widgets/utility/get_text_with_max.h" - #include "../zones/view_zone_logic.h" #include @@ -1627,14 +1626,13 @@ static bool isUnwritableRevealZone(CardZoneLogic *zone) void PlayerActions::playSelectedCards(QList selectedCards, const bool faceDown) { - playSelectedCardsImpl(faceDown, nullptr); + playSelectedCardsImpl(selectedCards, faceDown, nullptr); } -void PlayerActions::playSelectedCardsImpl(bool faceDown, +void PlayerActions::playSelectedCardsImpl(QList selectedCards, + bool faceDown, const std::function &postPlayCallback) { - QList selectedCards = player->getGameScene()->selectedCards(); - // CardIds will get shuffled downwards when cards leave the deck. // We need to iterate through the cards in reverse order so cardIds don't get changed out from under us as we play // out the cards one-by-one. @@ -1652,9 +1650,9 @@ void PlayerActions::playSelectedCardsImpl(bool faceDown, } } -void PlayerActions::actPlayAndIncreaseTax() +void PlayerActions::actPlayAndIncreaseTax(QList selectedCards) { - playSelectedCardsImpl(false, [this](CardItem * /*card*/, const QString &originalZone) { + playSelectedCardsImpl(selectedCards, false, [this](CardItem * /*card*/, const QString &originalZone) { if (originalZone == ZoneNames::COMMAND) { AbstractCounter *ctr = player->getCounterWidget(CounterIds::CommanderTax); if (ctr && ctr->isActive()) { @@ -1664,9 +1662,9 @@ void PlayerActions::actPlayAndIncreaseTax() }); } -void PlayerActions::actPlayAndIncreasePartnerTax() +void PlayerActions::actPlayAndIncreasePartnerTax(QList selectedCards) { - playSelectedCardsImpl(false, [this](CardItem * /*card*/, const QString &originalZone) { + playSelectedCardsImpl(selectedCards, false, [this](CardItem * /*card*/, const QString &originalZone) { if (originalZone == ZoneNames::COMMAND) { AbstractCounter *ctr = player->getCounterWidget(CounterIds::PartnerTax); if (ctr && ctr->isActive()) { diff --git a/cockatrice/src/game/player/player_actions.h b/cockatrice/src/game/player/player_actions.h index 3c552f509..c8ef1d359 100644 --- a/cockatrice/src/game/player/player_actions.h +++ b/cockatrice/src/game/player/player_actions.h @@ -128,9 +128,9 @@ public slots: void actPlay(QList selectedCards); void actPlayFacedown(QList selectedCards); /** @brief Plays the selected card and increments the primary commander tax counter. */ - void actPlayAndIncreaseTax(); + void actPlayAndIncreaseTax(QList selectedCards); /** @brief Plays the selected card and increments the partner commander tax counter. */ - void actPlayAndIncreasePartnerTax(); + void actPlayAndIncreasePartnerTax(QList selectedCards); /** @brief Modifies a tax counter by delta if it is active. */ void actModifyTaxCounter(int counterId, int delta); /** @brief Toggles a tax counter's active state (only if inactive or value is 0). */ @@ -257,10 +257,14 @@ private: /** * @brief Shared implementation for playing selected cards with an optional post-play callback. + * @param selectedCards + * @param selectedCards + * @param selectedCards * @param postPlayCallback Called after each card is played, receiving the card and its *original* zone name * (captured before playCard, since playCard sends a move command that may change the card's zone). */ - void playSelectedCardsImpl(bool faceDown, + void playSelectedCardsImpl(QList selectedCards, + bool faceDown, const std::function &postPlayCallback = nullptr); void cmdSetTopCard(Command_MoveCard &cmd); diff --git a/cockatrice/src/game/player/player_event_handler.cpp b/cockatrice/src/game/player/player_event_handler.cpp index 6900e2c16..9f9aca671 100644 --- a/cockatrice/src/game/player/player_event_handler.cpp +++ b/cockatrice/src/game/player/player_event_handler.cpp @@ -4,7 +4,6 @@ #include "../../game_graphics/board/card_item.h" #include "../../game_graphics/zones/view_zone.h" #include "../../interface/widgets/tabs/tab_game.h" -#include "../board/abstract_counter.h" #include "../board/arrow_data.h" #include "../board/card_list.h" #include "player_actions.h" @@ -287,11 +286,12 @@ void PlayerEventHandler::eventSetCounterActive(const Event_SetCounterActive &eve } state->setActive(event.active()); - AbstractCounter *widget = player->getGraphicsItem()->getCounterWidget(event.counter_id()); + // TODO: The counters data should emit this and the widget hook up to it. Don't reach into graphics like this. + /*AbstractCounter *widget = player->getGraphicsItem()->getCounterWidget(event.counter_id()); if (widget) { widget->setActive(event.active()); emit player->rearrangeCounters(); - } + }*/ } void PlayerEventHandler::eventDelCounter(const Event_DelCounter &event) diff --git a/cockatrice/src/game/player/player_logic.cpp b/cockatrice/src/game/player/player_logic.cpp index 35b197763..84180a2f5 100644 --- a/cockatrice/src/game/player/player_logic.cpp +++ b/cockatrice/src/game/player/player_logic.cpp @@ -2,9 +2,11 @@ #include "../../game_graphics/board/arrow_item.h" #include "../../game_graphics/board/card_item.h" +#include "../../game_graphics/board/commander_tax_counter.h" #include "../../game_graphics/board/counter_general.h" #include "../../game_graphics/game_scene.h" #include "../../game_graphics/player/player_target.h" +#include "../../game_graphics/zones/command_zone.h" #include "../../game_graphics/zones/hand_zone.h" #include "../../game_graphics/zones/pile_zone.h" #include "../../game_graphics/zones/stack_zone.h" @@ -12,10 +14,6 @@ #include "../../interface/theme_manager.h" #include "../../interface/widgets/tabs/tab_game.h" #include "../board/card_list.h" -#include "../board/commander_tax_counter.h" -#include "../board/counter_general.h" -#include "../game_scene.h" -#include "../zones/command_zone.h" #include "player_actions.h" #include @@ -320,7 +318,9 @@ CounterState *PlayerLogic::getLifeCounter() const AbstractCounter *PlayerLogic::getCounterWidget(int counterId) const { - return graphicsItem->getCounterWidget(counterId); + Q_UNUSED(counterId); + return nullptr; + // TODO: Do not reach into graphics like this return graphicsItem->getCounterWidget(counterId); } bool PlayerLogic::clearCardsToDelete() diff --git a/cockatrice/src/game/player/player_logic.h b/cockatrice/src/game/player/player_logic.h index 4bb22f80c..b530d96bd 100644 --- a/cockatrice/src/game/player/player_logic.h +++ b/cockatrice/src/game/player/player_logic.h @@ -26,6 +26,7 @@ #include #include #include +#include #include inline Q_LOGGING_CATEGORY(PlayerLog, "player"); diff --git a/cockatrice/src/game/zones/command_zone_logic.cpp b/cockatrice/src/game/zones/command_zone_logic.cpp index 3e97ece41..687ee49d1 100644 --- a/cockatrice/src/game/zones/command_zone_logic.cpp +++ b/cockatrice/src/game/zones/command_zone_logic.cpp @@ -1,6 +1,6 @@ #include "command_zone_logic.h" -#include "../board/card_item.h" +#include "../../game_graphics/board/card_item.h" #include "card_zone_algorithms.h" CommandZoneLogic::CommandZoneLogic(PlayerLogic *_player, diff --git a/cockatrice/src/game/board/commander_tax_counter.cpp b/cockatrice/src/game_graphics/board/commander_tax_counter.cpp similarity index 97% rename from cockatrice/src/game/board/commander_tax_counter.cpp rename to cockatrice/src/game_graphics/board/commander_tax_counter.cpp index d0ae0ad5c..d3cd83a6c 100644 --- a/cockatrice/src/game/board/commander_tax_counter.cpp +++ b/cockatrice/src/game_graphics/board/commander_tax_counter.cpp @@ -1,6 +1,6 @@ #include "commander_tax_counter.h" -#include "counter_state.h" +#include "../../game/board/counter_state.h" #include "translate_counter_name.h" #include diff --git a/cockatrice/src/game/board/commander_tax_counter.h b/cockatrice/src/game_graphics/board/commander_tax_counter.h similarity index 100% rename from cockatrice/src/game/board/commander_tax_counter.h rename to cockatrice/src/game_graphics/board/commander_tax_counter.h diff --git a/cockatrice/src/game_graphics/player/menu/card_menu.cpp b/cockatrice/src/game_graphics/player/menu/card_menu.cpp index cac772023..67c5ad716 100644 --- a/cockatrice/src/game_graphics/player/menu/card_menu.cpp +++ b/cockatrice/src/game_graphics/player/menu/card_menu.cpp @@ -83,6 +83,8 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho aUnattach = makeAction(this, [actions, sel]() { actions->actUnattach(sel()); }); aSetAnnotation = makeAction(this, [actions, sel]() { actions->actRequestSetAnnotationDialog(sel()); }); aPlay = makeAction(this, [actions, sel]() { actions->actPlay(sel()); }); + aPlayAndIncreaseTax = makeAction(this, [actions, sel]() { actions->actPlayAndIncreaseTax(sel()); }); + aPlayAndIncreasePartnerTax = makeAction(this, [actions, sel]() { actions->actPlayAndIncreasePartnerTax(sel()); }); aPlayFacedown = makeAction(this, [actions, sel]() { actions->actPlayFacedown(sel()); }); aHide = makeAction(this, [actions, sel]() { actions->actHide(sel()); }); aReduceLifeByPower = makeAction(this, [actions, sel]() { actions->actReduceLifeByPower(sel()); }); @@ -94,12 +96,6 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho aSelectRow = new QAction(this); aSelectColumn = new QAction(this); - aPlayAndIncreaseTax = new QAction(this); - connect(aPlayAndIncreaseTax, &QAction::triggered, playerActions, &PlayerActions::actPlayAndIncreaseTax); - aPlayAndIncreasePartnerTax = new QAction(this); - connect(aPlayAndIncreasePartnerTax, &QAction::triggered, playerActions, - &PlayerActions::actPlayAndIncreasePartnerTax); - connect(aAttach, &QAction::triggered, actions, &PlayerActions::actAttach); connect(aDrawArrow, &QAction::triggered, actions, &PlayerActions::actDrawArrow); connect(aSelectAll, &QAction::triggered, actions, &PlayerActions::actSelectAll); diff --git a/cockatrice/src/game_graphics/player/menu/command_zone_menu.cpp b/cockatrice/src/game_graphics/player/menu/command_zone_menu.cpp index f7d979b7d..2a4935bc6 100644 --- a/cockatrice/src/game_graphics/player/menu/command_zone_menu.cpp +++ b/cockatrice/src/game_graphics/player/menu/command_zone_menu.cpp @@ -2,11 +2,11 @@ #include "../../../client/settings/cache_settings.h" #include "../../board/abstract_counter.h" +#include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game_scene.h" #include "../../zones/command_zone.h" -#include "../player_actions.h" #include "../player_graphics_item.h" -#include "../player_logic.h" #include #include @@ -21,7 +21,7 @@ CommandZoneMenu::CommandZoneMenu(PlayerLogic *_player, QMenu *playerMenu) : QMen aViewZone = new QAction(this); connect(aViewZone, &QAction::triggered, this, - [this]() { player->getGameScene()->toggleZoneView(player, ZoneNames::COMMAND, -1); }); + [this]() { emit player->requestZoneViewToggle(player, ZoneNames::COMMAND, -1, false); }); if (player->getPlayerInfo()->getLocalOrJudge()) { addAction(aViewZone); @@ -106,10 +106,11 @@ void CommandZoneMenu::retranslateUi() void CommandZoneMenu::actToggleMinimized() { - CommandZone *zone = player->getGraphicsItem()->getCommandZoneGraphicsItem(); + // TODO + /*CommandZone *zone = player->getGraphicsItem()->getCommandZoneGraphicsItem(); if (zone) { zone->toggleMinimized(); - } + }*/ } void CommandZoneMenu::updateTaxCounterActionStates() diff --git a/cockatrice/src/game_graphics/player/menu/player_menu.cpp b/cockatrice/src/game_graphics/player/menu/player_menu.cpp index 6fab513b0..dba319b21 100644 --- a/cockatrice/src/game_graphics/player/menu/player_menu.cpp +++ b/cockatrice/src/game_graphics/player/menu/player_menu.cpp @@ -33,14 +33,15 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_ if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) { sideboardMenu = addManagedMenu(player, playerMenu); - commandZoneMenu = addManagedMenu(player, playerMenu); + // TODO + /*commandZoneMenu = addManagedMenu(player, playerMenu); auto updateCommandZoneMenuVisibility = [this](bool has) { if (commandZoneMenu) { commandZoneMenu->menuAction()->setVisible(has); } }; connect(player, &PlayerLogic::commandZoneSupportChanged, this, updateCommandZoneMenuVisibility); - updateCommandZoneMenuVisibility(player->hasServerCommandZone()); + updateCommandZoneMenuVisibility(player->hasServerCommandZone());*/ customZonesMenu = addManagedMenu(player); playerMenu->addSeparator(); diff --git a/cockatrice/src/game_graphics/player/menu/player_menu.h b/cockatrice/src/game_graphics/player/menu/player_menu.h index e77401f67..226d93e01 100644 --- a/cockatrice/src/game_graphics/player/menu/player_menu.h +++ b/cockatrice/src/game_graphics/player/menu/player_menu.h @@ -8,7 +8,7 @@ #define COCKATRICE_PLAYER_MENU_H #include "../../../interface/widgets/menus/tearoff_menu.h" -#include "../player_logic.h" +#include "../../game/player/player_logic.h" #include "command_zone_menu.h" #include "custom_zone_menu.h" #include "grave_menu.h" diff --git a/cockatrice/src/game_graphics/player/player_graphics_item.cpp b/cockatrice/src/game_graphics/player/player_graphics_item.cpp index 7d5541c5f..ca1f5572f 100644 --- a/cockatrice/src/game_graphics/player/player_graphics_item.cpp +++ b/cockatrice/src/game_graphics/player/player_graphics_item.cpp @@ -6,6 +6,8 @@ #include "../board/commander_tax_counter.h" #include "../board/counter_general.h" #include "../hand_counter.h" +#include "../z_values.h" +#include "../zones/command_zone.h" #include "../zones/hand_zone.h" #include "../zones/pile_zone.h" #include "../zones/stack_zone.h" @@ -14,9 +16,6 @@ #include "player_dialogs.h" #include -#include "../z_values.h" -#include "../zones/command_zone.h" - #include PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player) @@ -66,6 +65,7 @@ PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player) connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this, &PlayerGraphicsItem::onCustomZoneAdded); + connect(player, &PlayerLogic::commandZoneSupportChanged, this, &PlayerGraphicsItem::setCommandZoneVisible); playerMenu->setMenusForGraphicItems(); diff --git a/cockatrice/src/game/zones/command_zone.cpp b/cockatrice/src/game_graphics/zones/command_zone.cpp similarity index 96% rename from cockatrice/src/game/zones/command_zone.cpp rename to cockatrice/src/game_graphics/zones/command_zone.cpp index cbac7ce31..ed3e52b9d 100644 --- a/cockatrice/src/game/zones/command_zone.cpp +++ b/cockatrice/src/game_graphics/zones/command_zone.cpp @@ -1,14 +1,14 @@ #include "command_zone.h" #include "../../client/settings/cache_settings.h" -#include "../../game_graphics/zones/select_zone.h" +#include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../interface/theme_manager.h" #include "../board/card_drag_item.h" #include "../board/card_item.h" #include "../board/commander_tax_counter.h" -#include "../player/player_actions.h" -#include "../player/player_logic.h" #include "../z_values.h" +#include "select_zone.h" #include #include @@ -140,7 +140,8 @@ void CommandZone::reorganizeCards() void CommandZone::rearrangeTaxCounters() { - bool commandZoneVisible = isVisible(); + // TODO + /*bool commandZoneVisible = isVisible(); int activeTaxCounterCount = 0; auto *graphicsItem = getLogic()->getPlayer()->getGraphicsItem(); @@ -162,7 +163,7 @@ void CommandZone::rearrangeTaxCounters() int minHeight = activeTaxCounterCount * (TaxCounterSizes::TAX_COUNTER_SIZE + TaxCounterSizes::TAX_COUNTER_MARGIN) + TaxCounterSizes::TAX_COUNTER_MARGIN; - setMinimumHeight(minHeight); + setMinimumHeight(minHeight);*/ } void CommandZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) diff --git a/cockatrice/src/game/zones/command_zone.h b/cockatrice/src/game_graphics/zones/command_zone.h similarity index 97% rename from cockatrice/src/game/zones/command_zone.h rename to cockatrice/src/game_graphics/zones/command_zone.h index 4a6143890..9a23b03f5 100644 --- a/cockatrice/src/game/zones/command_zone.h +++ b/cockatrice/src/game_graphics/zones/command_zone.h @@ -7,9 +7,9 @@ #ifndef COCKATRICE_COMMAND_ZONE_H #define COCKATRICE_COMMAND_ZONE_H -#include "../../game_graphics/zones/select_zone.h" +#include "../../game/zones/command_zone_logic.h" #include "../card_dimensions.h" -#include "command_zone_logic.h" +#include "select_zone.h" #include