refactor: rename Evolution badges to Refractor tier names
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m24s
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m24s
- Badge labels: [R] Refractor, [GR] Gold Refractor, [SF] Superfractor, [SF★] fully evolved
- Fix broken {e} log format strings (restore `as e` + add f-string prefix)
- Restore ruff.toml from main (branch had stripped global config)
- Update all test assertions for new badge names (11/11 pass)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0304753e92
commit
fc8508fbd5
@ -115,7 +115,8 @@ async def get_card_embeds(card, include_stats=False) -> list:
|
|||||||
evo_state = await db_get(f"evolution/cards/{card['id']}")
|
evo_state = await db_get(f"evolution/cards/{card['id']}")
|
||||||
if evo_state and evo_state.get("current_tier", 0) > 0:
|
if evo_state and evo_state.get("current_tier", 0) > 0:
|
||||||
tier = evo_state["current_tier"]
|
tier = evo_state["current_tier"]
|
||||||
tier_badge = f"[{'EVO' if tier >= 4 else f'T{tier}'}] "
|
TIER_BADGES = {1: "R", 2: "GR", 3: "SF"}
|
||||||
|
tier_badge = f"[{TIER_BADGES.get(tier, 'SF★')}] "
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -210,9 +211,9 @@ async def get_card_embeds(card, include_stats=False) -> list:
|
|||||||
)
|
)
|
||||||
if evo_mon is not None:
|
if evo_mon is not None:
|
||||||
embed.add_field(name="Evolves Into", value=f"{evo_mon['p_name']}")
|
embed.add_field(name="Evolves Into", value=f"{evo_mon['p_name']}")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logging.error(
|
logging.error(
|
||||||
"could not pull evolution: {e}", exc_info=True, stack_info=True
|
f"could not pull evolution: {e}", exc_info=True, stack_info=True
|
||||||
)
|
)
|
||||||
if "420420" not in card["player"]["strat_code"]:
|
if "420420" not in card["player"]["strat_code"]:
|
||||||
try:
|
try:
|
||||||
@ -221,9 +222,9 @@ async def get_card_embeds(card, include_stats=False) -> list:
|
|||||||
)
|
)
|
||||||
if evo_mon is not None:
|
if evo_mon is not None:
|
||||||
embed.add_field(name="Evolves From", value=f"{evo_mon['p_name']}")
|
embed.add_field(name="Evolves From", value=f"{evo_mon['p_name']}")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logging.error(
|
logging.error(
|
||||||
"could not pull evolution: {e}", exc_info=True, stack_info=True
|
f"could not pull evolution: {e}", exc_info=True, stack_info=True
|
||||||
)
|
)
|
||||||
|
|
||||||
if include_stats:
|
if include_stats:
|
||||||
|
|||||||
40
ruff.toml
40
ruff.toml
@ -1,5 +1,37 @@
|
|||||||
|
# Ruff configuration for paper-dynasty discord bot
|
||||||
|
# See https://docs.astral.sh/ruff/configuration/
|
||||||
|
|
||||||
|
[lint]
|
||||||
|
# Rules suppressed globally because they reflect intentional project patterns:
|
||||||
|
# F403/F405: star imports — __init__.py files use `from .module import *` for re-exports
|
||||||
|
# E712: SQLAlchemy/SQLModel ORM comparisons require == syntax (not `is`)
|
||||||
|
# F541: f-strings without placeholders — 1000+ legacy occurrences; cosmetic, deferred
|
||||||
|
ignore = ["F403", "F405", "F541", "E712"]
|
||||||
|
|
||||||
|
# Per-file suppressions for pre-existing violations in legacy code.
|
||||||
|
# New files outside these paths get the full rule set.
|
||||||
|
# Remove entries here as files are cleaned up.
|
||||||
[lint.per-file-ignores]
|
[lint.per-file-ignores]
|
||||||
# helpers/main.py uses star imports as a legacy pattern (api_calls, constants,
|
# Core cogs — F841/F401 widespread; E711/E713/F811 pre-existing
|
||||||
# discord_ui, etc.). F403/F405 are suppressed here to allow the pre-commit hook
|
"cogs/**" = ["F841", "F401", "E711", "E713", "F811"]
|
||||||
# to pass without requiring a full refactor of the star import chain.
|
# Game engine — F841/F401 widespread; E722/F811 pre-existing bare-excepts and redefinitions
|
||||||
"helpers/main.py" = ["F403", "F405", "E722", "E721"]
|
"in_game/**" = ["F841", "F401", "E722", "F811"]
|
||||||
|
# Helpers — F841/F401 widespread; E721/E722 pre-existing type-comparison and bare-excepts
|
||||||
|
"helpers/**" = ["F841", "F401", "E721", "E722"]
|
||||||
|
# Game logic and commands
|
||||||
|
"command_logic/**" = ["F841", "F401"]
|
||||||
|
# Test suite — E711/F811/F821 pre-existing test assertion patterns
|
||||||
|
"tests/**" = ["F841", "F401", "E711", "F811", "F821"]
|
||||||
|
# Utilities
|
||||||
|
"utilities/**" = ["F841", "F401"]
|
||||||
|
# Migrations
|
||||||
|
"migrations/**" = ["F401"]
|
||||||
|
# Top-level legacy files
|
||||||
|
"db_calls_gameplay.py" = ["F841", "F401"]
|
||||||
|
"gauntlets.py" = ["F841", "F401"]
|
||||||
|
"dice.py" = ["F841", "E711"]
|
||||||
|
"manual_pack_distribution.py" = ["F841"]
|
||||||
|
"play_lock.py" = ["F821"]
|
||||||
|
"paperdynasty.py" = ["F401"]
|
||||||
|
"api_calls.py" = ["F401"]
|
||||||
|
"health_server.py" = ["F401"]
|
||||||
|
|||||||
@ -103,7 +103,7 @@ class TestTierBadgeFormat:
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_tier_one_badge(self):
|
async def test_tier_one_badge(self):
|
||||||
"""current_tier=1 should prefix title with [T1]."""
|
"""current_tier=1 should prefix title with [R] (Refractor)."""
|
||||||
card = _make_card()
|
card = _make_card()
|
||||||
evo_state = {"current_tier": 1, "card_id": 1}
|
evo_state = {"current_tier": 1, "card_id": 1}
|
||||||
|
|
||||||
@ -111,11 +111,11 @@ class TestTierBadgeFormat:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title == "[T1] Mike Trout"
|
assert embeds[0].title == "[R] Mike Trout"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_tier_two_badge(self):
|
async def test_tier_two_badge(self):
|
||||||
"""current_tier=2 should prefix title with [T2]."""
|
"""current_tier=2 should prefix title with [GR] (Gold Refractor)."""
|
||||||
card = _make_card()
|
card = _make_card()
|
||||||
evo_state = {"current_tier": 2, "card_id": 1}
|
evo_state = {"current_tier": 2, "card_id": 1}
|
||||||
|
|
||||||
@ -123,11 +123,11 @@ class TestTierBadgeFormat:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title == "[T2] Mike Trout"
|
assert embeds[0].title == "[GR] Mike Trout"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_tier_three_badge(self):
|
async def test_tier_three_badge(self):
|
||||||
"""current_tier=3 should prefix title with [T3]."""
|
"""current_tier=3 should prefix title with [SF] (Superfractor)."""
|
||||||
card = _make_card()
|
card = _make_card()
|
||||||
evo_state = {"current_tier": 3, "card_id": 1}
|
evo_state = {"current_tier": 3, "card_id": 1}
|
||||||
|
|
||||||
@ -135,11 +135,11 @@ class TestTierBadgeFormat:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title == "[T3] Mike Trout"
|
assert embeds[0].title == "[SF] Mike Trout"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_tier_four_evo_badge(self):
|
async def test_tier_four_superfractor_badge(self):
|
||||||
"""current_tier=4 (fully evolved) should prefix title with [EVO]."""
|
"""current_tier=4 (fully evolved) should prefix title with [SF★]."""
|
||||||
card = _make_card()
|
card = _make_card()
|
||||||
evo_state = {"current_tier": 4, "card_id": 1}
|
evo_state = {"current_tier": 4, "card_id": 1}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class TestTierBadgeFormat:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title == "[EVO] Mike Trout"
|
assert embeds[0].title == "[SF★] Mike Trout"
|
||||||
|
|
||||||
|
|
||||||
class TestTierBadgeInTitle:
|
class TestTierBadgeInTitle:
|
||||||
@ -163,16 +163,16 @@ class TestTierBadgeInTitle:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title.startswith("[T2] ")
|
assert embeds[0].title.startswith("[GR] ")
|
||||||
assert "Juan Soto" in embeds[0].title
|
assert "Juan Soto" in embeds[0].title
|
||||||
|
|
||||||
|
|
||||||
class TestFullyEvolvedBadge:
|
class TestFullyEvolvedBadge:
|
||||||
"""Unit: fully evolved card shows [EVO] badge."""
|
"""Unit: fully evolved card shows [SF★] badge."""
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_fully_evolved_badge(self):
|
async def test_fully_evolved_badge(self):
|
||||||
"""T4 card should show [EVO] prefix, not [T4]."""
|
"""T4 card should show [SF★] prefix, not [T4]."""
|
||||||
card = _make_card()
|
card = _make_card()
|
||||||
evo_state = {"current_tier": 4}
|
evo_state = {"current_tier": 4}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ class TestFullyEvolvedBadge:
|
|||||||
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
mock_db.side_effect = _patch_db_get(evo_response=evo_state)
|
||||||
embeds = await _call_get_card_embeds(card)
|
embeds = await _call_get_card_embeds(card)
|
||||||
|
|
||||||
assert embeds[0].title.startswith("[EVO] ")
|
assert embeds[0].title.startswith("[SF★] ")
|
||||||
assert "[T4]" not in embeds[0].title
|
assert "[T4]" not in embeds[0].title
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user