feat: Enhance weapon switching logic and add tests for animation pacing and menu behavior

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-23 12:35:31 +01:00
parent 827b8c779e
commit a66ccf52c5
6 changed files with 66 additions and 15 deletions
@@ -115,5 +115,22 @@ void main() {
expect(player.bonusFlash, lessThan(1.0));
expect(player.bonusFlash, greaterThan(0.0));
});
test('weapon switch animates at canonical tic pacing', () {
final player = Player(x: 1.5, y: 1.5, angle: 0);
player.weapons[WeaponType.machineGun] = MachineGun();
player.requestWeaponSwitch(WeaponType.machineGun);
expect(player.switchState, WeaponSwitchState.lowering);
player.tick(const Duration(milliseconds: 86));
expect(player.switchState, WeaponSwitchState.raising);
expect(player.weaponAnimOffset, closeTo(500.0, 0.001));
expect(player.currentWeapon.type, WeaponType.machineGun);
player.tick(const Duration(milliseconds: 86));
expect(player.switchState, WeaponSwitchState.idle);
expect(player.weaponAnimOffset, closeTo(0.0, 0.001));
});
});
}