From 6bdb026447582d103c4bf1e06217c5cc9d737bf5 Mon Sep 17 00:00:00 2001 From: Jeffrey Han Date: Mon, 30 Jun 2014 04:03:39 -0400 Subject: [PATCH] Added support for floating-point difficulty values (v13). Thanks to Marcin for the info and FieryLight for the report. --- src/itdelatrisu/opsu/GameScore.java | 12 +++++----- src/itdelatrisu/opsu/OsuFile.java | 10 ++++---- src/itdelatrisu/opsu/OsuGroupNode.java | 2 +- src/itdelatrisu/opsu/OsuParser.java | 10 ++++---- src/itdelatrisu/opsu/objects/Circle.java | 4 ++-- src/itdelatrisu/opsu/objects/Slider.java | 4 ++-- src/itdelatrisu/opsu/objects/Spinner.java | 4 ++-- src/itdelatrisu/opsu/states/Game.java | 28 +++++++++++------------ 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/itdelatrisu/opsu/GameScore.java b/src/itdelatrisu/opsu/GameScore.java index f921ef53..1d9764a2 100644 --- a/src/itdelatrisu/opsu/GameScore.java +++ b/src/itdelatrisu/opsu/GameScore.java @@ -168,12 +168,12 @@ public class GameScore { /** * Beatmap HPDrainRate value. (0:easy ~ 10:hard) */ - private byte drainRate = 5; + private float drainRate = 5f; /** * Beatmap OverallDifficulty value. (0:easy ~ 10:hard) */ - private byte difficulty = 5; + private float difficulty = 5f; /** * Scorebar-related images. @@ -367,14 +367,14 @@ public class GameScore { /** * Sets or returns the health drain rate. */ - public void setDrainRate(byte drainRate) { this.drainRate = drainRate; } - public byte getDrainRate() { return drainRate; } + public void setDrainRate(float drainRate) { this.drainRate = drainRate; } + public float getDrainRate() { return drainRate; } /** * Sets or returns the difficulty. */ - public void setDifficulty(byte difficulty) { this.difficulty = difficulty; } - public byte getDifficulty() { return difficulty; } + public void setDifficulty(float difficulty) { this.difficulty = difficulty; } + public float getDifficulty() { return difficulty; } /** * Draws a number with defaultSymbols. diff --git a/src/itdelatrisu/opsu/OsuFile.java b/src/itdelatrisu/opsu/OsuFile.java index 780ba8a1..fbc31d78 100644 --- a/src/itdelatrisu/opsu/OsuFile.java +++ b/src/itdelatrisu/opsu/OsuFile.java @@ -68,10 +68,10 @@ public class OsuFile implements Comparable { public int beatmapSetID = 0; // beatmap set ID /* [Difficulty] */ - public byte HPDrainRate = 5; // HP drain (0:easy ~ 10:hard) - public byte circleSize = 4; // size of circles - public byte overallDifficulty = 5; // affects timing window, spinners, and approach speed (0:easy ~ 10:hard) - public byte approachRate = -1; // how long circles stay on the screen (0:long ~ 10:short) **not in old format** + public float HPDrainRate = 5f; // HP drain (0:easy ~ 10:hard) + public float circleSize = 4f; // size of circles + public float overallDifficulty = 5f; // affects timing window, spinners, and approach speed (0:easy ~ 10:hard) + public float approachRate = -1f; // how long circles stay on the screen (0:long ~ 10:short) **not in old format** public float sliderMultiplier = 1f; // slider movement speed multiplier public float sliderTickRate = 1f; // rate at which slider ticks are placed (x per beat) @@ -138,7 +138,7 @@ public class OsuFile implements Comparable { */ @Override public int compareTo(OsuFile that) { - int cmp = Byte.compare(this.overallDifficulty, that.overallDifficulty); + int cmp = Float.compare(this.overallDifficulty, that.overallDifficulty); if (cmp == 0) cmp = Integer.compare( this.hitObjectCircle + this.hitObjectSlider + this.hitObjectSpinner, diff --git a/src/itdelatrisu/opsu/OsuGroupNode.java b/src/itdelatrisu/opsu/OsuGroupNode.java index 97162f40..a9d3c9d4 100644 --- a/src/itdelatrisu/opsu/OsuGroupNode.java +++ b/src/itdelatrisu/opsu/OsuGroupNode.java @@ -171,7 +171,7 @@ public class OsuGroupNode implements Comparable { (osu.hitObjectCircle + osu.hitObjectSlider + osu.hitObjectSpinner)); info[3] = String.format("Circles: %d Sliders: %d Spinners: %d", osu.hitObjectCircle, osu.hitObjectSlider, osu.hitObjectSpinner); - info[4] = String.format("CS:%d HP:%d AR:%d OD:%d", + info[4] = String.format("CS:%.1f HP:%.1f AR:%.1f OD:%.1f", osu.circleSize, osu.HPDrainRate, osu.approachRate, osu.overallDifficulty); return info; } diff --git a/src/itdelatrisu/opsu/OsuParser.java b/src/itdelatrisu/opsu/OsuParser.java index 31b95853..6ff0f07b 100644 --- a/src/itdelatrisu/opsu/OsuParser.java +++ b/src/itdelatrisu/opsu/OsuParser.java @@ -254,16 +254,16 @@ public class OsuParser { tokens = tokenize(line); switch (tokens[0]) { case "HPDrainRate": - osu.HPDrainRate = Byte.parseByte(tokens[1]); + osu.HPDrainRate = Float.parseFloat(tokens[1]); break; case "CircleSize": - osu.circleSize = Byte.parseByte(tokens[1]); + osu.circleSize = Float.parseFloat(tokens[1]); break; case "OverallDifficulty": - osu.overallDifficulty = Byte.parseByte(tokens[1]); + osu.overallDifficulty = Float.parseFloat(tokens[1]); break; case "ApproachRate": - osu.approachRate = Byte.parseByte(tokens[1]); + osu.approachRate = Float.parseFloat(tokens[1]); break; case "SliderMultiplier": osu.sliderMultiplier = Float.parseFloat(tokens[1]); @@ -273,7 +273,7 @@ public class OsuParser { break; } } - if (osu.approachRate == -1) // not in old format + if (osu.approachRate == -1f) // not in old format osu.approachRate = osu.overallDifficulty; break; case "[Events]": diff --git a/src/itdelatrisu/opsu/objects/Circle.java b/src/itdelatrisu/opsu/objects/Circle.java index 88e24a18..252a99a6 100644 --- a/src/itdelatrisu/opsu/objects/Circle.java +++ b/src/itdelatrisu/opsu/objects/Circle.java @@ -72,8 +72,8 @@ public class Circle { * @param circleSize the map's circleSize value * @throws SlickException */ - public static void init(GameContainer container, byte circleSize) throws SlickException { - int diameter = 96 - (circleSize * 8); + public static void init(GameContainer container, float circleSize) throws SlickException { + int diameter = (int) (96 - (circleSize * 8)); diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480) hitCircle = new Image("hitcircle.png").getScaledCopy(diameter, diameter); hitCircleOverlay = new Image("hitcircleoverlay.png").getScaledCopy(diameter, diameter); diff --git a/src/itdelatrisu/opsu/objects/Slider.java b/src/itdelatrisu/opsu/objects/Slider.java index 140f6d1f..93e56436 100644 --- a/src/itdelatrisu/opsu/objects/Slider.java +++ b/src/itdelatrisu/opsu/objects/Slider.java @@ -253,8 +253,8 @@ public class Slider { * @param osu the associated OsuFile object * @throws SlickException */ - public static void init(GameContainer container, byte circleSize, OsuFile osu) throws SlickException { - int diameter = 96 - (circleSize * 8); + public static void init(GameContainer container, float circleSize, OsuFile osu) throws SlickException { + int diameter = (int) (96 - (circleSize * 8)); diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480) sliderBall = new Animation(); diff --git a/src/itdelatrisu/opsu/objects/Spinner.java b/src/itdelatrisu/opsu/objects/Spinner.java index cb65469e..1369c74e 100644 --- a/src/itdelatrisu/opsu/objects/Spinner.java +++ b/src/itdelatrisu/opsu/objects/Spinner.java @@ -109,8 +109,8 @@ public class Spinner { this.score = score; // calculate rotations needed - int spinsPerMinute = 100 + (score.getDifficulty() * 15); - rotationsNeeded = (float) spinsPerMinute * (hitObject.endTime - hitObject.time) / 60000f; + float spinsPerMinute = 100 + (score.getDifficulty() * 15); + rotationsNeeded = spinsPerMinute * (hitObject.endTime - hitObject.time) / 60000f; } /** diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 7a48f9f8..bded3dfe 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -695,15 +695,15 @@ public class Game extends BasicGameState { private void setMapModifiers() { try { // map-based properties, so re-initialize each game - byte circleSize = osu.circleSize; - byte approachRate = osu.approachRate; - byte overallDifficulty = osu.overallDifficulty; - byte HPDrainRate = osu.HPDrainRate; + float circleSize = osu.circleSize; + float approachRate = osu.approachRate; + float overallDifficulty = osu.overallDifficulty; + float HPDrainRate = osu.HPDrainRate; if (Options.isModActive(Options.MOD_HARD_ROCK)) { // hard rock modifiers - circleSize = (byte) Math.max(circleSize - 1, 0); - approachRate = (byte) Math.min(approachRate + 3, 10); - overallDifficulty = (byte) Math.min(overallDifficulty + 3, 10); - HPDrainRate = (byte) Math.min(HPDrainRate + 3, 10); + circleSize = Math.max(circleSize - 1, 0); + approachRate = Math.min(approachRate + 3, 10); + overallDifficulty = Math.min(overallDifficulty + 3, 10); + HPDrainRate = Math.min(HPDrainRate + 3, 10); } Circle.init(container, circleSize); @@ -711,16 +711,16 @@ public class Game extends BasicGameState { // approachRate (hit object approach time) if (approachRate < 5) - approachTime = 1800 - (approachRate * 120); + approachTime = (int) (1800 - (approachRate * 120)); else - approachTime = 1200 - ((approachRate - 5) * 150); + approachTime = (int) (1200 - ((approachRate - 5) * 150)); // overallDifficulty (hit result time offsets) hitResultOffset = new int[GameScore.HIT_MAX]; - hitResultOffset[GameScore.HIT_300] = 78 - (overallDifficulty * 6); - hitResultOffset[GameScore.HIT_100] = 138 - (overallDifficulty * 8); - hitResultOffset[GameScore.HIT_50] = 198 - (overallDifficulty * 10); - hitResultOffset[GameScore.HIT_MISS] = 500 - (overallDifficulty * 10); + hitResultOffset[GameScore.HIT_300] = (int) (78 - (overallDifficulty * 6)); + hitResultOffset[GameScore.HIT_100] = (int) (138 - (overallDifficulty * 8)); + hitResultOffset[GameScore.HIT_50] = (int) (198 - (overallDifficulty * 10)); + hitResultOffset[GameScore.HIT_MISS] = (int) (500 - (overallDifficulty * 10)); // HPDrainRate (health change), overallDifficulty (scoring) score.setDrainRate(HPDrainRate);