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
+79
View File
@@ -0,0 +1,79 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum MatchOutcome {
Win,
Draw,
Loss,
}
#[derive(Debug, Deserialize)]
pub struct SubmitMatchRequest {
pub squad_id: String,
pub opponent_name: String,
pub goals_for: i64,
pub goals_against: i64,
pub mode: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct Match {
pub id: String,
pub profile_id: String,
pub squad_id: String,
pub opponent_name: String,
pub goals_for: i64,
pub goals_against: i64,
pub outcome: String,
pub coins_awarded: i64,
pub xp_awarded: i64,
pub mode: String,
pub played_at: String,
}
impl Match {
#[allow(clippy::too_many_arguments)]
pub fn new(
profile_id: &str,
squad_id: &str,
opponent_name: &str,
goals_for: i64,
goals_against: i64,
mode: &str,
coins_awarded: i64,
xp_awarded: i64,
) -> Self {
let outcome = if goals_for > goals_against {
"win"
} else if goals_for == goals_against {
"draw"
} else {
"loss"
};
Self {
id: Uuid::new_v4().to_string(),
profile_id: profile_id.to_string(),
squad_id: squad_id.to_string(),
opponent_name: opponent_name.to_string(),
goals_for,
goals_against,
outcome: outcome.to_string(),
coins_awarded,
xp_awarded,
mode: mode.to_string(),
played_at: chrono::Utc::now().to_rfc3339(),
}
}
}
#[derive(Debug, Serialize)]
pub struct MatchRewardResult {
pub match_record: Match,
pub coins_awarded: i64,
pub xp_awarded: i64,
pub objectives_updated: Vec<String>,
}