Simplified some booleans and if elses

This commit is contained in:
BB 2022-03-01 20:37:47 +01:00
parent 570b8caf78
commit 0eced1b9f2
10 changed files with 15 additions and 48 deletions

@ -2598,12 +2598,7 @@ function augmentationExists(name: string): boolean {
export function isRepeatableAug(aug: Augmentation): boolean { export function isRepeatableAug(aug: Augmentation): boolean {
const augName = aug instanceof Augmentation ? aug.name : aug; const augName = aug instanceof Augmentation ? aug.name : aug;
return augName === AugmentationNames.NeuroFluxGovernor;
if (augName === AugmentationNames.NeuroFluxGovernor) {
return true;
}
return false;
} }
export { installAugmentations, initAugmentations, applyAugmentation, augmentationExists }; export { installAugmentations, initAugmentations, applyAugmentation, augmentationExists };

@ -132,7 +132,7 @@ export function BitverseRoot(props: IProps): React.ReactElement {
const player = use.Player(); const player = use.Player();
const enter = enterBitNode; const enter = enterBitNode;
const destroyed = player.bitNodeN; const destroyed = player.bitNodeN;
const [destroySequence, setDestroySequence] = useState(true && !props.quick); const [destroySequence, setDestroySequence] = useState(!props.quick);
// Update NextSourceFileFlags // Update NextSourceFileFlags
const nextSourceFileFlags = SourceFileFlags.slice(); const nextSourceFileFlags = SourceFileFlags.slice();

@ -186,8 +186,7 @@ export class OfficeSpace {
jobCount--; jobCount--;
} }
} }
if (jobCount !== amount) return false; return jobCount === amount;
return true;
} }
toJSON(): any { toJSON(): any {

@ -20,14 +20,7 @@ export function determineCrimeSuccess(p: IPlayer, type: string): boolean {
dialogBoxCreate(`ERR: Unrecognized crime type: ${type} This is probably a bug please contact the developer`); dialogBoxCreate(`ERR: Unrecognized crime type: ${type} This is probably a bug please contact the developer`);
return false; return false;
} }
return Math.random() <= chance;
if (Math.random() <= chance) {
//Success
return true;
} else {
//Failure
return false;
}
} }
export function findCrime(roughName: string): Crime | null { export function findCrime(roughName: string): Crime | null {

@ -6,8 +6,7 @@ export let LastExportBonus = 0;
const bonusTimer = 24 * 60 * 60 * 1000; // 24h const bonusTimer = 24 * 60 * 60 * 1000; // 24h
export function canGetBonus(): boolean { export function canGetBonus(): boolean {
const now = new Date().getTime(); const now = new Date().getTime();
if (now - LastExportBonus > bonusTimer) return true; return now - LastExportBonus > bonusTimer;
return false;
} }
export function onExport(p: IPlayer): void { export function onExport(p: IPlayer): void {

@ -60,8 +60,5 @@ export function isScriptErrorMessage(msg: string): boolean {
return false; return false;
} }
const splitMsg = msg.split("|DELIMITER|"); const splitMsg = msg.split("|DELIMITER|");
if (splitMsg.length != 4) { return splitMsg.length == 4;
return false;
}
return true;
} }

@ -807,7 +807,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
if (possibleLogs[fn] === undefined) { if (possibleLogs[fn] === undefined) {
throw makeRuntimeErrorMsg("isLogEnabled", `Invalid argument: ${fn}.`); throw makeRuntimeErrorMsg("isLogEnabled", `Invalid argument: ${fn}.`);
} }
return workerScript.disableLogs[fn] ? false : true; return !workerScript.disableLogs[fn];
}, },
getScriptLogs: function (fn: any, hostname: any, ...scriptArgs: any): any { getScriptLogs: function (fn: any, hostname: any, ...scriptArgs: any): any {
const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs); const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs);
@ -1590,10 +1590,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
} }
const txtFile = getTextFile(filename, server); const txtFile = getTextFile(filename, server);
if (txtFile != null) { return txtFile != null;
return true;
}
return false;
}, },
isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any): any { isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any): any {
updateDynamicRam("isRunning", getRamCost(Player, "isRunning")); updateDynamicRam("isRunning", getRamCost(Player, "isRunning"));
@ -1655,7 +1652,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}else{ }else{
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`); workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`);
} }
return ""; return "";
} }

@ -2002,18 +2002,13 @@ export function isQualified(this: IPlayer, company: Company, position: CompanyPo
const reqAgility = position.requiredDexterity > 0 ? position.requiredDexterity + offset : 0; const reqAgility = position.requiredDexterity > 0 ? position.requiredDexterity + offset : 0;
const reqCharisma = position.requiredCharisma > 0 ? position.requiredCharisma + offset : 0; const reqCharisma = position.requiredCharisma > 0 ? position.requiredCharisma + offset : 0;
if ( return this.hacking >= reqHacking &&
this.hacking >= reqHacking &&
this.strength >= reqStrength && this.strength >= reqStrength &&
this.defense >= reqDefense && this.defense >= reqDefense &&
this.dexterity >= reqDexterity && this.dexterity >= reqDexterity &&
this.agility >= reqAgility && this.agility >= reqAgility &&
this.charisma >= reqCharisma && this.charisma >= reqCharisma &&
company.playerReputation >= position.requiredReputation company.playerReputation >= position.requiredReputation;
) {
return true;
}
return false;
} }
/********** Reapplying Augmentations and Source File ***********/ /********** Reapplying Augmentations and Source File ***********/
@ -2571,7 +2566,7 @@ export function queueAugmentation(this: IPlayer, name: string): void {
/************* Coding Contracts **************/ /************* Coding Contracts **************/
export function gainCodingContractReward(this: IPlayer, reward: ICodingContractReward, difficulty = 1): string { export function gainCodingContractReward(this: IPlayer, reward: ICodingContractReward, difficulty = 1): string {
if (reward == null || reward.type == null || reward == null) { if (reward == null || reward.type == null) {
return `No reward for this contract`; return `No reward for this contract`;
} }

@ -161,7 +161,7 @@ class BitburnerSaveObject {
return reject(new Error("Error importing file")); return reject(new Error("Error importing file"));
} }
const result = target.result; const result = target.result;
if (typeof result !== "string" || result === null) { if (typeof result !== "string") {
return reject(new Error("FileReader event was not type string")); return reject(new Error("FileReader event was not type string"));
} }
const contents = result; const contents = result;

@ -307,15 +307,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
reach = Math.max(i + data[i], reach); reach = Math.max(i + data[i], reach);
} }
const solution: boolean = i === n; const solution: boolean = i === n;
return (ans === "1" && solution) || (ans === "0" && !solution);
if (ans === "1" && solution) {
return true;
}
if (ans === "0" && !solution) {
return true;
}
return false;
}, },
}, },
{ {
@ -921,7 +913,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
"The provided answer should be an array of strings containing the valid expressions.", "The provided answer should be an array of strings containing the valid expressions.",
"The data provided by this problem is an array with two elements. The first element", "The data provided by this problem is an array with two elements. The first element",
"is the string of digits, while the second element is the target number:\n\n", "is the string of digits, while the second element is the target number:\n\n",
`["${digits}", ${target}]\n\n`, `["${digits}", ${target}]\n\n`,
"NOTE: The order of evaluation expects script operator precedence", "NOTE: The order of evaluation expects script operator precedence",
"NOTE: Numbers in the expression cannot have leading 0's. In other words,", "NOTE: Numbers in the expression cannot have leading 0's. In other words,",
`"1+01" is not a valid expression`, `"1+01" is not a valid expression`,