style(core): apply cargo fmt across routes, services, models, tests
CI / Build, lint & test (push) Successful in 2m19s

Pure rustfmt reflow (import grouping, array/match-arm/call-arg wrapping,
alphabetized module decls, comment realignment). No semantic change:
full-diff and `git diff -w` both confirm logic byte-identical to 271c363;
workspace builds and all 74 core tests pass. Retained pre-existing WIP
brought forward after verification.
This commit is contained in:
funman300
2026-08-20 16:05:41 +00:00
parent 271c3639ed
commit a034e74c16
27 changed files with 436 additions and 273 deletions
+75 -21
View File
@@ -7,13 +7,14 @@ use crate::{
match_result::{Match, MatchRewardResult, SubmitMatchRequest},
objective::ObjectiveDefinition,
},
services::{achievement, card_db::CardDb, club, notification, objective, profile, season as season_svc, statistics},
services::{
achievement, card_db::CardDb, club, notification, objective, profile, season as season_svc,
statistics,
},
};
use rand::{seq::SliceRandom, Rng};
const FORMATIONS: &[&str] = &[
"4-3-3", "4-4-2", "4-2-3-1", "4-1-2-1-2", "3-5-2", "5-3-2",
];
const FORMATIONS: &[&str] = &["4-3-3", "4-4-2", "4-2-3-1", "4-1-2-1-2", "3-5-2", "5-3-2"];
/// Generate a random AI opponent squad for Squad Battles.
///
@@ -27,23 +28,53 @@ pub fn generate_opponent(card_db: &CardDb, difficulty: &str) -> serde_json::Valu
let (min_overall, names): (u8, &[&str]) = match difficulty {
"professional" => (
70,
&["Athletic CF", "City Wanderers", "The Rovers", "United Select", "Blue Stars FC"],
&[
"Athletic CF",
"City Wanderers",
"The Rovers",
"United Select",
"Blue Stars FC",
],
),
"world_class" => (
78,
&["Elite Stars FC", "Champions Select", "Premier XI", "Galaxy United", "Titan FC"],
&[
"Elite Stars FC",
"Champions Select",
"Premier XI",
"Galaxy United",
"Titan FC",
],
),
"legendary" => (
85,
&["Legends United", "Ultimate XI", "Gold Standard FC", "The Icons", "Heritage FC"],
&[
"Legends United",
"Ultimate XI",
"Gold Standard FC",
"The Icons",
"Heritage FC",
],
),
"ultimate" => (
90,
&["Apex XI", "Pantheon FC", "Gods of FUT", "Invincibles Select", "Eternal XI"],
&[
"Apex XI",
"Pantheon FC",
"Gods of FUT",
"Invincibles Select",
"Eternal XI",
],
),
_ => (
55,
&["Amateur Town FC", "Sunday League XI", "Park FC", "Village Stars", "Reserve XI"],
&[
"Amateur Town FC",
"Sunday League XI",
"Park FC",
"Village Stars",
"Reserve XI",
],
),
};
@@ -59,7 +90,11 @@ pub fn generate_opponent(card_db: &CardDb, difficulty: &str) -> serde_json::Valu
let mut indices: Vec<usize> = (0..pool.len()).collect();
indices.shuffle(&mut rng);
let cards: Vec<_> = indices.into_iter().take(11).map(|i| pool[i].clone()).collect();
let cards: Vec<_> = indices
.into_iter()
.take(11)
.map(|i| pool[i].clone())
.collect();
let squad_rating = if cards.is_empty() {
0
@@ -147,11 +182,18 @@ pub async fn process_match(
for ev in &level_ups {
let body = if let Some(ref pack) = ev.pack_granted {
format!("You reached level {}! Reward: {} coins + {pack}.", ev.new_level, ev.coins_granted)
format!(
"You reached level {}! Reward: {} coins + {pack}.",
ev.new_level, ev.coins_granted
)
} else {
format!("You reached level {}! Reward: {} coins.", ev.new_level, ev.coins_granted)
format!(
"You reached level {}! Reward: {} coins.",
ev.new_level, ev.coins_granted
)
};
let _ = notification::create(pool, "level_up", &format!("Level {}!", ev.new_level), &body).await;
let _ = notification::create(pool, "level_up", &format!("Level {}!", ev.new_level), &body)
.await;
}
statistics::record_match(
@@ -195,15 +237,20 @@ pub async fn process_match(
.find(|d| &d.id == obj_id)
.map(|d| d.title.as_str())
.unwrap_or(obj_id.as_str());
let body = format!("\"{}\" is now complete. Claim your reward in Objectives.", display_name);
let _ = notification::create(pool, "objective_complete", "Objective complete!", &body).await;
let body = format!(
"\"{}\" is now complete. Claim your reward in Objectives.",
display_name
);
let _ =
notification::create(pool, "objective_complete", "Objective complete!", &body).await;
}
// Decrement loan matches remaining for squad starters; collect expired loan IDs.
let expired_loans = process_loan_expiry(pool, club_id, &req.squad_id).await?;
for owned_id in &expired_loans {
let body = format!("Loan card (id: {owned_id}) has expired and been removed from your club.");
let body =
format!("Loan card (id: {owned_id}) has expired and been removed from your club.");
let _ = notification::create(pool, "loan_expired", "Loan card expired", &body).await;
}
@@ -218,14 +265,21 @@ pub async fn process_match(
SeasonResult::Relegated => "Relegated",
SeasonResult::Maintained => "Maintained",
};
let body = format!("{direction} — now in Division {}. Rewards: {} coins{}.", se.new_division, se.coins_awarded, se.pack_awarded.as_deref().map(|p| format!(" + {p}")).unwrap_or_default());
let body = format!(
"{direction} — now in Division {}. Rewards: {} coins{}.",
se.new_division,
se.coins_awarded,
se.pack_awarded
.as_deref()
.map(|p| format!(" + {p}"))
.unwrap_or_default()
);
let _ = notification::create(pool, "season_end", "Season complete!", &body).await;
}
let achievements_unlocked =
achievement::check_and_unlock(pool, ach_defs, profile_id, club_id)
.await
.unwrap_or_default();
let achievements_unlocked = achievement::check_and_unlock(pool, ach_defs, profile_id, club_id)
.await
.unwrap_or_default();
Ok(MatchRewardResult {
match_record,