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.
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.