Added support for floating-point difficulty values (v13).

Thanks to Marcin for the info and FieryLight for the report.
This commit is contained in:
Jeffrey Han 2014-06-30 04:03:39 -04:00
parent 9da166f60f
commit 6bdb026447
8 changed files with 37 additions and 37 deletions

View File

@ -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.

View File

@ -68,10 +68,10 @@ public class OsuFile implements Comparable<OsuFile> {
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<OsuFile> {
*/
@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,

View File

@ -171,7 +171,7 @@ public class OsuGroupNode implements Comparable<OsuGroupNode> {
(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;
}

View File

@ -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]":

View File

@ -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);

View File

@ -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();

View File

@ -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;
}
/**

View File

@ -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);