[chuni] Update rating calculation

This commit is contained in:
samnyan
2020-12-25 12:38:54 +08:00
parent fcee3d70a2
commit 658fa4db75
5 changed files with 96 additions and 24 deletions

View File

@@ -0,0 +1,17 @@
package icu.samnyan.aqua.sega.util;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author sam_nya (privateamusement@protonmail.com)
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VersionInfo {
private Integer majorVersion;
private Integer minorVersion;
private Integer releaseVersion;
}

View File

@@ -2,6 +2,26 @@ package icu.samnyan.aqua.sega.util;
public class VersionUtil {
public static VersionInfo parseVersion(String version) {
var vs = version.split("\\.");
try {
VersionInfo v = new VersionInfo();
if (vs.length > 0) {
v.setMajorVersion(Integer.parseInt(vs[0]));
}
if (vs.length > 1) {
v.setMinorVersion(Integer.parseInt(vs[1]));
}
if (vs.length > 2) {
v.setReleaseVersion(Integer.parseInt(vs[2]));
}
return v;
} catch (Exception e) {
return new VersionInfo(0, 0, 0);
}
}
public static String getTargetVersion(String savedVersion, String currentVersion) {
var v1s = savedVersion.split("\\.");
var v2s = currentVersion.split("\\.");