mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Refactor] Retype PlayerActions onto CardState (#7435)
* [Refactor] Retype card containers and zone logic onto CardState * [Refactor] Retype PlayerActions onto CardState --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
65e9f1b370
commit
7ca23430cd
18 changed files with 138 additions and 136 deletions
|
|
@ -19,7 +19,7 @@ class GameMetaInfo;
|
||||||
class GameReplay;
|
class GameReplay;
|
||||||
class GameState;
|
class GameState;
|
||||||
class PlayerManager;
|
class PlayerManager;
|
||||||
|
class CardState;
|
||||||
class AbstractGame : public QObject
|
class AbstractGame : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../../game_graphics/dialogs/dlg_create_token.h"
|
#include "../../game_graphics/dialogs/dlg_create_token.h"
|
||||||
#include "../abstract_game.h"
|
#include "../abstract_game.h"
|
||||||
#include "../board/arrow_data.h"
|
#include "../board/arrow_data.h"
|
||||||
|
#include "../board/card_state.h"
|
||||||
#include "../board/counter_state.h"
|
#include "../board/counter_state.h"
|
||||||
#include "../game_event_handler.h"
|
#include "../game_event_handler.h"
|
||||||
#include "../zones/card_zone_logic.h"
|
#include "../zones/card_zone_logic.h"
|
||||||
|
|
@ -91,7 +92,7 @@ PlayerActions::PlayerActions(PlayerLogic *_player)
|
||||||
connect(moveTopCardTimer, &QTimer::timeout, [this]() { actMoveTopCardToPlay(); });
|
connect(moveTopCardTimer, &QTimer::timeout, [this]() { actMoveTopCardToPlay(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::playCard(CardItem *card, bool faceDown)
|
void PlayerActions::playCard(CardState *card, bool faceDown)
|
||||||
{
|
{
|
||||||
if (card == nullptr) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -144,7 +145,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
||||||
* Like {@link PlayerActions::playCard}, but forces the card to be played to the table zone.
|
* Like {@link PlayerActions::playCard}, but forces the card to be played to the table zone.
|
||||||
* Cards with tablerow 3 (the stack) will be played to tablerow 1 (the noncreatures row).
|
* Cards with tablerow 3 (the stack) will be played to tablerow 1 (the noncreatures row).
|
||||||
*/
|
*/
|
||||||
void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
void PlayerActions::playCardToTable(const CardState *card, bool faceDown)
|
||||||
{
|
{
|
||||||
if (card == nullptr) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -177,7 +178,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::attachCards(CardItem *startCard, const CardItem *targetCard)
|
void PlayerActions::attachCards(CardState *startCard, const CardState *targetCard)
|
||||||
{
|
{
|
||||||
if (targetCard->getAttachedTo() || targetCard->getZone()->getName() != ZoneNames::TABLE) {
|
if (targetCard->getAttachedTo() || targetCard->getZone()->getName() != ZoneNames::TABLE) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -197,7 +198,7 @@ void PlayerActions::attachCards(CardItem *startCard, const CardItem *targetCard)
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::createArrow(CardItem *startCard, const ArrowData &arrow, int deleteInPhase)
|
void PlayerActions::createArrow(CardState *startCard, const ArrowData &arrow, int deleteInPhase)
|
||||||
{
|
{
|
||||||
Command_CreateArrow cmd;
|
Command_CreateArrow cmd;
|
||||||
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(arrow.color));
|
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(arrow.color));
|
||||||
|
|
@ -603,7 +604,7 @@ void PlayerActions::moveTopCardsUntil(const QString &expr, MoveTopCardsUntilOpti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::moveOneCardUntil(CardItem *card)
|
void PlayerActions::moveOneCardUntil(CardState *card)
|
||||||
{
|
{
|
||||||
moveTopCardTimer->stop();
|
moveTopCardTimer->stop();
|
||||||
|
|
||||||
|
|
@ -1000,7 +1001,7 @@ void PlayerActions::actCreatePredefinedToken()
|
||||||
actCreateAnotherToken();
|
actCreateAnotherToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actCreateRelatedCard(const CardItem *sourceCard, int index)
|
void PlayerActions::actCreateRelatedCard(const CardState *sourceCard, int index)
|
||||||
{
|
{
|
||||||
if (!sourceCard) {
|
if (!sourceCard) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1012,7 +1013,7 @@ void PlayerActions::actCreateRelatedCard(const CardItem *sourceCard, int index)
|
||||||
actRequestCreateRelatedFromRelationDialog(sourceCard, cardRelation);
|
actRequestCreateRelatedFromRelationDialog(sourceCard, cardRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actCreateAllRelatedCards(const CardItem *sourceCard)
|
void PlayerActions::actCreateAllRelatedCards(const CardState *sourceCard)
|
||||||
{
|
{
|
||||||
if (!sourceCard) {
|
if (!sourceCard) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1099,13 +1100,13 @@ void PlayerActions::actCreateAllRelatedCards(const CardItem *sourceCard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actRequestCreateRelatedFromRelationDialog(const CardItem *sourceCard,
|
void PlayerActions::actRequestCreateRelatedFromRelationDialog(const CardState *sourceCard,
|
||||||
const CardRelation *cardRelation)
|
const CardRelation *cardRelation)
|
||||||
{
|
{
|
||||||
emit requestCreateRelatedFromRelationDialog(sourceCard, cardRelation);
|
emit requestCreateRelatedFromRelationDialog(sourceCard, cardRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerActions::createRelatedFromRelation(const CardItem *sourceCard,
|
bool PlayerActions::createRelatedFromRelation(const CardState *sourceCard,
|
||||||
const CardRelation *cardRelation,
|
const CardRelation *cardRelation,
|
||||||
int variableCount)
|
int variableCount)
|
||||||
{
|
{
|
||||||
|
|
@ -1157,7 +1158,7 @@ bool PlayerActions::createRelatedFromRelation(const CardItem *sourceCard,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::onRelatedCardCreated(const CardItem *sourceCard, const CardRelation *cardRelation)
|
void PlayerActions::onRelatedCardCreated(const CardState *sourceCard, const CardRelation *cardRelation)
|
||||||
{
|
{
|
||||||
if (sourceCard == nullptr || cardRelation == nullptr) {
|
if (sourceCard == nullptr || cardRelation == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1177,7 +1178,7 @@ void PlayerActions::onRelatedCardCreated(const CardItem *sourceCard, const CardR
|
||||||
setLastToken(relatedCard.getCardPtr());
|
setLastToken(relatedCard.getCardPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::createCard(const CardItem *sourceCard,
|
void PlayerActions::createCard(const CardState *sourceCard,
|
||||||
const QString &dbCardName,
|
const QString &dbCardName,
|
||||||
CardRelationType attachType,
|
CardRelationType attachType,
|
||||||
bool persistent,
|
bool persistent,
|
||||||
|
|
@ -1263,7 +1264,7 @@ void PlayerActions::actRequestMoveCardXCardsFromTopDialog()
|
||||||
emit requestMoveCardXCardsFromTopDialog(defaultNumberTopCardsToPlaceBelow, deckSize);
|
emit requestMoveCardXCardsFromTopDialog(defaultNumberTopCardsToPlaceBelow, deckSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actMoveCardXCardsFromTop(QList<CardItem *> selectedCards, int number)
|
void PlayerActions::actMoveCardXCardsFromTop(QList<CardState *> selectedCards, int number)
|
||||||
{
|
{
|
||||||
defaultNumberTopCardsToPlaceBelow = number;
|
defaultNumberTopCardsToPlaceBelow = number;
|
||||||
|
|
||||||
|
|
@ -1297,7 +1298,7 @@ void PlayerActions::actMoveCardXCardsFromTop(QList<CardItem *> selectedCards, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actIncPT(QList<CardItem *> selectedCards, int deltaP, int deltaT)
|
void PlayerActions::actIncPT(QList<CardState *> selectedCards, int deltaP, int deltaT)
|
||||||
{
|
{
|
||||||
int playerid = player->getPlayerInfo()->getId();
|
int playerid = player->getPlayerInfo()->getId();
|
||||||
|
|
||||||
|
|
@ -1330,7 +1331,7 @@ void PlayerActions::actIncPT(QList<CardItem *> selectedCards, int deltaP, int de
|
||||||
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actResetPT(QList<CardItem *> selectedCards)
|
void PlayerActions::actResetPT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
int playerid = player->getPlayerInfo()->getId();
|
int playerid = player->getPlayerInfo()->getId();
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
|
|
@ -1363,7 +1364,7 @@ void PlayerActions::actResetPT(QList<CardItem *> selectedCards)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actRequestSetPTDialog(QList<CardItem *> selectedCards)
|
void PlayerActions::actRequestSetPTDialog(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
QString oldPT;
|
QString oldPT;
|
||||||
|
|
||||||
|
|
@ -1376,7 +1377,7 @@ void PlayerActions::actRequestSetPTDialog(QList<CardItem *> selectedCards)
|
||||||
emit requestSetPTDialog(oldPT);
|
emit requestSetPTDialog(oldPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actSetPT(QList<CardItem *> selectedCards, const QString &pt)
|
void PlayerActions::actSetPT(QList<CardState *> selectedCards, const QString &pt)
|
||||||
{
|
{
|
||||||
int playerid = player->getPlayerInfo()->getId();
|
int playerid = player->getPlayerInfo()->getId();
|
||||||
|
|
||||||
|
|
@ -1416,42 +1417,42 @@ void PlayerActions::actSetPT(QList<CardItem *> selectedCards, const QString &pt)
|
||||||
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
player->getGame()->getGameEventHandler()->sendGameCommand(prepareGameCommand(commandList), playerid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actIncP(QList<CardItem *> selectedCards)
|
void PlayerActions::actIncP(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 1, 0);
|
actIncPT(selectedCards, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actDecP(QList<CardItem *> selectedCards)
|
void PlayerActions::actDecP(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, -1, 0);
|
actIncPT(selectedCards, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actIncT(QList<CardItem *> selectedCards)
|
void PlayerActions::actIncT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 0, 1);
|
actIncPT(selectedCards, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actDecT(QList<CardItem *> selectedCards)
|
void PlayerActions::actDecT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 0, -1);
|
actIncPT(selectedCards, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actIncPT(QList<CardItem *> selectedCards)
|
void PlayerActions::actIncPT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 1, 1);
|
actIncPT(selectedCards, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actDecPT(QList<CardItem *> selectedCards)
|
void PlayerActions::actDecPT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, -1, -1);
|
actIncPT(selectedCards, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actFlowP(QList<CardItem *> selectedCards)
|
void PlayerActions::actFlowP(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, 1, -1);
|
actIncPT(selectedCards, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actFlowT(QList<CardItem *> selectedCards)
|
void PlayerActions::actFlowT(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
actIncPT(selectedCards, -1, 1);
|
actIncPT(selectedCards, -1, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -1474,7 +1475,7 @@ void PlayerActions::actSetCounter(int counterId, int value)
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actReduceLifeByPower(QList<CardItem *> selectedCards)
|
void PlayerActions::actReduceLifeByPower(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
// find life counter
|
// find life counter
|
||||||
auto lifeCounter = player->getLifeCounter();
|
auto lifeCounter = player->getLifeCounter();
|
||||||
|
|
@ -1499,7 +1500,7 @@ void PlayerActions::actReduceLifeByPower(QList<CardItem *> selectedCards)
|
||||||
sendGameCommand(prepareGameCommand(cmd));
|
sendGameCommand(prepareGameCommand(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actRequestSetAnnotationDialog(QList<CardItem *> selectedCards)
|
void PlayerActions::actRequestSetAnnotationDialog(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
QString oldAnnotation;
|
QString oldAnnotation;
|
||||||
for (auto card : selectedCards) {
|
for (auto card : selectedCards) {
|
||||||
|
|
@ -1511,7 +1512,7 @@ void PlayerActions::actRequestSetAnnotationDialog(QList<CardItem *> selectedCard
|
||||||
emit requestSetAnnotationDialog(oldAnnotation);
|
emit requestSetAnnotationDialog(oldAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actSetAnnotation(QList<CardItem *> selectedCards, const QString &annotation)
|
void PlayerActions::actSetAnnotation(QList<CardState *> selectedCards, const QString &annotation)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
for (auto card : selectedCards) {
|
for (auto card : selectedCards) {
|
||||||
|
|
@ -1525,7 +1526,7 @@ void PlayerActions::actSetAnnotation(QList<CardItem *> selectedCards, const QStr
|
||||||
sendGameCommand(prepareGameCommand(commandList));
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actUnattach(QList<CardItem *> selectedCards)
|
void PlayerActions::actUnattach(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
for (auto card : selectedCards) {
|
for (auto card : selectedCards) {
|
||||||
|
|
@ -1541,17 +1542,17 @@ void PlayerActions::actUnattach(QList<CardItem *> selectedCards)
|
||||||
sendGameCommand(prepareGameCommand(commandList));
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actAddCardCounter(QList<CardItem *> selectedCards, int counterId)
|
void PlayerActions::actAddCardCounter(QList<CardState *> selectedCards, int counterId)
|
||||||
{
|
{
|
||||||
offsetCardCounter(selectedCards, counterId, 1);
|
offsetCardCounter(selectedCards, counterId, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actRemoveCardCounter(QList<CardItem *> selectedCards, int counterId)
|
void PlayerActions::actRemoveCardCounter(QList<CardState *> selectedCards, int counterId)
|
||||||
{
|
{
|
||||||
offsetCardCounter(selectedCards, counterId, -1);
|
offsetCardCounter(selectedCards, counterId, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::offsetCardCounter(QList<CardItem *> selectedCards, int counterId, int offset)
|
void PlayerActions::offsetCardCounter(QList<CardState *> selectedCards, int counterId, int offset)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
for (auto card : selectedCards) {
|
for (auto card : selectedCards) {
|
||||||
|
|
@ -1577,7 +1578,7 @@ void PlayerActions::offsetCardCounter(QList<CardItem *> selectedCards, int count
|
||||||
sendGameCommand(prepareGameCommand(commandList));
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actRequestSetCardCounterDialog(QList<CardItem *> selectedCards, int counterId)
|
void PlayerActions::actRequestSetCardCounterDialog(QList<CardState *> selectedCards, int counterId)
|
||||||
{
|
{
|
||||||
// If a single card is selected, we show the old value in the dialog. Otherwise, we show "x"
|
// If a single card is selected, we show the old value in the dialog. Otherwise, we show "x"
|
||||||
QString oldValueForDlg = "x";
|
QString oldValueForDlg = "x";
|
||||||
|
|
@ -1589,7 +1590,7 @@ void PlayerActions::actRequestSetCardCounterDialog(QList<CardItem *> selectedCar
|
||||||
emit requestSetCardCounterDialog(counterId, oldValueForDlg);
|
emit requestSetCardCounterDialog(counterId, oldValueForDlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actSetCardCounter(QList<CardItem *> selectedCards, int counterId, const QString &counterValue)
|
void PlayerActions::actSetCardCounter(QList<CardState *> selectedCards, int counterId, const QString &counterValue)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
for (auto card : selectedCards) {
|
for (auto card : selectedCards) {
|
||||||
|
|
@ -1610,12 +1611,12 @@ void PlayerActions::actSetCardCounter(QList<CardItem *> selectedCards, int count
|
||||||
sendGameCommand(prepareGameCommand(commandList));
|
sendGameCommand(prepareGameCommand(commandList));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actIncrementAllCardCounters(QList<CardItem *> cardsToUpdate)
|
void PlayerActions::actIncrementAllCardCounters(QList<CardState *> cardsToUpdate)
|
||||||
{
|
{
|
||||||
if (cardsToUpdate.isEmpty()) {
|
if (cardsToUpdate.isEmpty()) {
|
||||||
// If no cards selected, update all cards on table
|
// If no cards selected, update all cards on table
|
||||||
for (auto *state : player->getTableZone()->getCards()) {
|
for (auto *state : player->getTableZone()->getCards()) {
|
||||||
cardsToUpdate.append(qobject_cast<CardItem *>(state->parent()));
|
cardsToUpdate.append(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1659,7 +1660,7 @@ static bool isUnwritableRevealZone(CardZoneLogic *zone)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::playSelectedCards(QList<CardItem *> selectedCards, const bool faceDown)
|
void PlayerActions::playSelectedCards(QList<CardState *> selectedCards, const bool faceDown)
|
||||||
{
|
{
|
||||||
// CardIds will get shuffled downwards when cards leave the deck.
|
// 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
|
// We need to iterate through the cards in reverse order so cardIds don't get changed out from under us as we play
|
||||||
|
|
@ -1674,27 +1675,26 @@ void PlayerActions::playSelectedCards(QList<CardItem *> selectedCards, const boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actPlay(QList<CardItem *> selectedCards)
|
void PlayerActions::actPlay(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
playSelectedCards(selectedCards, false);
|
playSelectedCards(selectedCards, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actPlayFacedown(QList<CardItem *> selectedCards)
|
void PlayerActions::actPlayFacedown(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
playSelectedCards(selectedCards, true);
|
playSelectedCards(selectedCards, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actHide(QList<CardItem *> selectedCards)
|
void PlayerActions::actHide(QList<CardState *> selectedCards)
|
||||||
{
|
{
|
||||||
for (const auto &item : selectedCards) {
|
for (const auto &card : selectedCards) {
|
||||||
auto *card = static_cast<CardItem *>(item);
|
if (isUnwritableRevealZone(card->getZone())) {
|
||||||
if (card && isUnwritableRevealZone(card->getZone())) {
|
card->getZone()->removeCard(card);
|
||||||
card->getZone()->removeCard(card->getState());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actReveal(QList<CardItem *> selectedCards, QAction *action)
|
void PlayerActions::actReveal(QList<CardState *> selectedCards, QAction *action)
|
||||||
{
|
{
|
||||||
const int otherPlayerId = action->data().toInt();
|
const int otherPlayerId = action->data().toInt();
|
||||||
|
|
||||||
|
|
@ -1785,9 +1785,9 @@ void PlayerActions::actRevealRandomGraveyardCard(int revealToPlayerId)
|
||||||
sendGameCommand(cmd);
|
sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::cardMenuAction(QList<CardItem *> selectedCards, CardMenuActionType type)
|
void PlayerActions::cardMenuAction(QList<CardState *> selectedCards, CardMenuActionType type)
|
||||||
{
|
{
|
||||||
QList<CardItem *> cardList = selectedCards;
|
QList<CardState *> cardList = selectedCards;
|
||||||
|
|
||||||
QList<const ::google::protobuf::Message *> commandList;
|
QList<const ::google::protobuf::Message *> commandList;
|
||||||
if (type <= cmClone) {
|
if (type <= cmClone) {
|
||||||
|
|
@ -2079,10 +2079,10 @@ PendingCommand *PlayerActions::prepareZoneDump(CardZoneLogic *zone, int numberCa
|
||||||
return prepareGameCommand(cmd);
|
return prepareGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actToggleTapped(const QString &zoneName, const QList<CardItem *> &cards, bool tapped)
|
void PlayerActions::actToggleTapped(const QString &zoneName, const QList<CardState *> &cards, bool tapped)
|
||||||
{
|
{
|
||||||
QList<const ::google::protobuf::Message *> cmdList;
|
QList<const ::google::protobuf::Message *> cmdList;
|
||||||
for (CardItem *card : cards) {
|
for (CardState *card : cards) {
|
||||||
if (card->getTapped() != tapped) {
|
if (card->getTapped() != tapped) {
|
||||||
auto *cmd = new Command_SetCardAttr;
|
auto *cmd = new Command_SetCardAttr;
|
||||||
cmd->set_zone(zoneName.toStdString());
|
cmd->set_zone(zoneName.toStdString());
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
#ifndef COCKATRICE_PLAYER_ACTIONS_H
|
||||||
#define COCKATRICE_PLAYER_ACTIONS_H
|
#define COCKATRICE_PLAYER_ACTIONS_H
|
||||||
|
|
||||||
#include "../../game_graphics/board/card_item.h" // IWYU pragma: keep - moc instantiates the metatype for QList<CardItem *>, which Qt 6.4 needs complete
|
|
||||||
#include "../board/card_list.h"
|
#include "../board/card_list.h"
|
||||||
#include "card_menu_action_type.h"
|
#include "card_menu_action_type.h"
|
||||||
#include "card_move_request.h"
|
#include "card_move_request.h"
|
||||||
|
|
@ -37,6 +36,7 @@ class Message;
|
||||||
}
|
}
|
||||||
} // namespace google
|
} // namespace google
|
||||||
|
|
||||||
|
class CardState;
|
||||||
class CardZoneLogic;
|
class CardZoneLogic;
|
||||||
class Command_MoveCard;
|
class Command_MoveCard;
|
||||||
class PendingCommand;
|
class PendingCommand;
|
||||||
|
|
@ -84,14 +84,14 @@ public:
|
||||||
* @param cards Cards the view wants toggled.
|
* @param cards Cards the view wants toggled.
|
||||||
* @param tapped Desired tapped state.
|
* @param tapped Desired tapped state.
|
||||||
*/
|
*/
|
||||||
void actToggleTapped(const QString &zoneName, const QList<CardItem *> &cards, bool tapped);
|
void actToggleTapped(const QString &zoneName, const QList<CardState *> &cards, bool tapped);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Attaches one card to another on the table on behalf of a view.
|
* @brief Attaches one card to another on the table on behalf of a view.
|
||||||
* @param startCard Card being attached.
|
* @param startCard Card being attached.
|
||||||
* @param targetCard Card being attached to.
|
* @param targetCard Card being attached to.
|
||||||
*/
|
*/
|
||||||
void attachCards(CardItem *startCard, const CardItem *targetCard);
|
void attachCards(CardState *startCard, const CardState *targetCard);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Draws an arrow from a card to another card or a player on behalf of a view.
|
* @brief Draws an arrow from a card to another card or a player on behalf of a view.
|
||||||
|
|
@ -103,9 +103,9 @@ public:
|
||||||
* @param arrow Arrow endpoints and color, as resolved by the view.
|
* @param arrow Arrow endpoints and color, as resolved by the view.
|
||||||
* @param deleteInPhase Phase the arrow expires in, 0 to keep it until removed.
|
* @param deleteInPhase Phase the arrow expires in, 0 to keep it until removed.
|
||||||
*/
|
*/
|
||||||
void createArrow(CardItem *startCard, const ArrowData &arrow, int deleteInPhase);
|
void createArrow(CardState *startCard, const ArrowData &arrow, int deleteInPhase);
|
||||||
|
|
||||||
void moveOneCardUntil(CardItem *card);
|
void moveOneCardUntil(CardState *card);
|
||||||
void stopMoveTopCardsUntil();
|
void stopMoveTopCardsUntil();
|
||||||
|
|
||||||
[[nodiscard]] bool isMovingCardsUntil() const
|
[[nodiscard]] bool isMovingCardsUntil() const
|
||||||
|
|
@ -134,7 +134,7 @@ signals:
|
||||||
void requestDrawBottomCardsDialog(int defaultNumberBottomCards, int maxCards);
|
void requestDrawBottomCardsDialog(int defaultNumberBottomCards, int maxCards);
|
||||||
void requestRollDieDialog();
|
void requestRollDieDialog();
|
||||||
void requestCreateTokenDialog(const QStringList &predefinedTokens);
|
void requestCreateTokenDialog(const QStringList &predefinedTokens);
|
||||||
void requestCreateRelatedFromRelationDialog(const CardItem *sourceCard, const CardRelation *cardRelation);
|
void requestCreateRelatedFromRelationDialog(const CardState *sourceCard, const CardRelation *cardRelation);
|
||||||
void requestMoveCardXCardsFromTopDialog(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
void requestMoveCardXCardsFromTopDialog(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
||||||
void requestSetPTDialog(const QString &oldPT);
|
void requestSetPTDialog(const QString &oldPT);
|
||||||
void requestSetAnnotationDialog(const QString &oldAnnotation);
|
void requestSetAnnotationDialog(const QString &oldAnnotation);
|
||||||
|
|
@ -147,8 +147,8 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
void setLastToken(CardInfoPtr cardInfo);
|
void setLastToken(CardInfoPtr cardInfo);
|
||||||
void setLastTokenInfo(CardInfoPtr cardInfo);
|
void setLastTokenInfo(CardInfoPtr cardInfo);
|
||||||
void playCard(CardItem *c, bool faceDown);
|
void playCard(CardState *c, bool faceDown);
|
||||||
void playCardToTable(const CardItem *c, bool faceDown);
|
void playCardToTable(const CardState *c, bool faceDown);
|
||||||
|
|
||||||
void actUntapAll();
|
void actUntapAll();
|
||||||
void actRequestRollDieDialog();
|
void actRequestRollDieDialog();
|
||||||
|
|
@ -157,9 +157,9 @@ public slots:
|
||||||
void actRequestCreateTokenDialog(const QStringList &predefinedTokens);
|
void actRequestCreateTokenDialog(const QStringList &predefinedTokens);
|
||||||
void actCreateToken(TokenInfo tokenToCreate);
|
void actCreateToken(TokenInfo tokenToCreate);
|
||||||
void actCreateAnotherToken();
|
void actCreateAnotherToken();
|
||||||
void actRequestCreateRelatedFromRelationDialog(const CardItem *sourceCard, const CardRelation *cardRelation);
|
void actRequestCreateRelatedFromRelationDialog(const CardState *sourceCard, const CardRelation *cardRelation);
|
||||||
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation, int variableCount);
|
bool createRelatedFromRelation(const CardState *sourceCard, const CardRelation *cardRelation, int variableCount);
|
||||||
void onRelatedCardCreated(const CardItem *sourceCard, const CardRelation *cardRelation);
|
void onRelatedCardCreated(const CardState *sourceCard, const CardRelation *cardRelation);
|
||||||
void setLastRelatedCreationSucceeded(bool succeeded)
|
void setLastRelatedCreationSucceeded(bool succeeded)
|
||||||
{
|
{
|
||||||
lastRelatedCreationSucceeded = succeeded;
|
lastRelatedCreationSucceeded = succeeded;
|
||||||
|
|
@ -179,9 +179,9 @@ public slots:
|
||||||
void actMulliganMinusOne();
|
void actMulliganMinusOne();
|
||||||
void doMulligan(int number);
|
void doMulligan(int number);
|
||||||
|
|
||||||
void actPlay(QList<CardItem *> selectedCards);
|
void actPlay(QList<CardState *> selectedCards);
|
||||||
void actPlayFacedown(QList<CardItem *> selectedCards);
|
void actPlayFacedown(QList<CardState *> selectedCards);
|
||||||
void actHide(QList<CardItem *> selectedCards);
|
void actHide(QList<CardState *> selectedCards);
|
||||||
|
|
||||||
void actMoveTopCardToPlay();
|
void actMoveTopCardToPlay();
|
||||||
void actMoveTopCardToPlayFaceDown();
|
void actMoveTopCardToPlayFaceDown();
|
||||||
|
|
@ -230,29 +230,29 @@ public slots:
|
||||||
|
|
||||||
void actOpenDeckInDeckEditor();
|
void actOpenDeckInDeckEditor();
|
||||||
void actCreatePredefinedToken();
|
void actCreatePredefinedToken();
|
||||||
void actCreateRelatedCard(const CardItem *sourceCard, int index);
|
void actCreateRelatedCard(const CardState *sourceCard, int index);
|
||||||
void actCreateAllRelatedCards(const CardItem *sourceCard);
|
void actCreateAllRelatedCards(const CardState *sourceCard);
|
||||||
|
|
||||||
void actRequestMoveCardXCardsFromTopDialog();
|
void actRequestMoveCardXCardsFromTopDialog();
|
||||||
void actMoveCardXCardsFromTop(QList<CardItem *> selectedCards, int number);
|
void actMoveCardXCardsFromTop(QList<CardState *> selectedCards, int number);
|
||||||
void actRemoveCardCounter(QList<CardItem *> selectedCards, int counterId);
|
void actRemoveCardCounter(QList<CardState *> selectedCards, int counterId);
|
||||||
void actAddCardCounter(QList<CardItem *> selectedCards, int counterId);
|
void actAddCardCounter(QList<CardState *> selectedCards, int counterId);
|
||||||
void actRequestSetCardCounterDialog(QList<CardItem *> selectedCards, int counterId);
|
void actRequestSetCardCounterDialog(QList<CardState *> selectedCards, int counterId);
|
||||||
void actSetCardCounter(QList<CardItem *> selectedCards, int counterId, const QString &counterValue);
|
void actSetCardCounter(QList<CardState *> selectedCards, int counterId, const QString &counterValue);
|
||||||
void actIncrementAllCardCounters(QList<CardItem *> cardsToUpdate);
|
void actIncrementAllCardCounters(QList<CardState *> cardsToUpdate);
|
||||||
void actUnattach(QList<CardItem *> selectedCards);
|
void actUnattach(QList<CardState *> selectedCards);
|
||||||
void actIncPT(QList<CardItem *> selectedCards, int deltaP, int deltaT);
|
void actIncPT(QList<CardState *> selectedCards, int deltaP, int deltaT);
|
||||||
void actResetPT(QList<CardItem *> selectedCards);
|
void actResetPT(QList<CardState *> selectedCards);
|
||||||
void actRequestSetPTDialog(QList<CardItem *> selectedCards);
|
void actRequestSetPTDialog(QList<CardState *> selectedCards);
|
||||||
void actSetPT(QList<CardItem *> selectedCards, const QString &pt);
|
void actSetPT(QList<CardState *> selectedCards, const QString &pt);
|
||||||
void actIncP(QList<CardItem *> selectedCards);
|
void actIncP(QList<CardState *> selectedCards);
|
||||||
void actDecP(QList<CardItem *> selectedCards);
|
void actDecP(QList<CardState *> selectedCards);
|
||||||
void actIncT(QList<CardItem *> selectedCards);
|
void actIncT(QList<CardState *> selectedCards);
|
||||||
void actDecT(QList<CardItem *> selectedCards);
|
void actDecT(QList<CardState *> selectedCards);
|
||||||
void actIncPT(QList<CardItem *> selectedCards);
|
void actIncPT(QList<CardState *> selectedCards);
|
||||||
void actDecPT(QList<CardItem *> selectedCards);
|
void actDecPT(QList<CardState *> selectedCards);
|
||||||
void actFlowP(QList<CardItem *> selectedCards);
|
void actFlowP(QList<CardState *> selectedCards);
|
||||||
void actFlowT(QList<CardItem *> selectedCards);
|
void actFlowT(QList<CardState *> selectedCards);
|
||||||
|
|
||||||
/** @brief Adjusts a player counter by a signed delta. */
|
/** @brief Adjusts a player counter by a signed delta. */
|
||||||
void actIncrementCounter(int counterId, int delta);
|
void actIncrementCounter(int counterId, int delta);
|
||||||
|
|
@ -260,18 +260,18 @@ public slots:
|
||||||
/** @brief Sets a player counter to an absolute value. */
|
/** @brief Sets a player counter to an absolute value. */
|
||||||
void actSetCounter(int counterId, int value);
|
void actSetCounter(int counterId, int value);
|
||||||
|
|
||||||
void actReduceLifeByPower(QList<CardItem *> selectedCards);
|
void actReduceLifeByPower(QList<CardState *> selectedCards);
|
||||||
|
|
||||||
void actRequestSetAnnotationDialog(QList<CardItem *> selectedCards);
|
void actRequestSetAnnotationDialog(QList<CardState *> selectedCards);
|
||||||
void actSetAnnotation(QList<CardItem *> selectedCards, const QString &annotation);
|
void actSetAnnotation(QList<CardState *> selectedCards, const QString &annotation);
|
||||||
void actReveal(QList<CardItem *> selectedCards, QAction *action);
|
void actReveal(QList<CardState *> selectedCards, QAction *action);
|
||||||
void actRevealHand(int revealToPlayerId);
|
void actRevealHand(int revealToPlayerId);
|
||||||
void actRevealRandomHandCard(int revealToPlayerId);
|
void actRevealRandomHandCard(int revealToPlayerId);
|
||||||
void actRevealLibrary(int revealToPlayerId);
|
void actRevealLibrary(int revealToPlayerId);
|
||||||
|
|
||||||
void actSortHand();
|
void actSortHand();
|
||||||
|
|
||||||
void cardMenuAction(QList<CardItem *> selectedCards, CardMenuActionType type);
|
void cardMenuAction(QList<CardState *> selectedCards, CardMenuActionType type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerLogic *player;
|
PlayerLogic *player;
|
||||||
|
|
@ -292,18 +292,18 @@ private:
|
||||||
|
|
||||||
bool lastRelatedCreationSucceeded = false;
|
bool lastRelatedCreationSucceeded = false;
|
||||||
|
|
||||||
void createCard(const CardItem *sourceCard,
|
void createCard(const CardState *sourceCard,
|
||||||
const QString &dbCardName,
|
const QString &dbCardName,
|
||||||
CardRelationType attach = CardRelationType::DoesNotAttach,
|
CardRelationType attach = CardRelationType::DoesNotAttach,
|
||||||
bool persistent = false,
|
bool persistent = false,
|
||||||
bool faceDown = false);
|
bool faceDown = false);
|
||||||
|
|
||||||
void playSelectedCards(QList<CardItem *> selectedCards, bool faceDown = false);
|
void playSelectedCards(QList<CardState *> selectedCards, bool faceDown = false);
|
||||||
|
|
||||||
void cmdSetTopCard(Command_MoveCard &cmd);
|
void cmdSetTopCard(Command_MoveCard &cmd);
|
||||||
void cmdSetBottomCard(Command_MoveCard &cmd);
|
void cmdSetBottomCard(Command_MoveCard &cmd);
|
||||||
|
|
||||||
void offsetCardCounter(QList<CardItem *> selectedCards, int counterId, int offset);
|
void offsetCardCounter(QList<CardState *> selectedCards, int counterId, int offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCKATRICE_PLAYER_ACTIONS_H
|
#endif // COCKATRICE_PLAYER_ACTIONS_H
|
||||||
|
|
|
||||||
|
|
@ -396,7 +396,7 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
|
||||||
|
|
||||||
if (player->getPlayerActions()->isMovingCardsUntil() && startZoneString == ZoneNames::DECK &&
|
if (player->getPlayerActions()->isMovingCardsUntil() && startZoneString == ZoneNames::DECK &&
|
||||||
targetZone->getName() == ZoneNames::STACK) {
|
targetZone->getName() == ZoneNames::STACK) {
|
||||||
player->getPlayerActions()->moveOneCardUntil(toCardItem(card));
|
player->getPlayerActions()->moveOneCardUntil(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
#include "pile_zone_logic.h"
|
#include "pile_zone_logic.h"
|
||||||
|
|
||||||
#include "../board/card_list.h"
|
|
||||||
#include "../board/card_state.h"
|
#include "../board/card_state.h"
|
||||||
|
|
||||||
class PlayerLogic;
|
|
||||||
class QObject;
|
|
||||||
|
|
||||||
PileZoneLogic::PileZoneLogic(PlayerLogic *_player,
|
PileZoneLogic::PileZoneLogic(PlayerLogic *_player,
|
||||||
const QString &_name,
|
const QString &_name,
|
||||||
bool _hasCardAttr,
|
bool _hasCardAttr,
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
#include "table_zone_logic.h"
|
#include "table_zone_logic.h"
|
||||||
|
|
||||||
#include "../board/card_list.h"
|
|
||||||
#include "../board/card_state.h"
|
#include "../board/card_state.h"
|
||||||
#include "libcockatrice/card/card_info.h"
|
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
class PlayerLogic;
|
|
||||||
class QObject;
|
|
||||||
|
|
||||||
TableZoneLogic::TableZoneLogic(PlayerLogic *_player,
|
TableZoneLogic::TableZoneLogic(PlayerLogic *_player,
|
||||||
const QString &_name,
|
const QString &_name,
|
||||||
bool _hasCardAttr,
|
bool _hasCardAttr,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "view_zone_logic.h"
|
#include "view_zone_logic.h"
|
||||||
|
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../board/card_list.h"
|
|
||||||
#include "../board/card_state.h"
|
#include "../board/card_state.h"
|
||||||
#include "../player/player_actions.h"
|
#include "../player/player_actions.h"
|
||||||
#include "../player/player_logic.h"
|
#include "../player/player_logic.h"
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
startCard->playCard(false);
|
startCard->playCard(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
player->getPlayerActions()->createArrow(startCard, arrow, deleteInPhase);
|
player->getPlayerActions()->createArrow(startCard->getState(), arrow, deleteInPhase);
|
||||||
}
|
}
|
||||||
|
|
||||||
delArrow();
|
delArrow();
|
||||||
|
|
@ -536,7 +536,7 @@ void ArrowAttachItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
auto *startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
auto *startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
||||||
auto *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
auto *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
||||||
if (startCard && targetCard) {
|
if (startCard && targetCard) {
|
||||||
player->getPlayerActions()->attachCards(startCard, targetCard);
|
player->getPlayerActions()->attachCards(startCard->getState(), targetCard->getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ void CardItem::playCard(bool faceDown)
|
||||||
emit playSelected(this);
|
emit playSelected(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
state->getZone()->getPlayer()->getPlayerActions()->playCard(this, faceDown);
|
state->getZone()->getPlayer()->getPlayerActions()->playCard(state, faceDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,15 @@ void GameScene::retranslateUi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<CardState *> GameScene::selectedCardStates() const
|
||||||
|
{
|
||||||
|
QList<CardState *> selectedStates;
|
||||||
|
for (auto *card : selectedCards()) {
|
||||||
|
selectedStates.append(card->getState());
|
||||||
|
}
|
||||||
|
return selectedStates;
|
||||||
|
}
|
||||||
|
|
||||||
QList<CardItem *> GameScene::selectedCards() const
|
QList<CardItem *> GameScene::selectedCards() const
|
||||||
{
|
{
|
||||||
QList<CardItem *> selectedCards;
|
QList<CardItem *> selectedCards;
|
||||||
|
|
@ -235,7 +244,7 @@ void GameScene::playSelected(AbstractCardItem *card)
|
||||||
if (!card->getOwner()) {
|
if (!card->getOwner()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
card->getOwner()->getPlayerActions()->actPlay(selectedCards());
|
card->getOwner()->getPlayerActions()->actPlay(selectedCardStates());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::playSelectedFaceDown(AbstractCardItem *card)
|
void GameScene::playSelectedFaceDown(AbstractCardItem *card)
|
||||||
|
|
@ -246,7 +255,7 @@ void GameScene::playSelectedFaceDown(AbstractCardItem *card)
|
||||||
if (!card->getOwner()) {
|
if (!card->getOwner()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
card->getOwner()->getPlayerActions()->actPlayFacedown(selectedCards());
|
card->getOwner()->getPlayerActions()->actPlayFacedown(selectedCardStates());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::hideSelected(AbstractCardItem *card)
|
void GameScene::hideSelected(AbstractCardItem *card)
|
||||||
|
|
@ -257,7 +266,7 @@ void GameScene::hideSelected(AbstractCardItem *card)
|
||||||
if (!card->getOwner()) {
|
if (!card->getOwner()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
card->getOwner()->getPlayerActions()->actHide(selectedCards());
|
card->getOwner()->getPlayerActions()->actHide(selectedCardStates());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ public:
|
||||||
|
|
||||||
/** @brief Gets all selected CardItems. */
|
/** @brief Gets all selected CardItems. */
|
||||||
QList<CardItem *> selectedCards() const;
|
QList<CardItem *> selectedCards() const;
|
||||||
|
QList<CardState *> selectedCardStates() const;
|
||||||
|
|
||||||
/** @brief Selects every card sharing the zone of @p card. */
|
/** @brief Selects every card sharing the zone of @p card. */
|
||||||
void selectAllInZone(const CardItem *card);
|
void selectAllInZone(const CardItem *card);
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, CardItem *_card, bool _shortcuts
|
||||||
auto *gameScene = player->getGameScene();
|
auto *gameScene = player->getGameScene();
|
||||||
|
|
||||||
// Single selection resolver used by all lambdas — called at trigger time
|
// Single selection resolver used by all lambdas — called at trigger time
|
||||||
auto sel = [gameScene]() { return gameScene->selectedCards(); };
|
auto sel = [gameScene]() { return gameScene->selectedCardStates(); };
|
||||||
|
|
||||||
// Unified dispatcher for card menu actions
|
// Unified dispatcher for card menu actions
|
||||||
auto invoke = [actions, sel](CardMenuActionType type) {
|
auto invoke = [actions, sel](CardMenuActionType type) {
|
||||||
|
|
@ -337,7 +337,7 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
|
||||||
initContextualPlayersMenu(revealMenu, aRevealToAll);
|
initContextualPlayersMenu(revealMenu, aRevealToAll);
|
||||||
|
|
||||||
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
|
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
|
||||||
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action);
|
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCardStates(), action);
|
||||||
});
|
});
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
@ -486,8 +486,9 @@ void CardMenu::addRelatedCardActions()
|
||||||
|
|
||||||
auto *createRelated = new QAction(text, this);
|
auto *createRelated = new QAction(text, this);
|
||||||
const int relatedIndex = index++;
|
const int relatedIndex = index++;
|
||||||
connect(createRelated, &QAction::triggered, this,
|
connect(createRelated, &QAction::triggered, this, [this, playerActions, relatedIndex] {
|
||||||
[this, playerActions, relatedIndex] { playerActions->actCreateRelatedCard(card, relatedIndex); });
|
playerActions->actCreateRelatedCard(card->getState(), relatedIndex);
|
||||||
|
});
|
||||||
addAction(createRelated);
|
addAction(createRelated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,7 +498,7 @@ void CardMenu::addRelatedCardActions()
|
||||||
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
|
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
|
||||||
}
|
}
|
||||||
connect(createRelatedCards, &QAction::triggered, this,
|
connect(createRelatedCards, &QAction::triggered, this,
|
||||||
[this, playerActions] { playerActions->actCreateAllRelatedCards(card); });
|
[this, playerActions] { playerActions->actCreateAllRelatedCards(card->getState()); });
|
||||||
addAction(createRelatedCards);
|
addAction(createRelatedCards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
|
||||||
|
|
||||||
auto invoke = [player](CardMenuActionType type) {
|
auto invoke = [player](CardMenuActionType type) {
|
||||||
return [type, player]() {
|
return [type, player]() {
|
||||||
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
|
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCardStates(), type);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,34 +15,35 @@ PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness"))
|
||||||
|
|
||||||
aIncP = new QAction(this);
|
aIncP = new QAction(this);
|
||||||
connect(aIncP, &QAction::triggered, playerActions,
|
connect(aIncP, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCardStates()); });
|
||||||
aDecP = new QAction(this);
|
aDecP = new QAction(this);
|
||||||
connect(aDecP, &QAction::triggered, playerActions,
|
connect(aDecP, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCardStates()); });
|
||||||
aIncT = new QAction(this);
|
aIncT = new QAction(this);
|
||||||
connect(aIncT, &QAction::triggered, playerActions,
|
connect(aIncT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCardStates()); });
|
||||||
aDecT = new QAction(this);
|
aDecT = new QAction(this);
|
||||||
connect(aDecT, &QAction::triggered, playerActions,
|
connect(aDecT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCardStates()); });
|
||||||
aIncPT = new QAction(this);
|
aIncPT = new QAction(this);
|
||||||
connect(aIncPT, &QAction::triggered, playerActions,
|
connect(aIncPT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCardStates()); });
|
||||||
aDecPT = new QAction(this);
|
aDecPT = new QAction(this);
|
||||||
connect(aDecPT, &QAction::triggered, playerActions,
|
connect(aDecPT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCardStates()); });
|
||||||
aFlowP = new QAction(this);
|
aFlowP = new QAction(this);
|
||||||
connect(aFlowP, &QAction::triggered, playerActions,
|
connect(aFlowP, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCardStates()); });
|
||||||
aFlowT = new QAction(this);
|
aFlowT = new QAction(this);
|
||||||
connect(aFlowT, &QAction::triggered, playerActions,
|
connect(aFlowT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCardStates()); });
|
||||||
aSetPT = new QAction(this);
|
aSetPT = new QAction(this);
|
||||||
connect(aSetPT, &QAction::triggered, playerActions,
|
connect(aSetPT, &QAction::triggered, playerActions, [player, playerActions] {
|
||||||
[player, playerActions] { playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCards()); });
|
playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCardStates());
|
||||||
|
});
|
||||||
aResetPT = new QAction(this);
|
aResetPT = new QAction(this);
|
||||||
connect(aResetPT, &QAction::triggered, playerActions,
|
connect(aResetPT, &QAction::triggered, playerActions,
|
||||||
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCards()); });
|
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCardStates()); });
|
||||||
|
|
||||||
addAction(aIncP);
|
addAction(aIncP);
|
||||||
addAction(aDecP);
|
addAction(aDecP);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu
|
||||||
aIncrementAllCardCounters = new QAction(this);
|
aIncrementAllCardCounters = new QAction(this);
|
||||||
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
|
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
|
||||||
player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
|
player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
|
||||||
player->getGameScene()->selectedCards());
|
player->getGameScene()->selectedCardStates());
|
||||||
});
|
});
|
||||||
|
|
||||||
createPredefinedTokenMenu = new QMenu(QString());
|
createPredefinedTokenMenu = new QMenu(QString());
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ void PlayerDialogs::onRollDieDialogRequested()
|
||||||
playerActions->actRollDie(dlg.getDieSideCount(), dlg.getDiceToRollCount());
|
playerActions->actRollDie(dlg.getDieSideCount(), dlg.getDiceToRollCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerDialogs::onCreateRelatedFromRelationDialogRequested(const CardItem *sourceCard,
|
void PlayerDialogs::onCreateRelatedFromRelationDialogRequested(const CardState *sourceCard,
|
||||||
const CardRelation *cardRelation)
|
const CardRelation *cardRelation)
|
||||||
{
|
{
|
||||||
if (sourceCard == nullptr || cardRelation == nullptr) {
|
if (sourceCard == nullptr || cardRelation == nullptr) {
|
||||||
|
|
@ -252,14 +252,14 @@ void PlayerDialogs::onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopC
|
||||||
number -= 1; // indexes start at 0
|
number -= 1; // indexes start at 0
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCards(), number);
|
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCardStates(), number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
|
void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
auto cards = player->getGameScene()->selectedCards();
|
auto cards = player->getGameScene()->selectedCardStates();
|
||||||
emit requestDialogSemaphore(true);
|
emit requestDialogSemaphore(true);
|
||||||
QString pt = getTextWithMax(dialogParent(), tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
|
QString pt = getTextWithMax(dialogParent(), tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
|
||||||
oldPT, &ok);
|
oldPT, &ok);
|
||||||
|
|
@ -274,7 +274,7 @@ void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
|
||||||
|
|
||||||
void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
|
void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
|
||||||
{
|
{
|
||||||
auto cards = player->getGameScene()->selectedCards();
|
auto cards = player->getGameScene()->selectedCardStates();
|
||||||
emit requestDialogSemaphore(true);
|
emit requestDialogSemaphore(true);
|
||||||
AnnotationDialog *dialog = new AnnotationDialog(dialogParent());
|
AnnotationDialog *dialog = new AnnotationDialog(dialogParent());
|
||||||
dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput);
|
dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput);
|
||||||
|
|
@ -292,7 +292,7 @@ void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
|
||||||
|
|
||||||
void PlayerDialogs::onSetCardCounterDialogRequested(int counterId, const QString &oldValueForDlg)
|
void PlayerDialogs::onSetCardCounterDialogRequested(int counterId, const QString &oldValueForDlg)
|
||||||
{
|
{
|
||||||
auto cards = player->getGameScene()->selectedCards();
|
auto cards = player->getGameScene()->selectedCardStates();
|
||||||
emit requestDialogSemaphore(true);
|
emit requestDialogSemaphore(true);
|
||||||
|
|
||||||
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
|
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public slots:
|
||||||
bool faceDown);
|
bool faceDown);
|
||||||
void onDrawBottomCardsDialogRequested(int defaultNumberBottomCards, int maxCards);
|
void onDrawBottomCardsDialogRequested(int defaultNumberBottomCards, int maxCards);
|
||||||
void onRollDieDialogRequested();
|
void onRollDieDialogRequested();
|
||||||
void onCreateRelatedFromRelationDialogRequested(const CardItem *sourceCard, const CardRelation *cardRelation);
|
void onCreateRelatedFromRelationDialogRequested(const CardState *sourceCard, const CardRelation *cardRelation);
|
||||||
void onCreateTokenDialogRequested(const QStringList &predefinedTokens);
|
void onCreateTokenDialogRequested(const QStringList &predefinedTokens);
|
||||||
void onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
void onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
||||||
void onSetPTDialogRequested(const QString &oldPT);
|
void onSetPTDialogRequested(const QString &oldPT);
|
||||||
|
|
|
||||||
|
|
@ -266,16 +266,16 @@ void TableZone::reorganizeCards()
|
||||||
|
|
||||||
void TableZone::toggleTapped()
|
void TableZone::toggleTapped()
|
||||||
{
|
{
|
||||||
QList<CardItem *> selectedCards;
|
QList<CardState *> selectedCards;
|
||||||
for (auto *item : scene()->selectedItems()) {
|
for (auto *item : scene()->selectedItems()) {
|
||||||
auto *card = qgraphicsitem_cast<CardItem *>(item);
|
auto *card = qgraphicsitem_cast<CardItem *>(item);
|
||||||
if (card && card->getZone()->getName() == ZoneNames::TABLE) {
|
if (card && card->getZone()->getName() == ZoneNames::TABLE) {
|
||||||
selectedCards.append(card);
|
selectedCards.append(card->getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool tapAll = std::any_of(selectedCards.begin(), selectedCards.end(),
|
const bool tapAll = std::any_of(selectedCards.begin(), selectedCards.end(),
|
||||||
[](const CardItem *card) { return !card->getTapped(); });
|
[](const CardState *card) { return !card->getTapped(); });
|
||||||
|
|
||||||
getLogic()->getPlayer()->getPlayerActions()->actToggleTapped(getLogic()->getName(), selectedCards, tapAll);
|
getLogic()->getPlayer()->getPlayerActions()->actToggleTapped(getLogic()->getName(), selectedCards, tapAll);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue