mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
BLADEBURNER: Improve terminal logging (#1361)
This commit is contained in:
parent
8b3206e1c6
commit
ebf08d5d1f
@ -17,7 +17,7 @@ import {
|
|||||||
} from "@enums";
|
} from "@enums";
|
||||||
import { getKeyList } from "../utils/helpers/getKeyList";
|
import { getKeyList } from "../utils/helpers/getKeyList";
|
||||||
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
||||||
import { formatNumberNoSuffix } from "../ui/formatNumber";
|
import { formatHp, formatNumberNoSuffix, formatSleeveShock } from "../ui/formatNumber";
|
||||||
import { Skills } from "./data/Skills";
|
import { Skills } from "./data/Skills";
|
||||||
import { City } from "./City";
|
import { City } from "./City";
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
@ -46,6 +46,8 @@ import { clampInteger, clampNumber } from "../utils/helpers/clampNumber";
|
|||||||
import { parseCommand } from "../Terminal/Parser";
|
import { parseCommand } from "../Terminal/Parser";
|
||||||
import { BlackOperations } from "./data/BlackOperations";
|
import { BlackOperations } from "./data/BlackOperations";
|
||||||
import { GeneralActions } from "./data/GeneralActions";
|
import { GeneralActions } from "./data/GeneralActions";
|
||||||
|
import { PlayerObject } from "../PersonObjects/Player/PlayerObject";
|
||||||
|
import { Sleeve } from "../PersonObjects/Sleeve/Sleeve";
|
||||||
|
|
||||||
export const BladeburnerPromise: PromisePair<number> = { promise: null, resolve: null };
|
export const BladeburnerPromise: PromisePair<number> = { promise: null, resolve: null };
|
||||||
|
|
||||||
@ -854,6 +856,22 @@ export class Bladeburner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
completeAction(person: Person, actionIdent: ActionIdentifier, isPlayer = true): WorkStats {
|
completeAction(person: Person, actionIdent: ActionIdentifier, isPlayer = true): WorkStats {
|
||||||
|
const currentHp = person.hp.current;
|
||||||
|
const getExtraLogAfterTakingDamage = (damage: number) => {
|
||||||
|
let extraLog = "";
|
||||||
|
if (currentHp <= damage) {
|
||||||
|
if (person instanceof PlayerObject) {
|
||||||
|
extraLog += ` ${person.whoAmI()} was hospitalized. Current HP is ${formatHp(person.hp.current)}.`;
|
||||||
|
} else if (person instanceof Sleeve) {
|
||||||
|
extraLog += ` ${person.whoAmI()} was shocked. Current shock is ${formatSleeveShock(
|
||||||
|
person.shock,
|
||||||
|
)}. Current HP is ${formatHp(person.hp.current)}.`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
extraLog += ` HP reduced from ${formatHp(currentHp)} to ${formatHp(person.hp.current)}.`;
|
||||||
|
}
|
||||||
|
return extraLog;
|
||||||
|
};
|
||||||
let retValue = newWorkStats();
|
let retValue = newWorkStats();
|
||||||
const action = this.getActionObject(actionIdent);
|
const action = this.getActionObject(actionIdent);
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
@ -899,12 +917,12 @@ export class Bladeburner {
|
|||||||
this.changeRank(person, gain);
|
this.changeRank(person, gain);
|
||||||
if (isOperation && this.logging.ops) {
|
if (isOperation && this.logging.ops) {
|
||||||
this.log(
|
this.log(
|
||||||
`${person.whoAmI()}: ${action.name} successfully completed! Gained ${formatBigNumber(gain)} rank`,
|
`${person.whoAmI()}: ${action.name} successfully completed! Gained ${formatBigNumber(gain)} rank.`,
|
||||||
);
|
);
|
||||||
} else if (!isOperation && this.logging.contracts) {
|
} else if (!isOperation && this.logging.contracts) {
|
||||||
this.log(
|
this.log(
|
||||||
`${person.whoAmI()}: ${action.name} contract successfully completed! Gained ` +
|
`${person.whoAmI()}: ${action.name} contract successfully completed! Gained ` +
|
||||||
`${formatBigNumber(gain)} rank and ${formatMoney(moneyGain)}`,
|
`${formatBigNumber(gain)} rank and ${formatMoney(moneyGain)}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -930,15 +948,15 @@ export class Bladeburner {
|
|||||||
}
|
}
|
||||||
let logLossText = "";
|
let logLossText = "";
|
||||||
if (loss > 0) {
|
if (loss > 0) {
|
||||||
logLossText += "Lost " + formatNumberNoSuffix(loss, 3) + " rank. ";
|
logLossText += ` Lost ${formatNumberNoSuffix(loss, 3)} rank.`;
|
||||||
}
|
}
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
logLossText += "Took " + formatNumberNoSuffix(damage, 0) + " damage.";
|
logLossText += ` Took ${formatNumberNoSuffix(damage, 0)} damage.${getExtraLogAfterTakingDamage(damage)}`;
|
||||||
}
|
}
|
||||||
if (isOperation && this.logging.ops) {
|
if (isOperation && this.logging.ops) {
|
||||||
this.log(`${person.whoAmI()}: ` + action.name + " failed! " + logLossText);
|
this.log(`${person.whoAmI()}: ${action.name} failed!${logLossText}`);
|
||||||
} else if (!isOperation && this.logging.contracts) {
|
} else if (!isOperation && this.logging.contracts) {
|
||||||
this.log(`${person.whoAmI()}: ` + action.name + " contract failed! " + logLossText);
|
this.log(`${person.whoAmI()}: ${action.name} contract failed!${logLossText}`);
|
||||||
}
|
}
|
||||||
isOperation ? this.completeOperation(false) : this.completeContract(false, action);
|
isOperation ? this.completeOperation(false) : this.completeContract(false, action);
|
||||||
}
|
}
|
||||||
@ -977,7 +995,9 @@ export class Bladeburner {
|
|||||||
teamLossMax = Math.ceil(teamCount / 2);
|
teamLossMax = Math.ceil(teamCount / 2);
|
||||||
|
|
||||||
if (this.logging.blackops) {
|
if (this.logging.blackops) {
|
||||||
this.log(`${person.whoAmI()}: ${action.name} successful! Gained ${formatNumberNoSuffix(rankGain, 1)} rank`);
|
this.log(
|
||||||
|
`${person.whoAmI()}: ${action.name} successful! Gained ${formatNumberNoSuffix(rankGain, 1)} rank.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
retValue = this.getActionStats(action, person, false);
|
retValue = this.getActionStats(action, person, false);
|
||||||
@ -1003,7 +1023,7 @@ export class Bladeburner {
|
|||||||
`${person.whoAmI()}: ${action.name} failed! Lost ${formatNumberNoSuffix(
|
`${person.whoAmI()}: ${action.name} failed! Lost ${formatNumberNoSuffix(
|
||||||
rankLoss,
|
rankLoss,
|
||||||
1,
|
1,
|
||||||
)} rank and took ${formatNumberNoSuffix(damage, 0)} damage`,
|
)} rank. Took ${formatNumberNoSuffix(damage, 0)} damage.${getExtraLogAfterTakingDamage(damage)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1026,7 +1046,7 @@ export class Bladeburner {
|
|||||||
this.teamLost += losses;
|
this.teamLost += losses;
|
||||||
if (this.logging.blackops) {
|
if (this.logging.blackops) {
|
||||||
this.log(
|
this.log(
|
||||||
`${person.whoAmI()}: You lost ${formatNumberNoSuffix(losses, 0)} team members during ${action.name}`,
|
`${person.whoAmI()}: You lost ${formatNumberNoSuffix(losses, 0)} team members during ${action.name}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1059,7 +1079,7 @@ export class Bladeburner {
|
|||||||
formatExp(agiExpGain) +
|
formatExp(agiExpGain) +
|
||||||
" agi exp, " +
|
" agi exp, " +
|
||||||
formatBigNumber(staminaGain) +
|
formatBigNumber(staminaGain) +
|
||||||
" max stamina",
|
" max stamina.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1089,7 +1109,7 @@ export class Bladeburner {
|
|||||||
`${person.whoAmI()}: ` +
|
`${person.whoAmI()}: ` +
|
||||||
`Field analysis completed. Gained ${formatBigNumber(rankGain)} rank, ` +
|
`Field analysis completed. Gained ${formatBigNumber(rankGain)} rank, ` +
|
||||||
`${formatExp(hackingExpGain)} hacking exp, and ` +
|
`${formatExp(hackingExpGain)} hacking exp, and ` +
|
||||||
`${formatExp(charismaExpGain)} charisma exp`,
|
`${formatExp(charismaExpGain)} charisma exp.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1105,7 +1125,7 @@ export class Bladeburner {
|
|||||||
`${person.whoAmI()}: ` +
|
`${person.whoAmI()}: ` +
|
||||||
"Successfully recruited a team member! Gained " +
|
"Successfully recruited a team member! Gained " +
|
||||||
formatExp(expGain) +
|
formatExp(expGain) +
|
||||||
" charisma exp",
|
" charisma exp.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1116,7 +1136,7 @@ export class Bladeburner {
|
|||||||
`${person.whoAmI()}: ` +
|
`${person.whoAmI()}: ` +
|
||||||
"Failed to recruit a team member. Gained " +
|
"Failed to recruit a team member. Gained " +
|
||||||
formatExp(expGain) +
|
formatExp(expGain) +
|
||||||
" charisma exp",
|
" charisma exp.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1132,7 +1152,7 @@ export class Bladeburner {
|
|||||||
this.log(
|
this.log(
|
||||||
`${person.whoAmI()}: Diplomacy completed. Chaos levels in the current city fell by ${formatPercent(
|
`${person.whoAmI()}: Diplomacy completed. Chaos levels in the current city fell by ${formatPercent(
|
||||||
1 - eff,
|
1 - eff,
|
||||||
)}`,
|
)}.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1140,14 +1160,22 @@ export class Bladeburner {
|
|||||||
case BladeGeneralActionName.hyperbolicRegen: {
|
case BladeGeneralActionName.hyperbolicRegen: {
|
||||||
person.regenerateHp(BladeburnerConstants.HrcHpGain);
|
person.regenerateHp(BladeburnerConstants.HrcHpGain);
|
||||||
|
|
||||||
|
const currentStamina = this.stamina;
|
||||||
const staminaGain = this.maxStamina * (BladeburnerConstants.HrcStaminaGain / 100);
|
const staminaGain = this.maxStamina * (BladeburnerConstants.HrcStaminaGain / 100);
|
||||||
this.stamina = Math.min(this.maxStamina, this.stamina + staminaGain);
|
this.stamina = Math.min(this.maxStamina, this.stamina + staminaGain);
|
||||||
if (this.logging.general) {
|
if (this.logging.general) {
|
||||||
this.log(
|
let extraLog = "";
|
||||||
`${person.whoAmI()}: Rested in Hyperbolic Regeneration Chamber. Restored ${
|
if (Player.hp.current > currentHp) {
|
||||||
BladeburnerConstants.HrcHpGain
|
extraLog += ` Restored ${formatHp(BladeburnerConstants.HrcHpGain)} HP. Current HP is ${formatHp(
|
||||||
} HP and gained ${formatStamina(staminaGain)} stamina`,
|
Player.hp.current,
|
||||||
);
|
)}.`;
|
||||||
|
}
|
||||||
|
if (this.stamina > currentStamina) {
|
||||||
|
extraLog += ` Restored ${formatStamina(staminaGain)} stamina. Current stamina is ${formatStamina(
|
||||||
|
this.stamina,
|
||||||
|
)}.`;
|
||||||
|
}
|
||||||
|
this.log(`${person.whoAmI()}: Rested in Hyperbolic Regeneration Chamber.${extraLog}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user