2023-03-11 18:38:20 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
2023-10-19 19:21:17 +02:00
|
|
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
|
|
|
import { Money } from "@spt-aki/models/enums/Money";
|
|
|
|
import { IInventoryConfig } from "@spt-aki/models/spt/config/IInventoryConfig";
|
|
|
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class PaymentHelper
|
|
|
|
{
|
2023-03-11 18:38:20 +01:00
|
|
|
protected inventoryConfig: IInventoryConfig;
|
|
|
|
|
2023-11-16 02:35:05 +01:00
|
|
|
constructor(@inject("ConfigServer") protected configServer: ConfigServer)
|
2023-03-11 18:38:20 +01:00
|
|
|
{
|
|
|
|
this.inventoryConfig = this.configServer.getConfig(ConfigTypes.INVENTORY);
|
|
|
|
}
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
/**
|
2023-03-11 18:38:20 +01:00
|
|
|
* Is the passed in tpl money (also checks custom currencies in inventoryConfig.customMoneyTpls)
|
2023-03-03 16:23:46 +01:00
|
|
|
* @param {string} tpl
|
|
|
|
* @returns void
|
|
|
|
*/
|
|
|
|
public isMoneyTpl(tpl: string): boolean
|
|
|
|
{
|
2023-11-16 02:35:05 +01:00
|
|
|
return [Money.DOLLARS, Money.EUROS, Money.ROUBLES, ...this.inventoryConfig.customMoneyTpls].some((element) =>
|
|
|
|
element === tpl
|
|
|
|
);
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-11-16 02:35:05 +01:00
|
|
|
* Gets currency TPL from TAG
|
|
|
|
* @param {string} currency
|
|
|
|
* @returns string
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public getCurrency(currency: string): string
|
|
|
|
{
|
|
|
|
switch (currency)
|
|
|
|
{
|
|
|
|
case "EUR":
|
|
|
|
return Money.EUROS;
|
|
|
|
case "USD":
|
|
|
|
return Money.DOLLARS;
|
|
|
|
case "RUB":
|
|
|
|
return Money.ROUBLES;
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
2023-11-16 02:35:05 +01:00
|
|
|
}
|