Initial commit: OpenFUT Core

Offline Ultimate Team backend — game-independent REST API.

- 19 API endpoints: auth, profiles, clubs, cards, packs, squads,
  objectives, SBCs, match rewards, NPC market, statistics
- Axum + SQLite + SQLx with full migrations
- Weighted pack generator, SBC validation engine
- JSON-driven mod data (cards, packs, objectives, SBCs)
- 5 integration tests passing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-06-25 14:52:06 -07:00
commit 1ffe0ffa9f
60 changed files with 6152 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
use axum::{
extract::{Path, State},
Json,
};
use serde_json::{json, Value};
use crate::{
app::AppState,
error::AppResult,
models::pack::PackOpenResult,
services::{club as club_svc, objective, pack as pack_svc, profile as profile_svc, statistics},
};
pub async fn get_packs(State(state): State<AppState>) -> AppResult<Json<Value>> {
let profile = profile_svc::get_active_profile(&state.pool).await?;
let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?;
let packs = pack_svc::get_unopened_packs(&state.pool, &club.id).await?;
let with_defs: Vec<Value> = packs
.iter()
.map(|p| {
let def = state.pack_defs.iter().find(|d| d.id == p.definition_id);
json!({
"pack_id": p.id,
"definition_id": p.definition_id,
"name": def.map(|d| &d.name),
"description": def.map(|d| &d.description),
"created_at": p.created_at,
})
})
.collect();
Ok(Json(json!({ "packs": with_defs })))
}
pub async fn post_open_pack(
State(state): State<AppState>,
Path(pack_id): Path<String>,
) -> AppResult<Json<PackOpenResult>> {
let profile = profile_svc::get_active_profile(&state.pool).await?;
let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?;
let result = pack_svc::open_pack(
&state.pool,
&state.card_db,
&state.pack_defs,
&club.id,
&pack_id,
)
.await?;
statistics::increment_packs_opened(&state.pool, &profile.id).await?;
objective::increment_metric(&state.pool, &profile.id, &state.obj_defs, "packsopened", 1)
.await?;
Ok(Json(result))
}