package components;

import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import objects.SoccerMatch;

public class MatchSummaryPanelRow extends HBox {
    public MatchSummaryPanelRow(SoccerMatch match, float bank, float odds, float betAmount) {
        String matchTeams = match.getHomeTeam().getTeamName() + " vs " + match.getAwayTeam().getTeamName();
        String matchResult = match.getHomeScore() + " : " + match.getAwayScore();
        String matchOdds = String.format("%.2f", odds);

        this.setSpacing(5d);

        this.getChildren().add(new Label(matchTeams));
        this.getChildren().add(new Label(matchOdds));
        this.getChildren().add(new Label(matchResult));

        if(match.getHomeScore() >= match.getAwayScore()) {
            this.getChildren().add(new Label(String.valueOf(bank + (betAmount * odds) - betAmount)));
            this.setStyle("-fx-background-color: green");
        } else {
            this.getChildren().add(new Label(String.valueOf(bank - betAmount)));
            this.setStyle("-fx-background-color: red");
        }
    }
}
