0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00
server/project/src/helpers/PaymentHelper.ts
IsaacSin 58ee2c66d3 Fix GP coin ragfair offers being excluded by "Exclude bartering offers" filter. (!363)
BSG now considers GP coin to be a currency.
Commit 4788f6b407 (diff-d1c96eaf446b0afaf70c62191c7a688471fca50c) already added GP coin to the `Money` enum, but it needs to be added to `PaymentHelper.isMoneyTpl()` to prevent it from being filtered by the barter filter as with other money offers.
See attached screenshots for a demonstration of SPT vs live behavior.

Reviewed-on: SPT/Server#363
Co-authored-by: IsaacSin <Isaacgsds@gmail.com>
Co-committed-by: IsaacSin <Isaacgsds@gmail.com>
2024-06-13 13:28:37 +00:00

51 lines
1.4 KiB
TypeScript

import { inject, injectable } from "tsyringe";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { Money } from "@spt/models/enums/Money";
import { IInventoryConfig } from "@spt/models/spt/config/IInventoryConfig";
import { ConfigServer } from "@spt/servers/ConfigServer";
@injectable()
export class PaymentHelper
{
protected inventoryConfig: IInventoryConfig;
constructor(@inject("ConfigServer") protected configServer: ConfigServer)
{
this.inventoryConfig = this.configServer.getConfig(ConfigTypes.INVENTORY);
}
/**
* Is the passed in tpl money (also checks custom currencies in inventoryConfig.customMoneyTpls)
* @param {string} tpl
* @returns void
*/
public isMoneyTpl(tpl: string): boolean
{
return [Money.DOLLARS, Money.EUROS, Money.ROUBLES, Money.GP, ...this.inventoryConfig.customMoneyTpls].some(
(element) => element === tpl,
);
}
/**
* Gets currency TPL from TAG
* @param {string} currency
* @returns string
*/
public getCurrency(currency: string): string
{
switch (currency)
{
case "EUR":
return Money.EUROS;
case "USD":
return Money.DOLLARS;
case "RUB":
return Money.ROUBLES;
case "GP":
return Money.GP;
default:
return "";
}
}
}