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:
@@ -4,6 +4,7 @@ from sqlalchemy import select
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.evolution import Evolution
|
||||
from app.models.game import Game
|
||||
from app.models.pokemon import Pokemon
|
||||
from app.models.route import Route
|
||||
@@ -118,3 +119,36 @@ async def upsert_route_encounters(
|
||||
count += 1
|
||||
|
||||
return count
|
||||
|
||||
|
||||
async def upsert_evolutions(
|
||||
session: AsyncSession,
|
||||
evolutions: list[dict],
|
||||
dex_to_id: dict[int, int],
|
||||
) -> int:
|
||||
"""Upsert evolution pairs, return count of upserted rows."""
|
||||
# Clear existing evolutions and re-insert (simpler than complex upsert)
|
||||
from sqlalchemy import delete
|
||||
await session.execute(delete(Evolution))
|
||||
|
||||
count = 0
|
||||
for evo in evolutions:
|
||||
from_id = dex_to_id.get(evo["from_national_dex"])
|
||||
to_id = dex_to_id.get(evo["to_national_dex"])
|
||||
if from_id is None or to_id is None:
|
||||
continue
|
||||
|
||||
evolution = Evolution(
|
||||
from_pokemon_id=from_id,
|
||||
to_pokemon_id=to_id,
|
||||
trigger=evo["trigger"],
|
||||
min_level=evo.get("min_level"),
|
||||
item=evo.get("item"),
|
||||
held_item=evo.get("held_item"),
|
||||
condition=evo.get("condition"),
|
||||
)
|
||||
session.add(evolution)
|
||||
count += 1
|
||||
|
||||
await session.flush()
|
||||
return count
|
||||
|
||||
Reference in New Issue
Block a user