Fix matches results updater

This commit is contained in:
Julian Arndt
2023-08-14 10:03:44 +02:00
parent 2acc6acafe
commit 23cef6f545
9 changed files with 91 additions and 19 deletions

View File

@@ -79,14 +79,23 @@ public class APIFootballMatch extends BaseMatch {
private void parseResult(JSONObject json) {
Object resultFulltime = ((JSONObject) json.get("score")).get("fulltime");
if(resultFulltime != null) {
this.goalsHome = Integer.parseInt(resultFulltime.toString().substring(0, 1));
this.goalsGuest = Integer.parseInt(resultFulltime.toString().substring(2, 3));
String[] result = resultFulltime.toString().split("-");
this.goalsHome = Integer.parseInt(result[0]);
this.goalsGuest = Integer.parseInt(result[1]);
}
Object resultExtratime = ((JSONObject) json.get("score")).get("extratime");
if(resultExtratime != null) {
this.goalsOvertimeHome = this.goalsHome + Integer.parseInt(resultExtratime.toString().substring(0, 1));
this.goalsOvertimeGuest = this.goalsGuest + Integer.parseInt(resultExtratime.toString().substring(2, 3));
String[] result = resultExtratime.toString().split("-");
this.goalsOvertimeHome = this.goalsHome + Integer.parseInt(result[0]);
this.goalsOvertimeGuest = this.goalsGuest + Integer.parseInt(result[1]);
}
Object resultPenalty = ((JSONObject) json.get("score")).get("penalty");
if(resultPenalty != null) {
String[] result = resultPenalty.toString().split("-");
this.goalsPenaltyHome = this.goalsOvertimeHome + Integer.parseInt(result[0]);
this.goalsPenaltyGuest = this.goalsOvertimeGuest + Integer.parseInt(result[1]);
}
}
}