Merge pull request #3055 from ApamNapat/simplified_some_boolean_logic

Simplified some booleans and if elses
This commit is contained in:
hydroflame 2022-03-10 22:11:26 -05:00 committed by GitHub
commit 31a26a31ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 47 deletions

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

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

@ -186,8 +186,7 @@ export class OfficeSpace {
jobCount--;
}
}
if (jobCount !== amount) return false;
return true;
return jobCount === amount;
}
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`);
return false;
}
if (Math.random() <= chance) {
//Success
return true;
} else {
//Failure
return false;
}
return Math.random() <= chance;
}
export function findCrime(roughName: string): Crime | null {

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

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

@ -806,7 +806,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
if (possibleLogs[fn] === undefined) {
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 {
const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs);
@ -1589,10 +1589,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
}
}
const txtFile = getTextFile(filename, server);
if (txtFile != null) {
return true;
}
return false;
return txtFile != null;
},
isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any): any {
updateDynamicRam("isRunning", getRamCost(Player, "isRunning"));

@ -2004,18 +2004,13 @@ export function isQualified(this: IPlayer, company: Company, position: CompanyPo
const reqAgility = position.requiredDexterity > 0 ? position.requiredDexterity + offset : 0;
const reqCharisma = position.requiredCharisma > 0 ? position.requiredCharisma + offset : 0;
if (
this.hacking >= reqHacking &&
return this.hacking >= reqHacking &&
this.strength >= reqStrength &&
this.defense >= reqDefense &&
this.dexterity >= reqDexterity &&
this.agility >= reqAgility &&
this.charisma >= reqCharisma &&
company.playerReputation >= position.requiredReputation
) {
return true;
}
return false;
company.playerReputation >= position.requiredReputation;
}
/********** Reapplying Augmentations and Source File ***********/
@ -2573,7 +2568,7 @@ export function queueAugmentation(this: IPlayer, name: string): void {
/************* Coding Contracts **************/
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`;
}

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

@ -307,15 +307,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
reach = Math.max(i + data[i], reach);
}
const solution: boolean = i === n;
if (ans === "1" && solution) {
return true;
}
if (ans === "0" && !solution) {
return true;
}
return false;
return (ans === "1" && solution) || (ans === "0" && !solution);
},
},
{