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:
funman300
2026-06-25 15:25:30 -07:00
parent 1ffe0ffa9f
commit 34bce2ce75
14 changed files with 378 additions and 196 deletions
+42 -2
View File
@@ -1,12 +1,52 @@
use axum::{extract::State, Json};
use axum::{
extract::{Query, State},
Json,
};
use serde::Deserialize;
use serde_json::{json, Value};
use crate::{
app::AppState,
error::AppResult,
models::match_result::{MatchRewardResult, SubmitMatchRequest},
models::match_result::{Match, MatchRewardResult, SubmitMatchRequest},
services::{club as club_svc, match_service, profile as profile_svc},
};
#[derive(Deserialize)]
pub struct MatchHistoryQuery {
pub limit: Option<i64>,
pub mode: Option<String>,
}
pub async fn get_matches(
State(state): State<AppState>,
Query(query): Query<MatchHistoryQuery>,
) -> AppResult<Json<Value>> {
let profile = profile_svc::get_active_profile(&state.pool).await?;
let limit = query.limit.unwrap_or(20).clamp(1, 100);
let matches = if let Some(mode) = &query.mode {
sqlx::query_as::<_, Match>(
"SELECT id, profile_id, squad_id, opponent_name, goals_for, goals_against, outcome, coins_awarded, xp_awarded, mode, played_at FROM matches WHERE profile_id = ? AND mode = ? ORDER BY played_at DESC LIMIT ?"
)
.bind(&profile.id)
.bind(mode)
.bind(limit)
.fetch_all(&state.pool)
.await?
} else {
sqlx::query_as::<_, Match>(
"SELECT id, profile_id, squad_id, opponent_name, goals_for, goals_against, outcome, coins_awarded, xp_awarded, mode, played_at FROM matches WHERE profile_id = ? ORDER BY played_at DESC LIMIT ?"
)
.bind(&profile.id)
.bind(limit)
.fetch_all(&state.pool)
.await?
};
Ok(Json(json!({ "matches": matches, "total": matches.len() })))
}
pub async fn post_match_result(
State(state): State<AppState>,
Json(req): Json<SubmitMatchRequest>,