diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 10:40:01 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 10:40:01 +0300 |
| commit | 20161fbf4fab9080a2d0d6ceedbf1344435cfda0 (patch) | |
| tree | 174be0827089abc4407af7289142d66d9f995ae7 /crates/fparkan-runtime/src/strategic_roster.rs | |
| parent | 5f0b8c076b40f8eca67e2745367c731f803914f4 (diff) | |
| download | fparkan-20161fbf4fab9080a2d0d6ceedbf1344435cfda0.tar.xz fparkan-20161fbf4fab9080a2d0d6ceedbf1344435cfda0.zip | |
feat(ui): show live Control stats in the warbot card
Diffstat (limited to 'crates/fparkan-runtime/src/strategic_roster.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/strategic_roster.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/strategic_roster.rs b/crates/fparkan-runtime/src/strategic_roster.rs index acf22590..df615e0a 100644 --- a/crates/fparkan-runtime/src/strategic_roster.rs +++ b/crates/fparkan-runtime/src/strategic_roster.rs @@ -71,6 +71,8 @@ pub struct WarbotRow { pub chassis: u32, /// Whether the unit is eligible for automatic selection. pub selectable: bool, + /// Remaining provider capacity of all nodes, rounded as in the original list. + pub durability_percent: Option<i32>, } /// Returns the player's warbots in registration order, including any entries whose controller is depleted. @@ -122,6 +124,7 @@ pub fn warbot_rows(engine: &Engine, cockpit: StartingCockpit) -> Vec<WarbotRow> size, chassis, selectable: !table.node_provider_depletion_marked, + durability_percent: crate::warbot_stats::durability_percent(table), }; Some((sequence, row)) }) @@ -209,6 +212,15 @@ mod tests { ] ); + let heavy = crate::warbot_stats::warbot_stats(&engine, rows[1].handle).unwrap(); + assert_eq!(rows[1].durability_percent, Some(100)); + assert_eq!(heavy.radar, Some(400.0)); + assert_eq!(heavy.offence.unwrap().to_bits(), 0x4556_9556); + assert!( + (heavy.defence.unwrap() - 14_329.729).abs() < 0.5, + "{heavy:?}" + ); + set_owner(&mut engine.world, rows[0].handle, None).unwrap(); assert_eq!(warbot_rows(&engine, cockpit), rows[1..]); } |
