Files
itgmania212121/stepmania/src/GameState.h
T
Chris Danford ea8c87c46f fix category feats show wrong score on ScreenNameEntryTraditional
store both iScore and fPercentDP for courses and categories
2003-12-10 11:35:34 +00:00

275 lines
8.3 KiB
C++

#ifndef GAMESTATE_H
#define GAMESTATE_H
/*
-----------------------------------------------------------------------------
Class: GameState
Desc: Holds game data that is not saved between sessions.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "GameConstantsAndTypes.h"
#include "PlayerOptions.h"
#include "SongOptions.h"
#include "Game.h"
#include "Style.h"
#include "Grade.h"
#include "StageStats.h"
#include "Attack.h"
#include <map>
class Song;
class Steps;
class Course;
class GameDef;
class StyleDef;
class NoteFieldPositioning;
class Character;
class UnlockSystem;
class GameState
{
public:
GameState();
~GameState();
void Reset();
void BeginGame(); // called when first player joins
void EndGame(); // called on ScreenGameOver, ScreenMusicScroll, ScreenCredits
void Update( float fDelta );
//
// Main state info
//
UnlockSystem *m_pUnlockingSys;
Game m_CurGame;
Style m_CurStyle;
bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side
PlayMode m_PlayMode; // many screens display different info depending on this value
int m_iCoins; // not "credits"
PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides
bool m_bIsOnSystemMenu; // system screens will not be effected by the operator key -- Miryokuteki
bool m_bDifficultCourses; // used in nonstop
time_t m_timeGameStated; // from the moment the first player pressed Start
/* This is set to a random number per-game/round; it can be used for a random seed. */
int m_iGameSeed, m_iRoundSeed;
bool PlayersCanJoin() const; // true if it's not too late for a player to join
int GetNumSidesJoined() const;
GameDef* GetCurrentGameDef();
const StyleDef* GetCurrentStyleDef();
void GetPlayerInfo( PlayerNumber pn, bool& bIsEnabledOut, bool& bIsHumanOut );
bool IsPlayerEnabled( PlayerNumber pn );
bool IsPlayerEnabled( int p ) { return IsPlayerEnabled( (PlayerNumber)p ); };
int GetNumPlayersEnabled()
{
int count = 0;
for( int p=0; p<NUM_PLAYERS; p++ )
if( IsPlayerEnabled(p) )
count++;
return count;
};
bool IsHumanPlayer( PlayerNumber pn );
bool IsHumanPlayer( int p ) { return IsHumanPlayer( (PlayerNumber)p ); };
PlayerNumber GetFirstHumanPlayer();
bool IsCpuPlayer( PlayerNumber pn );
bool IsCpuPlayer( int p ) { return IsCpuPlayer( (PlayerNumber)p ); };
bool AnyPlayersAreCpu()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( IsCpuPlayer(p) )
return true;
return false;
}
void GetCharacters( vector<Character*> &apCharactersOut );
Character* GameState::GetRandomCharacter();
Character* GameState::GetDefaultCharacter();
PlayerController m_PlayerController[NUM_PLAYERS];
// Used in Battle and Rave
int m_iCpuSkill[NUM_PLAYERS]; // only used when m_PlayerController is PC_CPU
// Used in Rave
float m_fSuperMeterGrowthScale[NUM_PLAYERS];
bool IsCourseMode() const;
bool IsBattleMode() const; /* not Rave */
bool ShowMarvelous() const;
CString m_sLoadingMessage; // used in loading screen
CString m_sPreferredGroup; // GROUP_ALL_MUSIC denotes no preferred group
bool m_bChangedFailType; // true if FailType was changed in the song options screen
Difficulty m_PreferredDifficulty[NUM_PLAYERS];
SongSortOrder m_SongSortOrder; // used by MusicWheel
bool m_bEditing; // NoteField does special stuff when this is true
bool m_bDemonstrationOrJukebox; // ScreenGameplay does special stuff when this is true
bool m_bJukeboxUsesModifiers;
int m_iCurrentStageIndex; // incremented on Eval screen. For a Course, this is always 0
int GetStageIndex();
int GetNumStagesLeft();
bool IsFinalStage();
bool IsExtraStage();
bool IsExtraStage2();
CString GetStageText();
void GetAllStageTexts( CStringArray &out );
int GetCourseSongIndex();
//
// State Info used during gameplay
//
Song* m_pCurSong;
Steps* m_pCurNotes[NUM_PLAYERS];
Course* m_pCurCourse;
//
// Music statistics: Arcade: the current stage (one song). Oni/Endles: a single song in a course
//
// Let a lot of classes access this info here so the don't have to keep their own copies.
//
float m_fMusicSeconds; // time into the current song
float m_fSongBeat;
float m_fCurBPS;
bool m_bFreeze; // in the middle of a freeze
bool m_bPastHereWeGo;
float m_fLastDrawnBeat[NUM_PLAYERS]; // set by NoteField
map<float,CString> m_BeatToNoteSkin[NUM_PLAYERS];
int m_BeatToNoteSkinRev; /* hack: incremented whenever m_BeatToNoteSkin changes */
void ResetNoteSkins();
void ResetNoteSkinsForPlayer( PlayerNumber pn );
void GetAllUsedNoteSkins( vector<CString> &out ) const;
static const float MUSIC_SECONDS_INVALID;
void ResetMusicStatistics(); // Call this when it's time to play a new song. Clears the values above.
void UpdateSongPosition(float fPositionSeconds);
float GetSongPercent( float beat ) const;
//
// Stage Statistics:
// Arcade: for the current stage (one song).
// Nonstop/Oni/Endless: for current course (which usually contains multiple songs)
//
StageStats m_CurStageStats; // current stage (not necessarily passed if Extra Stage)
enum HealthState { HOT, ALIVE, DANGER, DEAD };
HealthState m_HealthState[NUM_PLAYERS];
bool AllAreInDangerOrWorse() const;
bool AllAreDead() const;
bool OneIsHot() const;
// used in PLAY_MODE_BATTLE and PLAY_MODE_RAVE
AttackArray m_ActiveAttacks[NUM_PLAYERS];
vector<Attack> m_ModsToApply[NUM_PLAYERS];
void SetNoteSkinForBeatRange( PlayerNumber pn, CString sNoteSkin, float StartBeat, float EndBeat );
// used in PLAY_MODE_BATTLE
Attack m_Inventory[NUM_PLAYERS][NUM_INVENTORY_SLOTS];
float m_fOpponentHealthPercent;
// used in PLAY_MODE_RAVE
float m_fTugLifePercentP1;
float m_fSuperMeter[NUM_PLAYERS]; // between 0 and NUM_ATTACK_LEVELS
bool m_bAttackBeganThisUpdate[NUM_PLAYERS]; // flag for other objects to watch (play sounds)
bool m_bAttackEndedThisUpdate[NUM_PLAYERS]; // flag for other objects to watch (play sounds)
void GetUndisplayedBeats( PlayerNumber pn, float TotalSeconds, float &StartBeat, float &EndBeat ); // only meaningful when a NoteField is in use
void LaunchAttack( PlayerNumber target, Attack aa );
void RebuildPlayerOptionsFromActiveAttacks( PlayerNumber pn );
void RemoveAllActiveAttacks() // called on end of song
{
for( int p=0; p<NUM_PLAYERS; p++ )
RemoveActiveAttacksForPlayer( (PlayerNumber)p );
}
void RemoveActiveAttacksForPlayer( PlayerNumber pn, AttackLevel al=NUM_ATTACK_LEVELS /*all*/ );
void RemoveAllInventory();
int GetSumOfActiveAttackLevels( PlayerNumber pn );
PlayerNumber GetBestPlayer();
StageResult GetStageResult( PlayerNumber pn );
void ResetStageStatistics(); // Call this when it's time to play a new stage.
vector<StageStats> m_vPlayedStageStats; // Only useful in Arcade for final evaluation
// A song is only inserted here if at least one player passed.
// StageStats are added by the Evaluation screen
void GetFinalEvalStatsAndSongs( StageStats& statsOut, vector<Song*>& vSongsOut ); // shown on arcade final evaluation
//
// Options stuff
//
PlayerOptions m_CurrentPlayerOptions[NUM_PLAYERS]; // current approaches destination
PlayerOptions m_PlayerOptions[NUM_PLAYERS]; // change this, and current will move gradually toward it
PlayerOptions m_StoredPlayerOptions[NUM_PLAYERS]; // user's choices on the PlayerOptions screen
SongOptions m_SongOptions;
SongOptions m_StoredSongOptions;
void ApplyModifiers( PlayerNumber pn, CString sModifiers );
void StoreSelectedOptions();
void RestoreSelectedOptions();
void AdjustFailType();
// character stuff
private:
vector<Character*> m_pCharacters;
public:
Character* m_pCurCharacters[NUM_PLAYERS];
void ReloadCharacters();
bool HasEarnedExtraStage();
bool m_bAllow2ndExtraStage; //only used when "Allow Selection of Extra Stage is on"
//
// Ranking Stuff
//
struct RankingFeats
{
enum { SONG, COURSE, CATEGORY } Type;
Grade grade;
int iScore;
float fPercentDP;
CString Banner;
CString Feat;
CString *pStringToFill;
};
void GetRankingFeats( PlayerNumber pn, vector<RankingFeats> &asFeatsOut );
/* Called by name entry screens: */
void StoreRankingName( PlayerNumber pn, CString name );
//
// Arrow positioning
//
NoteFieldPositioning *m_pPosition;
};
extern GameState* GAMESTATE; // global and accessable from anywhere in our program
#endif