Implement magazine template saving
This commit is contained in:
parent
2f3b2590d6
commit
8dc322180f
@ -1,4 +1,5 @@
|
|||||||
import { BuildController } from "@spt-aki/controllers/BuildController";
|
import { BuildController } from "@spt-aki/controllers/BuildController";
|
||||||
|
import { ISetMagazineRequest } from "@spt-aki/models/eft/builds/ISetMagazineRequest";
|
||||||
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
||||||
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
||||||
import { IUserBuilds } from "@spt-aki/models/eft/profile/IAkiProfile";
|
import { IUserBuilds } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||||
@ -27,9 +28,11 @@ export class BuildsCallbacks
|
|||||||
* Handle client/builds/magazine/save
|
* Handle client/builds/magazine/save
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
public setMagazine(url: string, info: IEmptyRequestData, sessionID: string): any
|
public createMagazineTemplate(url: string, request: ISetMagazineRequest, sessionID: string): IGetBodyResponseData<string>
|
||||||
{
|
{
|
||||||
throw new Error("Not implemented");
|
this.buildController.createMagazineTemplate(sessionID, request)
|
||||||
|
|
||||||
|
return this.httpResponse.emptyResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
|
||||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||||
|
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
|
||||||
|
import { ISetMagazineRequest } from "@spt-aki/models/eft/builds/ISetMagazineRequest";
|
||||||
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||||
import { IPresetBuildActionRequestData } from "@spt-aki/models/eft/presetBuild/IPresetBuildActionRequestData";
|
import { IPresetBuildActionRequestData } from "@spt-aki/models/eft/presetBuild/IPresetBuildActionRequestData";
|
||||||
import { IRemoveBuildRequestData } from "@spt-aki/models/eft/presetBuild/IRemoveBuildRequestData";
|
import { IRemoveBuildRequestData } from "@spt-aki/models/eft/presetBuild/IRemoveBuildRequestData";
|
||||||
import { IUserBuilds, IWeaponBuild } from "@spt-aki/models/eft/profile/IAkiProfile";
|
import { IMagazineBuild, IUserBuilds, IWeaponBuild } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
||||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
@ -22,6 +24,7 @@ export class BuildController
|
|||||||
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
|
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
|
||||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||||
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||||
@inject("SaveServer") protected saveServer: SaveServer,
|
@inject("SaveServer") protected saveServer: SaveServer,
|
||||||
)
|
)
|
||||||
@ -226,4 +229,20 @@ export class BuildController
|
|||||||
|
|
||||||
return this.eventOutputHolder.getOutput(sessionID);
|
return this.eventOutputHolder.getOutput(sessionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createMagazineTemplate(sessionId: string, request: ISetMagazineRequest): void
|
||||||
|
{
|
||||||
|
const result: IMagazineBuild = {
|
||||||
|
Id: request.Id,
|
||||||
|
Name: request.Name,
|
||||||
|
Caliber: request.Caliber,
|
||||||
|
TopCount: request.TopCount,
|
||||||
|
BottomCount: request.BottomCount,
|
||||||
|
Items: request.items,
|
||||||
|
type: "magazine"
|
||||||
|
};
|
||||||
|
|
||||||
|
const profile = this.profileHelper.getFullProfile(sessionId);
|
||||||
|
profile.userbuilds.magazineBuilds.push(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
|
|||||||
import { QuestHelper } from "@spt-aki/helpers/QuestHelper";
|
import { QuestHelper } from "@spt-aki/helpers/QuestHelper";
|
||||||
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
|
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
|
||||||
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||||
import { TemplateSide } from "@spt-aki/models/eft/common/tables/IProfileTemplate";
|
import { ITemplateSide } from "@spt-aki/models/eft/common/tables/IProfileTemplate";
|
||||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||||
import { IMiniProfile } from "@spt-aki/models/eft/launcher/IMiniProfile";
|
import { IMiniProfile } from "@spt-aki/models/eft/launcher/IMiniProfile";
|
||||||
import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData";
|
import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData";
|
||||||
@ -127,7 +127,7 @@ export class ProfileController
|
|||||||
public createProfile(info: IProfileCreateRequestData, sessionID: string): string
|
public createProfile(info: IProfileCreateRequestData, sessionID: string): string
|
||||||
{
|
{
|
||||||
const account = this.saveServer.getProfile(sessionID).info;
|
const account = this.saveServer.getProfile(sessionID).info;
|
||||||
const profile: TemplateSide =
|
const profile: ITemplateSide =
|
||||||
this.databaseServer.getTables().templates.profiles[account.edition][info.side.toLowerCase()];
|
this.databaseServer.getTables().templates.profiles[account.edition][info.side.toLowerCase()];
|
||||||
const pmcData = profile.character;
|
const pmcData = profile.character;
|
||||||
|
|
||||||
|
11
project/src/models/eft/builds/ISetMagazineRequest.ts
Normal file
11
project/src/models/eft/builds/ISetMagazineRequest.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { IMagazineTemplateAmmoItem } from "../profile/IAkiProfile"
|
||||||
|
|
||||||
|
export interface ISetMagazineRequest
|
||||||
|
{
|
||||||
|
Id: string
|
||||||
|
Name: string
|
||||||
|
Caliber: string
|
||||||
|
items: IMagazineTemplateAmmoItem[]
|
||||||
|
TopCount: number
|
||||||
|
BottomCount: number
|
||||||
|
}
|
@ -17,11 +17,11 @@ export interface IProfileTemplates
|
|||||||
export interface IProfileSides
|
export interface IProfileSides
|
||||||
{
|
{
|
||||||
descriptionLocaleKey: string;
|
descriptionLocaleKey: string;
|
||||||
usec: TemplateSide;
|
usec: ITemplateSide;
|
||||||
bear: TemplateSide;
|
bear: ITemplateSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TemplateSide
|
export interface ITemplateSide
|
||||||
{
|
{
|
||||||
character: IPmcData;
|
character: IPmcData;
|
||||||
suits: string[];
|
suits: string[];
|
||||||
|
@ -77,7 +77,19 @@ export interface IEquipmentBuild
|
|||||||
|
|
||||||
export interface IMagazineBuild
|
export interface IMagazineBuild
|
||||||
{
|
{
|
||||||
|
Id: string;
|
||||||
|
Name: string;
|
||||||
|
Caliber: string
|
||||||
|
TopCount: number
|
||||||
|
BottomCount: number
|
||||||
|
Items: IMagazineTemplateAmmoItem[]
|
||||||
|
type: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMagazineTemplateAmmoItem
|
||||||
|
{
|
||||||
|
TemplateId: string
|
||||||
|
Count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Dialogue
|
export interface Dialogue
|
||||||
|
@ -22,7 +22,7 @@ export class BuildsStaticRouter extends StaticRouter
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
(url: string, info: any, sessionID: string, output: string): any =>
|
(url: string, info: any, sessionID: string, output: string): any =>
|
||||||
{
|
{
|
||||||
return this.buildsCallbacks.setMagazine(url, info, sessionID);
|
return this.buildsCallbacks.createMagazineTemplate(url, info, sessionID);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
new RouteAction(
|
new RouteAction(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user