wavelength 1.0.0
Loading...
Searching...
No Matches
multigamelogic.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/gamelogic.h"
7#include "game/netarbiter.h"
8#include "met/metagame.h"
9#include "msg/arbiterpacket.h"
10#include "msg/bumperpacket.h"
11#include "msg/capturepacket.h"
12#include "msg/cripplerpacket.h"
15#include "msg/freestylepacket.h"
16#include "msg/gameendedmsg.h"
20#include "msg/slowdownpacket.h"
21#include "os/command.h"
22#include "os/ptr.h"
23#include "os/scheduler.h"
24#include "script/dataarray.h"
25
35class MultiGameLogic : public GameLogic {
36public:
49 MultiGameLogic(Song *pSong, DataArray *pConfig, int nSeed);
50
57 ~MultiGameLogic() override;
58
68 bool DispatchPriv(Message *pMsg) override;
69
77 int GetTick() override;
78
86 float GetTime() override;
87
95 void HandleInput(const RotateEvent &event) override;
96
108 void SetPaused(bool bPaused, int nPad, int nReason) override;
109
118 bool DeploySlowdown(Player *pPlayer) override;
119
130 bool DeployFreestyle(Player *pPlayer) override;
131
140 bool DeployBumper(Player *pPlayer) override;
141
150 bool DeployCrippler(Player *pPlayer) override;
151
159 void EndFreestyle(Player *pPlayer) override;
160
167 void OnStart() override;
168
176 void OnFinish(bool bWon) override;
177
185 void OnBar(int nBar) override;
186
193 void OnSection() override;
194
205 void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bAutocatch) override;
206
214 void OnPhraseEnded(Track *pTrack) override;
215
223 void OnPhraseMissed([[maybe_unused]] Track *pTrack) override {
224 }
225
226private:
234 bool IsPastEnd() const {
235 return TheSongScheduler.GetTick() / mTicksPerBar >= mNumBars;
236 }
237
247 void PauseOnline(bool bPaused, int nPad, int nReason);
248
258 void PauseLocal(bool bPaused, int nPad, int nReason);
259
268 static void OnLocalPauseDialog(Metagame::DialogAction action, void *pUserData);
269
278 static void OnOnlinePauseDialog(Metagame::DialogAction action, void *pUserData);
279
286 void PlayLeaderSound();
287
297 void UpdateLeader();
298
307 static void OnEndGameDialog(Metagame::DialogAction action, void *pUserData);
308
317 static void WinCheat(DataArray *pCommand, void *pUserData);
318
328 void ApplyWinCheat();
329
336 void ShowResults();
337
346 int GetPlayerFromNetOrder(int nNetOrder);
347
355 bool AllPlayersFinished();
356
365 void SendResults();
366
373 void LogResults();
374
382 void OnPlayerUpdate(PlayerUpdatePacket *pPacket);
383
391 void OnArbiter(ArbiterPacket *pPacket);
392
400 void OnCapture(CapturePacket *pPacket);
401
409 void OnBumper(BumperPacket *pPacket);
410
418 void OnCrippler(CripplerPacket *pPacket);
419
427 void OnSlowdown(SlowdownPacket *pPacket);
428
436 void OnMultiplier(MultiplierPacket *pPacket);
437
445 void OnFreestyle(FreestylePacket *pPacket);
446
454 void OnFreestyleBump(FreestyleBumpPacket *pPacket);
455
463 void OnFinalScore(FinalScorePacket *pPacket);
464
472 void OnGameEnded(GameEndedMsg *pMsg);
473
481 void OnPlayerAborted(PlayerAbortedMsg *pMsg);
482
483 Player *mLocalPlayer;
484 int mLeader;
485 Ptr<Command> mFinishCommand;
486 Ptr<Command> mLeaderCommand;
487 std::vector<unsigned> mVersions;
488 unsigned mArbiterVersion;
489 std::vector<int> mNetToPlayer;
490 std::unique_ptr<NetArbiter> mArbiter;
491 std::vector<bool> mFinished;
492};
Track whose phrases a player captures by playing them.
Definition catchtrack.h:33
Reference-counted array of script data nodes.
Definition dataarray.h:20
int mNumBars
Definition gamelogic.h:673
GameLogic(Song *pSong, DataArray *pConfig, int nSeed)
Construct the logic of a song.
int mTicksPerBar
Definition gamelogic.h:672
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
DialogAction
Choices a dialog reports to its callback.
Definition metagame.h:101
~MultiGameLogic() override
Release the arbiter, restore the song speed, and unregister the cheat.
void SetPaused(bool bPaused, int nPad, int nReason) override
Pause or resume, and show the pause dialog when pausing.
bool DeployFreestyle(Player *pPlayer) override
Move a player to the freestyle track.
void OnSection() override
Announce the completed stage while sections remain.
MultiGameLogic(Song *pSong, DataArray *pConfig, int nSeed)
Construct the logic of a song and register the win_cheat script command.
float GetTime() override
Report the time of the scheduler's clock.
bool DeploySlowdown(Player *pPlayer) override
Slow the song down for a player and, for a local player online, send a SlowdownPacket.
void EndFreestyle(Player *pPlayer) override
Move a player from the freestyle track back to a catch track.
bool DeployCrippler(Player *pPlayer) override
Cripple every other player on a player's track.
void OnPhraseMissed(Track *pTrack) override
Act once a player missed a phrase.
Definition multigamelogic.h:223
void OnBar(int nBar) override
Update the score leader.
void OnPhraseEnded(Track *pTrack) override
Act once a phrase of a track ended.
void OnStart() override
Enable the catch tracks, schedule the end of the song, and start the arbiter.
bool DeployBumper(Player *pPlayer) override
Bump every other player on a player's track to a random other track.
int GetTick() override
Report the tick of the scheduler's clock.
bool DispatchPriv(Message *pMsg) override
Apply a packet from another console, or hand any other message to WorldLogic.
void HandleInput(const RotateEvent &event) override
Move a player to a neighbouring track and ask the arbiter to settle the move.
void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bAutocatch) override
Update the score leader and, for a local player online, send a CapturePacket.
void OnFinish(bool bWon) override
Celebrate a won song and collect or send the final score.
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Input event that rotates a player's view of the tracks by one track.
Definition rotateevent.h:11
One song: its configuration from the song text file and the tracks its MIDI file builds.
Definition song.h:38
One instrument track of the song that a player can play.
Definition track.h:18
Scheduler TheSongScheduler
The scheduler of the song clock.