diff --git a/Common/src/main/java/edu/sdccd/cisc191/template/Bet.java b/Common/src/main/java/edu/sdccd/cisc191/template/Bet.java index 6bb12148..2c547d1d 100644 --- a/Common/src/main/java/edu/sdccd/cisc191/template/Bet.java +++ b/Common/src/main/java/edu/sdccd/cisc191/template/Bet.java @@ -29,7 +29,6 @@ public class Bet { private final double[][] winOddsOvertime = new double[numHours][2]; // Array to track odds over time private boolean fulfillment; - private final long currentEpochSeconds = System.currentTimeMillis() / 1000; // Current time in seconds @JsonIgnore private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -85,15 +84,17 @@ public Bet(Game g, int amt, String betTeam) { } else if (betTeam.equalsIgnoreCase("team2")) { winOdds = (int) Game.getTeam2Odd(); - if (winOdds >= 0) { - this.winAmt = (amt + (100 / winOdds) * amt); - } else { + if (winOdds < 0) { this.winAmt = (amt + Math.abs((winOdds / 100) * amt)); + } else { + this.winAmt = (amt + (100 / winOdds) * amt); } } // Populate winOddsOvertime with odds and timestamps for (int j = 0; j < numHours; j++) { + // Current time in seconds + long currentEpochSeconds = System.currentTimeMillis() / 1000; long timeStamp = currentEpochSeconds - (j * 3600L); // Decrement by hours double odd = calculateOddsForGameAtTime(timeStamp); winOddsOvertime[j][0] = odd; diff --git a/Common/src/main/java/edu/sdccd/cisc191/template/Game.java b/Common/src/main/java/edu/sdccd/cisc191/template/Game.java index 37f33809..c9c871ca 100644 --- a/Common/src/main/java/edu/sdccd/cisc191/template/Game.java +++ b/Common/src/main/java/edu/sdccd/cisc191/template/Game.java @@ -82,8 +82,8 @@ public Game(String t1, String t2, Date startDate, Date endDate) { this.startDate = startDate; this.endDate = endDate; - this.team1Odd = Math.round(Math.random() * 100); - this.team2Odd = Math.round(Math.random() * 100); + team1Odd = Math.round(Math.random() * 100); + team2Odd = Math.round(Math.random() * 100); this.dateClean = this.getDateClean(); } /** @@ -130,17 +130,17 @@ public Game(String t1, String t2, Date startDate, Date endDate, double team1Odd, this.team1ProfitFactor = team1PayoutRatio - 1; this.team2ProfitFactor = team2PayoutRatio - 1; - if (team1ProfitFactor >= 1) { - this.team1Odd = +(team1ProfitFactor * 100); + if (team1ProfitFactor < 1) { + this.team1Odd = -(100/team1ProfitFactor); } else { - this.team1Odd = -(100/team1ProfitFactor); + this.team1Odd = +(team1ProfitFactor * 100); } - if (this.team2ProfitFactor >= 1) { - this.team2Odd = +(team2ProfitFactor * 100); + if (this.team2ProfitFactor < 1) { + this.team2Odd = -(100/team2ProfitFactor); } else { - this.team2Odd = -(100/team2ProfitFactor); + this.team2Odd = +(team2ProfitFactor * 100); } } @@ -151,6 +151,7 @@ public Game(String t1, String t2, Date startDate, Date endDate, double team1Odd, */ @Override public String toString() { + return team1 + " vs. " + team2 + " on " + startDate.getMonth() + "/" + startDate.getDate() + "/" + (startDate.getYear() + 1900); } @@ -176,8 +177,8 @@ public boolean equals(Object obj) { boolean team2Equals = Objects.equals(this.team2, game.getTeam2()); boolean startDateEquals = this.startDate.compareTo(game.getStartDate()) == 0; boolean endDateEquals = this.endDate.compareTo(game.getEndDate()) == 0; - boolean team1OddEquals = Math.abs(this.team1Odd - game.getTeam1Odd()) < 0.0001; - boolean team2OddEquals = Math.abs(this.team2Odd - game.getTeam2Odd()) < 0.0001; + boolean team1OddEquals = Math.abs(team1Odd - getTeam1Odd()) < 0.0001; + boolean team2OddEquals = Math.abs(team2Odd - getTeam2Odd()) < 0.0001; return team1Equals && team2Equals && startDateEquals && endDateEquals && team1OddEquals && team2OddEquals; } @@ -244,6 +245,8 @@ public Date getEndDate() { * @return A string describing the start and end dates. */ public String getDateClean() { + //TODO use SimpleDateFormat to construct a clean date string for start and end dates + return (startDate.getMonth() + 1) + "/" + startDate.getDate() + "/" + (startDate.getYear() + 1900) + " - " + (endDate.getMonth() + 1) + "/" + endDate.getDate() + "/" + (endDate.getYear() + 1900); }