package objects;

public class MatchViewDTO extends SoccerMatchAnalysis {

    float homeWinPercent;
    float drawPercent;
    float awayWinPercent;

    float calculatedOdds1;
    float calculatedOddsX;
    float calculatedOdds2;
    float calculatedOddsOneX;
    float calculatedOddsX2;
    float calculatedOdds12;

    public MatchViewDTO(SoccerMatch match) {
        super(match);

        Percentages percentages = calculateWinPercentages();
        homeWinPercent = percentages.getHomeWinPercentage();
        drawPercent = percentages.getDrawPercentage();
        awayWinPercent = percentages.getAwayWinPercentage();

        calculatedOddsOneX = calculate1XOdds(match);
        calculatedOddsX2 = calculateX2Odds(match);
        calculatedOdds12 = calculate12Odds(match);

    }

    public float getCalculatedOdds1() {
        return calculatedOdds1;
    }

    public void setCalculatedOdds1(float calculatedOdds1) {
        this.calculatedOdds1 = calculatedOdds1;
    }

    public float getCalculatedOddsX() {
        return calculatedOddsX;
    }

    public void setCalculatedOddsX(float calculatedOddsX) {
        this.calculatedOddsX = calculatedOddsX;
    }

    public float getCalculatedOdds2() {
        return calculatedOdds2;
    }

    public void setCalculatedOdds2(float calculatedOdds2) {
        this.calculatedOdds2 = calculatedOdds2;
    }

    public float getCalculatedOddsOneX() {
        return calculatedOddsOneX;
    }

    public void setCalculatedOddsOneX(float calculatedOddsOneX) {
        this.calculatedOddsOneX = calculatedOddsOneX;
    }

    public float getCalculatedOddsX2() {
        return calculatedOddsX2;
    }

    public void setCalculatedOddsX2(float calculatedOddsX2) {
        this.calculatedOddsX2 = calculatedOddsX2;
    }

    public float getCalculatedOdds12() {
        return calculatedOdds12;
    }

    public void setCalculatedOdds12(float calculatedOdds12) {
        this.calculatedOdds12 = calculatedOdds12;
    }

    public float getHomeWinPercent() {
        return homeWinPercent;
    }

    public void setHomeWinPercent(float homeWinPercent) {
        this.homeWinPercent = homeWinPercent;
    }

    @Override
    public float getDrawPercent() {
        return drawPercent;
    }

    public void setDrawPercent(float drawPercent) {
        this.drawPercent = drawPercent;
    }

    public float getAwayWinPercent() {
        return awayWinPercent;
    }

    public void setAwayWinPercent(float awayWinPercent) {
        this.awayWinPercent = awayWinPercent;
    }

    private float calculate1XOdds(SoccerMatch match) {
        return match.getOddsX() * match.getOdds1() / (match.getOddsX() + match.getOdds1());
    }

    private float calculate1XOdds(float odds1, float oddsX) {
        return oddsX * odds1 / (oddsX + odds1);
    }

    private float calculateX2Odds(SoccerMatch match) {
        return match.getOddsX() * match.getOdds2() / (match.getOddsX() + match.getOdds2());
    }

    private float calculateX2Odds(float oddsX, float odds2) {
        return oddsX * odds2 / (oddsX + odds2);
    }

    private float calculate12Odds(SoccerMatch match) {
        return match.getOdds1() * match.getOdds2() / (match.getOdds1() + match.getOdds2());
    }

    private float calculate12Odds(float odds1, float odds2) {
        return odds1 * odds2 / (odds1 + odds2);
    }
}
