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];

@ -61,4 +61,4 @@ export interface IPerson {
regenerateHp: (amt: number) => void; regenerateHp: (amt: number) => void;
queryStatFromString: (str: string) => number; queryStatFromString: (str: string) => number;
whoAmI: () => string; whoAmI: () => string;
} }

@ -9,9 +9,9 @@ export interface ITaskTracker {
cha: number; cha: number;
int: number; int: number;
money: number; money: number;
} }
export function createTaskTracker(): ITaskTracker { export function createTaskTracker(): ITaskTracker {
return { return {
hack: 0, hack: 0,
str: 0, str: 0,
@ -22,4 +22,4 @@ export interface ITaskTracker {
int: 0, int: 0,
money: 0, money: 0,
}; };
} }

@ -304,8 +304,8 @@ export class PlayerObject implements IPlayer {
graftAugmentationWork: (numCycles: number) => boolean; graftAugmentationWork: (numCycles: number) => boolean;
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,25 +240,25 @@ 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;
} }
const action = bb.getActionObject(actionIdent); const action = bb.getActionObject(actionIdent);
if((action?.count ?? 0) > 0) { if ((action?.count ?? 0) > 0) {
const bbRetValue = bb.completeAction(p, this, actionIdent); const bbRetValue = bb.completeAction(p, this, actionIdent);
if(bbRetValue) { if (bbRetValue) {
retValue = this.gainExperience(p, bbRetValue); retValue = this.gainExperience(p, bbRetValue);
this.gainMoney(p, bbRetValue); this.gainMoney(p, bbRetValue);
@ -633,13 +633,13 @@ 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) {
const retVal = createTaskTracker(); const retVal = createTaskTracker();
retVal.int = CONSTANTS.IntelligenceClassBaseExpGain * Math.round(this.currentTaskTime / 1000); retVal.int = CONSTANTS.IntelligenceClassBaseExpGain * Math.round(this.currentTaskTime / 1000);
this.gainExperience(p, retVal);//Wont be shared with other sleeves this.gainExperience(p, retVal); //Wont be shared with other sleeves
} }
this.earningsForTask = createTaskTracker(); this.earningsForTask = createTaskTracker();
this.gainRatesForTask = createTaskTracker(); this.gainRatesForTask = createTaskTracker();
@ -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;
} }
@ -1121,41 +1121,41 @@ export class Sleeve extends Person {
contractSuccessChance(p: IPlayer, type: string, name: string): string { contractSuccessChance(p: IPlayer, type: string, name: string): string {
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}%`;
} }
} }
contractGainRates(p: IPlayer, type: string, name: string): void { contractGainRates(p: IPlayer, type: string, name: string): void {
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,28 +1167,30 @@ 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;
} }
} }
takeDamage(amt: number):boolean { takeDamage(amt: number): boolean {
if (typeof amt !== "number") { if (typeof amt !== "number") {
console.warn(`Player.takeDamage() called without a numeric argument: ${amt}`); console.warn(`Player.takeDamage() called without a numeric argument: ${amt}`);
return false; return false;
@ -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;
@ -86,7 +93,7 @@ function possibleFactions(player: IPlayer, sleeve: Sleeve): string[] {
function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] { function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] {
const bb = player.bladeburner; const bb = player.bladeburner;
if(bb === null){ if (bb === null) {
return ["------"]; return ["------"];
} }
let contracts = bb.getContractNamesNetscriptFn(); let contracts = bb.getContractNamesNetscriptFn();
@ -94,12 +101,11 @@ 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) {
return ["------"]; return ["------"];
} }
return contracts; return contracts;
@ -194,12 +200,13 @@ const tasks: {
return { return {
first: bladeburnerSelectorOptions, first: bladeburnerSelectorOptions,
second: (s1: string) => { second: (s1: string) => {
if(s1 === "Take on Contracts"){ if (s1 === "Take on Contracts") {
return possibleContracts(player, sleeve); return possibleContracts(player, sleeve);
} else { } else {
return ["------"]; return ["------"];
} }
} }; },
};
}, },
"Shock Recovery": (): ITaskDetails => { "Shock Recovery": (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] }; return { first: ["------"], second: () => ["------"] };