wavelength 1.0.0
Loading...
Searching...
No Matches
dueltrack.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
9#include "game/gemcatcher.h"
10#include "game/gemcursor.h"
11#include "game/netfaker.h"
13#include "game/player.h"
14#include "game/playmap.h"
16#include "game/track.h"
17#include "game/trackreactor.h"
18#include "gs/muse.h"
19#include "os/command.h"
20#include "os/ptr.h"
21
22// DuelLogic creates and deletes its DuelTrack objects, and each track reports to its DuelLogic.
23class DuelLogic;
24
35class DuelTrack : public Track, public TrackReactor {
36public:
38 enum Mode {
42 };
43
68 Player *pPlayer,
69 CatchTrackData *pCatchGems,
70 CatchTrackData *pPitchGems,
71 PitchTrackRiffData *pRiffData,
72 DuelPatternTable *pPatterns,
73 const float *pTickDuration,
74 PlayMap *pPlayMap,
75 SectionBoundaries *pSections,
76 int nSide,
77 int nOpponentSide,
78 int nLeadInBars,
79 int nNumBars,
80 int nTicksPerBar,
81 int nPhraseBars,
82 bool bEasiest);
83
90 ~DuelTrack() override;
91
98 void Start() override;
99
106 void Stop() override;
107
118 void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override;
119
128 void HandleInput([[maybe_unused]] Player *pPlayer,
129 [[maybe_unused]] const BtnEvent<8> &event) override {
130 }
131
140 void HandleInput(Player *pPlayer, const StickEvent<2> &event) override;
141
150 void HandleInput(Player *pPlayer, const StickEvent<6> &event) override;
151
160 void HandleInput([[maybe_unused]] Player *pPlayer,
161 [[maybe_unused]] const BtnEvent<10> &event) override {
162 }
163
171 int GetTicksPerBar() const override {
172 return mTicksPerBar;
173 }
174
182 Player *GetPlayer() const override {
183 return mSidePlayer;
184 }
185
194 bool IsBarActive(int nBar) override;
195
208 void HitGem(int nTick, const GemCursor &cursor, bool bRemote) override;
209
221 void MissGem(int nTick, const GemCursor &cursor, bool bRemote) override;
222
231
241 void ShowPhrase(int nMode, int nStartBar, int nEndBar);
242
253 void SetMode(int nMode, int nBar);
254
261 void CountGem();
262
271 void DropBars(int nStartBar, int nEndBar);
272
279 void Rewind();
280
288
297 void MissCatch();
298
308 void MakeCatch(int nBar);
309
318
319private:
325 class CatchReceiver : public GemCatcher::Receiver {
326 public:
333 ~CatchReceiver() override = default;
334
340 explicit CatchReceiver(DuelTrack *pOwner) : mOwner(pOwner) {
341 }
342
351 void OnHit(int nTick, const GemCursor &cursor) override {
352 mOwner->HitGem(nTick, cursor, false);
353 }
354
363 void OnPass(int nTick, const GemCursor &cursor) override {
364 mOwner->MissGem(nTick, cursor, false);
365 }
366
375 void OnMiss(int nTick, int nLane) override {
376 mOwner->OnPressMissed(nTick, nLane);
377 }
378
379 private:
380 DuelTrack *mOwner;
381 };
382
388 class PitchReceiver : public DuelTrackPitcher::Receiver {
389 public:
396 ~PitchReceiver() override = default;
397
403 explicit PitchReceiver(DuelTrack *pOwner) : mOwner(pOwner) {
404 }
405
414 void OnRejected(int nTick, [[maybe_unused]] int nSlot) override {
415 mOwner->OnPressRejected(nTick);
416 }
417
425 void OnPlaced(int nTick) override {
426 mOwner->OnGemPlaced(nTick);
427 }
428
429 private:
430 DuelTrack *mOwner;
431 };
432
442 void ShowBars(int nMode, int nStartBar, int nEndBar);
443
452 bool IsLastGemOfBar(const GemCursor &cursor);
453
460 void ShowCatchProgress();
461
470 void OnPressMissed(int nTick, int nLane);
471
479 void OnPressRejected(int nTick);
480
490 void OnGemPlaced(int nTick);
491
499 void CheckCatchMissed(int nTick);
500
509 void CheckCatchMade(const GemCursor &cursor, bool bRemote);
510
518 void OnPhraseTick();
519
520 Player *mSidePlayer;
521 std::unique_ptr<CatchReceiver> mCatchReceiver;
522 std::unique_ptr<PitchReceiver> mPitchReceiver;
523 DuelPatternTable *mPatterns;
524 PlayMap *mPlayMap;
525 DuelLogic *mLogic;
526 int mNumBars;
527 int mTicksPerBar;
528 int mPhraseBars;
529 int mFirstPhraseTick;
530 CatchTrackState mCatchState;
531 CatchTrackState mPitchState;
532 int mMode;
533 GemCatcher mGemCatcher;
534 DuelTrackPitcher mPitcher;
535 int mCatchMissed;
536 int mCatchMade;
537 int mCatchPoints;
538 Ptr<Command> mPhraseCommand;
539 int mCaughtGems;
540 int mPhraseGems;
541 int mCatchBar;
542 int mCatchEndBar;
543 int mRejectEndTick;
544 int mPhraseBonus;
545 int mPitchPoints;
546 int mPitchedGems;
547 Muse *mMuse;
548 std::unique_ptr<NetFaker> mNetFaker;
549 int mIgnoreMisses;
550};
Input event of a button press that names only the player.
Definition btnevent.h:15
The gems of one catch track, in the order of their ticks.
Definition catchtrackdata.h:14
Rules of the duel rule set.
Definition duellogic.h:35
The duel patterns of a song, each with the tick it applies from, embedded in the song at +0x20.
Definition duelpatterntable.h:14
void CountGem()
Count one more gem in the phrase to catch.
void HitGem(int nTick, const GemCursor &cursor, bool bRemote) override
Play the riff of a caught gem and show the catch.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Hand a press of the player on the track to the pitcher or to the catcher.
void MissGem(int nTick, const GemCursor &cursor, bool bRemote) override
End the catch as missed when a gem of the phrase to catch passes without a press.
void HandleInput(Player *pPlayer, const BtnEvent< 8 > &event) override
Ignore a button event.
Definition dueltrack.h:128
void ShowPhrase(int nMode, int nStartBar, int nEndBar)
Show the bars of the next phrase.
void MakeCatch(int nBar)
End the current catch as made.
void HandleInput(Player *pPlayer, const StickEvent< 2 > &event) override
Ignore a stick event.
void HandleInput(Player *pPlayer, const StickEvent< 6 > &event) override
Ignore a stick event.
DuelTrack(DuelLogic *pLogic, Player *pPlayer, CatchTrackData *pCatchGems, CatchTrackData *pPitchGems, PitchTrackRiffData *pRiffData, DuelPatternTable *pPatterns, const float *pTickDuration, PlayMap *pPlayMap, SectionBoundaries *pSections, int nSide, int nOpponentSide, int nLeadInBars, int nNumBars, int nTicksPerBar, int nPhraseBars, bool bEasiest)
Construct the track of one player.
void DropBars(int nStartBar, int nEndBar)
Disable a range of bars the song has passed and remove the gems the range has.
void Start() override
Start the track with the song.
void HandleInput(Player *pPlayer, const BtnEvent< 10 > &event) override
Ignore a button event.
Definition dueltrack.h:160
void SetMode(int nMode, int nBar)
Change what the player does on the track.
Mode
The values of SetMode() and ShowPhrase().
Definition dueltrack.h:38
@ kModePitch
Definition dueltrack.h:40
@ kModeCatch
Definition dueltrack.h:41
@ kModeIdle
Definition dueltrack.h:39
void MissCatch()
End the current catch as missed.
~DuelTrack() override
Release the track.
Player * GetPlayer() const override
Report the player of the side the track belongs to.
Definition dueltrack.h:182
int GetTicksPerBar() const override
Report the song ticks in one bar.
Definition dueltrack.h:171
bool IsBarActive(int nBar) override
Report that the phrase of every bar can be played.
void Rewind()
Move the playback of the track to the current song position.
void SetRiffData(PitchTrackRiffData *pRiffData)
Change the riffs the gems the player places play.
GemCursor GetCursor() override
Report a cursor at the first gem the player catches.
void Stop() override
Stop the track with the song.
void CancelPhrase()
Withdraw the command that runs once per phrase.
Object told of each judged gem and press.
Definition gemcatcher.h:25
Position at one gem of a catch track, walked in the order the song plays the gems.
Definition gemcursor.h:14
The riffs a pitch track plays, one set of riffs for each tick that starts a set.
Definition pitchtrackriffdata.h:16
Map from the bars a song plays to the bars of the song as written, with the loops that repeat stretch...
Definition playmap.h:11
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Input event of an analog stick position.
Definition stickevent.h:15
Interface through which the rules react to the phrases of a player's track.
Definition trackreactor.h:12
Track(int nIndex)
Construct a track with no player.