mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
Fix deck export and mana group ordering (#7729)
This commit is contained in:
parent
2056043104
commit
ca2301bc96
8 changed files with 113 additions and 10 deletions
|
|
@ -278,6 +278,37 @@ TEST(DeckListModelCustomZones, SortPlainNodeDoesNotReorderCustomZones)
|
|||
EXPECT_EQ(mapping[1].second, 1);
|
||||
}
|
||||
|
||||
TEST(DeckListModelCustomZones, ManaGroupsUseNumericOrderWithoutChangingOtherNodes)
|
||||
{
|
||||
InnerDecklistNode root;
|
||||
auto *board = new InnerDecklistNode(DECK_ZONE_MAIN, &root);
|
||||
const QStringList original = {"10", "2", "0.5", "1000000", "1", "unknown", "nan"};
|
||||
for (const auto &name : original) {
|
||||
new InnerDecklistNode(name, board);
|
||||
}
|
||||
auto *custom = new DecklistModelSubZoneNode("1x", board);
|
||||
new InnerDecklistNode("10", custom);
|
||||
new InnerDecklistNode("2", custom);
|
||||
root.setSortMethod(DeckSortMethod::ByName);
|
||||
|
||||
const auto mapping = DeckListModelCustomZones::sortWithCustomZonesLast(&root, board, Qt::AscendingOrder, true);
|
||||
EXPECT_EQ(childNames(board), (QStringList{"0.5", "1", "2", "10", "1000000", "nan", "unknown", "1x"}));
|
||||
QStringList before = original;
|
||||
before.append("1x");
|
||||
for (const auto &move : mapping) {
|
||||
EXPECT_EQ(board->at(move.second)->getName(), before.at(move.first));
|
||||
}
|
||||
|
||||
(void)DeckListModelCustomZones::sortWithCustomZonesLast(&root, board, Qt::DescendingOrder, true);
|
||||
EXPECT_EQ(childNames(board), (QStringList{"1000000", "10", "2", "1", "0.5", "unknown", "nan", "1x"}));
|
||||
|
||||
// The numeric flag only affects groups directly under a board.
|
||||
(void)DeckListModelCustomZones::sortWithCustomZonesLast(&root, custom, Qt::AscendingOrder, true);
|
||||
EXPECT_EQ(childNames(custom), (QStringList{"10", "2"}));
|
||||
(void)DeckListModelCustomZones::sortWithCustomZonesLast(&root, board, Qt::AscendingOrder);
|
||||
EXPECT_EQ(childNames(board), (QStringList{"0.5", "1", "10", "1000000", "2", "nan", "unknown", "1x"}));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
|||
|
|
@ -393,6 +393,28 @@ TEST(DeckListZones, MaybeboardCustomZoneCardsAreExcludedFromHash)
|
|||
EXPECT_EQ(deck.getDeckHash(), expected.getDeckHash());
|
||||
}
|
||||
|
||||
TEST(DeckListZones, PlainExportPutsMainFirstWithoutReorderingSavedZones)
|
||||
{
|
||||
DeckList deck;
|
||||
auto *tree = deck.getTree();
|
||||
ASSERT_NE(tree->addCustomZone(DECK_ZONE_SIDE, "Side Tech"), nullptr);
|
||||
tree->addCard("Side Card", 2, "Side Tech", -1);
|
||||
tree->addCard("Token Card", 1, DECK_ZONE_TOKENS, -1);
|
||||
ASSERT_NE(tree->addCustomZone(DECK_ZONE_MAIN, "Removal"), nullptr);
|
||||
tree->addCard("Main Card", 3, "Removal", -1);
|
||||
ASSERT_NE(tree->addCustomZone(DECK_ZONE_MAYBEBOARD, "Candidates"), nullptr);
|
||||
tree->addCard("Maybe Card", 4, "Candidates", -1);
|
||||
|
||||
const QString native = deck.writeToString_Native();
|
||||
EXPECT_EQ(deck.writeToString_Plain(true, false), QString("3 Main Card\nSB: 2 Side Card\n1 Token Card\n"));
|
||||
EXPECT_EQ(deck.writeToString_Plain(false, false), QString("3 Main Card\n2 Side Card\n1 Token Card\n"));
|
||||
EXPECT_EQ(deck.writeToString_Native(), native);
|
||||
|
||||
DeckList reopened(native);
|
||||
EXPECT_EQ(reopened.getZoneNodes().first()->getName(), DECK_ZONE_SIDE);
|
||||
EXPECT_EQ(reopened.writeToString_Plain(true, false), deck.writeToString_Plain(true, false));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue