Love live output parsing completed (#1)

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago
parent 0e37e8e5ef
commit 828035b23f
  1. 56
      readers/LoveLiveReader.java
  2. 30
      readers/Reader.java

@ -322,8 +322,64 @@ public class LoveLiveReader extends Reader{
case 2:{
notes[0]=convertToInt("PERFECT",splitter);
}break;
case 3:{
notes[1]=convertToInt("GREAT",splitter);
}break;
case 4:{
notes[2]=convertToInt("GOOD",splitter);
}break;
case 5:{
notes[3]=convertToInt("BAD",splitter);
}break;
case 6:{
notes[4]=convertToInt("MISS",splitter);
}break;
case 7:{
difficulty=getDifficulty(convertToString(splitter).toLowerCase());
}break;
case 8:{
title=convertToString(splitter);
}break;
case 9:{
pct=convertToPct(splitter);
}break;
case 10:{
maxcombo=convertToInt(splitter);
}break;
}
}
System.out.println(this);
}
double convertToPct(String[] str) {
int front=convertToInt(new String[]{str[1]});
int decimal=convertToInt(new String[]{str[2]});
double numb=0;
int placeValue=0;
int decimalPlaces=0;
while (decimal!=0) {
numb+=(decimal%10)*(Math.pow(10,placeValue++));
decimal/=10;
decimalPlaces++;
}
while (front!=0) {
numb+=(front%10)*(Math.pow(10,placeValue++));
front/=10;
}
for (int i=0;i<decimalPlaces;i++) {
numb/=10;
}
return numb;
}
int getDifficulty(String str) {
final String[] diffs={"easy","normal","hard","master","challenge"};
for (int i=0;i<diffs.length;i++) {
String diff = diffs[i].toLowerCase();
if (str.contains(diff)) {
return i;
}
}
return -1;
}
}

@ -13,7 +13,7 @@ public abstract class Reader{
int[] notes = new int[7];
int difficulty;
String title;
int pct;
double pct;
int maxcombo;
String other;
List<Box> readRegions = new ArrayList<>();
@ -146,16 +146,32 @@ public abstract class Reader{
/*9*/{'9','g','y',},
};
int convertToInt(String[]data){return convertToInt("",data);}
String convertToString(String[]data){
return String.join("\n",data);
}
int convertToInt(String[]data){return convertToInt(" ",data);}
int convertToInt(String prefix,String[] data) {
int numb=0;
for (int i=prefix.length();i<data.length;i++) {
for (int i=0;i<data.length;i++) {
String s = data[i];
for (int j=0;j<s.length();j++) {
if (s.charAt(j)>='0'&&s.charAt(j)<='9') {
numb*=10;
numb+=s.charAt(j)-'0';
int j=0;
if (i==1) {
j=prefix.length()-1;
} else {
j=0;
}
for (;j<s.length();j++) {
letter_iterator:
for (int k=0;k<number_alternatives.length;k++) {
for (int l=0;l<number_alternatives[k].length;l++) {
if (s.charAt(j)==number_alternatives[k][l]) {
numb*=10;
numb+=k;
break letter_iterator;
}
}
}
}
}

Loading…
Cancel
Save