jonesguy14 / footballcoach

Android App for playing/simulating/recruiting as a college football coach
Other
34 stars 8 forks source link

Fixed Walkoff Logic to Behave Properly #39

Closed destilla closed 8 years ago

destilla commented 8 years ago

This is why you don't code at 2 in the morning.

The old logic was:

(Math.abs(homeScore - awayScore) < 7) && ((gamePoss && offense == homeTeam) || (!gamePoss && offense == awayTeam))

Is the score difference less than 7 and then for some reason...does the homeTeam have the ball and were they passed in as offense or vice versa for the awayTeam. I have no idea what I was trying to do there because I'm checking the same thing twice. Anyway, I thought of a scenario that breaks this:

Home team is losing 20 to 29. Scores a TD as time expires. Score is now 26 to 29 (difference<7) and homeTeam is on offense. This fulfills the conditions and would print that they just won on a walkoff, when in reality they just saved some face.

So I just removed redundant possession check and added in a check to make sure that the team that just scored has the lead.

jonesguy14 commented 8 years ago

Ok, good catch. Just merged the changes.