Skip to content

Commit

Permalink
Create PlayerPractice derivative of Player for Practice Mode
Browse files Browse the repository at this point in the history
for finer control of the inner working of the game
and make cheating both easier and harder at the same time (please)
  • Loading branch information
poco0317 committed Nov 1, 2019
1 parent 93fad2e commit c3bc281
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Etterna/Actor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ list(APPEND ACTOR_GAMEPLAY_SRC
"Gameplay/NoteDisplay.cpp"
"Gameplay/NoteField.cpp"
"Gameplay/Player.cpp"
"Gameplay/PlayerPractice.cpp"
"Gameplay/PlayerReplay.cpp"
"Gameplay/ReceptorArrow.cpp"
"Gameplay/ReceptorArrowRow.cpp")
Expand All @@ -63,6 +64,7 @@ list(APPEND ACTOR_GAMEPLAY_HPP
"Gameplay/NoteDisplay.h"
"Gameplay/NoteField.h"
"Gameplay/Player.h"
"Gameplay/PlayerPractice.h"
"Gameplay/PlayerReplay.h"
"Gameplay/ReceptorArrow.h"
"Gameplay/ReceptorArrowRow.h")
Expand Down
84 changes: 84 additions & 0 deletions src/Etterna/Actor/Gameplay/PlayerPractice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include "Etterna/Globals/global.h"
#include "Etterna/Models/Misc/PlayerAI.h"
#include "Etterna/Models/Misc/PlayerState.h"
#include "ArrowEffects.h"
#include "NoteField.h"
#include "Etterna/Models/Misc/AdjustSync.h"
#include "Etterna/Models/Misc/Game.h"
#include "Etterna/Models/NoteData/NoteDataWithScoring.h"
#include "Etterna/Models/ScoreKeepers/ScoreKeeperNormal.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Singletons/NoteSkinManager.h"
#include "Etterna/Singletons/StatsManager.h"
#include "Etterna/Singletons/ScreenManager.h"
#include "Etterna/Singletons/ThemeManager.h"
#include "Etterna/Models/Misc/ThemeMetric.h"
#include "RageUtil/Utils/RageUtil.h"
#include "PlayerPractice.h"

PlayerPractice::PlayerPractice(NoteData& nd, bool bVisibleParts)
: Player(nd, bVisibleParts)
{
// eh
}

PlayerPractice::~PlayerPractice()
{
// dont have to do anything here
}

void
PlayerPractice::Init(const std::string& sType,
PlayerState* pPlayerState,
PlayerStageStats* pPlayerStageStats,
LifeMeter* pLM,
ScoreKeeper* pPrimaryScoreKeeper)
{
Player::Init(
sType, pPlayerState, pPlayerStageStats, pLM, pPrimaryScoreKeeper);
if (m_pPlayerStageStats)
m_pPlayerStageStats->m_bDisqualified = true;
}

void
PlayerPractice::Update(float fDeltaTime)
{
const auto now = std::chrono::steady_clock::now();
if (!m_bLoaded || GAMESTATE->m_pCurSong == NULL)
return;

ActorFrame::Update(fDeltaTime);

const float fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;
const int iSongRow = BeatToNoteRow(fSongBeat);

ArrowEffects::SetCurrentOptions(
&m_pPlayerState->m_PlayerOptions.GetCurrent());

UpdateVisibleParts();

// Sure, why not?
if (GAMESTATE->GetPaused())
return;

// Tell the NoteField we pressed (or didnt press) certain columns
UpdatePressedFlags();

// Tell Rolls to update (if in Autoplay)
// Tell Holds to update (lose life)
UpdateHoldsAndRolls(fDeltaTime, now);

// A lot of logic... basically everything not listed here
UpdateCrossedRows(now);

// Check for completely judged rows.
UpdateJudgedRows(fDeltaTime);
UpdateTapNotesMissedOlderThan(GetMaxStepDistanceSeconds());
}

void
PlayerPractice::PositionReset()
{
// Reset stage stats and stuff
countStats = false;
}
30 changes: 30 additions & 0 deletions src/Etterna/Actor/Gameplay/PlayerPractice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef PlayerPractice_H
#define PlayerPractice_H

#include "Player.h"

// Player derivative meant to ignore useless stuff
class PlayerPractice : public Player
{
public:
PlayerPractice(NoteData& nd, bool bVisibleParts = true);
~PlayerPractice() override;

void Init(const std::string& sType,
PlayerState* pPlayerState,
PlayerStageStats* pPlayerStageStats,
LifeMeter* pLM,
ScoreKeeper* pPrimaryScoreKeeper) override;
void Update(float fDeltaTime) override;

// When called, resets stage stats and necessary things
// Also sets countStats to false.
void PositionReset();

private:
// Becomes true immediately on first button press.
// Allows notes to pass without counting for anything.
bool countStats = false;
};

#endif
3 changes: 3 additions & 0 deletions src/Etterna/Models/Misc/PlayerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "PlayerStageStats.h"
#include "Etterna/Models/ScoreKeepers/ScoreKeeper.h"
#include "Etterna/Actor/Gameplay/Player.h"
#include "Etterna/Actor/Gameplay/PlayerPractice.h"
#include "Etterna/Actor/Gameplay/PlayerReplay.h"
#include "Etterna/Actor/Gameplay/LifeMeter.h"

Expand Down Expand Up @@ -64,6 +65,8 @@ PlayerInfo::Load(PlayerNumber pn,
m_ptextPlayerOptions = NULL;
if (mode == GameplayMode_Replay) {
m_pPlayer = new PlayerReplay(m_NoteData, bShowNoteField);
} else if (mode == GameplayMode_Practice) {
m_pPlayer = new PlayerPractice(m_NoteData, bShowNoteField);
} else {
m_pPlayer = new Player(m_NoteData, bShowNoteField);
}
Expand Down

0 comments on commit c3bc281

Please sign in to comment.