2023-11-05 11:49:20 +01:00
|
|
|
import "reflect-metadata";
|
|
|
|
import { container } from "tsyringe";
|
2023-11-10 23:21:20 +01:00
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2023-11-06 20:39:12 +01:00
|
|
|
|
|
|
|
import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper";
|
|
|
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
describe("InRaidHelper", () =>
|
|
|
|
{
|
|
|
|
let inraidHelper: any;
|
|
|
|
|
2023-11-06 20:39:12 +01:00
|
|
|
beforeEach(() =>
|
2023-11-05 11:49:20 +01:00
|
|
|
{
|
|
|
|
inraidHelper = container.resolve<InRaidHelper>("InRaidHelper");
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() =>
|
|
|
|
{
|
|
|
|
vi.restoreAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("calculateFenceStandingChangeFromKills", () =>
|
|
|
|
{
|
|
|
|
it("should return negative value when player kills 2 scavs as scav", () =>
|
|
|
|
{
|
|
|
|
const fenceStanding = 0;
|
2023-11-13 18:38:16 +01:00
|
|
|
const postRaidPlayerVictims = [{ Side: "Savage", Role: "assault" }, { Side: "Savage", Role: "assault" }]; // Kills
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
|
|
|
const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill;
|
|
|
|
|
|
|
|
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
|
|
|
|
expect(result).toBe(scavStandingChangeOnKill * postRaidPlayerVictims.length); // Scav rep loss times number of scav kills
|
|
|
|
expect(result).lessThan(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return positive value when player kills 2 PMCs of different sides as scav", () =>
|
|
|
|
{
|
|
|
|
const fenceStanding = 0;
|
2023-11-13 18:38:16 +01:00
|
|
|
const postRaidPlayerVictims = [{ Side: "Usec", Role: "sptUsec" }, { Side: "Bear", Role: "sptBear" }]; // Kills
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
|
|
|
const bearStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill;
|
|
|
|
const usecStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill;
|
|
|
|
|
|
|
|
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
|
|
|
|
expect(result).toBe(bearStandingChangeOnKill + usecStandingChangeOnKill);
|
|
|
|
expect(result).greaterThan(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return negative value when player kills 1 PMC, 1 boss and 2 scavs as scav", () =>
|
|
|
|
{
|
|
|
|
const fenceStanding = 0;
|
2023-11-13 18:38:16 +01:00
|
|
|
const postRaidPlayerVictims = [{ Side: "Usec", Role: "sptUsec" }, { Side: "savage", Role: "assault" }, {
|
2023-11-13 18:31:52 +01:00
|
|
|
Side: "savage",
|
|
|
|
Role: "bossBoar",
|
2023-11-13 18:38:16 +01:00
|
|
|
}, { Side: "savage", Role: "assault" }]; // Kills
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
|
|
|
const usecStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill;
|
|
|
|
const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill;
|
2023-11-10 23:21:20 +01:00
|
|
|
const bossBoarStandingChangeOnKill =
|
|
|
|
databaseServer.getTables().bots.types.bossboar.experience.standingForKill;
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
|
2023-11-10 23:21:20 +01:00
|
|
|
expect(result).toBe(
|
|
|
|
usecStandingChangeOnKill + (scavStandingChangeOnKill * 2) + bossBoarStandingChangeOnKill,
|
|
|
|
);
|
2023-11-05 11:49:20 +01:00
|
|
|
expect(result).lessThan(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 0 when player kills bot with undefined standing as scav", () =>
|
|
|
|
{
|
|
|
|
const fenceStanding = 0;
|
2023-11-13 18:38:16 +01:00
|
|
|
const postRaidPlayerVictims = [{ Side: "savage", Role: "testRole" }]; // Kills
|
2023-11-05 11:49:20 +01:00
|
|
|
|
|
|
|
// Fake getFenceStandingChangeForKillAsScav() returning null
|
2023-11-10 23:21:20 +01:00
|
|
|
vi.spyOn(inraidHelper, "getFenceStandingChangeForKillAsScav").mockReturnValueOnce(null).mockReturnValueOnce(
|
|
|
|
null,
|
|
|
|
);
|
2023-11-05 11:49:20 +01:00
|
|
|
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
|
|
|
|
expect(result).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
2023-11-06 20:39:12 +01:00
|
|
|
});
|