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

void main() {
  group('Canonical numeric parity', () {
    test('enemy HP values match source tables for implemented classes', () {
      final guardBaby = Guard(
        x: 1,
        y: 1,
        angle: 0,
        mapId: MapObject.guardStart,
        difficulty: Difficulty.baby,
      );
      final guardHard = Guard(
        x: 1,
        y: 1,
        angle: 0,
        mapId: MapObject.guardStart,
        difficulty: Difficulty.hard,
      );
      final mutantBaby = Mutant(
        x: 1,
        y: 1,
        angle: 0,
        mapId: MapObject.mutantStart,
        difficulty: Difficulty.baby,
      );
      final mutantEasy = Mutant(
        x: 1,
        y: 1,
        angle: 0,
        mapId: MapObject.mutantStart,
        difficulty: Difficulty.easy,
      );
      final mutantHard = Mutant(
        x: 1,
        y: 1,
        angle: 0,
        mapId: MapObject.mutantStart,
        difficulty: Difficulty.hard,
      );

      expect(guardBaby.health, 25);
      expect(guardHard.health, 25);
      expect(mutantBaby.health, 45);
      expect(mutantEasy.health, 55);
      expect(mutantHard.health, 65);
    });

    test('collectible pickup values match canonical amounts', () {
      const context = CollectiblePickupContext(
        health: 50,
        ammo: 10,
        hasGoldKey: false,
        hasSilverKey: false,
        hasMachineGun: false,
        hasChainGun: false,
        currentWeaponType: WeaponType.pistol,
      );

      final food = HealthCollectible(x: 1, y: 1, mapId: MapObject.food);
      final medkit = HealthCollectible(x: 1, y: 1, mapId: MapObject.medkit);
      final clip = AmmoCollectible(x: 1, y: 1);
      final clipDrop = SmallAmmoCollectible(x: 1, y: 1);
      final machineGun = WeaponCollectible(
        x: 1,
        y: 1,
        mapId: MapObject.machineGun,
      );
      final fullHeal = TreasureCollectible(
        x: 1,
        y: 1,
        mapId: MapObject.extraLife,
      );

      expect(food.tryCollect(context)?.healthToRestore, 10);
      expect(medkit.tryCollect(context)?.healthToRestore, 25);
      expect(clip.tryCollect(context)?.ammoToAdd, 8);
      expect(clipDrop.tryCollect(context)?.ammoToAdd, 4);
      expect(machineGun.tryCollect(context)?.ammoToAdd, 6);
      expect(fullHeal.tryCollect(context)?.healthToRestore, 99);
      expect(fullHeal.tryCollect(context)?.ammoToAdd, 25);
      expect(fullHeal.tryCollect(context)?.extraLivesToAdd, 1);
    });

    test('extra life collectible increases player lives and caps at 9', () {
      final player = Player(x: 1.5, y: 1.5, angle: 0);
      final extraLife = TreasureCollectible(
        x: 1,
        y: 1,
        mapId: MapObject.extraLife,
      );

      expect(player.lives, 3);
      player.tryPickup(extraLife);
      expect(player.lives, 4);

      for (int i = 0; i < 20; i++) {
        player.addLives(1);
      }
      expect(player.lives, 9);
    });
  });
}
