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.
49 lines
1.4 KiB
TypeScript
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 "";
|
|
}
|
|
}
|
|
}
|