Parse overtime goals

This commit is contained in:
2023-04-10 13:39:45 +02:00
parent d078a182a1
commit 12164c03ae
5 changed files with 67 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ public class APIFootballMatch extends BaseMatch {
throw new Exception("Did not find matchday for league '" + this.leagueId + "': '" + json.get("round").toString() + "'");
}
this.matchDatetime = (String) json.get("event_date");
this.parseResult(json);
}
public int getAPIFootBallMatchID() {
@@ -74,4 +75,16 @@ public class APIFootballMatch extends BaseMatch {
public Boolean getShowTable() {
return this.showTable;
}
private void parseResult(JSONObject json) {
String resultFulltime = ((JSONObject) json.get("score")).get("fulltime").toString();
this.goalsHome = Integer.parseInt(resultFulltime.substring(0, 1));
this.goalsGuest = Integer.parseInt(resultFulltime.substring(2, 3));
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));
}
}
}