2024-05-21 17:59:04 +00:00
|
|
|
import { ApplicationContext } from "@spt/context/ApplicationContext";
|
|
|
|
import { ContextVariableType } from "@spt/context/ContextVariableType";
|
2024-07-06 14:36:48 +01:00
|
|
|
import { IEndLocalRaidRequestData } from "@spt/models/eft/match/IEndLocalRaidRequestData";
|
2024-05-21 17:59:04 +00:00
|
|
|
import { IGetRaidConfigurationRequestData } from "@spt/models/eft/match/IGetRaidConfigurationRequestData";
|
|
|
|
import { IMatchGroupStartGameRequest } from "@spt/models/eft/match/IMatchGroupStartGameRequest";
|
|
|
|
import { IMatchGroupStatusRequest } from "@spt/models/eft/match/IMatchGroupStatusRequest";
|
|
|
|
import { IMatchGroupStatusResponse } from "@spt/models/eft/match/IMatchGroupStatusResponse";
|
|
|
|
import { IProfileStatusResponse } from "@spt/models/eft/match/IProfileStatusResponse";
|
2024-07-04 21:01:37 +01:00
|
|
|
import { IStartLocalRaidRequestData } from "@spt/models/eft/match/IStartLocalRaidRequestData";
|
|
|
|
import { IStartLocalRaidResponseData } from "@spt/models/eft/match/IStartLocalRaidResponseData";
|
2024-05-21 17:59:04 +00:00
|
|
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
|
|
|
import { IMatchConfig } from "@spt/models/spt/config/IMatchConfig";
|
|
|
|
import { IPmcConfig } from "@spt/models/spt/config/IPmcConfig";
|
|
|
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
|
|
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
|
|
|
import { SaveServer } from "@spt/servers/SaveServer";
|
2024-07-06 14:36:48 +01:00
|
|
|
import { LocationLifecycleService } from "@spt/services/LocationLifecycleService";
|
2024-05-21 17:59:04 +00:00
|
|
|
import { MatchLocationService } from "@spt/services/MatchLocationService";
|
|
|
|
import { ProfileSnapshotService } from "@spt/services/ProfileSnapshotService";
|
2024-07-06 14:04:51 +01:00
|
|
|
import { ICloner } from "@spt/utils/cloners/ICloner";
|
2024-07-23 11:12:53 -04:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
@injectable()
|
2024-07-23 11:12:53 -04:00
|
|
|
export class MatchController {
|
2023-03-03 15:23:46 +00:00
|
|
|
protected matchConfig: IMatchConfig;
|
2023-10-10 11:03:20 +00:00
|
|
|
protected pmcConfig: IPmcConfig;
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
constructor(
|
2024-05-28 14:04:20 +00:00
|
|
|
@inject("PrimaryLogger") protected logger: ILogger,
|
2023-03-03 15:23:46 +00:00
|
|
|
@inject("SaveServer") protected saveServer: SaveServer,
|
|
|
|
@inject("MatchLocationService") protected matchLocationService: MatchLocationService,
|
|
|
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
|
|
|
@inject("ProfileSnapshotService") protected profileSnapshotService: ProfileSnapshotService,
|
2023-11-16 21:42:06 +00:00
|
|
|
@inject("ApplicationContext") protected applicationContext: ApplicationContext,
|
2024-07-06 14:36:48 +01:00
|
|
|
@inject("LocationLifecycleService") protected locationLifecycleService: LocationLifecycleService,
|
2024-07-06 14:04:51 +01:00
|
|
|
@inject("PrimaryCloner") protected cloner: ICloner,
|
2024-07-23 11:12:53 -04:00
|
|
|
) {
|
2023-03-03 15:23:46 +00:00
|
|
|
this.matchConfig = this.configServer.getConfig(ConfigTypes.MATCH);
|
2023-10-10 11:03:20 +00:00
|
|
|
this.pmcConfig = this.configServer.getConfig(ConfigTypes.PMC);
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 11:12:53 -04:00
|
|
|
public getEnabled(): boolean {
|
2023-03-03 15:23:46 +00:00
|
|
|
return this.matchConfig.enabled;
|
|
|
|
}
|
|
|
|
|
2023-07-15 14:49:25 +01:00
|
|
|
/** Handle client/match/group/delete */
|
2024-07-23 11:12:53 -04:00
|
|
|
public deleteGroup(info: any): void {
|
2023-03-03 15:23:46 +00:00
|
|
|
this.matchLocationService.deleteGroup(info);
|
|
|
|
}
|
|
|
|
|
2023-07-15 14:49:25 +01:00
|
|
|
/** Handle match/group/start_game */
|
2024-07-23 11:12:53 -04:00
|
|
|
public joinMatch(info: IMatchGroupStartGameRequest, sessionId: string): IProfileStatusResponse {
|
2024-05-15 23:40:32 +01:00
|
|
|
const output: IProfileStatusResponse = { maxPveCountExceeded: false, profiles: [] };
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
// get list of players joining into the match
|
2023-05-20 18:37:39 +01:00
|
|
|
output.profiles.push({
|
2023-11-16 21:42:06 +00:00
|
|
|
profileid: "TODO",
|
2023-05-20 18:37:39 +01:00
|
|
|
profileToken: "TODO",
|
2023-11-16 21:42:06 +00:00
|
|
|
status: "MatchWait",
|
|
|
|
sid: "",
|
|
|
|
ip: "",
|
|
|
|
port: 0,
|
|
|
|
version: "live",
|
|
|
|
location: "TODO get location",
|
2023-03-03 15:23:46 +00:00
|
|
|
raidMode: "Online",
|
2023-11-16 21:42:06 +00:00
|
|
|
mode: "deathmatch",
|
2024-05-27 20:06:07 +00:00
|
|
|
shortId: undefined,
|
|
|
|
additional_info: undefined,
|
2023-03-03 15:23:46 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2023-07-15 14:49:25 +01:00
|
|
|
/** Handle client/match/group/status */
|
2024-07-23 11:12:53 -04:00
|
|
|
public getGroupStatus(info: IMatchGroupStatusRequest): IMatchGroupStatusResponse {
|
2023-11-16 21:42:06 +00:00
|
|
|
return { players: [], maxPveCountExceeded: false };
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle /client/raid/configuration
|
2023-07-15 14:49:25 +01:00
|
|
|
* @param request Raid config request
|
|
|
|
* @param sessionID Session id
|
2023-03-03 15:23:46 +00:00
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
public configureOfflineRaid(request: IGetRaidConfigurationRequestData, sessionID: string): void {
|
2023-07-15 14:49:25 +01:00
|
|
|
// Store request data for access during bot generation
|
2023-03-03 15:23:46 +00:00
|
|
|
this.applicationContext.addValue(ContextVariableType.RAID_CONFIGURATION, request);
|
|
|
|
|
2023-11-16 21:42:06 +00:00
|
|
|
// TODO: add code to strip PMC of equipment now they've started the raid
|
2023-03-03 15:23:46 +00:00
|
|
|
|
|
|
|
// Set pmcs to difficulty set in pre-raid screen if override in bot config isnt enabled
|
2024-07-23 11:12:53 -04:00
|
|
|
if (!this.pmcConfig.useDifficultyOverride) {
|
2023-11-16 21:42:06 +00:00
|
|
|
this.pmcConfig.difficulty = this.convertDifficultyDropdownIntoBotDifficulty(
|
|
|
|
request.wavesSettings.botDifficulty,
|
|
|
|
);
|
2023-03-03 15:23:46 +00:00
|
|
|
}
|
|
|
|
|
2023-11-16 21:42:06 +00:00
|
|
|
// Store the profile as-is for later use on the post-raid exp screen
|
2023-03-03 15:23:46 +00:00
|
|
|
const currentProfile = this.saveServer.getProfile(sessionID);
|
|
|
|
this.profileSnapshotService.storeProfileSnapshot(sessionID, currentProfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a difficulty value from pre-raid screen to a bot difficulty
|
|
|
|
* @param botDifficulty dropdown difficulty value
|
|
|
|
* @returns bot difficulty
|
|
|
|
*/
|
2024-07-23 11:12:53 -04:00
|
|
|
protected convertDifficultyDropdownIntoBotDifficulty(botDifficulty: string): string {
|
2023-03-03 15:23:46 +00:00
|
|
|
// Edge case medium - must be altered
|
2024-07-23 11:12:53 -04:00
|
|
|
if (botDifficulty.toLowerCase() === "medium") {
|
2023-03-03 15:23:46 +00:00
|
|
|
return "normal";
|
|
|
|
}
|
|
|
|
|
|
|
|
return botDifficulty;
|
|
|
|
}
|
|
|
|
|
2024-07-11 09:45:59 +01:00
|
|
|
/** Handle client/match/local/start */
|
2024-07-23 11:12:53 -04:00
|
|
|
public startLocalRaid(sessionId: string, request: IStartLocalRaidRequestData): IStartLocalRaidResponseData {
|
2024-07-06 14:36:48 +01:00
|
|
|
return this.locationLifecycleService.startLocalRaid(sessionId, request);
|
2024-07-06 14:04:51 +01:00
|
|
|
}
|
|
|
|
|
2024-07-11 09:45:59 +01:00
|
|
|
/** Handle client/match/local/end */
|
2024-07-23 11:12:53 -04:00
|
|
|
public endLocalRaid(sessionId: string, request: IEndLocalRaidRequestData): void {
|
2024-07-23 17:30:20 +01:00
|
|
|
this.locationLifecycleService.endLocalRaid(sessionId, request);
|
2024-07-04 21:01:37 +01:00
|
|
|
}
|
2023-11-16 21:42:06 +00:00
|
|
|
}
|