Includes some bug fixes:
* Fix sleeve shock internal/display discrepancy (0-100 vs 0-100)
* Special error message if ns function called without a this
* Change whitespace to pre-wrap for dialog box.
* Fix bug where idle sleeves do not consume cycles but still recover shock from those cycles. Now they do not recover during idle.
* attempted to tag commit as v2.2.0
* ns.codingcontract always returns a string (reward on success, empty on fail), simplifying usage and documentation of function.
* Because of the above, return value still works when used as a boolean, as long as no direct equality comparison to true/false.
* Documentation expanded and examples added.
Co-authored by @quacksouls
* 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.
Using code instead of key is strongly warned against at MDN and causes issues with nonstandard layouts:
https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event#keyboardevent.code
This also fixes ScriptEditorRoot.tsx, where some code snuck in that
wasn't using *any* of the constants.
This reverts commit 016a9a873fba71388bdbaa1423134fd1f2335a15.
* 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.
* 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.
* 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.
* 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.
* Removed unused partyEmployees and coffeeEmployees members of OfficeSpace
* Reworked formula for performance loss per market cycle.
* Rework both coffee and party formulas to allow easier recovery from low values.
* added ns.formulas.work.companyGains.
* Removed Work/Formulas folder, added Work/Formulas.ts
* CompanyPosition.calculateJobPerformance now takes in a Person instead of taking in a full set of stats, and it takes INT into account.
* formulas.crimeGains takes in a person object.
* Renamed ns Player type to Person.
* added multWorkStats, which multiplies a WorkStats object with a multipliers object.
* Remove unused types in NetscriptDefinitons.d.ts
* reuse formulas code in other parts of game
* getSleeveInformation also returns skills
Co-authored-by: Alexey <alexey.kozhemiakin@gmail.com>
Currently, the HTML line break sequence `<br /><br />` is hardcoded into the dialog box message when showing the content of these file types: ".js", ".script", and ".txt". By default, the function `dialogBoxCreate()` currently assumes that its first parameter is not HTML, but a text string, so whatever is in the string will appear in the dialog box. Use the newline character instead for line break.
* 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>
* purchasedByPlayer allows connect-from-anywhere as if the server was backdoored.
* Also added optional backdoorInstalled variable to type for BaseServer. This has no runtime effect, but it allows accessing that variable without TS needing us to verify whether it's instanceof Server first.
* A bunch of typographical fixes in the documentation of various Netscript functions. A main fix is standardizing the use of "hostname".
* Cross-reference the documentation of various Netscript functions. This makes it clear that we are referring to a particular Netscript function.
* Clarify the return values of various Netscript functions. Clarify the documentation of other functions.
* 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>
* 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
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.
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.
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.
* 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.
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.
INFILTRATION: Slash minigame fixed so attacking when the guard is preparing doesn't cause failure, fixed indicator when player has Might of Ares augmentation
Whenever StanekGift updated Sleeve's mult,
all mult were reset to default value (1.0 usually).
then stanek mult were merged.
but aug's mults never were.
=> Added a small loop to StanekGift updateMults() which reapply Aug's mult.
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 :-(
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.
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.
* 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.
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.
- Added ignoreAugment_WKSharmonizer to GameTimer to allow for strict, unmodified timers
- Changed SlashGame failure check
- Changed `timeUntilAttacking` value so the progress bar in SlashGame is accurate
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()`.
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.
Some typographical fixes. In the generated documentation for `tprintf()`, the documentation for the parameter `values` is missing because `@param msg` should be `@param values`.
Makes the Datamancer skill for Bladeburner apply to the Population Estimate change of the Tracking contract. If this was not desired, then the description of Datamancer needs to be made more accurate :D
Fixes#4067. The file name of a Coding Contract follows the format contract-xxx-rewardName.cct. The part `xxx` means a sequence of random decimal digits. The part `rewardName` can be an empty string if the player is not part of any faction nor is working for a company. However, if the player is working for a company or faction whose name has a special character, then the special character would also appear in the generated file name. We only want alphanumeric characters throughout the whole file name.
Fixes#4110. While online, there is 25% chance for a Coding Contract to appear. The same should apply when a player loads the game after being offline for a period of time. Currently, loading the game after being offline would give a generation probability of less than 25%. The mismatch between offline and online gives an unfair advantage to having the game running for an extended period of time.
In commit
7c5097ee83d9e2d185960a9c96739a78981bd600 the author extracted the functionality for infiltration rewards into a NS function and made it accessible via formulas.
The exposed function does however not use the same input parameters as the Victory screen after infiltration since he uses the difficulty and not the starting difficulty.
Difficulty is clamped to [0;3], so the formulas api showed for high difficulty servers a vastly lower result.