Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Common/src/main/java/edu/sdccd/cisc191/template/Bet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 13 additions & 10 deletions Common/src/main/java/edu/sdccd/cisc191/template/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
/**
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down