Returns all pack definitions with id, name, description, cost_coins, and total_cards so the dashboard can render a purchasable pack store without needing to know the definitions at compile time. Two new tests: store listing shape and buy-then-open round-trip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,25 @@ pub async fn post_buy_pack(
|
||||
))
|
||||
}
|
||||
|
||||
/// List all purchasable pack definitions with their coin costs.
|
||||
pub async fn get_pack_store(State(state): State<AppState>) -> AppResult<Json<Value>> {
|
||||
let store: Vec<Value> = state
|
||||
.pack_defs
|
||||
.iter()
|
||||
.map(|d| {
|
||||
let total_cards: u8 = d.slots.iter().map(|s| s.count).sum();
|
||||
json!({
|
||||
"id": d.id,
|
||||
"name": d.name,
|
||||
"description": d.description,
|
||||
"cost_coins": d.cost_coins,
|
||||
"total_cards": total_cards,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
Ok(Json(json!({ "packs": store })))
|
||||
}
|
||||
|
||||
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?;
|
||||
|
||||
Reference in New Issue
Block a user