fix: correct Elo calculator winner validation logic
The Elo calculator was incorrectly rejecting valid scores (10-7) because it checked if team score >= 10 without verifying the opposing team's score. Changes: - Update winner determination to check both score >= 10 AND score > opponent - Add detailed error message with actual scores for debugging - Ensure only one team can win (not both reaching 10 points)
This commit is contained in:
@@ -20,11 +20,12 @@ module EuchreCamp
|
||||
raise ArgumentError, "Team 2 must have exactly 2 players" unless team_2_players.length == 2
|
||||
|
||||
# Determine winner (first to 10 points)
|
||||
team_1_wins = team_1_score >= 10
|
||||
team_2_wins = team_2_score >= 10
|
||||
# Allow for exact score tie at 10-10 if provided
|
||||
team_1_wins = team_1_score > team_2_score && team_1_score >= 10
|
||||
team_2_wins = team_2_score > team_1_score && team_2_score >= 10
|
||||
|
||||
unless team_1_wins || team_2_wins
|
||||
raise ArgumentError, "One team must reach 10 points to win"
|
||||
raise ArgumentError, "One team must reach 10 points to win (Team 1: #{team_1_score}, Team 2: #{team_2_score})"
|
||||
end
|
||||
|
||||
if team_1_wins && team_2_wins
|
||||
|
||||
Reference in New Issue
Block a user