00001
00002
00003
#ifndef GAMESTATE_H
00004
#define GAMESTATE_H
00005
00006
#include "GameConstantsAndTypes.h"
00007
#include "SongOptions.h"
00008
#include "Grade.h"
00009
#include "Attack.h"
00010
#include "RageTimer.h"
00011
#include "Difficulty.h"
00012
00013
#include <map>
00014
#include <deque>
00015
#include <set>
00016
00017
class Song;
00018
class Steps;
00019
class Course;
00020
class Trail;
00021
class Game;
00022
class Style;
00023
class Character;
00024
class TimingData;
00025
struct StageStats;
00026
struct PlayerState;
00027
00028 class GameState
00029 {
00030
public:
00031
GameState();
00032
~GameState();
00033
void Reset();
00034
void ApplyCmdline();
00035
void BeginGame();
00036
void JoinPlayer(
PlayerNumber pn );
00037
void PlayersFinalized();
00038
void EndGame();
00039
void SaveCurrentSettingsToProfile(
PlayerNumber pn );
00040
00041
void Update(
float fDelta );
00042
00043
00044
00045
00046
00047 const Game*
m_pCurGame;
00048 const Style*
m_pCurStyle;
00049 bool m_bSideIsJoined[
NUM_PLAYERS];
00050 bool m_bPlayersFinalized;
00051 PlayMode m_PlayMode;
00052 int m_iCoins;
00053 PlayerNumber m_MasterPlayerNumber;
00054 bool m_bIsOnSystemMenu;
00055 CourseDifficulty m_PreferredCourseDifficulty[
NUM_PLAYERS];
00056
bool DifficultiesLocked();
00057
bool ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc );
00058
bool ChangePreferredDifficulty( PlayerNumber pn,
int dir );
00059
bool ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd );
00060
bool ChangePreferredCourseDifficulty( PlayerNumber pn,
int dir );
00061
bool IsCourseDifficultyShown( CourseDifficulty cd );
00062
Difficulty GetEasiestNotesDifficulty() const;
00063 RageTimer m_timeGameStarted;
00064 map<CString,CString> m_mapEnv;
00065
00066
00067 int m_iGameSeed, m_iRoundSeed;
00068
00069
bool PlayersCanJoin() const;
00070
bool EnoughCreditsToJoin() const;
00071
int GetNumSidesJoined() const;
00072
00073 const
Game* GetCurrentGame();
00074 const
Style* GetCurrentStyle() const;
00075
00076
void GetPlayerInfo( PlayerNumber pn,
bool& bIsEnabledOut,
bool& bIsHumanOut );
00077
bool IsPlayerEnabled( PlayerNumber pn ) const;
00078
int GetNumPlayersEnabled() const;
00079
bool PlayerUsingBothSides() const;
00080
00081
bool IsHumanPlayer( PlayerNumber pn ) const;
00082
int GetNumHumanPlayers() const;
00083 PlayerNumber GetFirstHumanPlayer() const;
00084 PlayerNumber GetFirstDisabledPlayer() const;
00085
bool IsCpuPlayer( PlayerNumber pn ) const;
00086
bool AnyPlayersAreCpu() const;
00087
00088
void GetCharacters( vector<
Character*> &apCharactersOut );
00089
Character*
GameState::GetRandomCharacter();
00090
Character*
GameState::GetDefaultCharacter();
00091
00092
00093
bool IsCourseMode() const;
00094
bool IsBattleMode() const;
00095
00096
bool ShowMarvelous() const;
00097
00098 CString m_sLoadingMessage;
00099 CString m_sPreferredSongGroup;
00100 bool m_bChangedFailType;
00101 Difficulty m_PreferredDifficulty[NUM_PLAYERS];
00102 SortOrder m_SortOrder;
00103 bool m_bEditing;
00104 bool m_bDemonstrationOrJukebox;
00105 bool m_bJukeboxUsesModifiers;
00106 int m_iNumStagesOfThisSong;
00107 int m_iCurrentStageIndex;
00108
00109
int GetStageIndex() const;
00110
void BeginStage();
00111
void CancelStage();
00112
void FinishStage();
00113
int GetNumStagesLeft() const;
00114
bool IsFinalStage() const;
00115
bool IsExtraStage() const;
00116
bool IsExtraStage2() const;
00117 CString GetStageText() const;
00118
void GetAllStageTexts( CStringArray &out ) const;
00119
int GetCourseSongIndex() const;
00120 CString GetPlayerDisplayName( PlayerNumber pn ) const;
00121
00122
00123
00124
00125
00126
00127
00128 Song* m_pCurSong;
00129
00130 Song* m_pPreferredSong;
00131 Steps* m_pCurSteps[NUM_PLAYERS];
00132
00133
00134 Course* m_pCurCourse;
00135
00136 Course* m_pPreferredCourse;
00137 Trail* m_pCurTrail[NUM_PLAYERS];
00138
00139
00140
00141
00142
00143
00144
00145 float m_fMusicSeconds;
00146 float m_fSongBeat;
00147 float m_fCurBPS;
00148 bool m_bFreeze;
00149 RageTimer m_LastBeatUpdate;
00150 bool m_bPastHereWeGo;
00151
00152 int m_BeatToNoteSkinRev;
00153
void ResetNoteSkins();
00154
void ResetNoteSkinsForPlayer( PlayerNumber pn );
00155
void GetAllUsedNoteSkins( vector<CString> &out ) const;
00156
00157 static const
float MUSIC_SECONDS_INVALID;
00158
00159
void ResetMusicStatistics();
00160
void UpdateSongPosition(
float fPositionSeconds, const
TimingData &timing, const
RageTimer ×tamp = RageZeroTimer );
00161
float GetSongPercent(
float beat ) const;
00162
00163
bool AllAreInDangerOrWorse() const;
00164
bool AllAreDead() const;
00165
bool AllHaveComboOf30OrMoreMisses() const;
00166
bool OneIsHot() const;
00167
00168
00169
void SetNoteSkinForBeatRange(
PlayerState* pPlayerState, const CString& sNoteSkin,
float StartBeat,
float EndBeat );
00170
00171
00172 float m_fOpponentHealthPercent;
00173
00174
00175 float m_fTugLifePercentP1;
00176
00177
void GetUndisplayedBeats( const
PlayerState* pPlayerState,
float TotalSeconds,
float &StartBeat,
float &EndBeat ) const;
00178
void LaunchAttack( PlayerNumber target, const
Attack& a );
00179
void RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn );
00180
void RemoveAllActiveAttacks();
00181
void RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al=NUM_ATTACK_LEVELS );
00182
void RemoveAllInventory();
00183
int GetSumOfActiveAttackLevels( PlayerNumber pn ) const;
00184 PlayerNumber GetBestPlayer() const;
00185 StageResult GetStageResult( PlayerNumber pn ) const;
00186
00187
void ResetStageStatistics();
00188
void GetFinalEvalStats(
StageStats& statsOut ) const;
00189
00190
00191
00192
00193
00194
00195 SongOptions m_SongOptions;
00196 SongOptions m_StoredSongOptions;
00197
00198
void ApplyModifiers( PlayerNumber pn, CString sModifiers );
00199
void StoreSelectedOptions();
00200
void RestoreSelectedOptions();
00201
00202
bool IsDisqualified( PlayerNumber pn );
00203
00204
void AdjustFailType();
00205
00206
00207 private:
00208 vector<
Character*> m_pCharacters;
00209
00210 public:
00211 Character* m_pCurCharacters[NUM_PLAYERS];
00212
00213
void ReloadCharacters();
00214
00215
00216
00217
00218
bool HasEarnedExtraStage() const;
00219 bool m_bAllow2ndExtraStage;
00220
00221
00222
00223
00224
00225 struct
RankingFeat
00226 {
00227
enum { SONG, COURSE, CATEGORY } Type;
00228 Song* pSong;
00229 Steps* pSteps;
00230 Course* pCourse;
00231 Grade grade;
00232 int iScore;
00233 float fPercentDP;
00234 CString Banner;
00235 CString Feat;
00236 CString *pStringToFill;
00237 };
00238
00239
void GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &vFeatsOut )
const;
00240
void StoreRankingName( PlayerNumber pn, CString name );
00241 vector<CString*>
m_vpsNamesThatWereFilled;
00242
00243
00244
00245
00246
00247
00248 deque<PerDifficultyAward>
m_vLastPerDifficultyAwards[
NUM_PLAYERS];
00249 deque<PeakComboAward>
m_vLastPeakComboAwards[
NUM_PLAYERS];
00250
00251
00252
00253
00254
00255 int m_iNumTimesThroughAttract;
00256
bool IsTimeToPlayAttractSounds();
00257
00258
00259
00260
00261
void GetDifficultiesToShow( set<Difficulty> &AddTo );
00262
void GetCourseDifficultiesToShow( set<CourseDifficulty> &AddTo );
00263
00264
00265
00266
00267 PlayerState*
m_pPlayerState[
NUM_PLAYERS];
00268 };
00269
00270
00271 extern GameState*
GAMESTATE;
00272
00273
#endif
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298