From 828035b23fb221b08b090d33df40e81f5cd213ed Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Thu, 11 Aug 2022 15:38:05 +0000 Subject: [PATCH] Love live output parsing completed (#1) Co-authored-by: sigonasr2 --- readers/LoveLiveReader.java | 56 +++++++++++++++++++++++++++++++++++++ readers/Reader.java | 30 +++++++++++++++----- 2 files changed, 79 insertions(+), 7 deletions(-) diff --git a/readers/LoveLiveReader.java b/readers/LoveLiveReader.java index 21158d4..e7724dd 100644 --- a/readers/LoveLiveReader.java +++ b/readers/LoveLiveReader.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 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='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