Migrate ragfair returnItems() to use new mail send service
Some renames + comments
This commit is contained in:
parent
3526b2764a
commit
f2caff3c70
@ -14,6 +14,7 @@ import { DatabaseServer } from "../servers/DatabaseServer";
|
||||
import { SaveServer } from "../servers/SaveServer";
|
||||
import { ItemFilterService } from "../services/ItemFilterService";
|
||||
import { LocaleService } from "../services/LocaleService";
|
||||
import { MailSendService } from "../services/MailSendService";
|
||||
import { HashUtil } from "../utils/HashUtil";
|
||||
import { JsonUtil } from "../utils/JsonUtil";
|
||||
import { RandomUtil } from "../utils/RandomUtil";
|
||||
@ -41,6 +42,7 @@ export class RagfairServerHelper
|
||||
@inject("LocaleService") protected localeService: LocaleService,
|
||||
@inject("DialogueHelper") protected dialogueHelper: DialogueHelper,
|
||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||
@inject("MailSendService") protected mailSendService: MailSendService,
|
||||
@inject("ItemFilterService") protected itemFilterService: ItemFilterService,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer
|
||||
)
|
||||
@ -77,7 +79,7 @@ export class RagfairServerHelper
|
||||
}
|
||||
|
||||
// Skip custom blacklisted items
|
||||
if (this.isItemBlacklisted(itemDetails[1]._id))
|
||||
if (this.isItemOnCustomFleaBlacklist(itemDetails[1]._id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -97,7 +99,12 @@ export class RagfairServerHelper
|
||||
return true;
|
||||
}
|
||||
|
||||
protected isItemBlacklisted(itemTemplateId: string): boolean
|
||||
/**
|
||||
* Is supplied item tpl on the ragfair custom blacklist from configs/ragfair.json/dynamic
|
||||
* @param itemTemplateId Item tpl to check is blacklisted
|
||||
* @returns True if its blacklsited
|
||||
*/
|
||||
protected isItemOnCustomBlacklist(itemTemplateId: string): boolean
|
||||
{
|
||||
if (!this.itemHelper.isValidItem(itemTemplateId))
|
||||
{
|
||||
@ -107,27 +114,51 @@ export class RagfairServerHelper
|
||||
return this.ragfairConfig.dynamic.blacklist.custom.includes(itemTemplateId);
|
||||
}
|
||||
|
||||
public isTrader(userID: string): boolean
|
||||
/**
|
||||
* is supplied id a trader
|
||||
* @param traderId
|
||||
* @returns True if id was a trader
|
||||
*/
|
||||
public isTrader(traderId: string): boolean
|
||||
{
|
||||
return userID in this.databaseServer.getTables().traders;
|
||||
return traderId in this.databaseServer.getTables().traders;
|
||||
}
|
||||
|
||||
public isPlayer(userID: string): boolean
|
||||
/**
|
||||
* Is this user id the logged in player
|
||||
* @param userId Id to test
|
||||
* @returns True is the current player
|
||||
*/
|
||||
public isPlayer(userId: string): boolean
|
||||
{
|
||||
if (this.profileHelper.getPmcProfile(userID) !== undefined)
|
||||
if (this.profileHelper.getPmcProfile(userId) !== undefined)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public returnItems(sessionID: string, items: Item[]): void
|
||||
/**
|
||||
* Send items back to player
|
||||
* @param sessionID Player to send items to
|
||||
* @param returnedItems Items to send to player
|
||||
*/
|
||||
public returnItems(sessionID: string, returnedItems: Item[]): void
|
||||
{
|
||||
const messageContent = this.dialogueHelper.createMessageContext(undefined, MessageType.MESSAGE_WITH_ITEMS, this.questConfig.redeemTime);
|
||||
const locale = this.localeService.getLocaleDb();
|
||||
messageContent.text = locale[RagfairServerHelper.goodsReturnedTemplate];
|
||||
//const messageContent = this.dialogueHelper.createMessageContext(undefined, MessageType.MESSAGE_WITH_ITEMS, this.questConfig.redeemTime);
|
||||
//const locale = this.localeService.getLocaleDb();
|
||||
//messageContent.text = locale[RagfairServerHelper.goodsReturnedTemplate];
|
||||
|
||||
this.dialogueHelper.addDialogueMessage(Traders.RAGMAN, messageContent, sessionID, items);
|
||||
//this.dialogueHelper.addDialogueMessage(Traders.RAGMAN, messageContent, sessionID, returnedItems);
|
||||
|
||||
this.mailSendService.sendLocalisedNpcMessageToPlayer(
|
||||
sessionID,
|
||||
Traders.RAGMAN,
|
||||
MessageType.MESSAGE_WITH_ITEMS,
|
||||
this.localeService.getLocaleDb()[RagfairServerHelper.goodsReturnedTemplate],
|
||||
returnedItems,
|
||||
this.questConfig.redeemTime
|
||||
);
|
||||
}
|
||||
|
||||
public calculateDynamicStackCount(tplId: string, isWeaponPreset: boolean): number
|
||||
|
Loading…
x
Reference in New Issue
Block a user