mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 17:55:21 -05:00
[Game] Refactor move cards from library actions (#6658)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 43) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 42) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Servatrice_Debian, DEB, yes, skip, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 22.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Ninja, macOS, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-15, Apple, 15, Debug, 1, 16.4) (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Windows10-installer, Visual Studio 17 2022, x64, 1, Windows, -Win10, win64_msvc2022_64, qtimageformats qtmultimedia qtwebsoc… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS13_Intel-package, Ninja, 1, macOS, 13, -macOS13_Intel, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, maco… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS14-package, Ninja, 1, macOS, -macOS14, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-14, Apple, 14,… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS15-package, Ninja, 1, macOS, -macOS15, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-15, Apple, 15,… (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 43) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 42) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Servatrice_Debian, DEB, yes, skip, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 22.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Ninja, macOS, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-15, Apple, 15, Debug, 1, 16.4) (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (Windows10-installer, Visual Studio 17 2022, x64, 1, Windows, -Win10, win64_msvc2022_64, qtimageformats qtmultimedia qtwebsoc… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS13_Intel-package, Ninja, 1, macOS, 13, -macOS13_Intel, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, maco… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS14-package, Ninja, 1, macOS, -macOS14, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-14, Apple, 14,… (push) Blocked by required conditions
Build Desktop / ${{matrix.os}} ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macOS15-package, Ninja, 1, macOS, -macOS15, clang_64, qtimageformats qtmultimedia qtwebsockets, 6.10.*, macos-15, Apple, 15,… (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* refactor move top/bottom cards actions * minor cleanup * translate zone display names
This commit is contained in:
parent
b36ab66583
commit
e7a3ad86eb
|
|
@ -424,37 +424,15 @@ void PlayerActions::actMoveTopCardToExile()
|
||||||
|
|
||||||
void PlayerActions::actMoveTopCardsToGrave()
|
void PlayerActions::actMoveTopCardsToGrave()
|
||||||
{
|
{
|
||||||
const int maxCards = player->getDeckZone()->getCards().size();
|
moveTopCardsTo("grave", tr("grave"));
|
||||||
if (maxCards == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move top cards to grave"),
|
|
||||||
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberTopCards, 1,
|
|
||||||
maxCards, 1, &ok);
|
|
||||||
if (!ok) {
|
|
||||||
return;
|
|
||||||
} else if (number > maxCards) {
|
|
||||||
number = maxCards;
|
|
||||||
}
|
|
||||||
defaultNumberTopCards = number;
|
|
||||||
|
|
||||||
Command_MoveCard cmd;
|
|
||||||
cmd.set_start_zone("deck");
|
|
||||||
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
|
||||||
cmd.set_target_zone("grave");
|
|
||||||
cmd.set_x(0);
|
|
||||||
cmd.set_y(0);
|
|
||||||
|
|
||||||
for (int i = number - 1; i >= 0; --i) {
|
|
||||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendGameCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actMoveTopCardsToExile()
|
void PlayerActions::actMoveTopCardsToExile()
|
||||||
|
{
|
||||||
|
moveTopCardsTo("rfg", tr("exile"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerActions::moveTopCardsTo(const QString &targetZone, const QString &zoneDisplayName)
|
||||||
{
|
{
|
||||||
const int maxCards = player->getDeckZone()->getCards().size();
|
const int maxCards = player->getDeckZone()->getCards().size();
|
||||||
if (maxCards == 0) {
|
if (maxCards == 0) {
|
||||||
|
|
@ -462,12 +440,14 @@ void PlayerActions::actMoveTopCardsToExile()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move top cards to exile"),
|
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move top cards to %1").arg(zoneDisplayName),
|
||||||
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberTopCards, 1,
|
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberTopCards, 1,
|
||||||
maxCards, 1, &ok);
|
maxCards, 1, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return;
|
return;
|
||||||
} else if (number > maxCards) {
|
}
|
||||||
|
|
||||||
|
if (number > maxCards) {
|
||||||
number = maxCards;
|
number = maxCards;
|
||||||
}
|
}
|
||||||
defaultNumberTopCards = number;
|
defaultNumberTopCards = number;
|
||||||
|
|
@ -475,7 +455,7 @@ void PlayerActions::actMoveTopCardsToExile()
|
||||||
Command_MoveCard cmd;
|
Command_MoveCard cmd;
|
||||||
cmd.set_start_zone("deck");
|
cmd.set_start_zone("deck");
|
||||||
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
||||||
cmd.set_target_zone("rfg");
|
cmd.set_target_zone(targetZone.toStdString());
|
||||||
cmd.set_x(0);
|
cmd.set_x(0);
|
||||||
cmd.set_y(0);
|
cmd.set_y(0);
|
||||||
|
|
||||||
|
|
@ -628,37 +608,15 @@ void PlayerActions::actMoveBottomCardToExile()
|
||||||
|
|
||||||
void PlayerActions::actMoveBottomCardsToGrave()
|
void PlayerActions::actMoveBottomCardsToGrave()
|
||||||
{
|
{
|
||||||
const int maxCards = player->getDeckZone()->getCards().size();
|
moveBottomCardsTo("grave", tr("grave"));
|
||||||
if (maxCards == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move bottom cards to grave"),
|
|
||||||
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberBottomCards, 1,
|
|
||||||
maxCards, 1, &ok);
|
|
||||||
if (!ok) {
|
|
||||||
return;
|
|
||||||
} else if (number > maxCards) {
|
|
||||||
number = maxCards;
|
|
||||||
}
|
|
||||||
defaultNumberBottomCards = number;
|
|
||||||
|
|
||||||
Command_MoveCard cmd;
|
|
||||||
cmd.set_start_zone("deck");
|
|
||||||
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
|
||||||
cmd.set_target_zone("grave");
|
|
||||||
cmd.set_x(0);
|
|
||||||
cmd.set_y(0);
|
|
||||||
|
|
||||||
for (int i = maxCards - number; i < maxCards; ++i) {
|
|
||||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendGameCommand(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerActions::actMoveBottomCardsToExile()
|
void PlayerActions::actMoveBottomCardsToExile()
|
||||||
|
{
|
||||||
|
moveBottomCardsTo("rfg", tr("exile"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerActions::moveBottomCardsTo(const QString &targetZone, const QString &zoneDisplayName)
|
||||||
{
|
{
|
||||||
const int maxCards = player->getDeckZone()->getCards().size();
|
const int maxCards = player->getDeckZone()->getCards().size();
|
||||||
if (maxCards == 0) {
|
if (maxCards == 0) {
|
||||||
|
|
@ -666,12 +624,14 @@ void PlayerActions::actMoveBottomCardsToExile()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move bottom cards to exile"),
|
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Move bottom cards to %1").arg(zoneDisplayName),
|
||||||
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberBottomCards, 1,
|
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberBottomCards, 1,
|
||||||
maxCards, 1, &ok);
|
maxCards, 1, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return;
|
return;
|
||||||
} else if (number > maxCards) {
|
}
|
||||||
|
|
||||||
|
if (number > maxCards) {
|
||||||
number = maxCards;
|
number = maxCards;
|
||||||
}
|
}
|
||||||
defaultNumberBottomCards = number;
|
defaultNumberBottomCards = number;
|
||||||
|
|
@ -679,7 +639,7 @@ void PlayerActions::actMoveBottomCardsToExile()
|
||||||
Command_MoveCard cmd;
|
Command_MoveCard cmd;
|
||||||
cmd.set_start_zone("deck");
|
cmd.set_start_zone("deck");
|
||||||
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
cmd.set_target_player_id(player->getPlayerInfo()->getId());
|
||||||
cmd.set_target_zone("rfg");
|
cmd.set_target_zone(targetZone.toStdString());
|
||||||
cmd.set_x(0);
|
cmd.set_x(0);
|
||||||
cmd.set_y(0);
|
cmd.set_y(0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,9 @@ private:
|
||||||
FilterString movingCardsUntilFilter;
|
FilterString movingCardsUntilFilter;
|
||||||
int movingCardsUntilCounter = 0;
|
int movingCardsUntilCounter = 0;
|
||||||
|
|
||||||
|
void moveTopCardsTo(const QString &targetZone, const QString &zoneDisplayName);
|
||||||
|
void moveBottomCardsTo(const QString &targetZone, const QString &zoneDisplayName);
|
||||||
|
|
||||||
void createCard(const CardItem *sourceCard,
|
void createCard(const CardItem *sourceCard,
|
||||||
const QString &dbCardName,
|
const QString &dbCardName,
|
||||||
CardRelationType attach = CardRelationType::DoesNotAttach,
|
CardRelationType attach = CardRelationType::DoesNotAttach,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user