Server/project/src/helpers/PaymentHelper.ts
TheSparta 418d9f2a8f Import path alias on the whole project (!157)
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-19 17:21:17 +00:00

49 lines
1.4 KiB
TypeScript

import { inject, injectable } from "tsyringe";
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";
@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, ...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;
default:
return "";
}
}
}