import 'dart:math' as math;

import 'package:test/test.dart';
import 'package:wolf_3d_dart/wolf_3d_data_types.dart';

void main() {
  group('Map patrol marker angles', () {
    test('maps marker ids 90-97 to T_Path 8-direction semantics', () {
      expect(MapObject.patrolAngleForMarker(MapObject.patrolEast), 0.0);

      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolNorth),
        closeTo(-math.pi / 4, 1e-9),
      );
      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolWest),
        closeTo(-math.pi / 2, 1e-9),
      );
      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolSouth),
        closeTo(-3 * math.pi / 4, 1e-9),
      );

      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolEastAlt),
        closeTo(math.pi, 1e-9),
      );
      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolNorthAlt),
        closeTo(3 * math.pi / 4, 1e-9),
      );
      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolWestAlt),
        closeTo(math.pi / 2, 1e-9),
      );
      expect(
        MapObject.patrolAngleForMarker(MapObject.patrolSouthAlt),
        closeTo(math.pi / 4, 1e-9),
      );
    });

    test('returns null for non-marker ids', () {
      expect(MapObject.patrolAngleForMarker(MapObject.pushwallTrigger), isNull);
      expect(MapObject.patrolAngleForMarker(MapObject.playerNorth), isNull);
      expect(MapObject.patrolAngleForMarker(0), isNull);
    });
  });
}
