mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 22:10:44 -05:00
Updated bot tests
This commit is contained in:
parent
9e9baf49b3
commit
79f0949610
@ -66,9 +66,9 @@ export class BotLevelGenerator {
|
||||
const minPossibleLevel =
|
||||
botGenerationDetails.isPmc && botGenerationDetails.locationSpecificPmcLevelOverride
|
||||
? Math.min(
|
||||
Math.max(levelDetails.min, botGenerationDetails.locationSpecificPmcLevelOverride.min), // Biggest between json min and the botgen min
|
||||
maxAvailableLevel, // Fallback if value above is crazy (default is 79)
|
||||
)
|
||||
Math.max(levelDetails.min, botGenerationDetails.locationSpecificPmcLevelOverride.min), // Biggest between json min and the botgen min
|
||||
maxAvailableLevel, // Fallback if value above is crazy (default is 79)
|
||||
)
|
||||
: Math.min(levelDetails.min, maxAvailableLevel); // Not pmc with override or non-pmc
|
||||
|
||||
const maxPossibleLevel =
|
||||
@ -86,6 +86,6 @@ export class BotLevelGenerator {
|
||||
return {
|
||||
min: minLevel,
|
||||
max: maxLevel,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,14 @@ import "reflect-metadata";
|
||||
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";
|
||||
import { container } from "tsyringe";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("BotLevelGenerator", () => {
|
||||
let botLevelGenerator: any;
|
||||
let databaseServer: DatabaseServer;
|
||||
let botLevelGenerator: BotLevelGenerator;
|
||||
|
||||
beforeEach(() => {
|
||||
botLevelGenerator = container.resolve<BotLevelGenerator>("BotLevelGenerator");
|
||||
databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -42,22 +39,45 @@ describe("BotLevelGenerator", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("chooseBotLevel", () => {
|
||||
describe("getRelativeBotLevelRange", () => {
|
||||
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.chooseBotLevel(levelDetails.min, levelDetails.max, 1, 1.15);
|
||||
// @ts-expect-error
|
||||
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
|
||||
|
||||
expect(result).greaterThanOrEqual(5);
|
||||
expect(result).lessThanOrEqual(10);
|
||||
expect(result.max).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.chooseBotLevel(levelDetails.min, levelDetails.max, 1, 1.15);
|
||||
// @ts-expect-error
|
||||
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
|
||||
|
||||
expect(result).toBe(100);
|
||||
expect(result.max).toBe(79);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user