Commit Graph

388 Commits

Author SHA1 Message Date
David Walker
7b5080a42b
NETSCRIPT: Add undocumented function printRaw() (#277)
This is analagous to tprintRaw (enabled by ns.iKnowWhatImDoing()), but
for logs instead of the terminal. This provides a supported* method of
creating complicated UIs for scripts.

*No actual support, expressed or implied, is provided for use of this
function.
2023-01-05 20:30:34 -05:00
Snarling
31bf0c43d1 v2.2.1 (#293)
* handle enums differently
* Enums are frozen and fed directly to the proxy
* Enums are not included in the NSFull definition, allowing samekeys for RamCostTree<API>, InternalAPI<API>, and ExternalAPI<API>
* Rewrote a lot of the ramcalc test, with better typing thanks to the samekeys above
* Fix ns1 for proxy (args, pid, and enums after above changes were not being added to ns1 scripts.)
* Fixed an overview issue where the bars could display inaccurately.
Update changelog and bump version to 2.2.1
2023-01-04 09:45:17 -05:00
David Walker
5f18b87323
New ns implementation using Proxy (#292) 2023-01-04 08:56:29 -05:00
omuretsu
0ec4ef31ab 2.2 2023-01-02 13:20:25 -05:00
Snarling
fb1f95c26e
VARIOUS: Various changes prior to release 2.2 (#271)
See PR #271 description
2022-12-29 20:28:53 -05:00
lucebac
5a86be8714
Update doc for ns.scp (#262) 2022-12-21 14:56:08 -05:00
David Walker
303c54c85c
NETSCRIPT: Fix a typo in scp (#256) 2022-12-19 14:39:03 -05:00
omuretsu
1dec0d00bd Add documentation for ns.pid 2022-12-13 09:09:12 -05:00
T.J. Eckman
52034ccedc
NETSCRIPT: Add ns.pid variable for accessing the current script's PID (#255) 2022-12-13 09:07:15 -05:00
G4mingJon4s
897a1fbc8e
Changed skill formatting from numeral to localeStr (#244) 2022-12-03 23:32:39 -05:00
Snarling
6af36e3b29
NETSCRIPT: Faster API wrapping on script launch. (#229)
* ns API is wrapped once
* when a new workerscript is created, each layer of ns is stamped with a private workerscript field that allows the functions to work.
* Test has been refactored to account for new method of wrapping
* BREAKING: ns functions need access to `this` value of their parent ns layer (or any ns layer)
* Enums are passed directly to player (no cloning) but are frozen.
2022-11-28 09:11:55 -05:00
Snarling
65cd14e33b
DOC: Add ns documentation for possible sleeve tasks (#217)
* Add specific types for sleeve tasks
* Moved LocationName enum to overall enums file
* Add LocationName enum to those provided to player
* remove trailing s on CompanyPosNames enum (now CompanyPosName, in line with LocationName)
* Also regenerated all ns documentation. This leads to an expected error when checking for generated files, because PRs should not normally touch markdown files. Also leads to a lint failure in generated file bitburner.d.ts
* also removed some exporting from NetscriptDefinitions.d.ts for anything that wasn't imported somewhere else.
2022-11-20 12:07:22 -05:00
Snarling
88d51e9a7e
MISC: A bunch of enums stuff. (#212)
* Some game enums moved to utils/enums. Others can eventually be moved there as well.
* findEnumMember function for performing fuzzy matching of player input with enum members, without needing separate fuzzy functions for every enum.
* Also used findEnumMember for safely loading save games (allows case changes in enum values)
* Changed capitalization on some enums.
* BREAKING: removed classGains work formulas function
* Split ClassType enum into UniversityClassType and GymType.
* Added universityGains and gymGains work formulas functions
* Provided the new split enums to the player on ns.enums.
2022-11-20 08:37:11 -05:00
Snarling
b275f88053
NETSCRIPT: Expose more enums for player use (#198)
* Add support for enums at other ns layers
* APIWrapper: simplified wrapping algorithm and modified to just use cloneDeep to copy enums instead of recursively wrapping enums as if they were new API layers
* Improve APIWrapper typing
* Changed some typings at RamCostGenerator to allow for enums at different levels without enums needing a ram cost
* Added enums to ns.corporation, removed getter functions that were being used instead.
* Add FactionWorkType for player use
* Add ClassType and CompanyWorkPos enums
* Change netscriptDefinitions to expect members of these new enums where appropriate.
2022-11-09 13:46:21 -05:00
Snarling
8e0e0eaa88
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200)
* BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form.
* BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner.
* Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person.
Added getSleeve, which provides a Sleeve object similar to getPlayer.
* Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency
* Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations.
* Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error.
* Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface.
* Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task
* Fixed leak of Player.jobs at ns.getPlayer
* Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 07:26:26 -05:00
Snarling
5205ff2837
Remove unused error blocks (#194) 2022-11-04 08:08:06 -04:00
Snarling
7ef2675e2c
Make writePort synchronous (#193) 2022-11-04 07:56:20 -04:00
Snarling
5fe89d5599
CORPORATION: Reorganize Industry data (#154) 2022-10-24 21:54:54 -04:00
Snarling
d7193ca8ff
fix negative time display (#153) 2022-10-24 20:09:10 -04:00
Snarling
0a3ff56331
WIP: Remove corp employees as objects (#143)
* Removed employees as objects from corporations
* Remove employees from office JSON after loading / convert to new parameters
* Showed down morale/etc gain; added optional position to hireEmployee
* enum support for corp employee positions

Mostly authored-by: Kelenius <kelenius@ya.ru>
2022-10-24 08:44:01 -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
omuretsu
9908f4aaa5 Error message fixes 2022-10-14 11:08:24 -04: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
Olivier Gagnon
6c84d64e67 rm unecessary return type 2022-10-13 01:07:10 -04:00
Olivier Gagnon
4c4f050214 simplify get money source 2022-10-13 00:55:57 -04: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
omuretsu
e192ad53ec Actually format + lint 2022-10-12 10:18:56 -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
Olivier Gagnon
cbb7f58231 Make the main player object an alias, makes it easier to import 2022-10-09 18:42:14 -04:00
Olivier Gagnon
3c03ac4f18 fix fileExists not finding coding contrafcts 2022-10-09 02:57:43 -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
Snarling
068533cd2f format, lint, more enums, revert fn rename 2022-10-05 14:52:48 -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
Snarling
b682d441e3 better fix for cores check 2022-09-29 00:02:33 -04:00
Snarling
17be0911b2 fix growthAnalyzeSecurity 2022-09-28 23:59:58 -04:00
Snarling
21a2d49de7 Finish removing player passing 2022-09-27 15:35:41 -04:00
Snarling
dc59a10e19 Fix lit files, reallow html alerts 2022-09-27 15:35:40 -04:00
Snarling
824d8db653 simplify/dehardcode failOnHacknetServer 2022-09-27 15:35:39 -04:00
Snarling
572c68738f Unify error handling 2022-09-27 15:34:47 -04:00
hydroflame
ed14f2a4d7
Merge pull request #4072 from Snarling/exitExits
NETSCRIPT: FIX #2376 ns.exit now exits immediately
2022-09-23 00:57:15 -03:00
Zoë Hoekstra
c7573cd97b
Remove unused imports. 2022-09-02 19:19:00 +02:00
Zoë Hoekstra
335eab0f14
tryWritePort now also uses helper function 2022-09-02 19:14:56 +02:00
Zoë Hoekstra
ec81fb60c3
Create ports on demand. Increase max to infinity. 2022-09-01 16:13:10 +02:00
Snarling
137f58c36d actually exitOnExit 2022-09-01 08:37:59 -04:00
Snarling
1be015898c exitExits 2022-09-01 08:23:31 -04:00
Olivier Gagnon
c9a0998cc1 Improve wrong arg user message and add ui.windowSize 2022-08-29 18:07:17 -04:00
Snarling
ef1f376c09 format, lint, remove unused "running" property on ws 2022-08-27 22:32:48 -04:00
Snarling
6f36e9cdc5 Fix/Unify NS1 wrapper 2022-08-27 20:56:12 -04:00
Snarling
bba9317ef6 incorporate read changes 2022-08-24 18:42:42 -04:00
Snarling
4d47785f28 Fix ns documentation for scp and write 2022-08-23 22:06:05 -04:00
hydroflame
849046df3a
Merge pull request #3985 from Snarling/synchronize
NETSCRIPT: ns.scp and ns.write are now synchronous + fix exec race condition
2022-08-23 12:25:24 -03:00
hydroflame
ed76c5e15d
Merge pull request #4019 from MageKing17/patch-4
API: All the player sub-objects need to be copied for `getPlayer`.
2022-08-23 12:07:34 -03:00
MageKing17
80aafc7d48
All the player sub-objects need to be copied.
Not just `mults`. Also, `hacking_chance_mult` still being at the base level appears to be a mistake.
2022-08-21 12:22:58 -07:00
Snarling
823cdf70ca Fix compile race conditions 2022-08-19 18:21:31 -04:00
Roman Ivaniuk
5c0c130b4b 3992 Fix: handle null duration in toast ns function
extend SnackbarEvents typing to allow null in third argument
also remove typos in Electron.tsx init functions comments
2022-08-19 14:38:46 +03:00
Snarling
07e9cb9277 refactor scp function 2022-08-17 20:31:26 -04:00
Snarling
f6a8d5d337 synchronize scp and write 2022-08-17 18:55:12 -04:00
Snarling
95a1c18139 synchronize write and scp 2022-08-17 17:11:59 -04:00
Snarling
b433c366d7 performance update 2022-08-09 19:10:55 -04:00
Snarling
c6cb4ca033 Type correctness 2022-08-09 19:02:33 -04:00
Snarling
648b7e84bf Some cleanup 2022-08-09 18:09:26 -04:00
Snarling
931ea730a5 Move entire ns object to top-level 2022-08-09 18:09:26 -04:00
Snarling
01e63b10a1 move ctx.log to NetscriptHelpers 2022-08-09 18:09:26 -04:00
Snarling
208495e269 Initial commit 2022-08-09 18:09:24 -04:00
Snarling
3a2e676c9b Move error functionality to new wrapper 2022-08-09 18:09:24 -04:00
Olivier Gagnon
07c7f0641a allbuild commit c8440ef2 2022-07-28 14:35:55 -04:00
Olivier Gagnon
315b2adf30 Make invalid hostname better 2022-07-27 00:59:43 -04:00
Olivier Gagnon
326d9fd7ef Move player skills and exp to their struct 2022-07-26 23:54:17 -04:00
Olivier Gagnon
faa3e212f3 fix a bunch of small v2 related bugs 2022-07-26 08:08:51 -04:00
Olivier Gagnon
631d6ef04a fix few bugs 2022-07-21 18:27:23 -04:00
Olivier Gagnon
43b8cfec5c fix test suite 2022-07-21 02:13:47 -04:00
Olivier Gagnon
d01fd55bde lint fmt 2022-07-21 01:58:47 -04:00
Olivier Gagnon
ec17cfdaf3 merge corp not async 2022-07-20 17:27:11 -04:00
Olivier Gagnon
94aa547459 more api break sad 2022-07-20 15:14:26 -04:00
Olivier Gagnon
e0a24cf381 fix args not beign passed to scripts 2022-07-20 11:34:49 -04:00
Olivier Gagnon
28b9c821d2 fix few as any 2022-07-20 02:36:21 -04:00
Olivier Gagnon
49f6fda1e4 remove last colon any for now 2022-07-20 01:48:54 -04:00
Olivier Gagnon
ceb9fa1249 fix more any 2022-07-20 01:13:06 -04:00
Olivier Gagnon
30291f7899 build fix for player in formulas 2022-07-19 23:05:46 -04:00
Olivier Gagnon
70d5390e4d most anys in NetFunc 2022-07-19 19:04:06 -04:00
Olivier Gagnon
c3a10d5d95 fix more anys 2022-07-19 18:25:06 -04:00
Olivier Gagnon
2442402af5 fix more anys 2022-07-19 16:46:03 -04:00
Olivier Gagnon
bb8af88b77 prep v2 2022-07-19 14:21:12 -04:00
Olivier Gagnon
4bee746576 rm any 2022-07-15 01:51:30 -04:00
Olivier Gagnon
5629c16def extract multipliers in its own type 2022-07-14 18:43:33 -04:00
Olivier Gagnon
fac6633347 remove so many fields and values used by the old system 2022-07-12 23:13:40 -04:00
Olivier Gagnon
f7805c4a51 convert faction work to new work system 2022-07-12 01:54:19 -04:00
Olivier Gagnon
606f1bf6c4 create program and grafting done 2022-07-10 01:37:36 -04:00
Olivier Gagnon
647392626e convert taking class ot new work system 2022-07-07 17:28:23 -04:00
Olivier Gagnon
3ee7d593d0 Convert crime to new work model 2022-07-07 02:00:23 -04:00
Staszek Welsh
02b07bb332 Fix relevant linter errors and run formatter 2022-06-02 22:54:50 +01:00
Olivier Gagnon
00adc2ffa2 allbuild commit ddf4ab26 2022-05-26 00:34:30 -04:00
hydroflame
bef953bf59
Merge pull request #3758 from danielyxie/api-wrap
Fix a few bugs related to api wrapping
2022-05-25 11:12:38 -04:00
Olivier Gagnon
4dd7afac9d allbuild commit 252b0a30 2022-05-25 11:10:25 -04:00
phyzical
bec40e5274
fix compliation error in dev
bugfix/fix-dev-build

File List:
src/NetscriptFunctions.ts
2022-05-25 17:20:32 +08:00
hydroflame
31fe43715e
Merge pull request #3743 from fdellwing/patch-1
MISC: Fix #3742 manualHack() should use correct BitNode Multiplier
2022-05-24 20:22:01 -04:00