Format, but git forgot this last time

This commit is contained in:
rderfler 2022-04-14 12:00:17 -04:00
parent 3886e31a45
commit 9d18118208
7 changed files with 146 additions and 132 deletions

@ -138,7 +138,7 @@ export function NetscriptBladeburner(
if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
try { try {
const time = bladeburner.getActionTimeNetscriptFn(player, type, name); const time = bladeburner.getActionTimeNetscriptFn(player, type, name);
if(typeof time === 'string'){ if (typeof time === "string") {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
workerScript.log("bladeburner.getActionTime", () => errorLogText); workerScript.log("bladeburner.getActionTime", () => errorLogText);
return -1; return -1;
@ -158,7 +158,7 @@ export function NetscriptBladeburner(
if (bladeburner === null) throw new Error("Should not be called without Bladeburner"); if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
try { try {
const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name); const chance = bladeburner.getActionEstimatedSuccessChanceNetscriptFn(player, type, name);
if(typeof chance === 'string'){ if (typeof chance === "string") {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
workerScript.log("bladeburner.getActionTime", () => errorLogText); workerScript.log("bladeburner.getActionTime", () => errorLogText);
return [-1, -1]; return [-1, -1];

@ -305,7 +305,7 @@ export class PlayerObject implements IPlayer {
finishGraftAugmentationWork: (cancelled: boolean) => string; finishGraftAugmentationWork: (cancelled: boolean) => string;
applyEntropy: (stacks?: number) => void; applyEntropy: (stacks?: number) => void;
whoAmI(): string { whoAmI(): string {
return 'Player'; return "Player";
} }
constructor() { constructor() {

@ -225,7 +225,7 @@ export class Sleeve extends Person {
const bb = p.bladeburner; const bb = p.bladeburner;
if (bb === null) { if (bb === null) {
const errorLogText = `bladeburner is null`; const errorLogText = `bladeburner is null`;
console.error(`Function: sleeves.finishTask; Message: '${errorLogText}'`) console.error(`Function: sleeves.finishTask; Message: '${errorLogText}'`);
this.resetTaskStatus(p); this.resetTaskStatus(p);
return retValue; return retValue;
} }
@ -240,17 +240,17 @@ export class Sleeve extends Person {
let type: string; let type: string;
let name: string; let name: string;
if (this.bbAction === "Take on Contracts") { if (this.bbAction === "Take on Contracts") {
type = 'Contracts'; type = "Contracts";
name = this.bbContract; name = this.bbContract;
} else { } else {
type = 'General'; type = "General";
name = this.bbAction; name = this.bbAction;
} }
const actionIdent = bb.getActionIdFromTypeAndName(type, name); const actionIdent = bb.getActionIdFromTypeAndName(type, name);
if (actionIdent === null) { if (actionIdent === null) {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
console.error(`Function: sleeves.finishTask; Message: '${errorLogText}'`) console.error(`Function: sleeves.finishTask; Message: '${errorLogText}'`);
this.resetTaskStatus(p); this.resetTaskStatus(p);
return retValue; return retValue;
} }
@ -633,7 +633,7 @@ export class Sleeve extends Person {
* Resets all parameters used to keep information about the current task * Resets all parameters used to keep information about the current task
*/ */
resetTaskStatus(p: IPlayer): void { resetTaskStatus(p: IPlayer): void {
if (this.bbAction == 'Support main sleeve') { if (this.bbAction == "Support main sleeve") {
p.bladeburner?.sleeveSupport(false); p.bladeburner?.sleeveSupport(false);
} }
if (this.currentTask == SleeveTaskType.Class) { if (this.currentTask == SleeveTaskType.Class) {
@ -1080,23 +1080,23 @@ export class Sleeve extends Person {
this.gainRatesForTask.agi = 0; this.gainRatesForTask.agi = 0;
this.gainRatesForTask.cha = 0; this.gainRatesForTask.cha = 0;
this.gainRatesForTask.money = 0; this.gainRatesForTask.money = 0;
this.currentTaskLocation = ''; this.currentTaskLocation = "";
let time = 0; let time = 0;
switch (action) { switch (action) {
case "Field Analysis": case "Field Analysis":
time = this.getBladeburnerActionTime(p, 'General', action); time = this.getBladeburnerActionTime(p, "General", action);
this.gainRatesForTask.hack = 20 * this.hacking_exp_mult; this.gainRatesForTask.hack = 20 * this.hacking_exp_mult;
this.gainRatesForTask.cha = 20 * this.charisma_exp_mult; this.gainRatesForTask.cha = 20 * this.charisma_exp_mult;
break; break;
case "Recruitment": case "Recruitment":
time = this.getBladeburnerActionTime(p, 'General', action); time = this.getBladeburnerActionTime(p, "General", action);
const recruitTime = (p.bladeburner?.getRecruitmentTime(this) ?? 0) * 1000; const recruitTime = (p.bladeburner?.getRecruitmentTime(this) ?? 0) * 1000;
this.gainRatesForTask.cha = 2 * BladeburnerConstants.BaseStatGain * recruitTime; this.gainRatesForTask.cha = 2 * BladeburnerConstants.BaseStatGain * recruitTime;
this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + '%'; this.currentTaskLocation = (p.bladeburner?.getRecruitmentSuccessChance(this) ?? 0).toString() + "%";
break; break;
case "Diplomacy": case "Diplomacy":
time = this.getBladeburnerActionTime(p, 'General', action); time = this.getBladeburnerActionTime(p, "General", action);
break; break;
case "Infiltrate synthoids": case "Infiltrate synthoids":
time = 60000; time = 60000;
@ -1106,9 +1106,9 @@ export class Sleeve extends Person {
time = 0; time = 0;
break; break;
case "Take on Contracts": case "Take on Contracts":
time = this.getBladeburnerActionTime(p, 'Contracts', contract); time = this.getBladeburnerActionTime(p, "Contracts", contract);
this.contractGainRates(p, 'Contracts', contract); this.contractGainRates(p, "Contracts", contract);
this.currentTaskLocation = this.contractSuccessChance(p, 'Contracts', contract); this.currentTaskLocation = this.contractSuccessChance(p, "Contracts", contract);
break; break;
} }
@ -1123,16 +1123,16 @@ export class Sleeve extends Person {
const bb = p.bladeburner; const bb = p.bladeburner;
if (bb === null) { if (bb === null) {
const errorLogText = `bladeburner is null`; const errorLogText = `bladeburner is null`;
console.error(`Function: sleeves.contractSuccessChance; Message: '${errorLogText}'`) console.error(`Function: sleeves.contractSuccessChance; Message: '${errorLogText}'`);
return '0%'; return "0%";
} }
const chances = bb.getActionEstimatedSuccessChanceNetscriptFn(this, type, name); const chances = bb.getActionEstimatedSuccessChanceNetscriptFn(this, type, name);
if(typeof chances === 'string'){ if (typeof chances === "string") {
console.error(`Function: sleeves.contractSuccessChance; Message: '${chances}'`) console.error(`Function: sleeves.contractSuccessChance; Message: '${chances}'`);
return '0%'; return "0%";
} }
if (chances[0] >= 1) { if (chances[0] >= 1) {
return '100%'; return "100%";
} else { } else {
return `${chances[0] * 100}% - ${chances[1] * 100}%`; return `${chances[0] * 100}% - ${chances[1] * 100}%`;
} }
@ -1142,20 +1142,20 @@ export class Sleeve extends Person {
const bb = p.bladeburner; const bb = p.bladeburner;
if (bb === null) { if (bb === null) {
const errorLogText = `bladeburner is null`; const errorLogText = `bladeburner is null`;
console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`) console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`);
return; return;
} }
const actionIdent = bb.getActionIdFromTypeAndName(type, name); const actionIdent = bb.getActionIdFromTypeAndName(type, name);
if (actionIdent === null) { if (actionIdent === null) {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`) console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`);
this.resetTaskStatus(p); this.resetTaskStatus(p);
return; return;
} }
const action = bb.getActionObject(actionIdent); const action = bb.getActionObject(actionIdent);
if (action === null) { if (action === null) {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`) console.error(`Function: sleeves.contractGainRates; Message: '${errorLogText}'`);
this.resetTaskStatus(p); this.resetTaskStatus(p);
return; return;
} }
@ -1167,21 +1167,23 @@ export class Sleeve extends Person {
this.gainRatesForTask.agi = retValue.agi; this.gainRatesForTask.agi = retValue.agi;
this.gainRatesForTask.cha = retValue.cha; this.gainRatesForTask.cha = retValue.cha;
const rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); const rewardMultiplier = Math.pow(action.rewardFac, action.level - 1);
this.gainRatesForTask.money = BladeburnerConstants.ContractBaseMoneyGain * rewardMultiplier * bb.skillMultipliers.money; this.gainRatesForTask.money =
BladeburnerConstants.ContractBaseMoneyGain * rewardMultiplier * bb.skillMultipliers.money;
} }
getBladeburnerActionTime(p: IPlayer, type: string, name: string): number{//Maybe find workerscript and use original getBladeburnerActionTime(p: IPlayer, type: string, name: string): number {
//Maybe find workerscript and use original
const bb = p.bladeburner; const bb = p.bladeburner;
if (bb === null) { if (bb === null) {
const errorLogText = `bladeburner is null`; const errorLogText = `bladeburner is null`;
console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`) console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`);
return -1; return -1;
} }
const time = bb.getActionTimeNetscriptFn(this, type, name); const time = bb.getActionTimeNetscriptFn(this, type, name);
if(typeof time === 'string'){ if (typeof time === "string") {
const errorLogText = `Invalid action: type='${type}' name='${name}'`; const errorLogText = `Invalid action: type='${type}' name='${name}'`;
console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`) console.error(`Function: sleeves.getBladeburnerActionTime; Message: '${errorLogText}'`);
return -1; return -1;
} else { } else {
return time; return time;
@ -1205,7 +1207,7 @@ export class Sleeve extends Person {
} }
whoAmI(): string { whoAmI(): string {
return 'Sleeve'; return "Sleeve";
} }
/** /**

@ -114,11 +114,16 @@ export function SleeveElem(props: IProps): React.ReactElement {
desc = <>This sleeve is currently working out at {props.sleeve.currentTaskLocation}.</>; desc = <>This sleeve is currently working out at {props.sleeve.currentTaskLocation}.</>;
break; break;
case SleeveTaskType.Bladeburner: case SleeveTaskType.Bladeburner:
let contract = ''; let contract = "";
if (props.sleeve.bbContract !== '------') { if (props.sleeve.bbContract !== "------") {
contract = ` - ${props.sleeve.bbContract} (Success Rate: ${props.sleeve.currentTaskLocation})`; contract = ` - ${props.sleeve.bbContract} (Success Rate: ${props.sleeve.currentTaskLocation})`;
} }
desc = <>This sleeve is currently attempting to {props.sleeve.bbAction}{contract}</> desc = (
<>
This sleeve is currently attempting to {props.sleeve.bbAction}
{contract}
</>
);
break; break;
case SleeveTaskType.Recovery: case SleeveTaskType.Recovery:
desc = ( desc = (
@ -186,10 +191,10 @@ export function SleeveElem(props: IProps): React.ReactElement {
</Button> </Button>
<Typography>{desc}</Typography> <Typography>{desc}</Typography>
<Typography> <Typography>
{(props.sleeve.currentTask === SleeveTaskType.Crime {(props.sleeve.currentTask === SleeveTaskType.Crime ||
|| props.sleeve.currentTask === SleeveTaskType.Bladeburner) props.sleeve.currentTask === SleeveTaskType.Bladeburner) &&
&& props.sleeve.currentTaskMaxTime > 0 props.sleeve.currentTaskMaxTime > 0 &&
&& createProgressBarText({ createProgressBarText({
progress: props.sleeve.currentTaskTime / props.sleeve.currentTaskMaxTime, progress: props.sleeve.currentTaskTime / props.sleeve.currentTaskMaxTime,
totalTicks: 25, totalTicks: 25,
})} })}

@ -22,7 +22,14 @@ const universitySelectorOptions: string[] = [
const gymSelectorOptions: string[] = ["Train Strength", "Train Defense", "Train Dexterity", "Train Agility"]; const gymSelectorOptions: string[] = ["Train Strength", "Train Defense", "Train Dexterity", "Train Agility"];
const bladeburnerSelectorOptions: string[] = ["Field Analysis", "Recruitment", "Diplomacy", "Infiltrate synthoids", "Support main sleeve", "Take on Contracts"]; const bladeburnerSelectorOptions: string[] = [
"Field Analysis",
"Recruitment",
"Diplomacy",
"Infiltrate synthoids",
"Support main sleeve",
"Take on Contracts",
];
interface IProps { interface IProps {
sleeve: Sleeve; sleeve: Sleeve;
@ -94,9 +101,8 @@ function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] {
if (sleeve === otherSleeve) { if (sleeve === otherSleeve) {
continue; continue;
} }
if (otherSleeve.currentTask === SleeveTaskType.Bladeburner if (otherSleeve.currentTask === SleeveTaskType.Bladeburner && otherSleeve.bbAction == "Take on Contracts") {
&& otherSleeve.bbAction == 'Take on Contracts') { contracts = contracts.filter((x) => x != otherSleeve.bbContract);
contracts = contracts.filter(x => x != otherSleeve.bbContract);
} }
} }
if (contracts.length === 0) { if (contracts.length === 0) {
@ -199,7 +205,8 @@ const tasks: {
} else { } else {
return ["------"]; return ["------"];
} }
} }; },
};
}, },
"Shock Recovery": (): ITaskDetails => { "Shock Recovery": (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] }; return { first: ["------"], second: () => ["------"] };