RhythmGame 1.4.3
Loading...
Searching...
No Matches
ScoreReplayer.h
Go to the documentation of this file.
1//
2// Created by PC on 02/12/2025.
3//
4
5#ifndef RHYTHMGAME_SCOREREPLAYER_H
6#define RHYTHMGAME_SCOREREPLAYER_H
8
9#include <qqmlintegration.h>
10#include <QHash>
11#include <QObject>
12
13namespace qml_components {
14
15class ScoreReplayer : public QObject
16{
17 Q_OBJECT
18 QML_ELEMENT
19 Q_PROPERTY(QList<gameplay_logic::HitEvent> hitEvents READ getHitEvents WRITE
21 Q_PROPERTY(double points READ getPoints NOTIFY pointsChanged RESET resetPoints)
22
23 QList<gameplay_logic::HitEvent> hitEvents;
24
25 // Saved score: points earned per note, keyed by (column << 32 | noteIndex).
26 // Built from noteRemoved=true events only — one definitive entry per note.
27 QHash<qint64, double> m_savedPointsByNote;
28
29 double m_accumulatedPoints = 0.0;
30
31 public:
32 explicit ScoreReplayer(QObject* parent = nullptr);
33 auto getHitEvents() const -> const QList<gameplay_logic::HitEvent>&;
34 void setHitEvents(const QList<gameplay_logic::HitEvent>& hitEvents);
35 void resetHitEvents();
36
37 auto getPoints() const -> double;
38
39 // Call this from QML's onHit for every hit event on the current player.
40 // The ghost score advances when noteRemoved == true (note definitively
41 // consumed), adding the saved score's points for that same note.
42 Q_INVOKABLE void notifyHit(const gameplay_logic::HitEvent& currentHit);
43
44 // Reset accumulated points for the current game (call at game start).
45 Q_INVOKABLE void resetPoints();
46
47 signals:
50};
51
52} // namespace qml_components
53
54#endif // RHYTHMGAME_SCOREREPLAYER_H
Definition ScoreReplayer.h:16
auto getPoints() const -> double
Definition ScoreReplayer.cpp:79
Q_INVOKABLE void notifyHit(const gameplay_logic::HitEvent &currentHit)
Definition ScoreReplayer.cpp:85
QML_ELEMENTQList< gameplay_logic::HitEvent > hitEvents
Definition ScoreReplayer.h:20
double points
Definition ScoreReplayer.h:21
auto getHitEvents() const -> const QList< gameplay_logic::HitEvent > &
Definition ScoreReplayer.cpp:26
void resetHitEvents()
Definition ScoreReplayer.cpp:73
void setHitEvents(const QList< gameplay_logic::HitEvent > &hitEvents)
Definition ScoreReplayer.cpp:32
Q_INVOKABLE void resetPoints()
Definition ScoreReplayer.cpp:103
Classes and functions mostly related to gameplay.
Definition ArenaGameplaySource.h:10
Contains classes that wrap some functionality for use in QML.
Definition ProfileArenaIdentityProvider.h:9