Brunot
Loading...
Searching...
No Matches
Scoring.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21#pragma once
22
23#include <random>
24
25#include "GameRules.h"
26#include "Framework/System.h"
29
30struct Message;
31class Board;
32class Card;
33
34
35namespace sys
36{
37class PlayerTurn;
38class Table;
41struct ScoringCalculatorContext;
42
47class Scoring : public System
48{
49public:
50#pragma region static_functions
51
55 static auto getEnum() -> Type
56 {
57 return Type::Scoring;
58 }
59
60#pragma endregion
61
62 Scoring();
63 ~Scoring() override;
64 Scoring(const Scoring& other) = default;
65 Scoring(Scoring&& other) noexcept;
66 auto operator=(const Scoring& other) -> Scoring&;
67 auto operator=(Scoring&& other) noexcept -> Scoring& = default;
68
69
70#pragma region overridden_functions
71
72 auto clone() const -> std::unique_ptr<GameObject> override
73 {
74 return std::make_unique<Scoring>(*this);
75 }
76
77protected:
78 auto systemShowMenu() -> void override;
79
80public:
81 auto onUpdate(float dt) -> void override;
82
83 auto endWindow() -> void override
84 {
85 }; // for debug ImGUI
86 auto onRender() -> void override;
87 auto onSceneStart(const std::string& sceneName) -> void override;
88 auto load(const Stream& stream) -> void override;
89 auto save(Stream& stream) const -> void override;
90
91 auto onEnterEngine() -> void override;
92
93#pragma endregion
94
95#pragma region scoring_functions
96
103 auto scoreBoard(Board& board, const std::vector<Card*>& cards) -> int;
104
108 auto scoringFeedback(std::vector<CategorizedHand> handsToHighlight) -> void;
109
113 auto turnOnScoringCalculator() -> void;
114
118 auto turnOffScoringCalculator() -> void;
119
125
130 auto scoringCalculatorHighlighting() -> void;
131
135 auto isScoringFeedbackHappening() const -> bool;
136
137#pragma endregion
138
139private:
140#pragma region member_variables
141
142 // random engine, copied from ParticleSpawner
143 std::ranlux24_base randSeed{std::random_device()()};
144
145 Table* table = nullptr;
148
149 // Used for other classes to know if there are scoring Feedback visuals currently occuring
151
153 float minPitch = 0.8f;
156 float maxPitch = 1.5f;
157
159 float extraPitchPerCard = 0.02f;
161 std::string cardScoredSFX = "chips_soundeffect";
163 std::string handScoredSFX = "Card_Success_1";
164
165#pragma endregion
166
167#pragma region helper_functions
168
172 auto scoringFeedbackSetUp(std::vector<CategorizedHand>& handsToHighlight) -> int;
173
174
191 void createActionsForCardScoredEvents(ScoringFeedbackContext& context, const Card* currPlayedCard,
192 Entity* cardParent, bool isImportant, float cardTime, float ratioThroughContributingCards, float cardsScored);
193
200
204 auto createCardActions(ScoringFeedbackContext& sfcRef, ScoringFeedbackActions& sfaRef, const CategorizedHand& currentPlayerHand) -> void;
205
209 auto scoringFeedbackDelayedFunction(float setInitialDelay) -> void;
210
214 auto addScoringCalculatorStars(const CategorizedHand& currentHand) -> void;
215
219 auto highlightStar(const CategorizedHand& currentHand) -> void;
220
225 auto clearScoringCalculator() -> void;
226
227#pragma endregion
228
229
230#pragma region static_variables
231
232
233
234#pragma endregion
235
236#pragma region Messages
237 auto linkMessages() -> void;
238
244 auto playAudioPerCard(const CardScoredMessage* cardScoredMessage) -> void;
245
251 auto receiveCardScoredMiddle(const Message* message) -> Message;
252
257 auto playAudioPerHand(const CardScoredMessage* cardScoredMessage) -> void;
258
264 auto receiveHandScored(const Message* message) -> Message;
265
266#pragma endregion
267
268};
269}
sys::Json Stream
Definition AudioObject.h:20
Holds a hand after it has been ranked, storing both the entire hand and the important cards.
The system responsible for keeping track of the rules the players want to have for their game.
Component that is responsible for managing the gameplay board, where cards are placed by Players.
Definition Board.h:38
Definition Card.h:34
friend Entity
Definition GameObject.h:90
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
Type
Definition System.h:20
@ Scoring
Definition System.h:30
System(const std::string &typeName, Type systemType)
Definition System.cpp:75
Definition GameRules.h:29
Definition PlayerTurn.h:40
auto playAudioPerCard(const CardScoredMessage *cardScoredMessage) -> void
helper function for receiveCardScoredMiddle, plays sfx on each card scoring
Definition Scoring.cpp:1163
PlayerTurn * playerTurn
Definition Scoring.h:147
auto operator=(Scoring &&other) noexcept -> Scoring &=default
auto addScoringCalculatorStars(const CategorizedHand &currentHand) -> void
Finds the first transparent star sequentially and colors it to the hand type.
Definition Scoring.cpp:973
std::string handScoredSFX
the audio file to play at the beginning of each hand scored
Definition Scoring.h:163
auto receiveCardScoredMiddle(const Message *message) -> Message
receive when a card is scored, to play an sfx on score, and maybe later to rotate a bit
Definition Scoring.cpp:1178
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Scoring.cpp:294
auto linkMessages() -> void
Definition Scoring.cpp:1151
~Scoring() override
Definition Scoring.cpp:244
float maxPitch
the pitch that audio will max out at (won't actually hit this value, will get to approximately 75% of...
Definition Scoring.h:156
float extraPitchPerCard
how much to pitch up between cards scoring
Definition Scoring.h:159
void sendHandScoredEvent(ScoringFeedbackContext &sfcRef, Card *card)
create actions that send an event that happens at the first "wait" time of a hand being scored
Definition Scoring.cpp:775
static auto getEnum() -> Type
function required by all systems
Definition Scoring.h:55
float minPitch
the sound pitch sounds should start at
Definition Scoring.h:153
Scoring(const Scoring &other)=default
auto receiveHandScored(const Message *message) -> Message
receives when a hand of cards is scored, plays an audio effect
Definition Scoring.cpp:1195
auto turnOffScoringCalculator() -> void
Moves players up, disables scoring calculator, and resets to default visuals.
Definition Scoring.cpp:631
auto scoreBoard(Board &board, const std::vector< Card * > &cards) -> int
Checks all played cards and gets the hands.
Definition Scoring.cpp:313
auto playAudioPerHand(const CardScoredMessage *cardScoredMessage) -> void
helper function for recieveHandScored, plays a single audio effect per hand
Definition Scoring.cpp:1185
auto turnOffScoringCalculatorWithoutMovingPlayers() -> void
Disables scoring calculator without moving players up.
Definition Scoring.cpp:641
bool scoringFeedbackActive
Definition Scoring.h:150
auto systemShowMenu() -> void override
Specific systems should override this function to show their specific menu for the system.
Definition Scoring.cpp:267
auto highlightStar(const CategorizedHand &currentHand) -> void
Intended for scoring calculator, which highlights all stars in a hand.
Definition Scoring.cpp:1030
GameRules * gameRules
Definition Scoring.h:146
Scoring()
Definition Scoring.cpp:237
std::ranlux24_base randSeed
Definition Scoring.h:143
auto scoringFeedback(std::vector< CategorizedHand > handsToHighlight) -> void
Highlights hands sequentially, being given them by scoring.
Definition Scoring.cpp:357
auto clearScoringCalculator() -> void
Handles the backend logic of turning off the scoring calculator.
Definition Scoring.cpp:1117
auto scoringFeedbackSetUp(std::vector< CategorizedHand > &handsToHighlight) -> int
Checks if hands evaluate at 0, makes selector invisible, and disables inputs.
Definition Scoring.cpp:686
auto turnOnScoringCalculator() -> void
Performs visual effects and adding star children to board when enabled.
Definition Scoring.cpp:572
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Scoring.h:83
auto scoringFeedbackDelayedFunction(float setInitialDelay) -> void
Calls all delayed actions at the end of scoring feedback, such as enabling feedback,...
Definition Scoring.cpp:934
auto scoringCalculatorHighlighting() -> void
Highlights stars while scoring calculator is enabled and players are moving through the board.
Definition Scoring.cpp:646
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Scoring.cpp:299
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Scoring.h:72
auto onSceneStart(const std::string &sceneName) -> void override
Hook that is called before the first frame a scene is run, but after the entire scene is loaded into ...
Definition Scoring.cpp:282
auto operator=(const Scoring &other) -> Scoring &
Definition Scoring.cpp:254
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Scoring.cpp:304
auto isScoringFeedbackHappening() const -> bool
Returns if there are scoring feedback visuals currently on screen.
Definition Scoring.cpp:681
Table * table
Definition Scoring.h:145
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Scoring.cpp:278
void createActionsForCardScoredEvents(ScoringFeedbackContext &context, const Card *currPlayedCard, Entity *cardParent, bool isImportant, float cardTime, float ratioThroughContributingCards, float cardsScored)
create actions that send 3 events for a scored card.
Definition Scoring.cpp:729
std::string cardScoredSFX
the audio file to play when each card is scored
Definition Scoring.h:161
auto onUpdate(float dt) -> void override
called once every frame.
Definition Scoring.cpp:273
auto createCardActions(ScoringFeedbackContext &sfcRef, ScoringFeedbackActions &sfaRef, const CategorizedHand &currentPlayerHand) -> void
Adds all actions to individual cards, including scaling, highlighting, and transform.
Definition Scoring.cpp:787
The system responsible for facilitating communication between gameplay components (Players,...
Definition Table.h:48
the type of elements in a basic_json container
Definition GameObject.h:37
Definition CardScoredMessage.h:15
Definition CategorizedHand.h:32
Definition Message.h:35
Definition Scoring.cpp:148
Definition Scoring.cpp:56