mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 08:24:39 -07:00
[Game] Refactor subtype tally code to be more generic (#7021)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (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 / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* [Game] Refactor subtype tally code to be more generic * remove default case * consolidate empty check * fix include guard * backwards compatibility with qt5
This commit is contained in:
parent
430fc117b4
commit
c5b37cdffe
8 changed files with 138 additions and 84 deletions
40
cockatrice/src/game_graphics/tally/tally.h
Normal file
40
cockatrice/src/game_graphics/tally/tally.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef COCKATRICE_TALLY_H
|
||||
#define COCKATRICE_TALLY_H
|
||||
#include <QString>
|
||||
|
||||
class CardItem;
|
||||
|
||||
/** @brief A single row of the tally output. */
|
||||
struct TallyRow
|
||||
{
|
||||
QString name; ///< The row name (displayed on the left)
|
||||
QString value; ///< Value for the row (displayed on the right)
|
||||
|
||||
bool operator==(const TallyRow &) const = default;
|
||||
};
|
||||
|
||||
/**
|
||||
* The tally type
|
||||
*/
|
||||
enum class TallyType
|
||||
{
|
||||
None,
|
||||
Subtypes,
|
||||
};
|
||||
|
||||
namespace Tally
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Analyzes the selected cards according to the tally type and builds the resulting tally rows.
|
||||
* This forwards the cards to the code for that tally type.
|
||||
*
|
||||
* @param cards The list of selected card items to analyze.
|
||||
* @param type The type of tally to do
|
||||
* @return Rows sorted in top-to-bottom display order
|
||||
*/
|
||||
QList<TallyRow> compute(const QList<CardItem *> &cards, TallyType type);
|
||||
|
||||
} // namespace Tally
|
||||
|
||||
#endif // COCKATRICE_TALLY_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue