Feature: Allow modders to define custom currencies (!62)

https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/11
Co-authored-by: Dev <dev@noreply.dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/62
This commit is contained in:
chomp 2023-03-11 17:38:20 +00:00
parent 900555fa0b
commit 00e367ffa5
3 changed files with 19 additions and 5 deletions

View File

@ -18,5 +18,6 @@
"544fb6cc4bdc2d34748b456e": 1
}
}
}
},
"customMoneyTpls": []
}

View File

@ -1,19 +1,30 @@
import { injectable } from "tsyringe";
import { inject, injectable } from "tsyringe";
import { ConfigTypes } from "../models/enums/ConfigTypes";
import { Money } from "../models/enums/Money";
import { IInventoryConfig } from "../models/spt/config/IInventoryConfig";
import { ConfigServer } from "../servers/ConfigServer";
@injectable()
export class PaymentHelper
{
protected inventoryConfig: IInventoryConfig;
constructor(
@inject("ConfigServer") protected configServer: ConfigServer
)
{
this.inventoryConfig = this.configServer.getConfig(ConfigTypes.INVENTORY);
}
/**
* Check whether tpl is Money
* 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].some(element => element === tpl);
return [Money.DOLLARS, Money.EUROS, Money.ROUBLES, ...this.inventoryConfig.customMoneyTpls].some(element => element === tpl);
}
/**

View File

@ -1,10 +1,12 @@
import { IBaseConfig } from "./IBaseConfig"
import { IBaseConfig } from "./IBaseConfig";
export interface IInventoryConfig extends IBaseConfig
{
kind: "aki-inventory"
newItemsMarkedFound: boolean
randomLootContainers: Record<string, RewardDetails>
/** Contains item tpls that the server should consider money and treat the same as roubles/euros/dollars */
customMoneyTpls: string[]
}
export interface RewardDetails