GigaPasjans
Loading...
Searching...
No Matches
GameRulesEngine.h
1// Plik utworzony przez Piotra ChudziƄskiego w dniu 27.04.2025
2#pragma once
3
4#include <array>
5#include <foundation/Common.h>
6#include "Card/Deck.h"
7
8namespace Game
9{
13 struct Scoring
14 {
19
24
29
34
39
40 constexpr Scoring(int32 stockToTableau, int32 stockToFoundation, int32 tableauToFoundation,
41 int32 foundationToTableau, int32 revealCard) :
42 StockToTableau(stockToTableau), StockToFoundation(stockToFoundation),
43 TableauToFoundation(tableauToFoundation), FoundationToTableau(foundationToTableau), RevealCard(revealCard)
44 {
45 }
46 };
47
48 namespace Scorings
49 {
53 static constexpr Scoring Microsoft() { return {5, 10, 10, -15, 5}; }
54
58 static constexpr Scoring ClassicEasy() { return {10, 15, 15, -5, 10}; }
59
63 static constexpr Scoring VegasStyle() { return {0, 5, 5, -10, 5}; }
64
68 static constexpr Scoring SpeedRun() { return {3, 8, 12, -5, 7}; }
69
73 static constexpr Scoring Hardcore() { return {1, 5, 5, -25, 2}; }
74
78 static constexpr Scoring CustomBalanced() { return {4, 10, 10, -10, 6}; }
79
83 static constexpr std::array<Scoring, 6> Table = {Microsoft(), ClassicEasy(), VegasStyle(),
84 SpeedRun(), Hardcore(), CustomBalanced()};
85 } // namespace Scorings
86
91 {
92 private:
96 inline static Scoring m_Scoring = Scorings::Microsoft();
97
101 static void givePoints(Card *card, CardStack *targetStack);
102
106 static void givePoints(const std::vector<Card *> &cards, CardStack *targetStack);
107
108 public:
112 static bool VerifyCardInteraction(Card *card, CardStack *targetStack);
113
117 static bool VerifyBulkCardInteraction(const std::vector<Card *> &cards, CardStack *targetStack);
118
122 static bool IsWin();
123
127 static void CheckForWin();
128
132 static void SetScoring(const Scoring &scoring);
133
137 static const Scoring &GetScoring();
138 };
139} // namespace Game
Represents a playing card in a game. This class defines a card with properties such as color,...
Definition Card.h:61
Represents a stack of cards in the game.
Definition Deck.h:14
Manages game rules, scoring, and win conditions.
Definition GameRulesEngine.h:91
static bool VerifyBulkCardInteraction(const std::vector< Card * > &cards, CardStack *targetStack)
Validates if a group of cards can be moved to the target stack.
Definition GameRulesEngine.cpp:89
static void SetScoring(const Scoring &scoring)
Sets the current scoring rule set.
Definition GameRulesEngine.cpp:127
static bool IsWin()
Checks whether current game state satisfies win conditions.
Definition GameRulesEngine.cpp:97
static bool VerifyCardInteraction(Card *card, CardStack *targetStack)
Validates if a card can be moved to the target stack.
Definition GameRulesEngine.cpp:47
static void CheckForWin()
Evaluates the game state and triggers win logic if necessary.
Definition GameRulesEngine.cpp:116
static const Scoring & GetScoring()
Gets the currently active scoring rule set.
Definition GameRulesEngine.cpp:129
Defines the point values for various game actions.
Definition GameRulesEngine.h:14
int32 StockToTableau
Points for moving a card from stock to tableau.
Definition GameRulesEngine.h:18
int32 FoundationToTableau
Points penalty for moving a card from foundation to tableau.
Definition GameRulesEngine.h:33
int32 RevealCard
Points for revealing a hidden card.
Definition GameRulesEngine.h:38
int32 StockToFoundation
Points for moving a card from stock to foundation.
Definition GameRulesEngine.h:23
int32 TableauToFoundation
Points for moving a card from tableau to foundation.
Definition GameRulesEngine.h:28