mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-28 11:53:11 -07:00
[Game] Fix not using zone-specific card menu for opponent's cards (#6695)
This commit is contained in:
@@ -113,32 +113,20 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
|
||||
addAction(aSelectAll);
|
||||
addAction(aSelectColumn);
|
||||
addRelatedCardView();
|
||||
} else if (writeableCard) {
|
||||
|
||||
} else {
|
||||
if (card->getZone()) {
|
||||
if (card->getZone()->getName() == ZoneNames::TABLE) {
|
||||
createTableMenu();
|
||||
createTableMenu(writeableCard);
|
||||
} else if (card->getZone()->getName() == ZoneNames::STACK) {
|
||||
createStackMenu();
|
||||
createStackMenu(writeableCard);
|
||||
} else if (card->getZone()->getName() == ZoneNames::EXILE ||
|
||||
card->getZone()->getName() == ZoneNames::GRAVE) {
|
||||
createGraveyardOrExileMenu();
|
||||
createGraveyardOrExileMenu(writeableCard);
|
||||
} else {
|
||||
createHandOrCustomZoneMenu();
|
||||
createHandOrCustomZoneMenu(writeableCard);
|
||||
}
|
||||
} else {
|
||||
addMenu(new MoveMenu(player));
|
||||
}
|
||||
} else {
|
||||
if (card->getZone() && card->getZone()->getName() != ZoneNames::HAND) {
|
||||
addAction(aDrawArrow);
|
||||
addSeparator();
|
||||
addRelatedCardView();
|
||||
addRelatedCardActions();
|
||||
addSeparator();
|
||||
addAction(aClone);
|
||||
addSeparator();
|
||||
addAction(aSelectAll);
|
||||
createZonelessMenu(writeableCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,11 +142,9 @@ void CardMenu::removePlayer(Player *playerToRemove)
|
||||
}
|
||||
}
|
||||
|
||||
void CardMenu::createTableMenu()
|
||||
void CardMenu::createTableMenu(bool canModifyCard)
|
||||
{
|
||||
// Card is on the battlefield
|
||||
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
|
||||
|
||||
if (!canModifyCard) {
|
||||
addRelatedCardView();
|
||||
addRelatedCardActions();
|
||||
@@ -213,10 +199,8 @@ void CardMenu::createTableMenu()
|
||||
addMenu(mCardCounters);
|
||||
}
|
||||
|
||||
void CardMenu::createStackMenu()
|
||||
void CardMenu::createStackMenu(bool canModifyCard)
|
||||
{
|
||||
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
|
||||
|
||||
// Card is on the stack
|
||||
if (canModifyCard) {
|
||||
addAction(aAttach);
|
||||
@@ -238,10 +222,8 @@ void CardMenu::createStackMenu()
|
||||
addRelatedCardActions();
|
||||
}
|
||||
|
||||
void CardMenu::createGraveyardOrExileMenu()
|
||||
void CardMenu::createGraveyardOrExileMenu(bool canModifyCard)
|
||||
{
|
||||
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
|
||||
|
||||
// Card is in the graveyard or exile
|
||||
if (canModifyCard) {
|
||||
addAction(aPlay);
|
||||
@@ -270,8 +252,20 @@ void CardMenu::createGraveyardOrExileMenu()
|
||||
addRelatedCardActions();
|
||||
}
|
||||
|
||||
void CardMenu::createHandOrCustomZoneMenu()
|
||||
void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
|
||||
{
|
||||
if (!canModifyCard) {
|
||||
addAction(aDrawArrow);
|
||||
addSeparator();
|
||||
addRelatedCardView();
|
||||
addRelatedCardActions();
|
||||
addSeparator();
|
||||
addAction(aClone);
|
||||
addSeparator();
|
||||
addAction(aSelectAll);
|
||||
return;
|
||||
}
|
||||
|
||||
// Card is in hand or a custom zone specified by server
|
||||
addAction(aPlay);
|
||||
addAction(aPlayFacedown);
|
||||
@@ -305,6 +299,13 @@ void CardMenu::createHandOrCustomZoneMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void CardMenu::createZonelessMenu(bool canModifyCard)
|
||||
{
|
||||
if (canModifyCard) {
|
||||
addMenu(new MoveMenu(player));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Populates the menu with an action for each active player.
|
||||
*
|
||||
|
||||
@@ -18,10 +18,11 @@ class CardMenu : public QMenu
|
||||
public:
|
||||
explicit CardMenu(Player *player, const CardItem *card, bool shortcutsActive);
|
||||
void removePlayer(Player *playerToRemove);
|
||||
void createTableMenu();
|
||||
void createStackMenu();
|
||||
void createGraveyardOrExileMenu();
|
||||
void createHandOrCustomZoneMenu();
|
||||
void createTableMenu(bool canModifyCard);
|
||||
void createStackMenu(bool canModifyCard);
|
||||
void createGraveyardOrExileMenu(bool canModifyCard);
|
||||
void createHandOrCustomZoneMenu(bool canModifyCard);
|
||||
void createZonelessMenu(bool canModifyCard);
|
||||
|
||||
QMenu *mCardCounters;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user