diff --git a/app/services/refractor_boost.py b/app/services/refractor_boost.py index 37d6ec1..321c34c 100644 --- a/app/services/refractor_boost.py +++ b/app/services/refractor_boost.py @@ -282,12 +282,12 @@ def apply_pitcher_boost(ratings_dict: dict, tb_budget: float = 1.5) -> dict: def compute_variant_hash( player_id: int, - evolution_tier: int, + refractor_tier: int, cosmetics: list[str] | None = None, ) -> int: """Compute a stable, deterministic variant identifier for a boosted card. - Hashes the combination of player_id, evolution_tier, and an optional sorted + Hashes the combination of player_id, refractor_tier, and an optional sorted list of cosmetic identifiers to produce a compact integer suitable for use as a database variant key. The result is derived from the first 8 hex characters of a SHA-256 digest, so collisions are extremely unlikely in @@ -298,7 +298,7 @@ def compute_variant_hash( Args: player_id: Player primary key. - evolution_tier: Refractor tier (0–4) the card has reached. + refractor_tier: Refractor tier (0–4) the card has reached. cosmetics: Optional list of cosmetic tag strings (e.g. special art identifiers). Order is normalised — callers need not sort. @@ -307,7 +307,7 @@ def compute_variant_hash( """ inputs = { "player_id": player_id, - "evolution_tier": evolution_tier, + "refractor_tier": refractor_tier, "cosmetics": sorted(cosmetics or []), } raw = hashlib.sha256(json.dumps(inputs, sort_keys=True).encode()).hexdigest() diff --git a/tests/test_refractor_boost.py b/tests/test_refractor_boost.py index f7506f4..3c5e97a 100644 --- a/tests/test_refractor_boost.py +++ b/tests/test_refractor_boost.py @@ -809,7 +809,7 @@ class TestVariantHash: """ def test_deterministic(self): - """Same (player_id, evolution_tier, cosmetics) inputs produce the + """Same (player_id, refractor_tier, cosmetics) inputs produce the same hash on every call. What: Call compute_variant_hash 20 times with the same arguments and @@ -827,8 +827,8 @@ class TestVariantHash: def test_different_tiers_different_hash(self): """Tier 1 and tier 2 for the same player produce different hashes. - What: Compare compute_variant_hash(player_id=1, evolution_tier=1) - vs compute_variant_hash(player_id=1, evolution_tier=2). + What: Compare compute_variant_hash(player_id=1, refractor_tier=1) + vs compute_variant_hash(player_id=1, refractor_tier=2). Why: Each Refractor tier represents a distinct card version. If two tiers produced the same hash, the DB unique-key constraint on variant @@ -841,8 +841,8 @@ class TestVariantHash: def test_different_players_different_hash(self): """Same tier for different players produces different hashes. - What: Compare compute_variant_hash(player_id=10, evolution_tier=1) - vs compute_variant_hash(player_id=11, evolution_tier=1). + What: Compare compute_variant_hash(player_id=10, refractor_tier=1) + vs compute_variant_hash(player_id=11, refractor_tier=1). Why: Each player's Refractor card is a distinct asset. If two players at the same tier shared a hash, their boosted variants could not be