Moved score multiplier field into GameMod enum.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-01-11 00:29:26 -05:00
parent 5a09689b4c
commit 6f7b2b6554
2 changed files with 37 additions and 15 deletions

View File

@ -29,12 +29,16 @@ import org.newdawn.slick.util.Log;
* Game mods.
*/
public enum GameMod {
EASY (0, "selection-mod-easy.png"),
NO_FAIL (1, "selection-mod-nofail.png"),
HARD_ROCK (2, "selection-mod-hardrock.png"),
EASY (0, "selection-mod-easy.png", 0.5f),
NO_FAIL (1, "selection-mod-nofail.png", 0.5f),
HARD_ROCK (2, "selection-mod-hardrock.png", 1.06f),
SUDDEN_DEATH (3, "selection-mod-suddendeath.png"),
SPUN_OUT (4, "selection-mod-spunout.png"),
SPUN_OUT (4, "selection-mod-spunout.png", 0.9f),
AUTO (5, "selection-mod-autoplay.png");
// HALF_TIME (, "selection-mod-halftime.png", 0.3f),
// DOUBLE_TIME (, "selection-mod-doubletime.png", 1.12f),
// HIDDEN (, "selection-mod-hidden.png", 1.06f),
// FLASHLIGHT (, "selection-mod-flashlight.png", 1.12f);
/**
* The ID of the mod (used for positioning).
@ -46,6 +50,11 @@ public enum GameMod {
*/
private String filename;
/**
* Score multiplier.
*/
private float multiplier;
/**
* Whether or not this mod is active.
*/
@ -85,6 +94,19 @@ public enum GameMod {
GameMod(int id, String filename) {
this.id = id;
this.filename = filename;
this.multiplier = 1f;
}
/**
* Constructor.
* @param id the ID of the mod (for positioning).
* @param filename the image file name
* @param multiplier the score multiplier
*/
GameMod(int id, String filename, float multiplier) {
this.id = id;
this.filename = filename;
this.multiplier = multiplier;
}
/**
@ -113,6 +135,12 @@ public enum GameMod {
}
}
/**
* Returns the score multiplier for the mod.
* @return the multiplier
*/
public float getMultiplier() { return multiplier; }
/**
* Toggles the active status of the mod.
* @param checkInverse if true, perform checks for mutual exclusivity

View File

@ -633,7 +633,7 @@ public class GameScore {
* @param trackPosition the current track position
*/
public void drawHitResults(int trackPosition) {
int fadeDelay = 500;
final int fadeDelay = 500;
Iterator<OsuHitObjectResult> iter = hitResultList.iterator();
while (iter.hasNext()) {
@ -897,16 +897,10 @@ public class GameScore {
// game mod score multipliers
float modMultiplier = 1f;
if (GameMod.EASY.isActive())
modMultiplier *= 0.5f;
if (GameMod.NO_FAIL.isActive())
modMultiplier *= 0.5f;
if (GameMod.HARD_ROCK.isActive())
modMultiplier *= 1.06f;
if (GameMod.SPUN_OUT.isActive())
modMultiplier *= 0.9f;
// not implemented:
// HALF_TIME (0.3x), DOUBLE_TIME (1.12x), HIDDEN (1.06x), FLASHLIGHT (1.12x)
for (GameMod mod : GameMod.values()) {
if (mod.isActive())
modMultiplier *= mod.getMultiplier();
}
/**
* [SCORE FORMULA]