2023-11-05 10:20:11 +01:00
|
|
|
import "reflect-metadata";
|
2024-05-21 19:59:04 +02:00
|
|
|
|
2023-11-05 10:20:11 +01:00
|
|
|
import { container } from "tsyringe";
|
2023-11-10 23:21:20 +01:00
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-05-21 19:59:04 +02:00
|
|
|
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";
|
2023-11-05 10:20:11 +01:00
|
|
|
|
|
|
|
describe("BotLevelGenerator", () =>
|
|
|
|
{
|
|
|
|
let botLevelGenerator: any;
|
|
|
|
let databaseServer: DatabaseServer;
|
|
|
|
|
2023-11-06 20:39:12 +01:00
|
|
|
beforeEach(() =>
|
2023-11-05 10:20:11 +01:00
|
|
|
{
|
|
|
|
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", () =>
|
|
|
|
{
|
2023-11-13 18:38:16 +01:00
|
|
|
const levelDetails: MinMax = { min: 5, max: 10 };
|
2023-11-05 10:20:11 +01:00
|
|
|
|
|
|
|
const botGenerationDetails: BotGenerationDetails = {
|
|
|
|
isPmc: false,
|
|
|
|
role: "",
|
|
|
|
side: "",
|
|
|
|
playerLevel: 5,
|
|
|
|
botRelativeLevelDeltaMax: 0,
|
2024-04-15 09:59:33 +02:00
|
|
|
botRelativeLevelDeltaMin: 0,
|
2023-11-05 10:20:11 +01:00
|
|
|
botCountToGenerate: 0,
|
|
|
|
botDifficulty: "",
|
2023-11-10 23:21:20 +01:00
|
|
|
isPlayerScav: false,
|
2023-11-05 10:20:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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", () =>
|
|
|
|
{
|
2023-11-13 18:38:16 +01:00
|
|
|
const levelDetails: MinMax = { min: 5, max: 10 };
|
2024-05-13 23:41:34 +02:00
|
|
|
const botGenDetails: BotGenerationDetails = {
|
|
|
|
isPmc: false,
|
|
|
|
role: "",
|
|
|
|
side: "",
|
|
|
|
botRelativeLevelDeltaMax: 5,
|
|
|
|
botRelativeLevelDeltaMin: 5,
|
|
|
|
playerLevel: 5,
|
|
|
|
botCountToGenerate: 0,
|
|
|
|
botDifficulty: "",
|
2024-05-21 19:59:04 +02:00
|
|
|
isPlayerScav: false,
|
2024-05-13 23:41:34 +02:00
|
|
|
};
|
2023-11-05 10:20:11 +01:00
|
|
|
|
2024-05-13 23:41:34 +02:00
|
|
|
const result = botLevelGenerator.getHighestRelativeBotLevel(botGenDetails, levelDetails, 79);
|
2023-11-05 10:20:11 +01:00
|
|
|
|
|
|
|
expect(result).toBe(10);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () =>
|
|
|
|
{
|
2023-11-13 18:38:16 +01:00
|
|
|
const levelDetails: MinMax = { min: 100, max: 100 };
|
2024-05-13 23:41:34 +02:00
|
|
|
const botGenDetails: BotGenerationDetails = {
|
|
|
|
isPmc: false,
|
|
|
|
role: "",
|
|
|
|
side: "",
|
|
|
|
botRelativeLevelDeltaMax: 5,
|
|
|
|
botRelativeLevelDeltaMin: 5,
|
|
|
|
playerLevel: 100,
|
|
|
|
botCountToGenerate: 0,
|
|
|
|
botDifficulty: "",
|
2024-05-21 19:59:04 +02:00
|
|
|
isPlayerScav: false,
|
2024-05-13 23:41:34 +02:00
|
|
|
};
|
2023-11-05 10:20:11 +01:00
|
|
|
|
2023-11-10 23:21:20 +01:00
|
|
|
const result = botLevelGenerator.getHighestRelativeBotLevel(
|
2024-05-13 23:41:34 +02:00
|
|
|
botGenDetails,
|
2023-11-10 23:21:20 +01:00
|
|
|
levelDetails,
|
2024-05-21 19:59:04 +02:00
|
|
|
79,
|
2023-11-10 23:21:20 +01:00
|
|
|
);
|
2023-11-05 10:20:11 +01:00
|
|
|
|
|
|
|
expect(result).toBe(79);
|
|
|
|
});
|
|
|
|
});
|
2023-11-06 20:39:12 +01:00
|
|
|
});
|