package de.jeyp91.tippliga;

import de.jeyp91.apifootball.APIFootballConnector;

import java.util.ArrayList;

public abstract class TLWMatchesCreatorBase {

    ArrayList<TLWMatch> TLWMatches;
    APIFootballConnector conn;

    public TLWMatchesCreatorBase() {
        this.TLWMatches = new ArrayList<>();
    }

    public ArrayList<TLWMatch> getMatches() {
        return this.TLWMatches;
    }

    public String getSQLInsertString() {
        String sql = "";

        ArrayList<TLWMatch> tlwMatches = getMatches();

        // Add matches from config
        for(TLWMatch match : tlwMatches) {
            sql += match.getSQLQueryInsert() + "\n";
        }

        return sql;
    }

    public int getNumberOfMatchdays() {
        int matchday = 0;
        for(TLWMatch match : this.TLWMatches) {
            if(match.getMatchday() > matchday) {
                matchday = match.getMatchday();
            }
        }
        return matchday;
    }

    public ArrayList<TLWMatch> getMatchesForMatchday(int matchday) {
        ArrayList<TLWMatch> matches = new ArrayList<>();

        for(TLWMatch match : this.TLWMatches) {
            if (match.getMatchday() == matchday) {
                matches.add(match);
            }
        }

        return matches;
    }
}
