Commit Graph

435 Commits

Author SHA1 Message Date
hydroflame
7784c2f8b2
Update NetscriptDefinitions.d.ts 2022-10-22 00:23:10 -04:00
Snarling
d74c380e42
WIP: Crimes streamlining. (#138)
* streamline crimes

* Crimes object is now indexed by CrimeType enum instead of an entirely new set of keys that aren't used for anything else. This eliminated a lot of instances of iterating to find the right crime for a given CrimeType.
* Removed unused `None` CrimeType which allowed typing Crimes as a Record<CrimeType, Crime>.
* Added slums tooltip text as a crime property, to allow streamlining slums.
* Refactor slums location - removed repetitive code, rerenders 1/sec to update chances
* Fix bugged descriptive text when sleeve is committing a crime (was "is attempting to DRUGS", now uses correct text e.g. "to deal drugs").
* Remove unused and now unneeded NewCrimeType enum. Values were identical to existing CrimeType values after removing unused None.

* Add CrimeType enum in NetscriptDefinition.d.ts

* Also update broken ToastVariant type. Better support for enums in player scripts.
* Still todo is modifying some NS functions to expect CrimeType as input (rough crime names will continue to work to avoid breaking scripts)

* Expect enum use for crime functions

Affected functions:
* ns.singularity.commitCrime
* ns.singularity.getCrimeChance
* ns.singularity.getCrimeStats
* ns.sleeve.setToCommitCrime
* formulas.work.crimeGains (param type only)

- Affected functions still will fall back to rough names, except formulas.work.crimeGains which already only accepted the enum members.
- Some documentation changes:
  * examples updated to use uppercase expected form.
  * Note on sleeve.setToCommitCrime that it only accepts exact matches removed. It already, and still does, accept any rough crime name (but the enum is expected input).
  * note about needing to use isBusy to schedule crimes remove - crimes autoloop now.
  * Since expected string inputs are documented directly on the type, removed list of crimes from sleeve.setToCommitCrimes
2022-10-21 11:57:37 -04:00
Snarling
1d0d4f8da6
fix grow doc (#136) 2022-10-19 17:25:54 -04:00
Snarling
3af6e7db45
Remove incorrect note about disableLog (#135) 2022-10-19 17:20:31 -04:00
Olivier Gagnon
af1a1ac58d Rename lots of reference from old to new repo 2022-10-20 03:56:59 +11:00
hydroflame
0f46d72a01
Merge pull request #4245 from dbachran/4239-adjust-write-documentation
MISC: Adjust write() documentation, only accepts strings now
2022-10-19 11:46:08 -04:00
hydroflame
51f8d29e7a
Merge pull request #4247 from quacksouls/doc-prompt
DOC: `ns.prompt()`: some cleanup and examples
2022-10-19 11:45:49 -04:00
hydroflame
1b7b4fa466
Merge pull request #4249 from Snarling/typeAssertion
NETSCRIPT: Fix ns.prompt typechecking
2022-10-19 11:44:59 -04:00
Duck McSouls
6f1822bf4d DOC: gang.canRecruitMember(): when this returns true or false
Elaborate on the conditions under which the function would return true or false.  In particular, after a gang is successfully created the function always return true so the player can recruit a number of founding members to their gang.  When the gang is at capacity, the function always return false.  In between, the function returns true or false depending on the amount of respect the player has.
2022-10-16 18:34:34 +11:00
Duck McSouls
ac0e7c9595 DOC: gang.canRecruitMember(): typo fixes
Some typographical fixes.
2022-10-16 17:56:45 +11:00
Duck McSouls
93090691b5 DOC: ns.prompt(): some examples
Add some examples to illustrate the use of the various options.  As per suggestion by @Snarling, simplify the examples on free-form text box and drop-down list.
2022-10-15 11:27:56 +11:00
Duck McSouls
473e6a2674 DOC: ns.prompt(): explain the various options
Elaborate on the effects of `options.type` and `options.choices`.  Break the explanation into bullet points for clearer presentation.  Thanks to @Snarling for pointing out that the default is to create a boolean dialog box.
2022-10-15 11:03:36 +11:00
omuretsu
ad0be471ce fix ns.prompt typechecking
Introduced some new type assertion functions, initial step in larger type safety rework.
2022-10-14 11:00:29 -04:00
Duck McSouls
a368c6904e DOC: ns.prompt(): a typo fix
A simple typographical fix.
2022-10-14 14:50:35 +11:00
Daniel Bachran
5acd5e84a3 #4239 Adjust write() documentation
write() only accepts strings now.
2022-10-13 17:45:40 +02:00
Olivier Gagnon
8ff840edfa getBitnodeM takes 2 arg 2022-10-13 00:51:53 -04:00
Olivier Gagnon
ae5fc168bf Add getMoneySources 2022-10-13 00:10:59 -04:00
hydroflame
93769c7089
Merge pull request #4224 from quacksouls/doc-scan
DOC: `ns.scan()`: typo fixes and add 2 examples
2022-10-12 23:52:34 -04:00
hydroflame
50bc41bf5b
Merge pull request #4231 from borisflagell/TypoRepReq#3811
API: Fix #3811 Update NetscriptDefinitions.d.ts
2022-10-12 23:51:39 -04:00
omuretsu
7a384d53f4 typefix netscriptFunctions (see desc)
* Types for InternalFunction and ExternalFunction have been modified to actually typecheck ns functions against docs.
* Internal functions are required to use unknown for any params on the inner function.
* Return types for internal function inner-function must match the respective external function.
* Added new typecheck assertion function for asserting dynamic object types, to allow unknownifying params that were previously hardcoded objec structures.
* Because type assertion for parameter types and return types is enforced by InternalAPI, removed all duplicate type declarations on NetscriptFunction params and returns.
2022-10-12 08:49:27 -04:00
borisflagell
b2886ba623 Update NetscriptDefinitions.d.ts 2022-10-11 18:45:38 +03:00
Duck McSouls
b03288a700 DOC: ns.scan(): add 2 examples
The first example shows how to use `ns.scan()` without passing an argument.  The second example uses `ns.scan()` by passing the hostname of a target server.  Both examples can be written more succinctly by using the `forEach()` method of array, but for the purposes of illustration the `for` loop should be easier for beginners to read.
2022-10-11 18:48:47 +11:00
Duck McSouls
afe6a837c3 DOC: ns.sleeve.setToCommitCrime(): add 1 example
An example on how to set a sleeve to commit a crime.  The example shows that sleeves are indexed from 0.
2022-10-10 20:49:33 +11:00
Duck McSouls
c728c550f5 DOC: ns.sleeve.setToCommitCrime(): add all crimes a sleeve can commit
Add a list of crimes that a sleeve can commit.  Update the parameter documentation to refer to this list.
2022-10-10 13:18:00 +11:00
Duck McSouls
304b7645b0 DOC: ns.sleeve.setToCommitCrime(): starting index of sleeves
Document the index of the first sleeve.  Sleeves are indexed starting from zero, i.e. 0.  Increment by 1 to get the index of the next sleeve.  And so on.
2022-10-10 12:47:20 +11:00
Duck McSouls
67f5d60116 DOC: ns.scan(): typo fixes
Some typographical fixes in the documentation of the function `ns.scan()`.  The function returns an array, not a string.
2022-10-10 09:55:31 +11:00
Olivier Gagnon
f803355335 fix doc 2022-10-09 18:48:58 -04:00
Olivier Gagnon
7a89c0a1bb regen doc 2022-10-09 18:46:13 -04:00
Olivier Gagnon
f4668b21ca functions to generate dummy contracts 2022-10-09 02:56:11 -04:00
Olivier Gagnon
5d4b72e1d1 Added some purchased server functions 2022-10-09 02:32:13 -04:00
Olivier Gagnon
f6f023eeb4 Fix tons of typos 2022-10-09 01:25:31 -04:00
hydroflame
a5b2512269
Merge pull request #4205 from Snarling/ramTestFix
TESTS: Refined ram calculation tests
2022-10-09 00:23:04 -04:00
hydroflame
b4d6ead5d2
Merge pull request #4206 from quacksouls/doc-exec
DOC: `ns.exec()`: typo fixes and clean presentation
2022-10-09 00:22:54 -04:00
Duck McSouls
351d769122 DOC: no trailing whitespace
Remove some trailing whitespaces in `src/ScriptEditor/NetscriptDefinitions.d.ts` because `npm run format` complains about them.  The trailing whitespaces were introduced in one of my earlier patches.  Sorry about this :-(
2022-10-06 23:29:06 +11:00
Duck McSouls
e3ace9f6d5 DOC: ns.exec(): break example comments into multiple lines
The comment of each example is so long that, in the generated documentation for `ns.exec()` shown at

https://github.com/danielyxie/bitburner/blob/dev/markdown/bitburner.ns.exec.md

you must use the horizontal scrollbar to read the whole comment.  Even if you maximize the browser window, you must still use the horizontal scrollbar to read the whole comment.  Tested on Brave, Chrome, Firefox, and Opera.  Fix this by limiting each line of comment to at most 90 characters.
2022-10-06 22:56:01 +11:00
Duck McSouls
5edcdaad81 DOC: ns.exec(): typo fixes
Some typographical fixes in the documentation of `ns.exec()`.  Link to the function `ns.run()`.  Currently, the line `* * @example` causes API Extractor to output an asterisk (i.e. `*`) between the two code examples.  The function `ns.exec()` calls the function `runScriptFromScript()` from `src/NetscriptWorker.ts`, which uses the floor function to round down the number of threads.
2022-10-06 22:34:00 +11:00
Snarling
0310a98237 Lint+format fix? 2022-10-05 15:29:56 -04:00
Snarling
068533cd2f format, lint, more enums, revert fn rename 2022-10-05 14:52:48 -04:00
Snarling
8bb88a5080 Better RamCost testing (see desc)
* RamCostGenerator will have an error if ramcosts are defined for nonexistent functions, in addition to error if not all functions have ram costs defined
* Removed a few random blank comment lines in NetscriptDefinitions.d.ts
* RamCalculation.test.ts checks exact expected static and dynamic ram usage from (almost) every function, based on defined RamCosts in RamCostGenerator.
2022-10-05 10:42:07 -04:00
hydroflame
5b699fa19f
Merge pull request #4188 from quacksouls/doc-stock
DOC: `stock.getPrice()`: typo fixes and update examples
2022-10-04 11:47:24 -04:00
hydroflame
774c3ef402
Merge pull request #4185 from quacksouls/doc-print
DOC: `print()` and friends: typo fixes and examples
2022-10-04 11:45:01 -04:00
Snarling
361466b7fa unasync trywriteport 2022-10-04 07:59:50 -04:00
Snarling
aa80cf6451 See description
Reverted ToastVariant back to an enum internally. Still exposed to player as just possible strings.
Changed all 1-line documentation comments to actually be 1-line. Moved some because they were not providing documentation for the thing they were trying to.
2022-10-04 06:40:10 -04:00
Snarling
50f14b4f58 Commit1 2022-10-03 12:12:16 -04:00
Duck McSouls
01e7ce2a05 DOC: stock.getPrice(): a simple example
Fixes #4184. The hard-coded stock symbol `"FISG"` should be `"FSIG"`.
2022-10-02 11:39:54 +11:00
Snarling
3addda7173 format and lint 2022-10-01 15:15:36 -04:00
Duck McSouls
4cf270138d DOC: stock.getPrice(): typo fix in examples
Fixes #4184.  The hard-coded stock symbol `"FISG"` should be `"FSIG"`.  The updated examples do not use a hard-coded stock symbol.  The documentation is updated to explain under which circumstances a player can run the function `stock.getPrice()`.
2022-10-01 10:07:20 +10:00
Duck McSouls
5e14d07d9a DOC: stock.getPrice(): typo fixes
Some typographical fixes for the documentation of `stock.getPrice()`.  The line for RAM cost should be separated by a blank line from the sentence about the definition of a stock's price.  Otherwise `npm run doc` would cram those information together onto one line.
2022-10-01 09:59:44 +10:00
Duck McSouls
d8ef63cfe9 NETSCRIPT: format fixes
The command `npm run format` reports some formatting issues under `src/ScriptEditor`.  Fix the reported formatting issues.
2022-09-30 14:47:33 +10:00
Duck McSouls
0488f6e7b3 DOC: print() and friends: some examples
Some examples for how to use `print()` and related functions.  Use cross-referencing to reduce duplicate examples.
2022-09-30 14:22:49 +10:00