wip: checkpoint multi-game core work
This commit is contained in:
+14
-4
@@ -88,13 +88,18 @@ pub async fn start_draft(
|
||||
let first_position = &pick_order[0];
|
||||
let candidates = pick_candidates(card_db, first_position, min_overall, CANDIDATES_PER_SLOT);
|
||||
|
||||
let pick_order_json = serde_json::to_string(&pick_order)
|
||||
.map_err(|e| AppError::Internal(anyhow::anyhow!("serialization failed: {e}")))?;
|
||||
let candidates_json = serde_json::to_string(&candidates)
|
||||
.map_err(|e| AppError::Internal(anyhow::anyhow!("serialization failed: {e}")))?;
|
||||
|
||||
let session = DraftSession {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
difficulty: difficulty.to_string(),
|
||||
pick_order: serde_json::to_string(&pick_order).unwrap(),
|
||||
pick_order: pick_order_json,
|
||||
picks: "[]".to_string(),
|
||||
current_candidates: Some(serde_json::to_string(&candidates).unwrap()),
|
||||
current_candidates: Some(candidates_json),
|
||||
status: "active".to_string(),
|
||||
reward_coins: 0,
|
||||
reward_pack_id: None,
|
||||
@@ -185,17 +190,22 @@ pub async fn pick_card(
|
||||
let next_pos = &pick_order[next_index];
|
||||
let next_candidates =
|
||||
pick_candidates(card_db, next_pos, min_overall, CANDIDATES_PER_SLOT);
|
||||
{
|
||||
let candidates_json = serde_json::to_string(&next_candidates)
|
||||
.map_err(|e| AppError::Internal(anyhow::anyhow!("serialization failed: {e}")))?;
|
||||
(
|
||||
Some(serde_json::to_string(&next_candidates).unwrap()),
|
||||
Some(candidates_json),
|
||||
"active".to_string(),
|
||||
0,
|
||||
None,
|
||||
0,
|
||||
None,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
let picks_json = serde_json::to_string(&picks).unwrap();
|
||||
let picks_json = serde_json::to_string(&picks)
|
||||
.map_err(|e| AppError::Internal(anyhow::anyhow!("serialization failed: {e}")))?;
|
||||
|
||||
sqlx::query(
|
||||
"UPDATE draft_sessions SET picks = ?, current_candidates = ?, status = ?, \
|
||||
|
||||
Reference in New Issue
Block a user