[Feature] Squad Battles AI Opponent Generator #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
Generate random AI opponent squads for Squad Battles mode. Each opponent should have a unique formation, a randomised name pool, and difficulty-adjusted overall ratings. The weekly lineup must be stable (same seed for 7 days).
Implementation Steps
1. Add AI club templates to
data/ai_clubs.jsonCreate at least 10 templates across six difficulty tiers:
beginner(55–65),amateur(66–72),semi_pro(73–78),professional(79–82),world_class(83–88),legendary(89–99)2. Add AI name pool to
data/ai_names.jsonAt least 50 first names and 50 last names for variety.
3. Implement
generate_ai_squadinsrc/services/squad_battles.rsoverall_range4. Add
GET /squad-battles/opponentsendpointReturns a stable weekly lineup of 5 AI opponents. Seed the RNG with
year * 100 + iso_week_numberso the lineup is identical for the whole week but rotates every Monday:Use
chrono::IsoWeekorchrono::Datelike::iso_week()for the seed.5. Extend
POST /matches/resultfor Squad Battles modeWhen
mode == "squad_battles", record the opponent's difficulty and award bonus coins:6. Wire coin reward into
src/routes/matches.rsExtend the match result handler to accept optional
opponent_idandmodefields in the request body.7. Write tests
generate_ai_squad(Difficulty::WorldClass, &mut rng)→ all players overall 83–88generate_ai_squad(Difficulty::Beginner, &mut rng)→ all players overall 55–65GET /squad-battles/opponents→ returns exactly 5 opponents; calling twice in the same week returns identical resultsAcceptance Criteria
GET /squad-battles/opponentsreturns 5 weekly AI opponentscargo clippy -- -D warningspasses