50c7a26a58
This is the first pass of ESLint on the codebase. ESLint formatting is less strict when it comes to line-length and line-breaks then dprint/biome, so if you see formatting that you don't like... fix it! It shouldn't require a configuration change. - This should merge clean into master (when the time comes). - This will not merge clean into `3.9.0-DEV`, but the conflicts aren't that bad.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { inject, injectable } from "tsyringe";
|
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
|
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
|
import { IWishlistActionData } from "@spt-aki/models/eft/wishlist/IWishlistActionData";
|
|
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
|
|
|
@injectable()
|
|
export class WishlistController
|
|
{
|
|
constructor(@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder)
|
|
{}
|
|
|
|
/** Handle AddToWishList */
|
|
public addToWishList(pmcData: IPmcData, body: IWishlistActionData, sessionID: string): IItemEventRouterResponse
|
|
{
|
|
for (const item in pmcData.WishList)
|
|
{
|
|
// Don't add the item
|
|
if (pmcData.WishList[item] === body.templateId)
|
|
{
|
|
return this.eventOutputHolder.getOutput(sessionID);
|
|
}
|
|
}
|
|
|
|
// add the item to the wishlist
|
|
pmcData.WishList.push(body.templateId);
|
|
return this.eventOutputHolder.getOutput(sessionID);
|
|
}
|
|
|
|
/** Handle RemoveFromWishList event */
|
|
public removeFromWishList(pmcData: IPmcData, body: IWishlistActionData, sessionID: string): IItemEventRouterResponse
|
|
{
|
|
for (let i = 0; i < pmcData.WishList.length; i++)
|
|
{
|
|
if (pmcData.WishList[i] === body.templateId)
|
|
{
|
|
pmcData.WishList.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
return this.eventOutputHolder.getOutput(sessionID);
|
|
}
|
|
}
|