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 { 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;
} }

@ -806,7 +806,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);
@ -1589,10 +1589,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"));

@ -2004,18 +2004,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 ***********/
@ -2573,7 +2568,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;
}, },
}, },
{ {