package objects;

import java.util.ArrayList;
import java.util.List;

public class ComparingResultsData {

    private int horseId;
    private int driverId;
    private int trainerId;
    private final int raceNumber;
    private final String raceDate;

    private String trackName;

    private String horseName;
    private int lane;
    private int distance;
    private int result;
    private float time;
    private String timeModifier;
    private String trainerName;
    private String driverName;
    private float laneWin;
    private boolean betOn;

    private String lastRacesDriver;
    private String lastRacesHorse;
    private String lastRacesBoth;
    private float combinedLastRaces = 0f;

    private Float avgTimeHorseChange;
    private Float avgTimeDriverChange;

    private Float avgTimeHorse;
    private Float avgTimeDriver;

    private float sumHorse;
    private float sumDriver;

    private int ratingSumHorse;
    private int ratingSumDriver;
    private int ratingLastResultsTotal;
    private int sumRatings;

    private boolean selected = false;

    public ComparingResultsData(HorseRaceData data) {
        horseName = data.getHorseName();
        lane = data.getLane();
        distance = data.getDistance();
        result = data.getResult();
        time = data.getTime();
        timeModifier = data.getTimeModifier();
        trainerName = data.getTrainerName();
        driverName = data.getDriverName();
        laneWin = data.getLaneWin();
        horseId = data.getHorseId();
        driverId = data.getDriverId();
        trainerId = data.getTrainerId();
        raceNumber = data.getRaceNumber();
        raceDate = data.getRaceDate();
        trackName = data.getTrackName();
        betOn = false;
    }

    public int getLane() {
        return lane;
    }

    public int getDistance() {
        return distance;
    }

    public int getResult() {
        return result;
    }

    public float getTime() {
        return time;
    }

    public String getTimeModifier() {
        return timeModifier;
    }

    public String getTrainerName() {
        return trainerName;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setLane(int lane) {
        this.lane = lane;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public void setTime(float time) {
        this.time = time;
    }

    public void setTimeModifier(String timeModifier) {
        this.timeModifier = timeModifier;
    }

    public void setTrainerName(String trainerName) {
        this.trainerName = trainerName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getHorseName() {
        return horseName;
    }

    public void setHorseName(String horseName) {
        this.horseName = horseName;
    }

    public float getLaneWin() {
        return laneWin;
    }

    public void setLaneWin(float laneWin) {
        this.laneWin = laneWin;
    }

    public static ArrayList<ComparingResultsData> convertHorseRaceDataList(List<HorseRaceData> races) {
        final ArrayList<ComparingResultsData> returnArray = new ArrayList<>();

        for (final HorseRaceData data : races) {
            returnArray.add(new ComparingResultsData(data));
        }

        return returnArray;
    }

    public int getHorseId() {
        return horseId;
    }

    public int getDriverId() {
        return driverId;
    }

    public int getTrainerId() {
        return trainerId;
    }

    public void setHorseId(int horseId) {
        this.horseId = horseId;
    }

    public void setDriverId(int driverId) {
        this.driverId = driverId;
    }

    public void setTrainerId(int trainerId) {
        this.trainerId = trainerId;
    }

    public int getRaceNumber() {
        return raceNumber;
    }

    public String getRaceDate() {
        return raceDate;
    }

    public String getLastRacesDriver() {
        return lastRacesDriver;
    }

    public String getLastRacesHorse() {
        return lastRacesHorse;
    }

    public String getLastRacesBoth() {
        return lastRacesBoth;
    }

    public void setLastRacesDriver(String lastRacesDriver) {
        final float val = Float.valueOf(lastRacesDriver.substring(0, lastRacesDriver.indexOf("(") - 1));
        if (val <= 0) {
            combinedLastRaces += 8f;
        } else {
            combinedLastRaces += val;
        }
        this.lastRacesDriver = lastRacesDriver;
    }

    public void setLastRacesHorse(String lastRacesHorse) {
        final float val = Float.valueOf(lastRacesHorse.substring(0, lastRacesHorse.indexOf("(") - 1));
        if (val <= 0) {
            combinedLastRaces += 8f;
        } else {
            combinedLastRaces += val;
        }
        this.lastRacesHorse = lastRacesHorse;
    }

    public void setLastRacesBoth(String lastRacesBoth) {
        final float val = Float.valueOf(lastRacesBoth.substring(0, lastRacesBoth.indexOf("(") - 1));
        if (val <= 0) {
            combinedLastRaces += 8f;
        } else {
            combinedLastRaces += val;
        }
        this.lastRacesBoth = lastRacesBoth;
    }

    public float getCombinedLastRaces() {
        return combinedLastRaces;
    }

    public String getTrackName() {
        return trackName;
    }

    public void setTrackName(String trackName) {
        this.trackName = trackName;
    }

    public Float getAvgTimeHorseChange() {
        return avgTimeHorseChange;
    }

    public void setAvgTimeHorseChange(float avgHorseTime) {
        this.avgTimeHorseChange = avgHorseTime;
    }

    public Float getAvgTimeDriverChange() {
        return avgTimeDriverChange;
    }

    public void setAvgTimeDriverChange(Float avgTimeDriver) {
        this.avgTimeDriverChange = avgTimeDriver;
    }

    public Float getAvgTimeHorse() {
        return avgTimeHorse;
    }

    public Float getAvgTimeDriver() {
        return avgTimeDriver;
    }

    public void setCombinedLastRaces(float combinedLastRaces) {
        this.combinedLastRaces = combinedLastRaces;
    }

    public void setAvgTimeHorseChange(Float avgTimeHorseChange) {
        this.avgTimeHorseChange = avgTimeHorseChange;
    }

    public void setAvgTimeHorse(Float avgTimeHorse) {
        this.avgTimeHorse = avgTimeHorse;
    }

    public void setAvgTimeDriver(Float avgTimeDriver) {
        this.avgTimeDriver = avgTimeDriver;
    }

    public float getSumAvgTimeHorse() {
        return sumHorse;
    }

    public float getSumAvgTimeDriver() {
        return sumDriver;
    }

    public void setSumAvgTimeHorse(float sumHorse) {
        this.sumHorse = sumHorse;
    }

    public void setSumAvgTimeDriver(float sumDriver) {
        this.sumDriver = sumDriver;
    }

    public float getSumHorse() {
        return sumHorse;
    }

    public float getSumDriver() {
        return sumDriver;
    }

    public int getRatingSumHorse() {
        return ratingSumHorse;
    }

    public int getRatingSumDriver() {
        return ratingSumDriver;
    }

    public int getRatingLastResultsTotal() {
        return ratingLastResultsTotal;
    }

    public void setSumHorse(float sumHorse) {
        this.sumHorse = sumHorse;
    }

    public void setSumDriver(float sumDriver) {
        this.sumDriver = sumDriver;
    }

    public void setRatingSumHorse(int ratingSumHorse) {
        this.ratingSumHorse = ratingSumHorse;
    }

    public void setRatingSumDriver(int ratingSumDriver) {
        this.ratingSumDriver = ratingSumDriver;
    }

    public void setRatingLastResultsTotal(int ratingLastResultsTotal) {
        this.ratingLastResultsTotal = ratingLastResultsTotal;
    }

    public int getSumRatings() {
        return sumRatings;
    }

    public void setSumRatings(int sumRatings) {
        this.sumRatings = sumRatings;
    }

    public void setBetOn(boolean value) {
        betOn = value;
    }

    public boolean getBetOn() {
        return betOn;
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }
}
