Rework payMoney()
to handle taking money from post-raid therapist healing
This commit is contained in:
parent
844cb12cc1
commit
bb8677bc65
@ -46,35 +46,29 @@ export class PaymentService
|
|||||||
// Track the amounts of each type of currency involved in the trade.
|
// Track the amounts of each type of currency involved in the trade.
|
||||||
const currencyAmounts: { [key: string]: number } = {};
|
const currencyAmounts: { [key: string]: number } = {};
|
||||||
|
|
||||||
// Delete barter items and track currencies if the action is "TradingConfirm".
|
// Delete barter items and track currencies
|
||||||
if (request.Action === "TradingConfirm")
|
for (const index in request.scheme_items)
|
||||||
{
|
{
|
||||||
for (const index in request.scheme_items)
|
// Find the corresponding item in the player's inventory.
|
||||||
|
const item = pmcData.Inventory.items.find(i => i._id === request.scheme_items[index].id);
|
||||||
|
if (item !== undefined)
|
||||||
{
|
{
|
||||||
// Find the corresponding item in the player's inventory.
|
if (!this.paymentHelper.isMoneyTpl(item._tpl))
|
||||||
const item = pmcData.Inventory.items.find(i => i._id === request.scheme_items[index].id);
|
|
||||||
if (item !== undefined)
|
|
||||||
{
|
{
|
||||||
if (!this.paymentHelper.isMoneyTpl(item._tpl))
|
// If the item is not money, remove it from the inventory.
|
||||||
{
|
output = this.inventoryHelper.removeItem(pmcData, item._id, sessionID, output);
|
||||||
// If the item is not money, remove it from the inventory.
|
request.scheme_items[index].count = 0;
|
||||||
output = this.inventoryHelper.removeItem(pmcData, item._id, sessionID, output);
|
}
|
||||||
request.scheme_items[index].count = 0;
|
else
|
||||||
}
|
{
|
||||||
else
|
// If the item is money, add its count to the currencyAmounts object.
|
||||||
{
|
currencyAmounts[item._tpl] = (currencyAmounts[item._tpl] || 0) + request.scheme_items[index].count;
|
||||||
// If the item is money, add its count to the currencyAmounts object.
|
|
||||||
currencyAmounts[item._tpl] = (currencyAmounts[item._tpl] || 0) + request.scheme_items[index].count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
// Needs specific handling, add up currency amounts for insured items
|
|
||||||
if (request.Action === "SptInsure")
|
|
||||||
{
|
|
||||||
for (const index in request.scheme_items)
|
|
||||||
{
|
{
|
||||||
|
// Used by `SptInsure`
|
||||||
|
// Handle differently, `id` is the money type tpl
|
||||||
const currencyTpl = request.scheme_items[index].id;
|
const currencyTpl = request.scheme_items[index].id;
|
||||||
currencyAmounts[currencyTpl] = (currencyAmounts[currencyTpl] || 0) + request.scheme_items[index].count;
|
currencyAmounts[currencyTpl] = (currencyAmounts[currencyTpl] || 0) + request.scheme_items[index].count;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user