Commit Graph

29 Commits

Author SHA1 Message Date
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
9e869bc876
NETSCRIPT: Add ns.formulas.work.companyGains function (#195)
* 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>
2022-11-06 17:27:04 -05: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
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
Snarling
83d357e758 commit1 2022-09-27 15:35:40 -04:00
Olivier Gagnon
89aa23f4b3 Add dummy function to generate a mock server or player for formulas stuff 2022-08-23 16:01:34 -04:00
Olivier Gagnon
a8bef50ef5 Added a few formulas to calculate work gains 2022-08-17 14:32:52 -04:00
Snarling
931ea730a5 Move entire ns object to top-level 2022-08-09 18:09:26 -04:00
Snarling
208495e269 Initial commit 2022-08-09 18:09:24 -04:00
Olivier Gagnon
2442402af5 fix more anys 2022-07-19 16:46:03 -04:00
Olivier Gagnon
76ccb0ba36 lint 2022-05-25 11:43:43 -04:00
Olivier Gagnon
0da2e74d12 more work on wrapping formulas 2022-05-24 17:51:48 -04:00
Olivier Gagnon
324f752d8a Wrap formulas but doesn't compile 2022-05-24 17:29:44 -04:00
Zoë Hoekstra
accb9f7e23
Add repFromDonation formula to the API 2022-04-14 20:01:31 +02:00
Olivier Gagnon
4b867fea3e rename factions formulas to reputation 2022-03-31 15:52:03 -04:00
PSEUDOSTAGE
a5f63e5932
fixed trailing spaces 2022-03-31 15:38:35 -04:00
PSEUDOSTAGE
a0333d36a5
Add calculateFavorToRep and calculateRepToFavor to Formulas.exe
The favorToRep and repToFavor formulas are displayed to the player in the factions pages but were not available in Formulas.exe. This change adds a FactionsFormulas interface with the calculateFavorToRep and calculateRepToFavor as new functions.
2022-03-31 15:27:02 -04:00
Olivier Gagnon
989d0709ed unknown-ify some code 2022-03-16 19:33:45 -04:00
Heikki Aitakangas
621df103cf Fix formulas access checks 2022-01-23 00:31:59 +02:00
Olivier Gagnon
394a286646 formulas for ascension 2021-12-09 12:52:51 -05:00
Olivier Gagnon
5a15df9ce7 rename the functions I created 2 minutes ago. 2021-12-08 19:03:33 -05:00
Olivier Gagnon
6eba92b36c rename the functions I created 2 minutes ago. 2021-12-08 18:41:49 -05:00
Olivier Gagnon
2af57cb01e formulas for gang stuff 2021-12-08 18:19:30 -05:00
Olivier Gagnon
7cc4295c63 fix a few bugs 2021-11-10 07:52:26 -05:00
Olivier Gagnon
73d0f2074c formulas time in millis 2021-11-05 00:27:30 -04:00
Olivier Gagnon
c5fb5155f3 work on making sure all the functions are accounted for 2021-11-03 18:16:10 -04:00
Olivier Gagnon
37845c57c0 migrate some of formulas 2021-11-02 22:58:40 -04:00
Olivier Gagnon
e892e16585 Formulas.exe 2021-10-27 23:41:47 -04:00
Olivier Gagnon
d3fc6a9d48 split NetscriptFunctions 2021-10-14 03:22:02 -04:00