DOC: Update documentation for workForFaction and workForCompany (#180)

* DOC: `ns.singularity.workForFaction()`: update doc and examples
* Additional Doc Fixes
* Remove unnecessary fluff in singularity.workForFaction examples
* Fix documentation for singularity.workForCompany similar to fixes already applied to workForFaction
* Correct some inaccuracies in workForFaction and workForCompany remarks sections
* Shorten some comment lines that are over 120 characters in NetscriptDefinitions.d.ts, for consistency.

Co-authored-by: Duck McSouls <quacksouls@gmail.com>
This commit is contained in:
Snarling 2022-11-01 12:24:25 -04:00 committed by GitHub
parent 634611f9db
commit 3ce4dcf612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1366,7 +1366,8 @@ export interface TIX {
* ... * ...
* } * }
* ``` * ```
* The Order type property can have one of the following four values: "Limit Buy Order", "Limit Sell Order", "Stop Buy Order", "Stop Sell Order". * The Order type property can have one of the following four values: "Limit Buy Order", "Limit Sell Order",
* "Stop Buy Order", "Stop Sell Order".
* Note that the order book will only contain information for stocks that you actually have orders in. * Note that the order book will only contain information for stocks that you actually have orders in.
* *
* @example * @example
@ -1417,7 +1418,8 @@ export interface TIX {
getVolatility(sym: string): number; getVolatility(sym: string): number;
/** /**
* Returns the probability that the specified stocks price will increase (as opposed to decrease) during the next tick. * Returns the probability that the specified stocks price will increase (as opposed to decrease) during the next
* tick.
* @remarks * @remarks
* RAM cost: 2.5 GB * RAM cost: 2.5 GB
* The probability is returned as a decimal value, NOT a percentage * The probability is returned as a decimal value, NOT a percentage
@ -1465,7 +1467,8 @@ export interface TIX {
/** /**
* Singularity API * Singularity API
* @remarks * @remarks
* This API requires Source-File 4 to use. The RAM cost of all these functions is multiplied by 16/4/1 based on Source-File 4 levels. * This API requires Source-File 4 to use. The RAM cost of all these functions is multiplied by 16/4/1 based on
* Source-File 4 levels.
* @public * @public
*/ */
export interface Singularity { export interface Singularity {
@ -1687,37 +1690,30 @@ export interface Singularity {
* RAM cost: 3 GB * 16/4/1 * RAM cost: 3 GB * 16/4/1
* *
* *
* This function will automatically set you to start working at the company * This function will set you to start working at your current job at a specified company at which you are employed.
* at which you are employed. If you are already in the middle of some working * If you are already in the middle of some working action (such as working for a faction, training at a gym, or
* action (such as working for a faction, training at a gym, or creating a program), * creating a program), then running this function will cancel that action.
* then running this function will automatically cancel that action and give you
* your earnings.
* *
* This function will return true if the player starts working, and false otherwise. * This function will return true if the player starts working, and false otherwise.
* *
* Note that when you are working for a company, you will not actually receive your earnings (reputation, money, experience) until you FINISH the action.
*
* @example * @example
* ```ts * ```js
* // NS1: * // NS1:
* //If you only want to work until you get 100,000 company reputation. One small hack to get around this is to continuously restart the action to receive your earnings: * var COMPANY_NAME = "Noodle Bar";
* while (getCompanyRep(COMPANY HERE) < VALUE) { *
* workForCompany(); * var success = singularity.workForCompany(COMPANY_NAME);
* sleep(60000); * if (!success) tprint("ERROR: Failed to start work at " + COMPANY_NAME + ".");
* }
* //This way, your company reputation will be updated every minute.
* ``` * ```
* @example * @example
* ```ts * ```js
* // NS2: * // NS2:
* //If you only want to work until you get 100,000 company reputation. One small hack to get around this is to continuously restart the action to receive your earnings: * const COMPANY_NAME = "Noodle Bar";
* while (ns.getCompanyRep(COMPANY HERE) < VALUE) { *
* ns.workForCompany(); * let success = ns.singularity.workForCompany(COMPANY_NAME);
* await ns.sleep(60000); * if (!success) ns.tprint(`ERROR: Failed to start work at ${COMPANY_NAME].`);
* }
* //This way, your company reputation will be updated every minute.
* ``` * ```
* @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this argument defaults to the last job that you worked * @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this
* argument defaults to the last job that you worked.
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true. * @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
* @returns True if the player starts working, and false otherwise. * @returns True if the player starts working, and false otherwise.
*/ */
@ -1829,42 +1825,35 @@ export interface Singularity {
* RAM cost: 3 GB * 16/4/1 * RAM cost: 3 GB * 16/4/1
* *
* *
* This function will automatically set you to start working for the specified faction. * This function will set you to start working for the specified faction. You must be a member of the faction and
* Obviously, you must be a member of the faction or else this function will fail. If * that faction must have the specified work type, or else this function will fail. If you are already in the
* you are already in the middle of some working action (such as working for a company, * middle of some working action (such as working for a company, training at a gym, or creating a program), then
* training at a gym, or creating a program), then running this function will automatically * running this function will cancel that action.
* cancel that action and give you your earnings.
* *
* This function will return true if you successfully start working for the specified faction, and false otherwise. * This function will return true if you successfully start working for the specified faction, and false otherwise.
* *
* Note that when you are working for a faction, you will not actually receive your earnings (reputation, experience) until you FINISH the action.
*
* @example * @example
* ```ts * ```js
* // NS1: * // NS1
* //If you only want to work until you get 100,000 faction reputation. One small hack to get around this is to continuously restart the action to receive your earnings: * var FACTION_NAME = "CyberSec", WORK_TYPE = "hacking";
* while (getFactionRep(FACTION NAME) < VALUE) { *
* workForFaction(FACNAME, WORKTYPE); * var success = singularity.workForFaction(FACTION_NAME, WORK_TYPE);
* sleep(60000); * if (!success) tprint("ERROR: Failed to start work for " + FACTION_NAME + " with work type " + WORK_TYPE);
* }
* //This way, your faction reputation will be updated every minute.
* ``` * ```
* @example * @example
* ```ts * ```js
* // NS2: * // NS2
* //If you only want to work until you get 100,000 faction reputation. One small hack to get around this is to continuously restart the action to receive your earnings: * const FACTION_NAME = "CyberSec", WORK_TYPE = "hacking";
* while (ns.getFactionRep(FACTION NAME) < VALUE) { *
* ns.workForFaction(FACNAME, WORKTYPE); * let success = ns.singularity.workForFaction(FACTION_NAME, WORK_TYPE);
* await ns.sleep(60000); * if (!success) ns.tprint(`ERROR: Failed to start work for ${FACTION_NAME} with work type ${WORK_TYPE}.`)
* }
* //This way, your faction reputation will be updated every minute.
* ``` * ```
* @param faction - Name of faction to work for. * @param faction - Name of faction to work for.
* @param workType - Type of work to perform for the faction. * @param workType - Type of work to perform for the faction.
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true. * @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
* @returns True if the player starts working, and false otherwise. * @returns True if the player starts working, and false otherwise.
*/ */
workForFaction(faction: string, workType: string, focus?: boolean): boolean; workForFaction(faction: string, workType: "hacking" | "field" | "security", focus?: boolean): boolean;
/** /**
* Get faction reputation. * Get faction reputation.
@ -1935,7 +1924,8 @@ export interface Singularity {
* *
* This function returns true if you successfully start working on the specified program, and false otherwise. * This function returns true if you successfully start working on the specified program, and false otherwise.
* *
* Note that creating a program using this function has the same hacking level requirements as it normally would. These level requirements are: * Note that creating a program using this function has the same hacking level requirements as it normally would.
* These level requirements are:
* * BruteSSH.exe: 50 * * BruteSSH.exe: 50
* * FTPCrack.exe: 100 * * FTPCrack.exe: 100
* * relaySMTP.exe: 250 * * relaySMTP.exe: 250
@ -2018,7 +2008,9 @@ export interface Singularity {
* *
* This function returns an array containing the names (as strings) of all Augmentations you have. * This function returns an array containing the names (as strings) of all Augmentations you have.
* *
* @param purchased - Specifies whether the returned array should include Augmentations you have purchased but not yet installed. By default, this argument is false which means that the return value will NOT have the purchased Augmentations. * @param purchased - Specifies whether the returned array should include Augmentations you have purchased but not
* yet installed. By default, this argument is false which means that the return value will NOT have the purchased
* Augmentations.
* @returns Array containing the names (as strings) of all Augmentations you have. * @returns Array containing the names (as strings) of all Augmentations you have.
*/ */
getOwnedAugmentations(purchased?: boolean): string[]; getOwnedAugmentations(purchased?: boolean): string[];