[Refactor] Untangle card_info.cpp and split into individual files. (#6202)

* Untangle the card_info.cpp mess and split into individual files.

Took 53 minutes

* Auto-lint was disabled and my pre-commit hook didn't fire. Oh well.

Took 3 minutes

* Fix oracle.

Took 35 seconds

* Lint!

Took 20 seconds

* Fix tests.

Took 3 minutes

* CMakeLists.txt: The reason why I have to disable auto-lint.

Took 2 minutes

* dbconverter.

Took 3 minutes

* Oracle again.

Took 3 minutes

* dbconverter again.

Took 3 minutes

* dbconverter again again.

Took 2 minutes

* More fixes.

Took 4 minutes

Took 21 seconds

* Everything needs everything.

Took 3 minutes

* Everything means everything.

Took 4 minutes

* All the tests.

Took 4 minutes

* I hate everything about this.

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-10-01 11:49:39 +02:00 committed by GitHub
parent 835e4af3e4
commit 89a8d0f6b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 743 additions and 516 deletions

View file

@ -1,6 +1,7 @@
#include "player_actions.h"
#include "../../../common/pb/context_move_card.pb.h"
#include "../../card/card_relation.h"
#include "../../client/get_text_with_max.h"
#include "../../database/card_database_manager.h"
#include "../../tabs/tab_game.h"
@ -977,7 +978,7 @@ void PlayerActions::actCreateAllRelatedCards()
dbName = cardRelationAll->getName();
bool persistent = cardRelationAll->getIsPersistent();
for (int i = 0; i < cardRelationAll->getDefaultCount(); ++i) {
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
createCard(sourceCard, dbName, CardRelationType::DoesNotAttach, persistent);
}
++tokensTypesCreated;
if (tokensTypesCreated == 1) {
@ -992,7 +993,7 @@ void PlayerActions::actCreateAllRelatedCards()
dbName = cardRelationNotExcluded->getName();
bool persistent = cardRelationNotExcluded->getIsPersistent();
for (int i = 0; i < cardRelationNotExcluded->getDefaultCount(); ++i) {
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
createCard(sourceCard, dbName, CardRelationType::DoesNotAttach, persistent);
}
++tokensTypesCreated;
if (tokensTypesCreated == 1) {
@ -1031,18 +1032,18 @@ bool PlayerActions::createRelatedFromRelation(const CardItem *sourceCard, const
return false;
}
for (int i = 0; i < count; ++i) {
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
createCard(sourceCard, dbName, CardRelationType::DoesNotAttach, persistent);
}
} else if (cardRelation->getDefaultCount() > 1) {
for (int i = 0; i < cardRelation->getDefaultCount(); ++i) {
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
createCard(sourceCard, dbName, CardRelationType::DoesNotAttach, persistent);
}
} else {
auto attachType = cardRelation->getAttachType();
// move card onto table first if attaching from some other zone
// we only do this for AttachTo because cross-zone TransformInto is already handled server-side
if (attachType == CardRelation::AttachTo && sourceCard->getZone()->getName() != "table") {
if (attachType == CardRelationType::AttachTo && sourceCard->getZone()->getName() != "table") {
playCardToTable(sourceCard, false);
}
@ -1053,7 +1054,7 @@ bool PlayerActions::createRelatedFromRelation(const CardItem *sourceCard, const
void PlayerActions::createCard(const CardItem *sourceCard,
const QString &dbCardName,
CardRelation::AttachType attachType,
CardRelationType attachType,
bool persistent)
{
CardInfoPtr cardInfo = CardDatabaseManager::query()->getCardInfo(dbCardName);
@ -1096,19 +1097,19 @@ void PlayerActions::createCard(const CardItem *sourceCard,
CardDatabaseManager::query()->getCardFromSameSet(cardInfo->getName(), sourceCard->getCard().getPrinting());
switch (attachType) {
case CardRelation::DoesNotAttach:
case CardRelationType::DoesNotAttach:
cmd.set_target_zone("table");
cmd.set_card_provider_id(relatedCard.getPrinting().getUuid().toStdString());
break;
case CardRelation::AttachTo:
case CardRelationType::AttachTo:
cmd.set_target_zone("table"); // We currently only support creating tokens on the table
cmd.set_card_provider_id(relatedCard.getPrinting().getUuid().toStdString());
cmd.set_target_card_id(sourceCard->getId());
cmd.set_target_mode(Command_CreateToken::ATTACH_TO);
break;
case CardRelation::TransformInto:
case CardRelationType::TransformInto:
// allow cards to directly transform on stack
cmd.set_zone(sourceCard->getZone()->getName() == "stack" ? "stack" : "table");
// Transform card zone changes are handled server-side