Files

26 lines
1005 B
Python

from app.schemas.deck import DeckConstraints
def build_constraint_context(constraints: DeckConstraints, owned_names: list[str] | None) -> str:
lines = []
if constraints.prefer_owned and owned_names:
lines.append("- Prefer cards the user already owns (marked [OWNED] in the list below)")
lines.append("- Mark any recommended card the user does NOT own with [UNOWNED] suffix")
if constraints.budget_enabled and constraints.budget_amount:
scope = "total deck" if constraints.budget_scope == "total" else "cards to purchase"
lines.append(f"- Budget limit: ${constraints.budget_amount:.2f} for {scope}")
if not lines:
lines.append("- No special constraints — recommend the strongest cards available")
return "\n".join(lines)
def build_owned_card_list(owned_names: list[str]) -> str:
if not owned_names:
return ""
card_list = "\n".join(f"- {name}" for name in sorted(owned_names))
return f"\nOWNED CARDS:\n{card_list}\n"