Add pokemon evolution support across the full stack

- Evolution model with trigger, level, item, and condition fields
- Encounter.current_pokemon_id tracks evolved species separately
- Alembic migration for evolutions table and current_pokemon_id column
- Seed pipeline loads evolution data with manual overrides
- GET /pokemon/{id}/evolutions and PATCH /encounters/{id} endpoints
- Evolve button in StatusChangeModal with evolution method details
- PokemonCard shows evolved species with "Originally" label

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 19:26:49 +01:00
parent c8d8e4b445
commit 9728773a94
19 changed files with 1077 additions and 38 deletions

View File

@@ -1,4 +1,5 @@
from app.models.encounter import Encounter
from app.models.evolution import Evolution
from app.models.game import Game
from app.models.nuzlocke_run import NuzlockeRun
from app.models.pokemon import Pokemon
@@ -7,6 +8,7 @@ from app.models.route_encounter import RouteEncounter
__all__ = [
"Encounter",
"Evolution",
"Game",
"NuzlockeRun",
"Pokemon",

View File

@@ -18,13 +18,21 @@ class Encounter(Base):
catch_level: Mapped[int | None] = mapped_column(SmallInteger)
faint_level: Mapped[int | None] = mapped_column(SmallInteger)
death_cause: Mapped[str | None] = mapped_column(String(100))
current_pokemon_id: Mapped[int | None] = mapped_column(
ForeignKey("pokemon.id"), index=True
)
caught_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now()
)
run: Mapped["NuzlockeRun"] = relationship(back_populates="encounters")
route: Mapped["Route"] = relationship(back_populates="encounters")
pokemon: Mapped["Pokemon"] = relationship(back_populates="encounters")
pokemon: Mapped["Pokemon"] = relationship(
foreign_keys=[pokemon_id], back_populates="encounters"
)
current_pokemon: Mapped["Pokemon | None"] = relationship(
foreign_keys=[current_pokemon_id]
)
def __repr__(self) -> str:
return f"<Encounter(id={self.id}, pokemon_id={self.pokemon_id}, status='{self.status}')>"

View File

@@ -0,0 +1,23 @@
from sqlalchemy import ForeignKey, SmallInteger, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
class Evolution(Base):
__tablename__ = "evolutions"
id: Mapped[int] = mapped_column(primary_key=True)
from_pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.id"), index=True)
to_pokemon_id: Mapped[int] = mapped_column(ForeignKey("pokemon.id"), index=True)
trigger: Mapped[str] = mapped_column(String(30)) # level-up, trade, use-item, etc.
min_level: Mapped[int | None] = mapped_column(SmallInteger)
item: Mapped[str | None] = mapped_column(String(50)) # e.g. thunder-stone
held_item: Mapped[str | None] = mapped_column(String(50))
condition: Mapped[str | None] = mapped_column(String(200)) # catch-all for other conditions
from_pokemon: Mapped["Pokemon"] = relationship(foreign_keys=[from_pokemon_id])
to_pokemon: Mapped["Pokemon"] = relationship(foreign_keys=[to_pokemon_id])
def __repr__(self) -> str:
return f"<Evolution(id={self.id}, from={self.from_pokemon_id}, to={self.to_pokemon_id}, trigger='{self.trigger}')>"