(More) Simple Parameter Reassignment Issues

Addresses some of the simple linting errors regarding the reassignment of function parameters.
This commit is contained in:
Refringe 2024-02-05 22:02:44 -05:00
parent d8fe911464
commit c29482394b
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E
6 changed files with 38 additions and 43 deletions

View File

@ -85,11 +85,13 @@ export class BotController
* Get bot difficulty settings
* adjust PMC settings to ensure they engage the correct bot types
* @param type what bot the server is requesting settings for
* @param difficulty difficulty level server requested settings for
* @param diffLevel difficulty level server requested settings for
* @returns Difficulty object
*/
public getBotDifficulty(type: string, difficulty: string): Difficulty
public getBotDifficulty(type: string, diffLevel: string): Difficulty
{
let difficulty = diffLevel.toLowerCase();
const raidConfig = this.applicationContext.getLatestValue(ContextVariableType.RAID_CONFIGURATION)?.getValue<
IGetRaidConfigurationRequestData
>();

View File

@ -452,11 +452,11 @@ export class InraidController
): void
{
// Update scav profile inventory
scavData = this.inRaidHelper.setInventory(sessionID, scavData, offraidData.profile);
const updatedScavData = this.inRaidHelper.setInventory(sessionID, scavData, offraidData.profile);
// Reset scav hp and save to json
this.healthHelper.resetVitality(sessionID);
this.saveServer.getProfile(sessionID).characters.scav = scavData;
this.saveServer.getProfile(sessionID).characters.scav = updatedScavData;
// Scav karma
this.handlePostRaidPlayerScavKarmaChanges(pmcData, offraidData);

View File

@ -299,10 +299,10 @@ export class BotGenerator
*/
protected logPmcGeneratedCount(output: IBotBase[]): void
{
const pmcCount = output.reduce(
(acc, cur) => cur.Info.Side === "Bear" || cur.Info.Side === "Usec" ? ++acc : acc,
0,
);
const pmcCount = output.reduce((acc, cur) =>
{
return cur.Info.Side === "Bear" || cur.Info.Side === "Usec" ? acc + 1 : acc;
}, 0);
this.logger.debug(`Generated ${output.length} total bots. Replaced ${pmcCount} with PMCs`);
}

View File

@ -903,12 +903,12 @@ export class RepeatableQuestGenerator
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
* Additionally, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {number} difficulty a reward scaling factor from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @param {object} repeatableConfig The configuration for the repeatable kind (daily, weekly) as configured in QuestConfig for the requested quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(
@ -919,7 +919,7 @@ export class RepeatableQuestGenerator
questConfig: IBaseQuestConfig,
): IQuestRewards
{
// difficulty could go from 0.2 ... -> for lowest diffuculty receive 0.2*nominal reward
// difficulty could go from 0.2 ... -> for lowest difficulty receive 0.2*nominal reward
const levelsConfig = repeatableConfig.rewardScaling.levels;
const roublesConfig = repeatableConfig.rewardScaling.roubles;
const xpConfig = repeatableConfig.rewardScaling.experience;
@ -929,19 +929,19 @@ export class RepeatableQuestGenerator
const skillPointRewardConfig = repeatableConfig.rewardScaling.skillPointReward;
const reputationConfig = repeatableConfig.rewardScaling.reputation;
const effectiveDifficulty = Number.isNaN(difficulty) ? 1 : difficulty;
if (Number.isNaN(difficulty))
{
difficulty = 1;
this.logger.warning(this.localisationService.getText("repeatable-difficulty_was_nan"));
}
// rewards are generated based on pmcLevel, difficulty and a random spread
const rewardXP = Math.floor(
difficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, xpConfig)
effectiveDifficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, xpConfig)
* this.randomUtil.getFloat(1 - rewardSpreadConfig, 1 + rewardSpreadConfig),
);
const rewardRoubles = Math.floor(
difficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, roublesConfig)
effectiveDifficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, roublesConfig)
* this.randomUtil.getFloat(1 - rewardSpreadConfig, 1 + rewardSpreadConfig),
);
const rewardNumItems = this.randomUtil.randInt(
@ -950,7 +950,7 @@ export class RepeatableQuestGenerator
);
const rewardReputation =
Math.round(
100 * difficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, reputationConfig)
100 * effectiveDifficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, reputationConfig)
* this.randomUtil.getFloat(1 - rewardSpreadConfig, 1 + rewardSpreadConfig),
) / 100;
const skillRewardChance = this.mathUtil.interp1(pmcLevel, levelsConfig, skillRewardChanceConfig);
@ -998,7 +998,7 @@ export class RepeatableQuestGenerator
const defaultPresets = Object.values(this.presetHelper.getDefaultPresets());
const defaultPresetClone = this.jsonUtil.clone(this.randomUtil.getArrayValue(defaultPresets));
// use _encyclopedia as its always the base items _tpl, items[0] isnt guaranteed to be base item
// use _encyclopedia as its always the base items _tpl, items[0] isn't guaranteed to be base item
rewards.Success.push(
this.generateRewardItem(defaultPresetClone._encyclopedia, 1, rewardIndex, defaultPresetClone._items),
);
@ -1014,7 +1014,7 @@ export class RepeatableQuestGenerator
if (this.itemHelper.isOfBaseclass(itemSelected._id, BaseClasses.AMMO))
{
// Dont reward ammo that stacks to less than what's defined in config
// Don't reward ammo that stacks to less than what's defined in config
if (itemSelected._props.StackMaxSize < repeatableConfig.rewardAmmoStackMinSize)
{
continue;
@ -1028,14 +1028,14 @@ export class RepeatableQuestGenerator
// Get a stack size of ammo that fits rouble budget
const stackSizeThatFitsBudget = Math.round(stackRoubleBudget / singleCartridgePrice);
// Get itemDbs max stack size for ammo - dont go above 100 (some mods mess around with stack sizes)
// Get itemDbs max stack size for ammo - don't go above 100 (some mods mess around with stack sizes)
const stackMaxCount = Math.min(itemSelected._props.StackMaxSize, 100);
// Choose smallest value between budget fitting size and stack max
rewardItemStackCount = Math.min(stackSizeThatFitsBudget, stackMaxCount);
}
// 25% chance to double,triple quadruple reward stack (Only occurs when item is stackable and not weapon or ammo)
// 25% chance to double, triple quadruple reward stack (Only occurs when item is stackable and not weapon or ammo)
if (this.canIncreaseRewardItemStackSize(itemSelected, 70000))
{
rewardItemStackCount = this.getRandomisedRewardItemStackSizeByPrice(itemSelected);

View File

@ -50,16 +50,12 @@ export class ItemHelper
/**
* Checks if an id is a valid item. Valid meaning that it's an item that be stored in stash
* @param {string} tpl the template id / tpl
* @returns boolean; true for items that may be in player possession and not quest items
* @param {string} tpl the template id / tpl
* @returns boolean; true for items that may be in player possession and not quest items
*/
public isValidItem(tpl: string, invalidBaseTypes: string[] = null): boolean
{
if (invalidBaseTypes === null)
{
invalidBaseTypes = this.defaultInvalidBaseTypes;
}
const baseTypes = invalidBaseTypes || this.defaultInvalidBaseTypes;
const itemDetails = this.getItem(tpl);
if (!itemDetails[0])
@ -67,10 +63,9 @@ export class ItemHelper
return false;
}
// Is item valid
return !itemDetails[1]._props.QuestItem
&& itemDetails[1]._type === "Item"
&& !this.isOfBaseclasses(tpl, invalidBaseTypes)
&& baseTypes.every((x) => !this.isOfBaseclass(tpl, x))
&& this.getItemPrice(tpl) > 0
&& !this.itemFilterService.isItemBlacklisted(tpl);
}
@ -1063,20 +1058,16 @@ export class ItemHelper
minSizePercent = 0.25,
): void
{
// no caliber defined, choose one at random
if (!caliber)
{
caliber = this.getRandomValidCaliber(magTemplate);
}
let chosenCaliber = caliber || this.getRandomValidCaliber(magTemplate);
// Edge case for the Klin pp-9, it has a typo in its ammo caliber
if (caliber === "Caliber9x18PMM")
if (chosenCaliber === "Caliber9x18PMM")
{
caliber = "Caliber9x18PM";
chosenCaliber = "Caliber9x18PM";
}
// Chose a randomly weighted cartridge that fits
const cartridgeTpl = this.drawAmmoTpl(caliber, staticAmmoDist);
const cartridgeTpl = this.drawAmmoTpl(chosenCaliber, staticAmmoDist);
this.fillMagazineWithCartridge(magazine, magTemplate, cartridgeTpl, minSizePercent);
}

View File

@ -83,18 +83,20 @@ export class RagfairSellHelper
const result: SellResult[] = [];
// Value can sometimes be NaN for whatever reason, default to base chance if that happens
const effectiveSellChance = Number.isNaN(sellChancePercent)
? this.ragfairConfig.sell.chance.base
: sellChancePercent;
if (Number.isNaN(sellChancePercent))
{
this.logger.warning(
`Sell chance was not a number: ${sellChancePercent}, defaulting to ${this.ragfairConfig.sell.chance.base} %`,
`Sell chance was not a number: ${sellChancePercent}, defaulting to ${this.ragfairConfig.sell.chance.base}%`,
);
sellChancePercent = this.ragfairConfig.sell.chance.base;
}
this.logger.debug(`Rolling to sell: ${itemSellCount} items (chance: ${sellChancePercent}%)`);
this.logger.debug(`Rolling to sell: ${itemSellCount} items (chance: ${effectiveSellChance}%)`);
// No point rolling for a sale on a 0% chance item, exit early
if (sellChancePercent === 0)
if (effectiveSellChance === 0)
{
return result;
}
@ -102,11 +104,11 @@ export class RagfairSellHelper
while (remainingCount > 0 && sellTime < endTime)
{
const boughtAmount = this.randomUtil.getInt(1, remainingCount);
if (this.randomUtil.getChance100(sellChancePercent))
if (this.randomUtil.getChance100(effectiveSellChance))
{
// Passed roll check, item will be sold
// Weight time to sell towards selling faster based on how cheap the item sold
const weighting = (100 - sellChancePercent) / 100;
const weighting = (100 - effectiveSellChance) / 100;
let maximumTime = weighting * (this.ragfairConfig.sell.time.max * 60);
const minimumTime = this.ragfairConfig.sell.time.min * 60;
if (maximumTime < minimumTime)