Add boss battles, level caps, and badge tracking
Introduces full boss battle system: data models (BossBattle, BossPokemon, BossResult), API endpoints for CRUD and per-run defeat tracking, and frontend UI including a sticky level cap bar with badge display on the run page, interleaved boss battle cards in the encounter list, and an admin panel section for managing boss battles and their pokemon teams. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
30
backend/src/app/models/boss_result.py
Normal file
30
backend/src/app/models/boss_result.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, ForeignKey, SmallInteger, String, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class BossResult(Base):
|
||||
__tablename__ = "boss_results"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("run_id", "boss_battle_id", name="uq_boss_results_run_boss"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
run_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("nuzlocke_runs.id", ondelete="CASCADE"), index=True
|
||||
)
|
||||
boss_battle_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("boss_battles.id"), index=True
|
||||
)
|
||||
result: Mapped[str] = mapped_column(String(10)) # won, lost
|
||||
attempts: Mapped[int] = mapped_column(SmallInteger, default=1)
|
||||
completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
|
||||
|
||||
run: Mapped["NuzlockeRun"] = relationship(back_populates="boss_results")
|
||||
boss_battle: Mapped["BossBattle"] = relationship()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<BossResult(id={self.id}, run_id={self.run_id}, boss_battle_id={self.boss_battle_id}, result='{self.result}')>"
|
||||
Reference in New Issue
Block a user