Files
OpenFUT/openfut-import-fifa17/src/model.rs
T
funman300 abe9e663c1 feat(fifa17): import consumable + staff content as first-class Core content
Close 20 of the 33-record content gap (17 consumables + 3 staff; 13 Legends are
unrecoverable from PC data). Verdict A (no Core change): consumables/staff become
ordinary Core CardDefinitions (neutral player fields + honest family/role names)
and owned instances via the SAME generic import path; a catalog kind lets the
adapter exclude them from the player-only /club projection.

- adapter fut::content_taxonomy: evidence-based cardsubtypeid->family/label
  (Ghidra-derived ranges) + staff role map; unknown subtype => defer, never fabricate.
- adapter catalog: Fifa17CardIdentity/RawCard gain optional kind+subtype
  (backward-compat: legacy catalogs load as player); kind_of/subtype_of lookups.
- adapter item/club_response: shape_club_response excludes non-player kinds
  (ShapeStats.excluded_non_player); ItemIdentityResolver::kind_of default=Player.
- host Fifa17IdentityResolver overrides kind_of to delegate to the catalog so
  /club excludes consumables/staff in production.
- import: Item gains cardsubtypeid/cardassetid/amount/contract; plan_non_player_definitions
  (resourceId-grouped, subtype-consistency gated); emit_content writes non-player
  defs + catalog kind + manifest; apply mints owned instances via owned_item_id.

Real profile 33068179: 1962 players + 20 non-player = 1982 owned; 18 non-player
defs (16 consumable + 2 staff, dup resourceIds shared); 0 deferred non-player; 0 blockers.
2026-08-14 05:26:02 +00:00

117 lines
3.7 KiB
Rust

//! Serde model of the real FIFA 17 Python profile (`fifa17_profile.json`).
//! Only the fields the importer reasons about are modelled; every field is
//! permissive (`Option`/`default`) because the source is external and unknown
//! fields are ignored. Nothing here is written back.
use anyhow::{Context, Result};
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct Profile {
#[serde(rename = "personaId", default)]
pub persona_id: i64,
#[serde(rename = "personaName", default)]
pub persona_name: String,
#[serde(rename = "clubName", default)]
pub club_name: String,
#[serde(rename = "clubAbbr", default)]
pub club_abbr: String,
#[serde(default)]
pub coins: i64,
/// Next wire id to issue (issue-then-increment: `fut_store.py` assigns this
/// value then increments). The allocation watermark to preserve.
#[serde(rename = "nextItemId", default)]
pub next_item_id: i64,
#[serde(default)]
pub items: Vec<Item>,
#[serde(default)]
pub squads: Vec<Squad>,
/// Unconsumed pack entitlements (`unopenedPackIds`), seeded into Core as
/// generic entitlements on import.
#[serde(rename = "unopenedPackIds", default)]
pub unopened_pack_ids: Vec<i64>,
}
impl Profile {
pub fn from_json_str(raw: &str) -> Result<Self> {
serde_json::from_str(raw).context("parsing fifa17_profile.json")
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Item {
/// The per-INSTANCE wire id (preserved on import).
pub id: i64,
/// The per-DEFINITION versioned id: `resourceId = (version << 24) | assetId`.
#[serde(rename = "resourceId", default)]
pub resource_id: i64,
#[serde(rename = "assetId", default)]
pub asset_id: Option<i64>,
#[serde(rename = "itemType", default)]
pub item_type: String,
#[serde(default)]
pub rareflag: Option<i64>,
#[serde(default)]
pub rating: Option<i64>,
#[serde(rename = "preferredPosition", default)]
pub preferred_position: Option<String>,
#[serde(default)]
pub nation: Option<i64>,
#[serde(default)]
pub teamid: Option<i64>,
#[serde(rename = "leagueId", default)]
pub league_id: Option<i64>,
#[serde(rename = "attributeList", default)]
pub attribute_list: Option<Vec<Attr>>,
/// FIFA `cardsubtypeid` — the consumable family / staff role selector. Absent
/// for player cards; present for consumables and staff.
#[serde(default)]
pub cardsubtypeid: Option<i64>,
/// Consumable ART id (small id), distinct from `resourceId`. Permissive.
#[serde(default)]
pub cardassetid: Option<i64>,
/// Consumable stack size (`amount`). Permissive.
#[serde(default)]
pub amount: Option<i64>,
/// Staff/contract `contract` count. Permissive.
#[serde(default)]
pub contract: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Attr {
pub index: i64,
pub value: i64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Squad {
#[serde(default)]
pub formation: String,
#[serde(rename = "squadName", default)]
pub squad_name: String,
#[serde(default)]
pub captain: Option<i64>,
/// Opaque staff refs; each is `{ "id": <wire id>, ... }`.
#[serde(default)]
pub manager: Vec<serde_json::Value>,
#[serde(default)]
pub players: Vec<SquadSlot>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct SquadSlot {
pub index: i64,
#[serde(rename = "itemData", default)]
pub item_data: SlotItem,
#[serde(rename = "kitNumber", default)]
pub kit_number: Option<i64>,
}
#[derive(Debug, Clone, Default, Deserialize)]
pub struct SlotItem {
/// Wire id of the owned instance in this slot; `0` = empty slot.
#[serde(default)]
pub id: i64,
}