d13e86ba46
Rebranded src code and scripts to SPT Co-authored-by: clodan <clodan@clodan.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/345 Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com> Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
import "reflect-metadata";
|
|
|
|
import { container } from "tsyringe";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { BotLevelGenerator } from "@spt/generators/BotLevelGenerator";
|
|
import { MinMax } from "@spt/models/common/MinMax";
|
|
import { BotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
|
|
import { DatabaseServer } from "@spt/servers/DatabaseServer";
|
|
|
|
describe("BotLevelGenerator", () =>
|
|
{
|
|
let botLevelGenerator: any;
|
|
let databaseServer: DatabaseServer;
|
|
|
|
beforeEach(() =>
|
|
{
|
|
botLevelGenerator = container.resolve<BotLevelGenerator>("BotLevelGenerator");
|
|
databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
|
});
|
|
|
|
afterEach(() =>
|
|
{
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
describe("generateBotLevel", () =>
|
|
{
|
|
it("should return value between 5 and 10 when player is level 5 and max is 10", () =>
|
|
{
|
|
const levelDetails: MinMax = { min: 5, max: 10 };
|
|
|
|
const botGenerationDetails: BotGenerationDetails = {
|
|
isPmc: false,
|
|
role: "",
|
|
side: "",
|
|
playerLevel: 5,
|
|
botRelativeLevelDeltaMax: 0,
|
|
botRelativeLevelDeltaMin: 0,
|
|
botCountToGenerate: 0,
|
|
botDifficulty: "",
|
|
isPlayerScav: false,
|
|
};
|
|
|
|
const result = botLevelGenerator.generateBotLevel(levelDetails, botGenerationDetails, null);
|
|
expect(result.level).greaterThan(0);
|
|
expect(result.level).lessThan(10);
|
|
});
|
|
});
|
|
|
|
describe("getHighestRelativeBotLevel", () =>
|
|
{
|
|
it("should return 10 when player level is 5 and delta is 5", () =>
|
|
{
|
|
const levelDetails: MinMax = { min: 5, max: 10 };
|
|
const botGenDetails: BotGenerationDetails = {
|
|
isPmc: false,
|
|
role: "",
|
|
side: "",
|
|
botRelativeLevelDeltaMax: 5,
|
|
botRelativeLevelDeltaMin: 5,
|
|
playerLevel: 5,
|
|
botCountToGenerate: 0,
|
|
botDifficulty: "",
|
|
isPlayerScav: false,
|
|
};
|
|
|
|
const result = botLevelGenerator.getHighestRelativeBotLevel(botGenDetails, levelDetails, 79);
|
|
|
|
expect(result).toBe(10);
|
|
});
|
|
|
|
it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () =>
|
|
{
|
|
const levelDetails: MinMax = { min: 100, max: 100 };
|
|
const botGenDetails: BotGenerationDetails = {
|
|
isPmc: false,
|
|
role: "",
|
|
side: "",
|
|
botRelativeLevelDeltaMax: 5,
|
|
botRelativeLevelDeltaMin: 5,
|
|
playerLevel: 100,
|
|
botCountToGenerate: 0,
|
|
botDifficulty: "",
|
|
isPlayerScav: false,
|
|
};
|
|
|
|
const result = botLevelGenerator.getHighestRelativeBotLevel(
|
|
botGenDetails,
|
|
levelDetails,
|
|
79,
|
|
);
|
|
|
|
expect(result).toBe(79);
|
|
});
|
|
});
|
|
});
|