wip: checkpoint multi-game core work
This commit is contained in:
+9
-4
@@ -1,3 +1,4 @@
|
||||
use crate::extractors::GameId;
|
||||
use axum::{
|
||||
extract::{Path, Query, State},
|
||||
Json,
|
||||
@@ -39,9 +40,10 @@ pub async fn get_draft_squad(
|
||||
/// until all 11 slots are filled.
|
||||
pub async fn post_draft_start(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
Query(query): Query<DraftQuery>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let difficulty = query.difficulty.as_deref().unwrap_or("professional");
|
||||
let session = draft_svc::start_draft(&state.pool, &state.card_db, &profile.id, difficulty).await?;
|
||||
Ok(Json(session))
|
||||
@@ -50,9 +52,10 @@ pub async fn post_draft_start(
|
||||
/// Get the current state of a draft session.
|
||||
pub async fn get_draft_session(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
Path(session_id): Path<String>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let session = draft_svc::get_draft(&state.pool, &state.card_db, &profile.id, &session_id).await?;
|
||||
Ok(Json(session))
|
||||
}
|
||||
@@ -69,10 +72,11 @@ pub struct PickRequest {
|
||||
/// and rewards (coins + optional pack) are granted automatically.
|
||||
pub async fn post_draft_pick(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
Path(session_id): Path<String>,
|
||||
Json(req): Json<PickRequest>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?;
|
||||
let session = draft_svc::pick_card(
|
||||
&state.pool,
|
||||
@@ -89,9 +93,10 @@ pub async fn post_draft_pick(
|
||||
/// Abandon an active draft session. No rewards are granted.
|
||||
pub async fn post_draft_abandon(
|
||||
State(state): State<AppState>,
|
||||
game: GameId,
|
||||
Path(session_id): Path<String>,
|
||||
) -> AppResult<Json<Value>> {
|
||||
let profile = profile_svc::get_active_profile(&state.pool).await?;
|
||||
let profile = profile_svc::get_active_profile(&state.pool, game.as_str()).await?;
|
||||
let result = draft_svc::abandon_draft(&state.pool, &profile.id, &session_id).await?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user