|
|
@@ -8,14 +8,18 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.AbstractMap.SimpleEntry;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import java.util.ResourceBundle;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.lang3.NotImplementedException;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
|
import data.GuiMysql;
|
|
|
import javafx.collections.FXCollections;
|
|
|
@@ -23,13 +27,18 @@ import javafx.collections.ObservableList;
|
|
|
import javafx.event.ActionEvent;
|
|
|
import javafx.fxml.FXML;
|
|
|
import javafx.fxml.Initializable;
|
|
|
+import javafx.scene.control.Button;
|
|
|
import javafx.scene.control.ComboBox;
|
|
|
import javafx.scene.control.DatePicker;
|
|
|
+import javafx.scene.control.Label;
|
|
|
+import javafx.scene.control.TableCell;
|
|
|
import javafx.scene.control.TableColumn;
|
|
|
import javafx.scene.control.TableView;
|
|
|
+import javafx.scene.control.TextArea;
|
|
|
import javafx.scene.control.cell.MapValueFactory;
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
import javafx.scene.text.Text;
|
|
|
+import javafx.util.Callback;
|
|
|
import objects.Constants;
|
|
|
import objects.SoccerMatch;
|
|
|
import tests.objects.Standing;
|
|
|
@@ -64,13 +73,18 @@ import tests.objects.Standing;
|
|
|
|
|
|
@FXML TableColumn<Map, String> sumScoringColumn = new TableColumn<>("Sum scoring");
|
|
|
@FXML TableColumn<Map, Float> positionAdjustmentColumn = new TableColumn<>("PositionAdjustment");
|
|
|
- @FXML TableColumn<Map, String> awayWinColumn = new TableColumn<>(Constants.AWAY_WIN);
|
|
|
+ @FXML TableColumn<Map, String> newScoringTestColumn = new TableColumn<>("New Scoring test");
|
|
|
+ @FXML TableColumn<Map, Void> addToBetsButtonColumn = new TableColumn<>("Add bet");
|
|
|
|
|
|
@FXML Text homeTeamPastResultsText;
|
|
|
@FXML Text awayTeamPastResultsText;
|
|
|
@FXML Text previousMeetingsText;
|
|
|
@FXML Text previousReverseMeetingsText;
|
|
|
|
|
|
+ @FXML Label NumberOfGamesText;
|
|
|
+ @FXML TextArea SystemsText;
|
|
|
+ @FXML Label ReslutsText;
|
|
|
+
|
|
|
ObservableList<String> sports = FXCollections.observableArrayList();
|
|
|
ObservableList<String> countries = FXCollections.observableArrayList();
|
|
|
ObservableList<String> leagues = FXCollections.observableArrayList();
|
|
|
@@ -83,6 +97,8 @@ import tests.objects.Standing;
|
|
|
private String selectedHomeTeam;
|
|
|
private String selectedAwayTeam;
|
|
|
|
|
|
+ Set<betSystemDTO> bets = new HashSet<>();
|
|
|
+
|
|
|
@Override public void initialize(URL arg0, ResourceBundle arg1) {
|
|
|
gameDateColumn.setCellValueFactory(new MapValueFactory<>("gameDate"));
|
|
|
homeTeamColumn.setCellValueFactory(new MapValueFactory<>("homeTeam"));
|
|
|
@@ -105,7 +121,34 @@ import tests.objects.Standing;
|
|
|
|
|
|
sumScoringColumn.setCellValueFactory(new MapValueFactory<>("sumScoring"));
|
|
|
positionAdjustmentColumn.setCellValueFactory(new MapValueFactory<>("positionAdjustment"));
|
|
|
- awayWinColumn.setCellValueFactory(new MapValueFactory<>(Constants.AWAY_WIN));
|
|
|
+ newScoringTestColumn.setCellValueFactory(new MapValueFactory<>("newScoringTest"));
|
|
|
+
|
|
|
+ Callback<TableColumn<Map, Void>, TableCell<Map, Void>> cellFactory = new Callback<TableColumn<Map, Void>, TableCell<Map, Void>>() {
|
|
|
+ @Override public TableCell<Map, Void> call(final TableColumn<Map, Void> param) {
|
|
|
+ return new TableCell<Map, Void>() {
|
|
|
+
|
|
|
+ private final Button btn = new Button("Submit");
|
|
|
+ {
|
|
|
+ btn.setOnAction((ActionEvent event) -> {
|
|
|
+ Map data = getTableView().getItems().get(getIndex());
|
|
|
+
|
|
|
+ addToBets(data);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override public void updateItem(Void item, boolean empty) {
|
|
|
+ super.updateItem(item, empty);
|
|
|
+ if (empty) {
|
|
|
+ setGraphic(null);
|
|
|
+ } else {
|
|
|
+ setGraphic(btn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ addToBetsButtonColumn.setCellFactory(cellFactory);
|
|
|
|
|
|
basePane.setPrefWidth(0.0);
|
|
|
basePane.setPrefHeight(0.0);
|
|
|
@@ -131,6 +174,51 @@ import tests.objects.Standing;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public void addToBets(Map data) {
|
|
|
+ String betType;
|
|
|
+ if (Float.valueOf(data.get("sumScoring").toString()) > 5.0f && Float.valueOf(data.get("newScoringTest").toString()) > 6.5f) {
|
|
|
+ betType = "O 1.5";
|
|
|
+ } else if (Float.valueOf(data.get("sumScoring").toString()) < 2.0f && Float.valueOf(data.get("newScoringTest").toString()) < 3.5f) {
|
|
|
+ betType = "U 3.5";
|
|
|
+ } else if (Float.valueOf(data.get("sumScoring").toString()) < 3.0f && Float.valueOf(data.get("newScoringTest").toString()) < 4.5f) {
|
|
|
+ betType = "U 4.5";
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ bets.add(new betSystemDTO(Integer.valueOf(data.get("id").toString()), Integer.valueOf(data.get("homeScore").toString()),
|
|
|
+ Integer.valueOf(data.get("awayScore").toString()), betType));
|
|
|
+ increaseNumberOfBets();
|
|
|
+ calculateSystems();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void increaseNumberOfBets() {
|
|
|
+ NumberOfGamesText.setText(String.valueOf(Integer.valueOf(NumberOfGamesText.getText()) + 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void calculateSystems() {
|
|
|
+ Set<Set<betSystemDTO>> combinations = Sets.powerSet(bets);
|
|
|
+
|
|
|
+ combinations = combinations.stream().sorted((s1, s2) -> Integer.compare(s1.size(), s2.size())).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ String combinationText = "";
|
|
|
+ int totalCombinations = 0;
|
|
|
+ Map<Integer, Integer> sets = new HashMap<>();
|
|
|
+ for (Set<betSystemDTO> set : combinations) {
|
|
|
+ if (set.size() > 0) {
|
|
|
+ totalCombinations += set.size();
|
|
|
+ sets.put(set.size(), sets.getOrDefault(set.size(), 0) + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String text = "Total Combinations: " + sets.values().stream().mapToInt(Integer::intValue).sum() + "\n";
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sets.forEach((k, v) -> sb.append(k.toString() + "'s: " + v.toString() + "\n"));
|
|
|
+
|
|
|
+ text += sb.toString();
|
|
|
+ SystemsText.setText(text);
|
|
|
+ }
|
|
|
+
|
|
|
private void updateMatchStats(Map<String, Object> newSelection) {
|
|
|
if (newSelection != null) {
|
|
|
Map<String, String> previousMatches = db.getPreviousMatches(5, newSelection.get("homeTeam").toString(),
|
|
|
@@ -198,8 +286,11 @@ import tests.objects.Standing;
|
|
|
float result = 0.0f;
|
|
|
int matchedMatches = 0;
|
|
|
|
|
|
- List<SoccerMatch> matchesBefore = GuiMysql.getInstance().getMatches(1, getCountryIdFromSelector(), getLeagueIdFromSelector(),
|
|
|
- date.getValue().toString(), "ASC", false);
|
|
|
+ if (placementDiff == 0) {
|
|
|
+ return 0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SoccerMatch> matchesBefore = GuiMysql.getInstance().getMatches(1, countryId, leagueId, date.getValue().toString(), "ASC", false, false);
|
|
|
|
|
|
for (SoccerMatch match : matchesBefore) {
|
|
|
Optional<Standing> homeTeamStanding = tempStanding.stream().filter(ts -> ts.getTeamName().equals(match.getHomeTeam().getTeamName()))
|
|
|
@@ -273,73 +364,86 @@ import tests.objects.Standing;
|
|
|
if (getCountryIdFromSelector() > 0) {
|
|
|
List<SoccerMatch> matchesList = db.getMatches(db.getSportId(MainController.SOCCER), getCountryIdFromSelector(),
|
|
|
db.getLeagueId(db.getSportId(MainController.SOCCER), getCountryIdFromSelector(), leagueSelector.getValue()),
|
|
|
- date.getValue().toString(), "ASC", true);
|
|
|
-
|
|
|
- ObservableList<Map<String, Object>> matches = FXCollections.<Map<String, Object>>observableArrayList();
|
|
|
-
|
|
|
- for (final SoccerMatch soccerMatch : matchesList) {
|
|
|
-
|
|
|
- final Map<String, Object> match = new HashMap<>();
|
|
|
- match.put("homeTeam", soccerMatch.getHomeTeam().getTeamName());
|
|
|
- match.put("awayTeam", soccerMatch.getAwayTeam().getTeamName());
|
|
|
- match.put("odds1", soccerMatch.getOdds1());
|
|
|
- match.put("oddsX", soccerMatch.getOddsX());
|
|
|
- match.put("odds2", soccerMatch.getOdds2());
|
|
|
-
|
|
|
- final List<Float> avgHomeTeamGoals = calculateAvgHomeScore(soccerMatch.getHomeTeam().getTeamId());
|
|
|
- final List<Float> avgAwayTeamGoals = calculateAvgAwayScore(soccerMatch.getAwayTeam().getTeamId());
|
|
|
-
|
|
|
- final List<Float> avgHomeTeamGoalsThisSeason = calculateAvgHomeScoreThisSeason(soccerMatch.getHomeTeam().getTeamId(),
|
|
|
- soccerMatch.getHomeTeam().getCountryId(), soccerMatch.getHomeTeam().getTeamLeagueId());
|
|
|
- final List<Float> avgAwayTeamGoalsThisSeason = calculateAvgAwayScoreThisSeason(soccerMatch.getAwayTeam().getTeamId(),
|
|
|
- soccerMatch.getAwayTeam().getCountryId(), soccerMatch.getAwayTeam().getTeamLeagueId());
|
|
|
-
|
|
|
- match.put("gameDate", soccerMatch.getGameDate().toString());
|
|
|
- match.put("avgScoreHome", avgHomeTeamGoals.get(0));
|
|
|
- match.put("avgConcededHome", avgHomeTeamGoals.get(1));
|
|
|
- match.put("avgScoreAway", avgAwayTeamGoals.get(0));
|
|
|
- match.put("avgConcededAway", avgAwayTeamGoals.get(1));
|
|
|
-
|
|
|
- match.put("avgScoredHomeSeason", avgHomeTeamGoalsThisSeason.get(0));
|
|
|
- match.put("avgConcededHomeSeason", avgHomeTeamGoalsThisSeason.get(1));
|
|
|
-
|
|
|
- match.put("avgScoredAwaySeason", avgAwayTeamGoalsThisSeason.get(0));
|
|
|
- match.put("avgConcededAwaySeason", avgAwayTeamGoalsThisSeason.get(1));
|
|
|
-
|
|
|
- match.put("sumScoring", avgHomeTeamGoalsThisSeason.get(0) * avgAwayTeamGoalsThisSeason.get(1)
|
|
|
- + avgAwayTeamGoalsThisSeason.get(0) * avgHomeTeamGoalsThisSeason.get(1));
|
|
|
-
|
|
|
- match.put("goalsHome",
|
|
|
- GuiMysql.getInstance().round(BigDecimal.valueOf(avgHomeTeamGoalsThisSeason.get(0) + avgAwayTeamGoalsThisSeason.get(1)),
|
|
|
- GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
- match.put("goalsAway",
|
|
|
- GuiMysql.getInstance().round(BigDecimal.valueOf(avgAwayTeamGoalsThisSeason.get(0) + avgHomeTeamGoalsThisSeason.get(1)),
|
|
|
- GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
-
|
|
|
- match.put("goalDiff",
|
|
|
- GuiMysql.getInstance()
|
|
|
- .round(BigDecimal.valueOf((avgHomeTeamGoalsThisSeason.get(0) * avgAwayTeamGoalsThisSeason.get(1))
|
|
|
- + (avgAwayTeamGoalsThisSeason.get(0) * avgHomeTeamGoalsThisSeason.get(1))),
|
|
|
- GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
- match.put("country", soccerMatch.getHomeTeam().getCountryName());
|
|
|
-
|
|
|
- List<Float> leagueAvarages = GuiMysql.getInstance().getLeagueAvarages(getLeagueIdFromSelector(), getCountryIdFromSelector(),
|
|
|
- soccerMatch.getGameDate().format(DateTimeFormatter.BASIC_ISO_DATE));
|
|
|
- match.put("positionAdjustment", getAvgGoalsWithSameDiff(soccerMatch.getHomeTeam().getCountryId(),
|
|
|
- soccerMatch.getHomeTeam().getTeamLeagueId(), MatchStatTabController.getInstance()
|
|
|
- .getTeamPositionDiff(soccerMatch.getHomeTeam().getTeamName(), soccerMatch.getAwayTeam().getTeamName()))
|
|
|
- - (leagueAvarages.get(0) + leagueAvarages.get(1)));
|
|
|
- match.put(Constants.LEAGUE, soccerMatch.getHomeTeam().getTeamLeague());
|
|
|
-
|
|
|
- final DecimalFormat df = new DecimalFormat("#.##");
|
|
|
- df.setRoundingMode(RoundingMode.CEILING);
|
|
|
+ date.getValue().toString(), "ASC", true, false);
|
|
|
+
|
|
|
+ addMatchesToTable(matchesList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addMatchesToTable(List<SoccerMatch> matchesList) {
|
|
|
+ ObservableList<Map<String, Object>> matches = FXCollections.<Map<String, Object>>observableArrayList();
|
|
|
+
|
|
|
+ for (final SoccerMatch soccerMatch : matchesList) {
|
|
|
+
|
|
|
+ final Map<String, Object> match = new HashMap<>();
|
|
|
+ match.put("homeTeam", soccerMatch.getHomeTeam().getTeamName());
|
|
|
+ match.put("awayTeam", soccerMatch.getAwayTeam().getTeamName());
|
|
|
+ match.put("odds1", soccerMatch.getOdds1());
|
|
|
+ match.put("oddsX", soccerMatch.getOddsX());
|
|
|
+ match.put("odds2", soccerMatch.getOdds2());
|
|
|
+
|
|
|
+ final List<Float> avgHomeTeamGoals = calculateAvgHomeScore(soccerMatch.getHomeTeam().getTeamId());
|
|
|
+ final List<Float> avgAwayTeamGoals = calculateAvgAwayScore(soccerMatch.getAwayTeam().getTeamId());
|
|
|
+
|
|
|
+ final List<Float> avgHomeTeamGoalsThisSeason = calculateAvgHomeScoreThisSeason(soccerMatch.getHomeTeam().getTeamId(),
|
|
|
+ soccerMatch.getHomeTeam().getCountryId(), soccerMatch.getHomeTeam().getTeamLeagueId());
|
|
|
+ final List<Float> avgAwayTeamGoalsThisSeason = calculateAvgAwayScoreThisSeason(soccerMatch.getAwayTeam().getTeamId(),
|
|
|
+ soccerMatch.getAwayTeam().getCountryId(), soccerMatch.getAwayTeam().getTeamLeagueId());
|
|
|
+
|
|
|
+ match.put("gameDate", soccerMatch.getGameDate().toString());
|
|
|
+ match.put("avgScoreHome", avgHomeTeamGoals.get(0));
|
|
|
+ match.put("avgConcededHome", avgHomeTeamGoals.get(1));
|
|
|
+ match.put("avgScoreAway", avgAwayTeamGoals.get(0));
|
|
|
+ match.put("avgConcededAway", avgAwayTeamGoals.get(1));
|
|
|
+
|
|
|
+ match.put("avgScoredHomeSeason", avgHomeTeamGoalsThisSeason.get(0));
|
|
|
+ match.put("avgConcededHomeSeason", avgHomeTeamGoalsThisSeason.get(1));
|
|
|
+
|
|
|
+ match.put("avgScoredAwaySeason", avgAwayTeamGoalsThisSeason.get(0));
|
|
|
+ match.put("avgConcededAwaySeason", avgAwayTeamGoalsThisSeason.get(1));
|
|
|
+
|
|
|
+ match.put("sumScoring", avgHomeTeamGoalsThisSeason.get(0) * avgAwayTeamGoalsThisSeason.get(1)
|
|
|
+ + avgAwayTeamGoalsThisSeason.get(0) * avgHomeTeamGoalsThisSeason.get(1));
|
|
|
+
|
|
|
+ match.put("goalsHome",
|
|
|
+ GuiMysql.getInstance().round(BigDecimal.valueOf(avgHomeTeamGoalsThisSeason.get(0) + avgAwayTeamGoalsThisSeason.get(1)),
|
|
|
+ GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
+ match.put("goalsAway",
|
|
|
+ GuiMysql.getInstance().round(BigDecimal.valueOf(avgAwayTeamGoalsThisSeason.get(0) + avgHomeTeamGoalsThisSeason.get(1)),
|
|
|
+ GuiMysql.getInstance().getIncrement(), RoundingMode.HALF_UP));
|
|
|
+
|
|
|
+ match.put("goalDiff",
|
|
|
+ GuiMysql.getInstance()
|
|
|
+ .round(BigDecimal.valueOf((avgHomeTeamGoalsThisSeason.get(0) * avgAwayTeamGoalsThisSeason.get(1))
|
|
|
+ + (avgAwayTeamGoalsThisSeason.get(0) * avgHomeTeamGoalsThisSeason.get(1))), GuiMysql.getInstance().getIncrement(),
|
|
|
+ RoundingMode.HALF_UP));
|
|
|
+ match.put("country", soccerMatch.getHomeTeam().getCountryName());
|
|
|
+
|
|
|
+ List<Float> leagueAvarages = GuiMysql.getInstance().getLeagueAvarages(getLeagueIdFromSelector(), getCountryIdFromSelector(),
|
|
|
+ soccerMatch.getGameDate().format(DateTimeFormatter.BASIC_ISO_DATE));
|
|
|
+ match.put("positionAdjustment", getAvgGoalsWithSameDiff(soccerMatch.getHomeTeam().getCountryId(),
|
|
|
+ soccerMatch.getHomeTeam().getTeamLeagueId(), MatchStatTabController.getInstance()
|
|
|
+ .getTeamPositionDiff(soccerMatch.getHomeTeam().getTeamName(), soccerMatch.getAwayTeam().getTeamName()))
|
|
|
+ - (leagueAvarages.get(0) + leagueAvarages.get(1)));
|
|
|
+
|
|
|
+ match.put("newScoringTest",
|
|
|
+ (avgHomeTeamGoalsThisSeason.get(0) * avgAwayTeamGoalsThisSeason.get(1)
|
|
|
+ + avgAwayTeamGoalsThisSeason.get(0) * avgHomeTeamGoalsThisSeason.get(1))
|
|
|
+ + ((avgHomeTeamGoals.get(0) * avgAwayTeamGoals.get(1)) + avgAwayTeamGoals.get(0) * avgHomeTeamGoals.get(1)) / 2);
|
|
|
+
|
|
|
+ match.put(Constants.LEAGUE, soccerMatch.getHomeTeam().getTeamLeague());
|
|
|
+
|
|
|
+ match.put("id", soccerMatch.getMatchId());
|
|
|
+ match.put("homeScore", soccerMatch.getHomeScore());
|
|
|
+ match.put("awayScore", soccerMatch.getAwayScore());
|
|
|
+ final DecimalFormat df = new DecimalFormat("#.##");
|
|
|
+ df.setRoundingMode(RoundingMode.CEILING);
|
|
|
|
|
|
// final League leagueInfo = GuiMysql.getInstance().getLeagueInfo(soccerMatch.getHomeTeam().getTeamLeague());
|
|
|
|
|
|
- matches.add(match);
|
|
|
- }
|
|
|
- matchTable.getItems().addAll(matches);
|
|
|
+ matches.add(match);
|
|
|
}
|
|
|
+ matchTable.getItems().addAll(matches);
|
|
|
}
|
|
|
|
|
|
private List<Float> calculateAvgHomeScore(int teamId) {
|
|
|
@@ -370,4 +474,127 @@ import tests.objects.Standing;
|
|
|
date.getValue().toString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @FXML private void getAllMatchesAtDate() {
|
|
|
+ String dateString = date.getValue().toString();
|
|
|
+
|
|
|
+ List<SoccerMatch> matches = GuiMysql.getInstance().getMatches(1, dateString, "ASC", true);
|
|
|
+ addMatchesToTable(matches);
|
|
|
+ }
|
|
|
+
|
|
|
+ @FXML private void ClearBetSlip() {
|
|
|
+ NumberOfGamesText.setText("0");
|
|
|
+ SystemsText.setText("");
|
|
|
+ ReslutsText.setText("");
|
|
|
+ bets.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ @FXML private void CheckBetSlip() {
|
|
|
+ Set<Set<betSystemDTO>> combinations = Sets.powerSet(bets);
|
|
|
+
|
|
|
+ Map<Integer, Integer> resultWins = new HashMap<>();
|
|
|
+ Map<Integer, Integer> resultLosses = new HashMap<>();
|
|
|
+
|
|
|
+ int setTest = 0;
|
|
|
+ double betAmount = 10.0d;
|
|
|
+
|
|
|
+ Map<Integer, Double> banks = new HashMap<>();
|
|
|
+
|
|
|
+ for (Set<betSystemDTO> set : combinations) {
|
|
|
+ if (set.size() > 0) {
|
|
|
+ System.out.println("Set " + ++setTest);
|
|
|
+ if (set.stream().allMatch(this::isWin)) {
|
|
|
+ resultWins.put(set.size(), resultWins.getOrDefault(set.size(), 0) + 1);
|
|
|
+ set.forEach(s -> {
|
|
|
+ System.out.println(
|
|
|
+ "WIN size " + set.size() + " GameId: " + s.getGameId() + " Score " + s.getHomeScore() + " - " + s.getAwayScore());
|
|
|
+ banks.put(set.size(), banks.getOrDefault(set.size(), 0d) + ((betAmount * Math.pow(1.15d, set.size())) - betAmount));
|
|
|
+ });
|
|
|
+
|
|
|
+ } else { // Set/combination lost
|
|
|
+ resultLosses.put(set.size(), resultLosses.getOrDefault(set.size(), 0) + 1);
|
|
|
+ set.forEach(s -> System.out.println("LOSS size " + set.size() + " GameId: " + s.getGameId() + " Score " + s.getHomeScore() + " - "
|
|
|
+ + s.getAwayScore() + " type " + s.getBetType()));
|
|
|
+ banks.put(set.size(), banks.getOrDefault(set.size(), 0d) - betAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder losses = new StringBuilder();
|
|
|
+ StringBuilder wins = new StringBuilder();
|
|
|
+ StringBuilder bankString = new StringBuilder();
|
|
|
+
|
|
|
+ resultLosses.forEach((k, v) -> losses.append("Set size: " + k + " number of losses: " + v + "\n"));
|
|
|
+ resultWins.forEach((k, v) -> wins.append("Set size: " + k + " number of Wins: " + v + "\n"));
|
|
|
+ banks.forEach((k, v) -> bankString.append("Set " + k + " result " + v + "\n"));
|
|
|
+
|
|
|
+ System.out.println("Results \n WINS \n" + wins.toString() + "\nLOSSES\n" + losses.toString() + "\nBanks:" + bankString);
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isWin(betSystemDTO bet) {
|
|
|
+ boolean result = false;
|
|
|
+ String betType = bet.getBetType();
|
|
|
+ String overUnder = betType.substring(0, 1);
|
|
|
+ float res = Float.valueOf(betType.substring(2, betType.length()));
|
|
|
+ int gameGoals = bet.getHomeScore() + bet.getAwayScore();
|
|
|
+
|
|
|
+ if (overUnder.equals("O")) {
|
|
|
+ if (gameGoals > res) {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ } else if (overUnder.equals("U")) {
|
|
|
+ if (gameGoals < res) {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ class betSystemDTO {
|
|
|
+ int gameId;
|
|
|
+ int homeScore;
|
|
|
+ int awayScore;
|
|
|
+ String betType;
|
|
|
+
|
|
|
+ public betSystemDTO(int gameId, int homeScore, int awayScore, String betType) {
|
|
|
+ super();
|
|
|
+ this.gameId = gameId;
|
|
|
+ this.homeScore = homeScore;
|
|
|
+ this.awayScore = awayScore;
|
|
|
+ this.betType = betType;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getGameId() {
|
|
|
+ return gameId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setGameId(int gameId) {
|
|
|
+ this.gameId = gameId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getHomeScore() {
|
|
|
+ return homeScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setHomeScore(int homeScore) {
|
|
|
+ this.homeScore = homeScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getAwayScore() {
|
|
|
+ return awayScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAwayScore(int awayScore) {
|
|
|
+ this.awayScore = awayScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBetType() {
|
|
|
+ return betType;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setBetType(String betType) {
|
|
|
+ this.betType = betType;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|