<commit_before>import { buildEncounter } from "../test/buildEncounter";

import { StatBlock } from "../../common/StatBlock";
import { InitializeSettings } from "../Settings/Settings";
import { Encounter } from "./Encounter";

describe("Encounter", () => {
    let encounter: Encounter;
    beforeEach(() => {
        InitializeSettings();
        encounter = buildEncounter();
    });

    test("A new Encounter has no combatants", () => {
        expect(encounter.Combatants().length).toBe(0);
    });

    test("Adding a statblock results in a combatant", () => {
        encounter.AddCombatantFromStatBlock(StatBlock.Default());
        expect(encounter.Combatants().length).toBe(1);
    });

    test("Combat should not be active", () => {
        expect(encounter.State()).toBe("inactive");
    });

    describe("Initiative Ordering", () => {
        test("By roll", () => {
            const slow = encounter.AddCombatantFromStatBlock(StatBlock.Default());
            const fast = encounter.AddCombatantFromStatBlock(StatBlock.Default());
            expect(encounter.Combatants()[0]).toBe(slow);
    
            fast.Initiative(20);
            slow.Initiative(1);
            encounter.StartEncounter();
            expect(encounter.Combatants()[0]).toBe(fast);
            expect(encounter.Combatants()[1]).toBe(slow);
        });
        
        test("By group modifier", () => {
            const slow = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 0 });
            const fast = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 2 });
            const loner = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 1 });
            slow.InitiativeGroup("group");
            fast.InitiativeGroup("group");
            encounter.StartEncounter();
            expect(encounter.Combatants()[0]).toBe(fast);<commit_msg>Test initiative ordering by modifier<commit_after>import { buildEncounter } from "../test/buildEncounter";

import { StatBlock } from "../../common/StatBlock";
import { InitializeSettings } from "../Settings/Settings";
import { Encounter } from "./Encounter";

describe("Encounter", () => {
    let encounter: Encounter;
    beforeEach(() => {
        InitializeSettings();
        encounter = buildEncounter();
    });

    test("A new Encounter has no combatants", () => {
        expect(encounter.Combatants().length).toBe(0);
    });

    test("Adding a statblock results in a combatant", () => {
        encounter.AddCombatantFromStatBlock(StatBlock.Default());
        expect(encounter.Combatants().length).toBe(1);
    });

    test("Combat should not be active", () => {
        expect(encounter.State()).toBe("inactive");
    });

    describe("Initiative Ordering", () => {
        test("By roll", () => {
            const slow = encounter.AddCombatantFromStatBlock(StatBlock.Default());
            const fast = encounter.AddCombatantFromStatBlock(StatBlock.Default());
            expect(encounter.Combatants()[0]).toBe(slow);
    
            fast.Initiative(20);
            slow.Initiative(1);
            encounter.StartEncounter();
            expect(encounter.Combatants()[0]).toBe(fast);
            expect(encounter.Combatants()[1]).toBe(slow);
        });

        test("By modifier", () => {
            const slow = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 0 });
            const fast = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 2 });
            encounter.StartEncounter();
            expect(encounter.Combatants()[0]).toBe(fast);
            expect(encounter.Combatants()[1]).toBe(slow);
        });

        test("By group modifier", () => {
            const slow = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 0 });
            const fast = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 2 });
            const loner = encounter.AddCombatantFromStatBlock({ ...StatBlock.Default(), InitiativeModifier: 1 });
            slow.InitiativeGroup("group");
            fast.InitiativeGroup("group");
            encounter.StartEncounter();
            expect(encounter.Combatants()[0]).toBe(fast);
{'fraction_non_alphanumeric': 0.1570631970260223, 'fraction_numerical': 0.006505576208178439, 'mean_word_length': 2.84375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '503494', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1134, 'n_words': 194}