34bce2ce75
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>
66 lines
1.5 KiB
Rust
66 lines
1.5 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum ObjectiveType {
|
|
Daily,
|
|
Weekly,
|
|
Lifetime,
|
|
Milestone,
|
|
Season,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum ObjectiveMetric {
|
|
MatchesWon,
|
|
MatchesPlayed,
|
|
GoalsScored,
|
|
PacksOpened,
|
|
SbcsCompleted,
|
|
CoinsEarned,
|
|
}
|
|
|
|
/// Objective definition from data/objectives/*.json
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ObjectiveDefinition {
|
|
pub id: String,
|
|
pub title: String,
|
|
pub description: String,
|
|
pub objective_type: ObjectiveType,
|
|
pub metric: ObjectiveMetric,
|
|
pub target: i64,
|
|
pub reward_coins: i64,
|
|
pub reward_pack_id: Option<String>,
|
|
pub reward_xp: i64,
|
|
}
|
|
|
|
/// Progress row in DB
|
|
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
|
|
pub struct ObjectiveProgress {
|
|
pub id: String,
|
|
pub profile_id: String,
|
|
pub objective_id: String,
|
|
pub current: i64,
|
|
pub completed: bool,
|
|
pub claimed: bool,
|
|
pub updated_at: String,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct ObjectiveWithProgress {
|
|
#[serde(flatten)]
|
|
pub definition: ObjectiveDefinition,
|
|
pub current: i64,
|
|
pub completed: bool,
|
|
pub claimed: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct ClaimRewardResult {
|
|
pub objective_id: String,
|
|
pub coins_granted: i64,
|
|
pub xp_granted: i64,
|
|
pub pack_granted: Option<String>,
|
|
}
|