Commit Graph

148 Commits

Author SHA1 Message Date
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
426ad5f296
Sleeve criming fix (#209)
Also simplify usage of findCrime
2022-11-10 11:05:42 -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
6f08aee8f6
Fix zombie scripts (#203)
Also made installAugmentations synchronously perform reset, but added a short timeout to the callback script launch for balance.
2022-11-08 12:17:34 -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
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
f6f023eeb4 Fix tons of typos 2022-10-09 01:25:31 -04:00
Snarling
16fac67257 fix broken rebase 2022-09-27 16:23:53 -04:00
Snarling
38063f62a7 build fix, lint, remove some instanceof checks 2022-09-27 16:09:32 -04:00
Snarling
e5e6b05be0 format+lint+build fix 2022-09-27 15:35:42 -04:00
Snarling
a21b1029d7 No more player/router context 2022-09-27 15:35:40 -04:00
Snarling
83d357e758 commit1 2022-09-27 15:35:40 -04:00
Duck McSouls
0a644aed58 Typo fix in ns.singularity.workForFaction()
Abbreviation of "you are" is "you're".  Also place a full stop at the end to complete the sentence.  Fixes #4118.
2022-09-23 20:32:53 +10:00
hydroflame
e49bd3d091
Merge branch 'dev' into feature/add-back-api-export 2022-09-23 00:34:19 -03:00
phyzical
4175960fc6
use bitnode multiplers in the output of crime stats 2022-09-20 17:56:05 +08:00
phyzical
ca2f1a62a5
add singularity function for exporting game save 2022-09-07 16:11:51 +08: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
445e365959 debounce updateRAM 2022-08-23 16:38:30 -04:00
hydroflame
fe3e34408d
Merge branch 'dev' into dev 2022-08-23 13:01:13 -03:00
MageKing17
28d7284323
Correct missing ! for boolean coercion.
`singularity.workForCompany()` was negating its `_focus` argument, unlike similar functions, which used double-negation to coerce to boolean. This was almost certainly a typo, since before PR-#3967 it used `_ctx.helper.boolean()` without negation, just like the other singularity functions.
2022-08-18 22:04:11 -07: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
326d9fd7ef Move player skills and exp to their struct 2022-07-26 23:54:17 -04:00
Olivier Gagnon
3e4f26ac0a allbuild commit e6d14eff 2022-07-26 15:30:12 -04:00
Aerophia
7c8c94d808
Add files via upload 2022-07-22 12:32:10 -05:00
Aerophia
c2ffb09514
Update Singularity.ts 2022-07-22 12:28:51 -05:00
Aerophia
1f918011dc
Update Singularity.ts 2022-07-22 12:16:48 -05:00
Aerophia
2ad978d8f4
Create Singularity.ts 2022-07-22 12:09:36 -05:00
Aerophia
dad4fcc25e
Update Singularity.ts 2022-07-22 12:09:01 -05:00
Aerophia
2907128291
Update Singularity.ts 2022-07-22 12:07:23 -05:00
Aerophia
757711ce5b
Update Singularity.ts 2022-07-22 10:29:40 -05:00
Olivier Gagnon
2d522ea1e6 allbuild commit e9254edf 2022-07-21 15:09:55 -04:00
hydroflame
a513a842e3
Merge pull request #3797 from Ansopedian/dev
BUGFIX: Singularity.goToLocation support for non-city-specific locations
2022-07-21 02:14:42 -04:00
Olivier Gagnon
43b8cfec5c fix test suite 2022-07-21 02:13:47 -04:00
Olivier Gagnon
4518eabc29 Remove some any and add getAugmentationBasePrice 2022-07-20 01:20:11 -04:00
Olivier Gagnon
83c26903c0 add argument for commitCrime focus 2022-07-19 22:30:07 -04:00
Olivier Gagnon
bb8af88b77 prep v2 2022-07-19 14:21:12 -04:00
Olivier Gagnon
5629c16def extract multipliers in its own type 2022-07-14 18:43:33 -04:00
Olivier Gagnon
0550bc188c refactor some stuff 2022-07-14 17:43:08 -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