"""Pure helper functions for the /dev refractor-test command. Builds synthetic game data to push a card over its next refractor tier threshold with the minimum number of plays. """ import math # Batter: value = PA + (TB * 2). A HR play: PA=1, TB=4 → value = 1 + 8 = 9 BATTER_VALUE_PER_PLAY = 9 # Pitcher: value = IP + K. A K play: outs=1 (IP=1/3), K=1 → value = 1/3 + 1 = 4/3 PITCHER_VALUE_PER_PLAY = 4 / 3 def calculate_plays_needed(gap: int, card_type: str) -> dict: """Calculate the number of synthetic plays needed to close a refractor gap. Args: gap: Points needed to reach the next tier threshold. A gap of 0 means the card is exactly at threshold — we still need 1 play to push past it. card_type: One of "batter", "sp", "rp". Returns: dict with keys: num_plays: int — number of plays to create total_value: float — total refractor value those plays will add value_per_play: float — value each play contributes """ if card_type == "batter": value_per_play = BATTER_VALUE_PER_PLAY else: value_per_play = PITCHER_VALUE_PER_PLAY num_plays = max(1, math.ceil(gap / value_per_play)) total_value = num_plays * value_per_play return { "num_plays": num_plays, "total_value": total_value, "value_per_play": value_per_play, }