feat(fifa17): serve staff, so the club has a manager and matches can start
FIFA refuses to kick off with "your player or managers contracts have expired".
The club had no manager, and could not have had one: `/club?type=manager` (the
token the STAFF tab actually sends) was rejected by the host, and staff items
were counted and dropped by the adapter instead of being shaped.
The squad's manager reference is a red herring worth recording. It points at
wire id 100000427, which resolves to resourceId 3000083 = a FITNESS COACH
(cardsubtypeid 8), not a manager. The client's own club/stats agrees:
staff:3, staffManager:0, staffGKCoach:1, staffFitnessCoach:2. This club has
never owned a manager, so one is MINTED rather than restored.
Wire shape is not guessed. `fifa17-recon/tools/fut_staff.py` is an
instruction-level reversal of the item parser and the managercards merge that
justifies every key by its record offset, and CARD_SYSTEM.md records it
confirmed live on 2026-08-05 (ten managers rendered with correct flags, league
names and "CONTRACT 7" on the card front). `shape_staff_item` emits exactly that
key set and nothing else:
* `nation` (rec+0xde) and `leagueId` (rec+0xe0) are MANAGER-ONLY slots the
client's merge never writes, so the server is their only source — they are the
flag, the league badge and both halves of manager chemistry. Coaches get
neither, because the four coach tables have no nation/league/team column and
emitting zeroes there would be invention.
* `resourceId` is the RAW merge key: staff are read as a u32 with NO &0xffffff
mask (players are the only masked family), so `version` must stay 0 or the
lookup misses — silently, since the manager branch has no else-arm.
* `preferredPosition`/`attributeList` are omitted because they SURVIVE the merge
and are then read by the card view-model; `assetId`/`rating`/`rareflag` are
omitted because the merge overwrites them from the client's own tables. A
staff card is therefore never routed through `shape_item`.
Managers stay inside `ContentKind::Staff`, discriminated by `cardsubtypeid == 4`
— the client's own discriminator, and its own stats model counts a manager
INSIDE the staff total with staffManager as a bucket within it. A parallel
`ContentKind::Manager` would have been a second source of truth for a fact the
subtype already carries, and would have silently under-counted club/stats.
`squad.manager[]` stays `[{id, dream}]`. The only populated form anywhere is the
oracle's DRAFT squad; no capture has ever shown itemData in a regular squad, and
feeding that deserializer the wrong container type freezes the SAX reader. The
contract reaches the client through the CardsDb record registered from the
/club envelope, which is a find-or-insert and therefore accumulates.
TWO SILENT BUGS FOUND ON THE WAY, both of which made a correct assignment look
like no assignment at all:
1. `get_squad_manager` read `manager.owned_card_id`, but Core returns the
assigned OWNED CARD, whose field is `id`. It therefore ALWAYS returned None —
indistinguishable from "no manager". Now reads `id`, and a present-but-
unreadable manager is an error rather than a silent absence. The projection
also now warns when an assignment cannot be resolved to an owned instance,
which is the documented "Core drops an owned card with no CardDefinition from
/collection without erroring" trap.
2. `Route::WatchList` was produced by NO classifier arm, so its handler was
unreachable and every `watchList` request fell through to Passthrough — the
same defect class as `season/list`. Against a stack whose Python upstream is
deliberately dead this 502'd. This was failing
`sbc_survives_complete_core_and_host_restart` at HEAD before this change.
The manager itself is seeded from the client's own tables, never invented:
managercards 1000509 (assetid == carddbid), nation 45, manager[509] "Luis
Enrique" teamid 241, leagueteamlinks 241 -> league 53. League 53 is also the
dominant league in the restored squad (12 of 23), so the chemistry pairing is
the correct one rather than an arbitrary pick.
Verified live against the restored club: /club?type=manager and ?type=staff both
return 4 items (the minted manager plus the 3 coaches the profile already owned
and could never see), the manager carries contract 7 with nation/league/team,
coaches correctly carry none of the three, squad.manager resolves to the same
wire id, and no staff leaks into ?type=player. Adapter 219 tests, host 114 lib +
36 host_test + all economy suites green.
This commit is contained in:
@@ -184,6 +184,30 @@ STAGING_KITS = [
|
||||
("away", "owned-a-kit-away", "fifa17_6400003", 6_400_003),
|
||||
]
|
||||
|
||||
# The club manager. FIFA refuses to start a match without one ("your player or
|
||||
# managers contracts have expired"), and NEITHER club owns a manager: the real
|
||||
# import has 1992 players and exactly 3 staff items, all coaches (2 fitness, 1 GK),
|
||||
# which the client's own club/stats confirms with staffManager:0. So a manager is
|
||||
# minted here rather than restored.
|
||||
#
|
||||
# Every value below is read out of the client's OWN tables, never invented:
|
||||
# managercards.carddbid 1000509 (assetid == carddbid on all 417 rows)
|
||||
# managercards.nation 45 -> the flag and the nation half of chemistry
|
||||
# manager[509].surname "Luis Enrique", teamid 241
|
||||
# leagueteamlinks[241].leagueid 53 -> the badge and the league half of chemistry
|
||||
# League 53 is also the dominant league in the restored squad (12 of 23 players),
|
||||
# so this manager is the chemistry-correct choice for it, not an arbitrary one.
|
||||
MANAGER_SUBTYPE = 4
|
||||
STAGING_MANAGER = {
|
||||
"owned_id": "owned-a-manager",
|
||||
"card_id": "fifa17_1000509",
|
||||
"resource_id": 1_000_509,
|
||||
"nation": 45,
|
||||
"league_id": 53,
|
||||
"team_id": 241,
|
||||
"label": "Luis Enrique",
|
||||
}
|
||||
|
||||
READY_TIMEOUT_S = 60.0
|
||||
|
||||
|
||||
@@ -499,13 +523,52 @@ def materialise(lay: Layout) -> None:
|
||||
"card_asset_id": 35,
|
||||
"team_id": KIT_TEAM_ID,
|
||||
}
|
||||
|
||||
mgr = STAGING_MANAGER
|
||||
if mgr["card_id"] not in existing:
|
||||
definitions.append({
|
||||
"id": mgr["card_id"],
|
||||
"name": mgr["label"],
|
||||
"overall": 0,
|
||||
"position": "",
|
||||
"nation": "",
|
||||
"league": "",
|
||||
"club": "",
|
||||
"pace": 0,
|
||||
"shooting": 0,
|
||||
"passing": 0,
|
||||
"dribbling": 0,
|
||||
"defending": 0,
|
||||
"physical": 0,
|
||||
"rarity": "bronze",
|
||||
"image_path": None,
|
||||
})
|
||||
# `version` MUST stay 0 and `asset_id` MUST be the raw carddbid: the client's
|
||||
# managercards merge reads the wire resourceId as a u32 WITHOUT masking off a
|
||||
# version byte (players are the only family that is masked), and the manager
|
||||
# branch has no else-arm, so a wrong key fails silently with a blank card.
|
||||
catalog["cards"][mgr["card_id"]] = {
|
||||
"asset_id": mgr["resource_id"],
|
||||
"version": 0,
|
||||
"rareflag": 0,
|
||||
"kind": "staff",
|
||||
"subtype": MANAGER_SUBTYPE,
|
||||
"team_id": mgr["team_id"],
|
||||
"nation": mgr["nation"],
|
||||
"league_id": mgr["league_id"],
|
||||
}
|
||||
with open(safe_path(lay.cards), "w") as fh:
|
||||
json.dump(definitions, fh, indent=2)
|
||||
fh.write("\n")
|
||||
with open(safe_path(lay.catalog), "w") as fh:
|
||||
json.dump(catalog, fh, indent=2)
|
||||
fh.write("\n")
|
||||
ok("added ownership-backed home/away kit fixtures from fcc_kitcards")
|
||||
ok(
|
||||
"added ownership-backed home/away kit fixtures from fcc_kitcards, and the "
|
||||
f"manager {STAGING_MANAGER['label']} (carddbid "
|
||||
f"{STAGING_MANAGER['resource_id']}, nation {STAGING_MANAGER['nation']}, "
|
||||
f"league {STAGING_MANAGER['league_id']}) from managercards"
|
||||
)
|
||||
|
||||
|
||||
def install_real_club(lay: Layout) -> dict:
|
||||
@@ -566,6 +629,7 @@ def assert_seed_cards_resolvable(lay: Layout, real_club: dict | None) -> None:
|
||||
[card for _, card in SELLER_SQUAD_CARDS]
|
||||
+ [DISPOSABLE_CARD]
|
||||
+ [card for _, _, card, _ in STAGING_KITS]
|
||||
+ [STAGING_MANAGER["card_id"]]
|
||||
)
|
||||
what = f"all {len(wanted)} fixture seed card ids"
|
||||
else:
|
||||
@@ -576,8 +640,9 @@ def assert_seed_cards_resolvable(lay: Layout, real_club: dict | None) -> None:
|
||||
finally:
|
||||
conn.close()
|
||||
wanted |= {card for _, _, card, _ in STAGING_KITS}
|
||||
wanted.add(STAGING_MANAGER["card_id"])
|
||||
what = (f"all {len(wanted)} distinct card ids owned by the real club "
|
||||
"(plus the kit fixtures)")
|
||||
"(plus the kit and manager fixtures)")
|
||||
missing_pack = sorted(wanted - pack_ids)
|
||||
missing_cat = sorted(wanted - catalog_ids)
|
||||
if missing_pack or missing_cat:
|
||||
@@ -725,6 +790,9 @@ def seed_core_db(lay: Layout, real_club: dict | None) -> None:
|
||||
(owned_id, seller_club, card_id, TS)
|
||||
for _slot, owned_id, card_id, _resource_id in STAGING_KITS
|
||||
]
|
||||
owned.append(
|
||||
(STAGING_MANAGER["owned_id"], seller_club, STAGING_MANAGER["card_id"], TS)
|
||||
)
|
||||
if real_club is None:
|
||||
owned = (
|
||||
[(item, SELLER_CLUB, card, TS) for item, card in SELLER_SQUAD_CARDS]
|
||||
@@ -760,6 +828,25 @@ def seed_core_db(lay: Layout, real_club: dict | None) -> None:
|
||||
for slot, owned_id, _card_id, _resource_id in STAGING_KITS
|
||||
],
|
||||
)
|
||||
|
||||
# Assign the manager to whichever squad the club actually has: the
|
||||
# fixture's own, or the real club's imported squad. Migration 0023
|
||||
# keys squad_managers by squad_id, so the assignment must name a real
|
||||
# squad row rather than the club.
|
||||
squad_row = conn.execute(
|
||||
"SELECT id FROM squads WHERE club_id = ? ORDER BY updated_at DESC "
|
||||
"LIMIT 1", (seller_club,)
|
||||
).fetchone()
|
||||
if squad_row is None:
|
||||
raise Fatal(
|
||||
f"club {seller_club} has no squad, so the manager cannot be "
|
||||
"assigned; FIFA refuses to start a match without one"
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT OR REPLACE INTO squad_managers (squad_id, owned_card_id, "
|
||||
"updated_at) VALUES (?, ?, ?)",
|
||||
(squad_row[0], STAGING_MANAGER["owned_id"], TS),
|
||||
)
|
||||
finally:
|
||||
conn.close()
|
||||
if real_club is None:
|
||||
@@ -773,7 +860,8 @@ def seed_core_db(lay: Layout, real_club: dict | None) -> None:
|
||||
f"kept the real club untouched ({real_club['owned_cards']} items, "
|
||||
f"{real_club['coins']:,} coins, squad {real_club['squads'][0]['name']!r} "
|
||||
f"with {real_club['squad_players']} players); added "
|
||||
f"{len(STAGING_KITS)} active kits and Buyer B ({BUYER_COINS} coins)"
|
||||
f"{len(STAGING_KITS)} active kits, the manager "
|
||||
f"{STAGING_MANAGER['label']} and Buyer B ({BUYER_COINS} coins)"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user