From 15673dc481ce9091089157ae76db5a1adab6f66d Mon Sep 17 00:00:00 2001 From: BruebachL Date: Tue, 13 Oct 2026 11:46:49 +0200 Subject: [PATCH] [DeckDiff] Use namespace instead of static-only class per review --- .../libcockatrice/deck_list/deck_diff.cpp | 10 +++-- .../libcockatrice/deck_list/deck_diff.h | 44 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.cpp b/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.cpp index b918dd9ee..538de57e8 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.cpp +++ b/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.cpp @@ -55,7 +55,9 @@ bool changeLessThan(const DeckCardChange &a, const DeckCardChange &b) } } // namespace -DeckDiffResult DeckDiff::diff(const DeckList &oldDeck, const DeckList &newDeck) +namespace DeckDiff +{ +DeckDiffResult diff(const DeckList &oldDeck, const DeckList &newDeck) { const QMap oldCounts = zoneCardCounts(oldDeck); const QMap newInfos = zoneCardInfos(newDeck); @@ -83,7 +85,7 @@ DeckDiffResult DeckDiff::diff(const DeckList &oldDeck, const DeckList &newDeck) return result; } -bool DeckDiff::canAutoMerge(const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges) +bool canAutoMerge(const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges) { QSet localKeys; for (const DeckCardChange &change : localChanges.changes) { @@ -97,8 +99,7 @@ bool DeckDiff::canAutoMerge(const DeckDiffResult &localChanges, const DeckDiffRe return true; } -DeckList -DeckDiff::merge(const DeckList &baseDeck, const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges) +DeckList merge(const DeckList &baseDeck, const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges) { QMap counts = zoneCardCounts(baseDeck); QMap printings; @@ -139,3 +140,4 @@ DeckDiff::merge(const DeckList &baseDeck, const DeckDiffResult &localChanges, co merged.refreshDeckHash(); return merged; } +} // namespace DeckDiff diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.h b/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.h index 563b54b70..4a6562292 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.h +++ b/libcockatrice_deck_list/libcockatrice/deck_list/deck_diff.h @@ -40,35 +40,33 @@ struct DeckDiffResult }; /** - * @class DeckDiff + * @namespace DeckDiff * @brief Pure card-count diff and three-way merge for deck sync. * * Compares card names and copy counts per zone only; a merged deck keeps * base printings for existing cards and carries the changed side's printing * for newly added cards. */ -class DeckDiff +namespace DeckDiff { -public: - /** @brief Diffs oldDeck against newDeck. */ - static DeckDiffResult diff(const DeckList &oldDeck, const DeckList &newDeck); - /** - * @brief True when both change sets touch disjoint (zone, card) keys and a merge needs no arbitration. - */ - static bool canAutoMerge(const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges); - /** - * @brief Applies both change sets onto a copy of baseDeck. - * - * @precondition localChanges and remoteChanges were both computed with - * diff() against baseDeck. Stale or foreign change sets silently - * resurrect or delete cards. - * - * Counts are clamped at zero. On overlapping keys the remote change wins; - * callers offer this result as "Use Merge" only when canAutoMerge is true. - * Metadata and sideboard plans come from baseDeck. - */ - static DeckList - merge(const DeckList &baseDeck, const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges); -}; +/** @brief Diffs oldDeck against newDeck. */ +DeckDiffResult diff(const DeckList &oldDeck, const DeckList &newDeck); +/** + * @brief True when both change sets touch disjoint (zone, card) keys and a merge needs no arbitration. + */ +bool canAutoMerge(const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges); +/** + * @brief Applies both change sets onto a copy of baseDeck. + * + * @precondition localChanges and remoteChanges were both computed with + * diff() against baseDeck. Stale or foreign change sets silently + * resurrect or delete cards. + * + * Counts are clamped at zero. On overlapping keys the remote change wins; + * callers offer this result as "Use Merge" only when canAutoMerge is true. + * Metadata and sideboard plans come from baseDeck. + */ +DeckList merge(const DeckList &baseDeck, const DeckDiffResult &localChanges, const DeckDiffResult &remoteChanges); +} // namespace DeckDiff #endif // DECK_DIFF_H