mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Added getTrader()
and utilise inside various classes
This commit is contained in:
parent
fdb7a2b7d8
commit
7cdac4e38b
@ -66,6 +66,7 @@
|
|||||||
"customisation-unable_to_find_suit_with_id": "Unable to find suit with offer id: %s",
|
"customisation-unable_to_find_suit_with_id": "Unable to find suit with offer id: %s",
|
||||||
"customisation-unable_to_get_trader_suits": "Unable to get suits from trader: %s",
|
"customisation-unable_to_get_trader_suits": "Unable to get suits from trader: %s",
|
||||||
"database-data_at_path_missing": "The database was unable to retreive data from: [%s] Please ensure your configs are valid and the data at the location exists",
|
"database-data_at_path_missing": "The database was unable to retreive data from: [%s] Please ensure your configs are valid and the data at the location exists",
|
||||||
|
"database-no_trader_found_with_id": "Unable to find trader: %s in database",
|
||||||
"dialog-chatbot_id_already_exists": "Chat bot: %s being registered already exists, unable to register bot",
|
"dialog-chatbot_id_already_exists": "Chat bot: %s being registered already exists, unable to register bot",
|
||||||
"dialog-missing_item_template": "Unable to find item tpl {{tpl}} in db, cannot send message of type {{type}}, skipping",
|
"dialog-missing_item_template": "Unable to find item tpl {{tpl}} in db, cannot send message of type {{type}}, skipping",
|
||||||
"dialogue-unable_to_find_dialogs_in_profile": "No dialog object in profile: {{sessionId}}",
|
"dialogue-unable_to_find_dialogs_in_profile": "No dialog object in profile: {{sessionId}}",
|
||||||
|
@ -39,7 +39,7 @@ export class CustomizationController
|
|||||||
{
|
{
|
||||||
const pmcData = this.profileHelper.getPmcProfile(sessionID);
|
const pmcData = this.profileHelper.getPmcProfile(sessionID);
|
||||||
const clothing = this.databaseService.getCustomization();
|
const clothing = this.databaseService.getCustomization();
|
||||||
const suits = this.databaseService.getTraders()[traderID].suits;
|
const suits = this.databaseService.getTrader(traderID).suits;
|
||||||
|
|
||||||
// Get an inner join of clothing from templates.customization and Ragman's suits array
|
// Get an inner join of clothing from templates.customization and Ragman's suits array
|
||||||
const matchingSuits = suits?.filter((suit) => suit.suiteId in clothing);
|
const matchingSuits = suits?.filter((suit) => suit.suiteId in clothing);
|
||||||
|
@ -675,7 +675,7 @@ export class InraidController
|
|||||||
const serverProfile = this.saveServer.getProfile(sessionId);
|
const serverProfile = this.saveServer.getProfile(sessionId);
|
||||||
const pmcData = serverProfile.characters.pmc;
|
const pmcData = serverProfile.characters.pmc;
|
||||||
|
|
||||||
const dialogueTemplates = this.databaseService.getTraders()[traderId].dialogue;
|
const dialogueTemplates = this.databaseService.getTrader(traderId).dialogue;
|
||||||
if (!dialogueTemplates)
|
if (!dialogueTemplates)
|
||||||
{
|
{
|
||||||
this.logger.error(this.localisationService.getText("inraid-unable_to_deliver_item_no_trader_found", traderId));
|
this.logger.error(this.localisationService.getText("inraid-unable_to_deliver_item_no_trader_found", traderId));
|
||||||
|
@ -586,7 +586,7 @@ export class InsuranceController
|
|||||||
const labsId = "laboratory";
|
const labsId = "laboratory";
|
||||||
// After all of the item filtering that we've done, if there are no items remaining, the insurance has
|
// After all of the item filtering that we've done, if there are no items remaining, the insurance has
|
||||||
// successfully "failed" to return anything and an appropriate message should be sent to the player.
|
// successfully "failed" to return anything and an appropriate message should be sent to the player.
|
||||||
const traderDialogMessages = this.databaseServer.getTraders()[insurance.traderId].dialogue;
|
const traderDialogMessages = this.databaseServer.getTrader(insurance.traderId).dialogue;
|
||||||
|
|
||||||
// Map is labs + insurance is disabled in base.json
|
// Map is labs + insurance is disabled in base.json
|
||||||
if (
|
if (
|
||||||
|
@ -724,7 +724,7 @@ export class InventoryController
|
|||||||
{
|
{
|
||||||
// Not fence
|
// Not fence
|
||||||
// get tpl from trader assort
|
// get tpl from trader assort
|
||||||
return this.databaseService.getTraders()[request.fromOwner.id].assort.items
|
return this.databaseService.getTrader(request.fromOwner.id).assort.items
|
||||||
.find((item) => item._id === request.item)._tpl;
|
.find((item) => item._id === request.item)._tpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ export class TradeController
|
|||||||
sessionId,
|
sessionId,
|
||||||
this.traderHelper.getTraderById(trader),
|
this.traderHelper.getTraderById(trader),
|
||||||
MessageType.MESSAGE_WITH_ITEMS,
|
MessageType.MESSAGE_WITH_ITEMS,
|
||||||
this.randomUtil.getArrayValue(this.databaseService.getTraders()[trader].dialogue.soldItems),
|
this.randomUtil.getArrayValue(this.databaseService.getTrader(trader).dialogue.soldItems),
|
||||||
curencyReward.flatMap((x) => x),
|
curencyReward.flatMap((x) => x),
|
||||||
this.timeUtil.getHoursAsSeconds(72),
|
this.timeUtil.getHoursAsSeconds(72),
|
||||||
);
|
);
|
||||||
|
@ -263,4 +263,21 @@ export class DatabaseService
|
|||||||
|
|
||||||
return this.databaseServer.getTables().traders!;
|
return this.databaseServer.getTables().traders!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get specific trader by their Id
|
||||||
|
* @param traderId Desired trader id
|
||||||
|
* @returns assets/database/traders/
|
||||||
|
*/
|
||||||
|
public getTrader(traderId: string): ITrader
|
||||||
|
{
|
||||||
|
const traders = this.getTraders();
|
||||||
|
const desiredTrader = traders[traderId];
|
||||||
|
if (!desiredTrader)
|
||||||
|
{
|
||||||
|
throw new error(this.localisationService.getText("database-no_trader_found_with_id", traderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return desiredTrader!;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user