diff --git a/openfut-adapter-fifa17/src/fut/club_stats.rs b/openfut-adapter-fifa17/src/fut/club_stats.rs index 70f6169..bccacbe 100644 --- a/openfut-adapter-fifa17/src/fut/club_stats.rs +++ b/openfut-adapter-fifa17/src/fut/club_stats.rs @@ -379,7 +379,10 @@ mod tests { #[test] fn honest_zero_club_items_present() { - let g = global(&club_stats_body(&[player(90, false, None)], ContextField::Nation)); + let g = global(&club_stats_body( + &[player(90, false, None)], + ContextField::Nation, + )); for atom in [ "stadia", "balls", @@ -411,7 +414,10 @@ mod tests { .filter(|r| r["contextId"] == 3 && r["contextValue"] == 13) .collect(); assert_eq!(league_rows.len(), 6); - let gold = league_rows.iter().find(|r| r["type"] == "playersGold").unwrap(); + let gold = league_rows + .iter() + .find(|r| r["type"] == "playersGold") + .unwrap(); assert_eq!(gold["typeValue"], 1); // league screen -> team (teamid) buckets: players/kits/badgeDBid (3 rows). diff --git a/openfut-adapter-fifa17/src/fut/non_economy.rs b/openfut-adapter-fifa17/src/fut/non_economy.rs index 5c75324..6c4d587 100644 --- a/openfut-adapter-fifa17/src/fut/non_economy.rs +++ b/openfut-adapter-fifa17/src/fut/non_economy.rs @@ -67,12 +67,19 @@ pub fn feature_off_body() -> Value { pub fn item_def(resource_id: i64) -> Value { let asset = resource_id & 0xff_ffff; // (name, rating, position, nation, leagueId, teamid, [6 attrs]) - let (name, rating, pos, nation, league, team, attrs): (&str, i64, &str, i64, i64, i64, [i64; 6]) = - if asset == 20801 { - ("Ronaldo", 94, "ST", 38, 53, 243, [90, 93, 82, 91, 33, 80]) - } else { - ("Player", 75, "CM", 0, 0, 0, [70, 70, 70, 70, 70, 70]) - }; + let (name, rating, pos, nation, league, team, attrs): ( + &str, + i64, + &str, + i64, + i64, + i64, + [i64; 6], + ) = if asset == 20801 { + ("Ronaldo", 94, "ST", 38, 53, 243, [90, 93, 82, 91, 33, 80]) + } else { + ("Player", 75, "CM", 0, 0, 0, [70, 70, 70, 70, 70, 70]) + }; let attribute_list: Vec = attrs .iter() .enumerate() @@ -365,7 +372,11 @@ pub fn user_mass_info_body( pub fn format_utc_datetime(epoch_secs: i64) -> String { let days = epoch_secs.div_euclid(86_400); let secs_of_day = epoch_secs.rem_euclid(86_400); - let (hour, min, sec) = (secs_of_day / 3600, (secs_of_day % 3600) / 60, secs_of_day % 60); + let (hour, min, sec) = ( + secs_of_day / 3600, + (secs_of_day % 3600) / 60, + secs_of_day % 60, + ); // civil_from_days: days is a count of days since 1970-01-01. let z = days + 719_468; let era = if z >= 0 { z } else { z - 146_096 } / 146_097; @@ -628,8 +639,14 @@ mod tests { }); 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})); + assert_eq!( + body["pileSizeClientData"]["entries"][0], + json!({"key": 2, "value": 100}) + ); + assert_eq!( + body["pileSizeClientData"]["entries"][1], + json!({"key": 4, "value": 50}) + ); assert_eq!(body["settings"], json!({"configs": []})); assert_eq!(body["userData"], json!({})); // userInfo economy + club identity. diff --git a/openfut-adapter-fifa17/src/fut/pack_content.rs b/openfut-adapter-fifa17/src/fut/pack_content.rs index c081155..5e8dd28 100644 --- a/openfut-adapter-fifa17/src/fut/pack_content.rs +++ b/openfut-adapter-fifa17/src/fut/pack_content.rs @@ -90,14 +90,30 @@ pub fn generate_pack_contents( } let all: Vec<&GeneratedCandidate> = pool.iter().collect(); let gold: Vec<&GeneratedCandidate> = pool.iter().filter(|c| c.rating >= 75).collect(); - let silver: Vec<&GeneratedCandidate> = - pool.iter().filter(|c| (65..75).contains(&c.rating)).collect(); + let silver: Vec<&GeneratedCandidate> = pool + .iter() + .filter(|c| (65..75).contains(&c.rating)) + .collect(); let bronze: Vec<&GeneratedCandidate> = pool.iter().filter(|c| c.rating < 65).collect(); let mut out = Vec::with_capacity(pack.count() as usize); draw_tier(&mut out, &gold, &all, pack.n_gold, pack.special_chance, rng); - draw_tier(&mut out, &silver, &all, pack.n_silver, pack.special_chance, rng); - draw_tier(&mut out, &bronze, &all, pack.n_bronze, pack.special_chance, rng); + draw_tier( + &mut out, + &silver, + &all, + pack.n_silver, + pack.special_chance, + rng, + ); + draw_tier( + &mut out, + &bronze, + &all, + pack.n_bronze, + pack.special_chance, + rng, + ); out } diff --git a/openfut-adapter-fifa17/src/fut/store_catalog.rs b/openfut-adapter-fifa17/src/fut/store_catalog.rs index 053c9fe..7d0d4f4 100644 --- a/openfut-adapter-fifa17/src/fut/store_catalog.rs +++ b/openfut-adapter-fifa17/src/fut/store_catalog.rs @@ -68,45 +68,153 @@ impl PackDef { /// never purchasable/openable. pub const PACK_CATALOG: &[PackDef] = &[ // ── Bronze category ── - PackDef { id: 1, name: "Bronze Pack", price: 400, - n_bronze: 10, n_silver: 2, n_gold: 0, rares: 1, category: "bronze", - special_chance: 0.01, owned_only: false }, - PackDef { id: 2, name: "Premium Bronze Pack", price: 750, - n_bronze: 10, n_silver: 2, n_gold: 0, rares: 3, category: "bronze", - special_chance: 0.02, owned_only: false }, + PackDef { + id: 1, + name: "Bronze Pack", + price: 400, + n_bronze: 10, + n_silver: 2, + n_gold: 0, + rares: 1, + category: "bronze", + special_chance: 0.01, + owned_only: false, + }, + PackDef { + id: 2, + name: "Premium Bronze Pack", + price: 750, + n_bronze: 10, + n_silver: 2, + n_gold: 0, + rares: 3, + category: "bronze", + special_chance: 0.02, + owned_only: false, + }, // ── Silver category ── - PackDef { id: 3, name: "Silver Pack", price: 2500, - n_bronze: 1, n_silver: 11, n_gold: 0, rares: 1, category: "silver", - special_chance: 0.015, owned_only: false }, - PackDef { id: 4, name: "Premium Silver Pack", price: 3750, - n_bronze: 1, n_silver: 11, n_gold: 0, rares: 3, category: "silver", - special_chance: 0.03, owned_only: false }, + PackDef { + id: 3, + name: "Silver Pack", + price: 2500, + n_bronze: 1, + n_silver: 11, + n_gold: 0, + rares: 1, + category: "silver", + special_chance: 0.015, + owned_only: false, + }, + PackDef { + id: 4, + name: "Premium Silver Pack", + price: 3750, + n_bronze: 1, + n_silver: 11, + n_gold: 0, + rares: 3, + category: "silver", + special_chance: 0.03, + owned_only: false, + }, // ── Gold category ── - PackDef { id: 5, name: "Gold Pack", price: 5000, - n_bronze: 0, n_silver: 2, n_gold: 10, rares: 1, category: "gold", - special_chance: 0.04, owned_only: false }, - PackDef { id: 6, name: "Premium Gold Pack", price: 7500, - n_bronze: 0, n_silver: 2, n_gold: 10, rares: 3, category: "gold", - special_chance: 0.06, owned_only: false }, + PackDef { + id: 5, + name: "Gold Pack", + price: 5000, + n_bronze: 0, + n_silver: 2, + n_gold: 10, + rares: 1, + category: "gold", + special_chance: 0.04, + owned_only: false, + }, + PackDef { + id: 6, + name: "Premium Gold Pack", + price: 7500, + n_bronze: 0, + n_silver: 2, + n_gold: 10, + rares: 3, + category: "gold", + special_chance: 0.06, + owned_only: false, + }, // ── Reward (owned-only; opened from My Packs, never coin-purchasable) ── - PackDef { id: 70, name: "Reward Gold Pack", price: 0, - n_bronze: 0, n_silver: 0, n_gold: 11, rares: 11, category: "gold", - special_chance: 1.0, owned_only: true }, - PackDef { id: 71, name: "Bronze Pack", price: 0, - n_bronze: 10, n_silver: 2, n_gold: 0, rares: 1, category: "bronze", - special_chance: 0.01, owned_only: true }, - PackDef { id: 72, name: "Silver Pack", price: 0, - n_bronze: 1, n_silver: 11, n_gold: 0, rares: 1, category: "silver", - special_chance: 0.02, owned_only: true }, - PackDef { id: 73, name: "Gold Pack", price: 0, - n_bronze: 0, n_silver: 2, n_gold: 10, rares: 1, category: "gold", - special_chance: 0.05, owned_only: true }, - PackDef { id: 74, name: "Rare Gold Pack", price: 0, - n_bronze: 0, n_silver: 2, n_gold: 10, rares: 3, category: "gold", - special_chance: 0.10, owned_only: true }, - PackDef { id: 75, name: "Icon Pack", price: 0, - n_bronze: 0, n_silver: 0, n_gold: 12, rares: 12, category: "gold", - special_chance: 1.0, owned_only: true }, + PackDef { + id: 70, + name: "Reward Gold Pack", + price: 0, + n_bronze: 0, + n_silver: 0, + n_gold: 11, + rares: 11, + category: "gold", + special_chance: 1.0, + owned_only: true, + }, + PackDef { + id: 71, + name: "Bronze Pack", + price: 0, + n_bronze: 10, + n_silver: 2, + n_gold: 0, + rares: 1, + category: "bronze", + special_chance: 0.01, + owned_only: true, + }, + PackDef { + id: 72, + name: "Silver Pack", + price: 0, + n_bronze: 1, + n_silver: 11, + n_gold: 0, + rares: 1, + category: "silver", + special_chance: 0.02, + owned_only: true, + }, + PackDef { + id: 73, + name: "Gold Pack", + price: 0, + n_bronze: 0, + n_silver: 2, + n_gold: 10, + rares: 1, + category: "gold", + special_chance: 0.05, + owned_only: true, + }, + PackDef { + id: 74, + name: "Rare Gold Pack", + price: 0, + n_bronze: 0, + n_silver: 2, + n_gold: 10, + rares: 3, + category: "gold", + special_chance: 0.10, + owned_only: true, + }, + PackDef { + id: 75, + name: "Icon Pack", + price: 0, + n_bronze: 0, + n_silver: 0, + n_gold: 12, + rares: 12, + category: "gold", + special_chance: 1.0, + owned_only: true, + }, ]; /// Look up a catalogue pack by id (the 65534 sentinel is never present).