diff --git a/scripts/sold-staging-seed-squad.py b/scripts/sold-staging-seed-squad.py index 1afe8e5..0e4cae4 100755 --- a/scripts/sold-staging-seed-squad.py +++ b/scripts/sold-staging-seed-squad.py @@ -35,6 +35,12 @@ STARTERS = 11 # GK, RB, CB, CB, LB, CM, CM, CM, RW, ST, LW. LINEUP = ["GK", "RB", "CB", "CB", "LB", "CM", "CM", "CM", "RW", "ST", "LW"] FORMATION = "f433" +SQUAD_TYPE = "REGULAR_SQUAD" +CHEMISTRY = 50 +# Production's opaque 33-int tactics array. Never parsed server-side; reused because +# only the shape (a JSON-encoded int array, not null) matters to the client. +CUSTOM = ("[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," + "50,50,0,50,40,65,0,65,50,50,1]") def call(method, path, body=None): @@ -90,14 +96,35 @@ def build_put(chosen): "kitNumber": idx + 1 if occupant else 0, }) captain = next((int(p["id"]) for p in chosen if p), 0) + ratings = [int(p.get("rating") or 0) for p in chosen if p] + mean_rating = sum(ratings) // len(ratings) if ratings else 0 return { "id": 0, "squadName": "Staging XI", "formation": FORMATION, "captain": captain, "players": players, + # A first attempt sent only name/formation/captain/players and the client + # STILL refused the hub, while the host logged squad-active 200 ok -- the + # route was fine and the body was not. Diffing against production's + # known-good squad showed staging returning null for exactly these five, + # because the PUT never carried them and the extension stored nothing. + # Types matter here: the client wants scalars, not null. + "squadType": SQUAD_TYPE, + "chemistry": CHEMISTRY, + "rating": mean_rating, + "starRating": mean_rating, + # Opaque 33-int tactics array, carried verbatim and never interpreted + # server-side. Reused from production because only its SHAPE matters. + "custom": CUSTOM, + # Production carries five, all pointing at one player. Mirrored so the + # array is populated rather than empty. + "kicktakers": [{"index": i, "id": captain, "dream": False} for i in range(5)], + # Left empty deliberately: production references an owned staff instance + # (100000427) and the staging club holds 11 players and zero staff, so + # there is no manager to point at. Inventing an id would reference a + # non-existent item. This is the one remaining shape difference. "manager": [], - "kicktakers": [], }