import { describe, expect, it } from "vitest";
import { ARENA_CENTER } from "./arena";
import { createBaseMotion, returnBossToArenaCenter } from "./bosses/shared";
import { freshParty } from "./data";
import { combatFormation, updatePartyPositions } from "./partyBehaviors";
import type { MemberId, WorldPosition } from "./types";

describe("party boss positioning", () => {
  it("brings each boss back to its center slot instead of following an edge-displaced tank", () => {
    const motion = { ...createBaseMotion("bulldrome"), formationOffsetX: 2.65, position: [7, 5] as WorldPosition };

    expect(returnBossToArenaCenter(motion, 10, 2)).toBe(true);
    expect(motion.position).toEqual([ARENA_CENTER[0] + 2.65, ARENA_CENTER[1]]);
  });

  it("places Brann in front of the boss and Vale behind it", () => {
    const formation = combatFormation([2, -1]);

    expect(formation.brann).toEqual([2, 3.25]);
    expect(formation.vale).toEqual([2, -2.7]);
  });

  it("moves the tank toward the front and the rogue toward the rear during uptime", () => {
    const sharedStart: WorldPosition = [0, 0];
    const positions: Record<MemberId, WorldPosition> = {
      aelia: [0, 4],
      brann: [...sharedStart],
      nia: [-3, 4],
      orin: [3, 4],
      vale: [...sharedStart],
    };
    const motion = { ...createBaseMotion("bulldrome"), position: [0, -1] as WorldPosition };

    const next = updatePartyPositions(positions, motion, freshParty(), 1, 0.5);

    expect(next.brann[1]).toBeGreaterThan(sharedStart[1]);
    expect(next.vale[1]).toBeLessThan(sharedStart[1]);
  });
});
