Migrate club rename and numeric squad reads

This commit is contained in:
funman300
2026-08-18 17:29:24 +00:00
parent fc55de19fa
commit bf6db98f0d
8 changed files with 645 additions and 136 deletions
+23 -14
View File
@@ -267,13 +267,19 @@ pub fn parse_account_sync(body: &[u8], default_persona: i64) -> AccountSyncReque
/// `POST /openfut/account/sync` — the launcher control-plane account summary.
/// `coins`/`unopened_packs` are the AUTHORITATIVE Core values (balance +
/// entitlement count), never Python's stale profile funds.
pub fn account_sync_body(req: &AccountSyncRequest, coins: i64, unopened_packs: usize) -> Value {
pub fn account_sync_body(
req: &AccountSyncRequest,
coins: i64,
unopened_packs: usize,
club_name: &str,
club_abbr: &str,
) -> Value {
json!({
"account": {
"personaId": req.persona_id,
"personaName": req.persona_name,
"clubName": "OpenFUT",
"clubAbbr": "OFC",
"clubName": club_name,
"clubAbbr": club_abbr,
"level": req.level,
"experience": req.experience,
"experienceMax": req.experience_max,
@@ -301,6 +307,9 @@ pub fn user_mass_info_body(
coins: i64,
unopened_packs: usize,
persona_id: i64,
club_name: &str,
club_abbr: &str,
established: &str,
) -> Value {
let actives: Vec<Value> = squad
.get("actives")
@@ -310,9 +319,9 @@ pub fn user_mass_info_body(
let squad_list = crate::fut::squad_projection::squad_list(&squad);
let mut user_info = json!({
"personaId": persona_id,
"clubName": "OpenFUT",
"clubAbbr": "OFC",
"established": "2026",
"clubName": club_name,
"clubAbbr": club_abbr,
"established": established,
"accountCreatedPlatformName": "pc",
"currencies": [
{"name": "coins", "funds": coins, "finalFunds": coins, "active": true},
@@ -583,10 +592,10 @@ mod tests {
assert_eq!(req.level, 1);
assert_eq!(req.experience_max, 1000);
assert_eq!(req.account_funds_cap, 100_000);
let body = account_sync_body(&req, 29_859_876, 2);
let body = account_sync_body(&req, 29_859_876, 2, "Real FUT", "RF");
let acc = &body["account"];
assert_eq!(acc["clubName"], "OpenFUT");
assert_eq!(acc["clubAbbr"], "OFC");
assert_eq!(acc["clubName"], "Real FUT");
assert_eq!(acc["clubAbbr"], "RF");
assert_eq!(acc["profilePath"], "accounts/33068179/fifa17_profile.json");
assert_eq!(acc["coins"], 29_859_876);
assert_eq!(acc["unopenedPacks"], 2);
@@ -617,7 +626,7 @@ mod tests {
"actives": [],
"players": [],
});
let body = user_mass_info_body(squad, 29_859_876, 0, 33_068_179);
let body = user_mass_info_body(squad, 29_859_876, 0, 33_068_179, "Real FUT", "RF", "2016");
// Flat top-level envelope.
assert_eq!(body["pileSizeClientData"]["entries"][0], json!({"key": 2, "value": 100}));
assert_eq!(body["pileSizeClientData"]["entries"][1], json!({"key": 4, "value": 50}));
@@ -626,9 +635,9 @@ mod tests {
// userInfo economy + club identity.
let ui = &body["userInfo"];
assert_eq!(ui["personaId"], 33_068_179);
assert_eq!(ui["clubName"], "OpenFUT");
assert_eq!(ui["clubAbbr"], "OFC");
assert_eq!(ui["established"], "2026"); // string, not number
assert_eq!(ui["clubName"], "Real FUT");
assert_eq!(ui["clubAbbr"], "RF");
assert_eq!(ui["established"], "2016"); // string, not number
assert_eq!(ui["accountCreatedPlatformName"], "pc");
assert_eq!(ui["currencies"][0]["name"], "coins");
assert_eq!(ui["currencies"][0]["funds"], 29_859_876);
@@ -645,7 +654,7 @@ mod tests {
#[test]
fn user_mass_info_includes_unopened_packs_when_present() {
let squad = json!({"id": 0, "actives": [], "players": []});
let body = user_mass_info_body(squad, 100, 3, 33_068_179);
let body = user_mass_info_body(squad, 100, 3, 33_068_179, "OpenFUT", "OFC", "2026");
assert_eq!(body["userInfo"]["unopenedPacks"]["recoveredPacks"], 3);
assert_eq!(body["userInfo"]["unopenedPacks"]["preOrderPacks"], 0);
}