Mod difficulty multipliers are now reflected in displayed song info.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-04-04 12:30:23 -04:00
parent 2efb18e225
commit 07075c094b
4 changed files with 40 additions and 31 deletions

View File

@ -176,6 +176,9 @@ public enum GameMod {
/** The last calculated track speed multiplier, or -1f if it must be recalculated. */
private static float speedMultiplier = -1f;
/** The last calculated difficulty multiplier, or -1f if it must be recalculated. */
private static float difficultyMultiplier = -1f;
/**
* Initializes the game mods.
* @param width the container width
@ -201,7 +204,7 @@ public enum GameMod {
mod.active = false;
}
scoreMultiplier = speedMultiplier = -1f;
scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f;
}
/**
@ -224,16 +227,31 @@ public enum GameMod {
*/
public static float getSpeedMultiplier() {
if (speedMultiplier < 0f) {
float multiplier = 1f;
if (DOUBLE_TIME.isActive())
multiplier = 1.5f;
speedMultiplier = 1.5f;
else if (HALF_TIME.isActive())
multiplier = 0.75f;
speedMultiplier = multiplier;
speedMultiplier = 0.75f;
else
speedMultiplier = 1f;
}
return speedMultiplier;
}
/**
* Returns the current difficulty multiplier from all active mods.
*/
public static float getDifficultyMultiplier() {
if (difficultyMultiplier < 0f) {
if (HARD_ROCK.isActive())
difficultyMultiplier = 1.4f;
else if (EASY.isActive())
difficultyMultiplier = 0.5f;
else
difficultyMultiplier = 1f;
}
return difficultyMultiplier;
}
/**
* Returns the current game mod state (bitwise OR of active mods).
*/
@ -251,7 +269,7 @@ public enum GameMod {
* @param state the state (bitwise OR of active mods)
*/
public static void loadModState(int state) {
scoreMultiplier = speedMultiplier = -1f;
scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f;
for (GameMod mod : GameMod.values())
mod.active = ((state & mod.getBit()) > 0);
}
@ -371,7 +389,7 @@ public enum GameMod {
return;
active = !active;
scoreMultiplier = speedMultiplier = -1f;
scoreMultiplier = speedMultiplier = difficultyMultiplier = -1f;
if (checkInverse) {
if (AUTO.isActive()) {

View File

@ -122,10 +122,10 @@ public class OsuGroupNode {
long endTime = (long) (osu.endTime / speedModifier);
int bpmMin = (int) (osu.bpmMin * speedModifier);
int bpmMax = (int) (osu.bpmMax * speedModifier);
float multiplier = GameMod.getDifficultyMultiplier();
String[] info = new String[5];
info[0] = osu.toString();
info[1] = String.format("Mapped by %s",
osu.creator);
info[1] = String.format("Mapped by %s", osu.creator);
info[2] = String.format("Length: %d:%02d BPM: %s Objects: %d",
TimeUnit.MILLISECONDS.toMinutes(endTime),
TimeUnit.MILLISECONDS.toSeconds(endTime) -
@ -135,7 +135,10 @@ public class OsuGroupNode {
info[3] = String.format("Circles: %d Sliders: %d Spinners: %d",
osu.hitObjectCircle, osu.hitObjectSlider, osu.hitObjectSpinner);
info[4] = String.format("CS:%.1f HP:%.1f AR:%.1f OD:%.1f",
osu.circleSize, osu.HPDrainRate, osu.approachRate, osu.overallDifficulty);
Math.min(osu.circleSize * multiplier, 10f),
Math.min(osu.HPDrainRate * multiplier, 10f),
Math.min(osu.approachRate * multiplier, 10f),
Math.min(osu.overallDifficulty * multiplier, 10f));
return info;
}

View File

@ -1358,26 +1358,11 @@ public class Game extends BasicGameState {
*/
private void setMapModifiers() {
// map-based properties, re-initialized each game
float circleSize = osu.circleSize;
float approachRate = osu.approachRate;
float overallDifficulty = osu.overallDifficulty;
float HPDrainRate = osu.HPDrainRate;
// "Hard Rock" modifiers
if (GameMod.HARD_ROCK.isActive()) {
circleSize = Math.min(circleSize * 1.4f, 10);
approachRate = Math.min(approachRate * 1.4f, 10);
overallDifficulty = Math.min(overallDifficulty * 1.4f, 10);
HPDrainRate = Math.min(HPDrainRate * 1.4f, 10);
}
// "Easy" modifiers
else if (GameMod.EASY.isActive()) {
circleSize /= 2f;
approachRate /= 2f;
overallDifficulty /= 2f;
HPDrainRate /= 2f;
}
float multiplier = GameMod.getDifficultyMultiplier();
float circleSize = Math.min(osu.circleSize * multiplier, 10f);
float approachRate = Math.min(osu.approachRate * multiplier, 10f);
float overallDifficulty = Math.min(osu.overallDifficulty * multiplier, 10f);
float HPDrainRate = Math.min(osu.HPDrainRate * multiplier, 10f);
// fixed difficulty overrides
if (Options.getFixedCS() > 0f)

View File

@ -356,7 +356,10 @@ public class SongMenu extends BasicGameState {
headerTextY += Utils.FONT_BOLD.getLineHeight() - 4;
Utils.FONT_DEFAULT.drawString(marginX, headerTextY, songInfo[3], Color.white);
headerTextY += Utils.FONT_DEFAULT.getLineHeight() - 4;
Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], Color.white);
float multiplier = GameMod.getDifficultyMultiplier();
Color color4 = (multiplier == 1f) ? Color.white :
(multiplier > 1f) ? Utils.COLOR_RED_HIGHLIGHT : Utils.COLOR_BLUE_HIGHLIGHT;
Utils.FONT_SMALL.drawString(marginX, headerTextY, songInfo[4], color4);
}
// score buttons