Added support for floating-point difficulty values (v13).
Thanks to Marcin for the info and FieryLight for the report.
This commit is contained in:
parent
9da166f60f
commit
6bdb026447
|
@ -168,12 +168,12 @@ public class GameScore {
|
||||||
/**
|
/**
|
||||||
* Beatmap HPDrainRate value. (0:easy ~ 10:hard)
|
* Beatmap HPDrainRate value. (0:easy ~ 10:hard)
|
||||||
*/
|
*/
|
||||||
private byte drainRate = 5;
|
private float drainRate = 5f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Beatmap OverallDifficulty value. (0:easy ~ 10:hard)
|
* Beatmap OverallDifficulty value. (0:easy ~ 10:hard)
|
||||||
*/
|
*/
|
||||||
private byte difficulty = 5;
|
private float difficulty = 5f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scorebar-related images.
|
* Scorebar-related images.
|
||||||
|
@ -367,14 +367,14 @@ public class GameScore {
|
||||||
/**
|
/**
|
||||||
* Sets or returns the health drain rate.
|
* Sets or returns the health drain rate.
|
||||||
*/
|
*/
|
||||||
public void setDrainRate(byte drainRate) { this.drainRate = drainRate; }
|
public void setDrainRate(float drainRate) { this.drainRate = drainRate; }
|
||||||
public byte getDrainRate() { return drainRate; }
|
public float getDrainRate() { return drainRate; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets or returns the difficulty.
|
* Sets or returns the difficulty.
|
||||||
*/
|
*/
|
||||||
public void setDifficulty(byte difficulty) { this.difficulty = difficulty; }
|
public void setDifficulty(float difficulty) { this.difficulty = difficulty; }
|
||||||
public byte getDifficulty() { return difficulty; }
|
public float getDifficulty() { return difficulty; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a number with defaultSymbols.
|
* Draws a number with defaultSymbols.
|
||||||
|
|
|
@ -68,10 +68,10 @@ public class OsuFile implements Comparable<OsuFile> {
|
||||||
public int beatmapSetID = 0; // beatmap set ID
|
public int beatmapSetID = 0; // beatmap set ID
|
||||||
|
|
||||||
/* [Difficulty] */
|
/* [Difficulty] */
|
||||||
public byte HPDrainRate = 5; // HP drain (0:easy ~ 10:hard)
|
public float HPDrainRate = 5f; // HP drain (0:easy ~ 10:hard)
|
||||||
public byte circleSize = 4; // size of circles
|
public float circleSize = 4f; // size of circles
|
||||||
public byte overallDifficulty = 5; // affects timing window, spinners, and approach speed (0:easy ~ 10:hard)
|
public float overallDifficulty = 5f; // 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 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 sliderMultiplier = 1f; // slider movement speed multiplier
|
||||||
public float sliderTickRate = 1f; // rate at which slider ticks are placed (x per beat)
|
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
|
@Override
|
||||||
public int compareTo(OsuFile that) {
|
public int compareTo(OsuFile that) {
|
||||||
int cmp = Byte.compare(this.overallDifficulty, that.overallDifficulty);
|
int cmp = Float.compare(this.overallDifficulty, that.overallDifficulty);
|
||||||
if (cmp == 0)
|
if (cmp == 0)
|
||||||
cmp = Integer.compare(
|
cmp = Integer.compare(
|
||||||
this.hitObjectCircle + this.hitObjectSlider + this.hitObjectSpinner,
|
this.hitObjectCircle + this.hitObjectSlider + this.hitObjectSpinner,
|
||||||
|
|
|
@ -171,7 +171,7 @@ public class OsuGroupNode implements Comparable<OsuGroupNode> {
|
||||||
(osu.hitObjectCircle + osu.hitObjectSlider + osu.hitObjectSpinner));
|
(osu.hitObjectCircle + osu.hitObjectSlider + osu.hitObjectSpinner));
|
||||||
info[3] = String.format("Circles: %d Sliders: %d Spinners: %d",
|
info[3] = String.format("Circles: %d Sliders: %d Spinners: %d",
|
||||||
osu.hitObjectCircle, osu.hitObjectSlider, osu.hitObjectSpinner);
|
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);
|
osu.circleSize, osu.HPDrainRate, osu.approachRate, osu.overallDifficulty);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,16 +254,16 @@ public class OsuParser {
|
||||||
tokens = tokenize(line);
|
tokens = tokenize(line);
|
||||||
switch (tokens[0]) {
|
switch (tokens[0]) {
|
||||||
case "HPDrainRate":
|
case "HPDrainRate":
|
||||||
osu.HPDrainRate = Byte.parseByte(tokens[1]);
|
osu.HPDrainRate = Float.parseFloat(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "CircleSize":
|
case "CircleSize":
|
||||||
osu.circleSize = Byte.parseByte(tokens[1]);
|
osu.circleSize = Float.parseFloat(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "OverallDifficulty":
|
case "OverallDifficulty":
|
||||||
osu.overallDifficulty = Byte.parseByte(tokens[1]);
|
osu.overallDifficulty = Float.parseFloat(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "ApproachRate":
|
case "ApproachRate":
|
||||||
osu.approachRate = Byte.parseByte(tokens[1]);
|
osu.approachRate = Float.parseFloat(tokens[1]);
|
||||||
break;
|
break;
|
||||||
case "SliderMultiplier":
|
case "SliderMultiplier":
|
||||||
osu.sliderMultiplier = Float.parseFloat(tokens[1]);
|
osu.sliderMultiplier = Float.parseFloat(tokens[1]);
|
||||||
|
@ -273,7 +273,7 @@ public class OsuParser {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (osu.approachRate == -1) // not in old format
|
if (osu.approachRate == -1f) // not in old format
|
||||||
osu.approachRate = osu.overallDifficulty;
|
osu.approachRate = osu.overallDifficulty;
|
||||||
break;
|
break;
|
||||||
case "[Events]":
|
case "[Events]":
|
||||||
|
|
|
@ -72,8 +72,8 @@ public class Circle {
|
||||||
* @param circleSize the map's circleSize value
|
* @param circleSize the map's circleSize value
|
||||||
* @throws SlickException
|
* @throws SlickException
|
||||||
*/
|
*/
|
||||||
public static void init(GameContainer container, byte circleSize) throws SlickException {
|
public static void init(GameContainer container, float circleSize) throws SlickException {
|
||||||
int diameter = 96 - (circleSize * 8);
|
int diameter = (int) (96 - (circleSize * 8));
|
||||||
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
||||||
hitCircle = new Image("hitcircle.png").getScaledCopy(diameter, diameter);
|
hitCircle = new Image("hitcircle.png").getScaledCopy(diameter, diameter);
|
||||||
hitCircleOverlay = new Image("hitcircleoverlay.png").getScaledCopy(diameter, diameter);
|
hitCircleOverlay = new Image("hitcircleoverlay.png").getScaledCopy(diameter, diameter);
|
||||||
|
|
|
@ -253,8 +253,8 @@ public class Slider {
|
||||||
* @param osu the associated OsuFile object
|
* @param osu the associated OsuFile object
|
||||||
* @throws SlickException
|
* @throws SlickException
|
||||||
*/
|
*/
|
||||||
public static void init(GameContainer container, byte circleSize, OsuFile osu) throws SlickException {
|
public static void init(GameContainer container, float circleSize, OsuFile osu) throws SlickException {
|
||||||
int diameter = 96 - (circleSize * 8);
|
int diameter = (int) (96 - (circleSize * 8));
|
||||||
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
||||||
|
|
||||||
sliderBall = new Animation();
|
sliderBall = new Animation();
|
||||||
|
|
|
@ -109,8 +109,8 @@ public class Spinner {
|
||||||
this.score = score;
|
this.score = score;
|
||||||
|
|
||||||
// calculate rotations needed
|
// calculate rotations needed
|
||||||
int spinsPerMinute = 100 + (score.getDifficulty() * 15);
|
float spinsPerMinute = 100 + (score.getDifficulty() * 15);
|
||||||
rotationsNeeded = (float) spinsPerMinute * (hitObject.endTime - hitObject.time) / 60000f;
|
rotationsNeeded = spinsPerMinute * (hitObject.endTime - hitObject.time) / 60000f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -695,15 +695,15 @@ public class Game extends BasicGameState {
|
||||||
private void setMapModifiers() {
|
private void setMapModifiers() {
|
||||||
try {
|
try {
|
||||||
// map-based properties, so re-initialize each game
|
// map-based properties, so re-initialize each game
|
||||||
byte circleSize = osu.circleSize;
|
float circleSize = osu.circleSize;
|
||||||
byte approachRate = osu.approachRate;
|
float approachRate = osu.approachRate;
|
||||||
byte overallDifficulty = osu.overallDifficulty;
|
float overallDifficulty = osu.overallDifficulty;
|
||||||
byte HPDrainRate = osu.HPDrainRate;
|
float HPDrainRate = osu.HPDrainRate;
|
||||||
if (Options.isModActive(Options.MOD_HARD_ROCK)) { // hard rock modifiers
|
if (Options.isModActive(Options.MOD_HARD_ROCK)) { // hard rock modifiers
|
||||||
circleSize = (byte) Math.max(circleSize - 1, 0);
|
circleSize = Math.max(circleSize - 1, 0);
|
||||||
approachRate = (byte) Math.min(approachRate + 3, 10);
|
approachRate = Math.min(approachRate + 3, 10);
|
||||||
overallDifficulty = (byte) Math.min(overallDifficulty + 3, 10);
|
overallDifficulty = Math.min(overallDifficulty + 3, 10);
|
||||||
HPDrainRate = (byte) Math.min(HPDrainRate + 3, 10);
|
HPDrainRate = Math.min(HPDrainRate + 3, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
Circle.init(container, circleSize);
|
Circle.init(container, circleSize);
|
||||||
|
@ -711,16 +711,16 @@ public class Game extends BasicGameState {
|
||||||
|
|
||||||
// approachRate (hit object approach time)
|
// approachRate (hit object approach time)
|
||||||
if (approachRate < 5)
|
if (approachRate < 5)
|
||||||
approachTime = 1800 - (approachRate * 120);
|
approachTime = (int) (1800 - (approachRate * 120));
|
||||||
else
|
else
|
||||||
approachTime = 1200 - ((approachRate - 5) * 150);
|
approachTime = (int) (1200 - ((approachRate - 5) * 150));
|
||||||
|
|
||||||
// overallDifficulty (hit result time offsets)
|
// overallDifficulty (hit result time offsets)
|
||||||
hitResultOffset = new int[GameScore.HIT_MAX];
|
hitResultOffset = new int[GameScore.HIT_MAX];
|
||||||
hitResultOffset[GameScore.HIT_300] = 78 - (overallDifficulty * 6);
|
hitResultOffset[GameScore.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
||||||
hitResultOffset[GameScore.HIT_100] = 138 - (overallDifficulty * 8);
|
hitResultOffset[GameScore.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
||||||
hitResultOffset[GameScore.HIT_50] = 198 - (overallDifficulty * 10);
|
hitResultOffset[GameScore.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
||||||
hitResultOffset[GameScore.HIT_MISS] = 500 - (overallDifficulty * 10);
|
hitResultOffset[GameScore.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
||||||
|
|
||||||
// HPDrainRate (health change), overallDifficulty (scoring)
|
// HPDrainRate (health change), overallDifficulty (scoring)
|
||||||
score.setDrainRate(HPDrainRate);
|
score.setDrainRate(HPDrainRate);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user