mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
BUGFIX: ns.bladeburner.getActionRepGain returns wrong value (#2186)
This commit is contained in:
@@ -29,7 +29,6 @@ import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
|
||||
import { BladeburnerConstants } from "./data/Constants";
|
||||
import { formatExp, formatMoney, formatPercent, formatBigNumber, formatStamina } from "../ui/formatNumber";
|
||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||
import { addOffset } from "../utils/helpers/addOffset";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { calculateHospitalizationCost } from "../Hospital/Hospital";
|
||||
@@ -56,6 +55,7 @@ import { assertObject } from "../utils/TypeAssertion";
|
||||
import { throwIfReachable } from "../utils/helpers/throwIfReachable";
|
||||
import { loadActionIdentifier } from "./utils/loadActionIdentifier";
|
||||
import { pluralize } from "../utils/I18nUtils";
|
||||
import { calculateActionRankGain, calculateActionReputationGain } from "./Formulas";
|
||||
|
||||
export const BladeburnerPromise: PromisePair<number> = { promise: null, resolve: null };
|
||||
|
||||
@@ -912,7 +912,7 @@ export class Bladeburner implements OperationTeam {
|
||||
action.setMaxLevel(BladeburnerConstants.ContractSuccessesPerLevel);
|
||||
}
|
||||
if (action.rankGain) {
|
||||
const gain = addOffset(action.rankGain * rewardMultiplier * currentNodeMults.BladeburnerRank, 10);
|
||||
const gain = addOffset(calculateActionRankGain(action), 10);
|
||||
this.changeRank(person, gain);
|
||||
if (isOperation && this.logging.ops) {
|
||||
this.log(
|
||||
@@ -994,7 +994,7 @@ export class Bladeburner implements OperationTeam {
|
||||
this.numBlackOpsComplete++;
|
||||
let rankGain = 0;
|
||||
if (action.rankGain) {
|
||||
rankGain = addOffset(action.rankGain * currentNodeMults.BladeburnerRank, 10);
|
||||
rankGain = addOffset(calculateActionRankGain(action), 10);
|
||||
this.changeRank(person, rankGain);
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ export class Bladeburner implements OperationTeam {
|
||||
}
|
||||
const hackingExpGain = 20 * person.mults.hacking_exp;
|
||||
const charismaExpGain = 20 * person.mults.charisma_exp;
|
||||
const rankGain = 0.1 * currentNodeMults.BladeburnerRank;
|
||||
const rankGain = calculateActionRankGain(action);
|
||||
retValue.hackExp = hackingExpGain;
|
||||
retValue.chaExp = charismaExpGain;
|
||||
retValue.intExp = BladeburnerConstants.BaseIntGain;
|
||||
@@ -1232,12 +1232,9 @@ export class Bladeburner implements OperationTeam {
|
||||
}
|
||||
this.maxRank = Math.max(this.rank, this.maxRank);
|
||||
|
||||
const bladeburnersFactionName = FactionName.Bladeburners;
|
||||
const bladeburnerFac = Factions[bladeburnersFactionName];
|
||||
if (bladeburnerFac.isMember) {
|
||||
const favorBonus = 1 + bladeburnerFac.favor / 100;
|
||||
bladeburnerFac.playerReputation +=
|
||||
BladeburnerConstants.RankToFactionRepFactor * change * person.mults.faction_rep * favorBonus;
|
||||
const bladeburnerFaction = Factions[FactionName.Bladeburners];
|
||||
if (bladeburnerFaction.isMember) {
|
||||
bladeburnerFaction.playerReputation += calculateActionReputationGain(person, change);
|
||||
}
|
||||
|
||||
// Gain skill points
|
||||
|
||||
33
src/Bladeburner/Formulas.ts
Normal file
33
src/Bladeburner/Formulas.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||
import { FactionName } from "../Enums";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import type { Person } from "../PersonObjects/Person";
|
||||
import { BladeburnerConstants } from "./data/Constants";
|
||||
import { BladeburnerActionType, BladeburnerGeneralActionName } from "./Enums";
|
||||
import type { Action } from "./Types";
|
||||
|
||||
export function calculateActionRankGain(action: Action, level?: number): number {
|
||||
switch (action.type) {
|
||||
case BladeburnerActionType.General:
|
||||
if (action.name === BladeburnerGeneralActionName.FieldAnalysis) {
|
||||
return 0.1 * currentNodeMults.BladeburnerRank;
|
||||
}
|
||||
break;
|
||||
case BladeburnerActionType.Contract:
|
||||
case BladeburnerActionType.Operation: {
|
||||
if (level == null) {
|
||||
level = action.level;
|
||||
}
|
||||
const rewardMultiplier = Math.pow(action.rewardFac, level - 1);
|
||||
return action.rankGain * rewardMultiplier * currentNodeMults.BladeburnerRank;
|
||||
}
|
||||
case BladeburnerActionType.BlackOp:
|
||||
return action.rankGain * currentNodeMults.BladeburnerRank;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function calculateActionReputationGain(person: Person, rankGain: number): number {
|
||||
const favorBonus = 1 + Factions[FactionName.Bladeburners].favor / 100;
|
||||
return BladeburnerConstants.RankToFactionRepFactor * rankGain * person.mults.faction_rep * favorBonus;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import { assertStringWithNSContext } from "../Netscript/TypeAssertion";
|
||||
import { BlackOperations, blackOpsArray } from "../Bladeburner/data/BlackOperations";
|
||||
import { checkSleeveAPIAccess, checkSleeveNumber } from "../NetscriptFunctions/Sleeve";
|
||||
import { canAccessBitNodeFeature } from "../BitNode/BitNodeUtils";
|
||||
import { calculateActionRankGain, calculateActionReputationGain } from "../Bladeburner/Formulas";
|
||||
|
||||
export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
|
||||
const checkBladeburnerAccess = function (ctx: NetscriptContext): void {
|
||||
@@ -151,8 +152,8 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
|
||||
checkBladeburnerAccess(ctx);
|
||||
const action = getAction(ctx, type, name);
|
||||
const level = isLevelableAction(action) ? helpers.number(ctx, "level", _level ?? action.level) : 1;
|
||||
const rewardMultiplier = isLevelableAction(action) ? Math.pow(action.rewardFac, level - 1) : 1;
|
||||
return action.rankGain * rewardMultiplier * currentNodeMults.BladeburnerRank;
|
||||
const rankGain = calculateActionRankGain(action, level);
|
||||
return calculateActionReputationGain(Player, rankGain);
|
||||
},
|
||||
getActionCountRemaining: (ctx) => (type, name) => {
|
||||
const bladeburner = getBladeburner(ctx);
|
||||
|
||||
@@ -191,5 +191,12 @@ export const breakingChanges300: VersionBreakingChange = {
|
||||
'It has been automatically replaced with "ns.getBitNodeMultipliers().FavorToDonateToFaction".',
|
||||
showPopUp: false,
|
||||
},
|
||||
{
|
||||
brokenAPIs: [{ name: "getActionRepGain" }],
|
||||
info:
|
||||
"ns.bladeburner.getActionRepGain returned the average rank gain instead of the average reputation gain.\n" +
|
||||
"This bug was fixed. Please check your code to see if it still works as you expect.",
|
||||
showPopUp: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user