mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2026-03-25 06:26:31 +01:00
feat: add Budget Mode with price cache infrastructure and stale price warnings (#61)
This commit is contained in:
parent
1aa8e4d7e8
commit
8643b72108
42 changed files with 6976 additions and 2753 deletions
|
|
@ -811,6 +811,33 @@ class IdealDeterminationError(DeckBuilderError):
|
|||
"""
|
||||
super().__init__(message, code="IDEAL_ERR", details=details)
|
||||
|
||||
class BudgetHardCapExceeded(DeckBuilderError):
|
||||
"""Raised when a deck violates a hard budget cap.
|
||||
|
||||
In hard mode, if the deck total exceeds ``budget_total`` after all
|
||||
feasible replacements, this exception surfaces the violation so callers
|
||||
can surface actionable messaging.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
total_price: float,
|
||||
budget_total: float,
|
||||
over_budget_cards: list | None = None,
|
||||
details: dict | None = None,
|
||||
) -> None:
|
||||
overage = round(total_price - budget_total, 2)
|
||||
message = (
|
||||
f"Deck cost ${total_price:.2f} exceeds hard budget cap "
|
||||
f"${budget_total:.2f} by ${overage:.2f}"
|
||||
)
|
||||
super().__init__(message, code="BUDGET_HARD_CAP", details=details or {})
|
||||
self.total_price = total_price
|
||||
self.budget_total = budget_total
|
||||
self.overage = overage
|
||||
self.over_budget_cards = over_budget_cards or []
|
||||
|
||||
|
||||
class PriceConfigurationError(DeckBuilderError):
|
||||
"""Raised when there are issues configuring price settings.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue