diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 20:47:50 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 20:47:50 +0300 |
| commit | 697241b84fb0446af5feba8eb1f78b3b04cdd5a4 (patch) | |
| tree | 2644c7bf23fa5530aef8d1872d976f0a80edab76 /crates/fparkan-runtime/src/lib.rs | |
| parent | 3c6341d162de663ade969f2d0df8510b89a69da7 (diff) | |
| download | fparkan-697241b84fb0446af5feba8eb1f78b3b04cdd5a4.tar.xz fparkan-697241b84fb0446af5feba8eb1f78b3b04cdd5a4.zip | |
test(runtime): measure firing cadence after weapon deployment
The firing range check now readies each selected weapon before measuring its cycle, so mount travel no longer masks objective and capture checks. The separate Constructor check covers mount travel and muzzle pose.
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index b6efbcf0..0cc01d72 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -18353,25 +18353,41 @@ mod tests { .collect::<Vec<_>>(), [Some(500), Some(150), None, Some(4)] ); - let mut weapons = weapons; - let mut shots = [const { Vec::new() }; 4]; let mut missile_points = Vec::new(); - for ms in (0..=9000).step_by(17) { - for (slot, _, muzzle) in weapons.fire(true, ms) { - shots[slot].push(ms); - if slot == 3 { - missile_points.push(muzzle.position); + for (slot, first_shots) in [ + [136, 408, 680, 952], + [255, 1020, 1785, 2550], + [136, 595, 1054, 1513], + [510, 2465, 4420, 6375], + ] + .into_iter() + .enumerate() + { + let mut weapons = starting_player_weapons(&engine, cockpit); + weapons.select(slot + 1); + // Measure the firing cycle after the selected weapon has moved into position. + assert!(weapons.fire(false, 0).next().is_none()); + let ready_ms = 1_000; + assert!(weapons.fire(false, ready_ms).next().is_none()); + let mut shots = Vec::new(); + for ms in (0..=9000).step_by(17) { + for (fired_slot, _, muzzle) in weapons.fire(true, ready_ms + ms) { + assert_eq!(fired_slot, slot); + shots.push(ms); + if slot == 3 { + missile_points.push(muzzle.position); + } } } + assert_eq!(&shots[..4], &first_shots, "slot {slot}"); + if slot == 3 { + assert_eq!(shots, first_shots); + assert_eq!(weapons.weapons()[slot].rounds_remaining(), Some(0)); + } } - assert_eq!(&shots[0][..4], [136, 408, 680, 952]); - assert_eq!(&shots[1][..4], [255, 1020, 1785, 2550]); - assert_eq!(&shots[2][..4], [136, 595, 1054, 1513]); - assert_eq!(shots[3], [510, 2465, 4420, 6375]); assert_ne!(missile_points[0], missile_points[1]); assert_eq!(missile_points[0], missile_points[2]); assert_eq!(missile_points[1], missile_points[3]); - assert_eq!(weapons.weapons()[3].rounds_remaining(), Some(0)); for (weapon, (speed, lifetime_ms)) in weapons.weapons().iter().zip([ (350.0, 1000), (150.0, 5000), |
