From 6f7b2b6554872c82aa65b36fb0b25d596ad76eff Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Sun, 11 Jan 2015 00:29:26 -0500 Subject: [PATCH] Moved score multiplier field into GameMod enum. Signed-off-by: Jeffrey Han --- src/itdelatrisu/opsu/GameMod.java | 36 +++++++++++++++++++++++++---- src/itdelatrisu/opsu/GameScore.java | 16 ++++--------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/itdelatrisu/opsu/GameMod.java b/src/itdelatrisu/opsu/GameMod.java index 496da214..d8469393 100644 --- a/src/itdelatrisu/opsu/GameMod.java +++ b/src/itdelatrisu/opsu/GameMod.java @@ -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 diff --git a/src/itdelatrisu/opsu/GameScore.java b/src/itdelatrisu/opsu/GameScore.java index 69785322..8624c7e7 100644 --- a/src/itdelatrisu/opsu/GameScore.java +++ b/src/itdelatrisu/opsu/GameScore.java @@ -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 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]