feat: Phase 1 — core game loop complete
New endpoints: - GET /cards/:card_id single card lookup - POST /packs/buy purchase pack with coins - POST /objectives/claim claim completed objective reward - GET /matches match history (limit/mode query params) - GET /sbc/:sbc_id single SBC lookup Card pool expanded: - Bronze: 11 → 30 cards (19 nations) - Silver: 0 → 20 cards (20 nations) - Rare Gold: 0 → 10 cards (10 nations) SBC pool expanded: - Added 5 new SBCs (tri_nations, silver_to_gold, league_loyalty, african_stars, gold_standard) Infrastructure: - SQLite WAL mode enabled on pool init - Foreign key enforcement enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -133,6 +133,23 @@ pub async fn open_pack(
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn buy_pack(
|
||||
pool: &Pool,
|
||||
pack_defs: &[PackDefinition],
|
||||
club_id: &str,
|
||||
definition_id: &str,
|
||||
) -> AppResult<Pack> {
|
||||
let def = pack_defs
|
||||
.iter()
|
||||
.find(|d| d.id == definition_id)
|
||||
.ok_or_else(|| {
|
||||
AppError::NotFound(format!("pack definition '{definition_id}' not found"))
|
||||
})?;
|
||||
|
||||
crate::services::club::spend_coins(pool, club_id, def.cost_coins).await?;
|
||||
grant_pack(pool, club_id, definition_id).await
|
||||
}
|
||||
|
||||
pub async fn get_unopened_packs(pool: &Pool, club_id: &str) -> AppResult<Vec<Pack>> {
|
||||
let packs = sqlx::query_as::<_, Pack>(
|
||||
"SELECT id, club_id, definition_id, opened, created_at FROM packs WHERE club_id = ? AND opened = 0"
|
||||
|
||||
Reference in New Issue
Block a user