class PointsService: """Service for calculating points and penalties""" STREAK_MULTIPLIERS = { 0: 0.0, 1: 0.0, 2: 0.1, 3: 0.2, 4: 0.3, } MAX_STREAK_MULTIPLIER = 0.4 DROP_PENALTIES = { 0: 0, # First drop is free 1: 10, 2: 25, } MAX_DROP_PENALTY = 50 def calculate_completion_points( self, base_points: int, current_streak: int ) -> tuple[int, int]: """ Calculate points earned for completing a challenge. Args: base_points: Base points for the challenge current_streak: Current streak before this completion Returns: Tuple of (total_points, streak_bonus) """ multiplier = self.STREAK_MULTIPLIERS.get( current_streak, self.MAX_STREAK_MULTIPLIER ) bonus = int(base_points * multiplier) return base_points + bonus, bonus def calculate_drop_penalty(self, consecutive_drops: int) -> int: """ Calculate penalty for dropping a challenge. Args: consecutive_drops: Number of drops since last completion Returns: Penalty points to subtract """ return self.DROP_PENALTIES.get( consecutive_drops, self.MAX_DROP_PENALTY )