Skip to content

Commit

Permalink
API: Add new feature "ns.${Api}.isEligible" functions for Bladeburner…
Browse files Browse the repository at this point in the history
… and Stanek APIs.
  • Loading branch information
ivanrodgon committed Jan 11, 2025
1 parent c37cdc7 commit 7adf5c1
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 77 deletions.
22 changes: 22 additions & 0 deletions markdown/bitburner.bladeburner.checkbladeburnerapiaccess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Bladeburner](./bitburner.bladeburner.md) &gt; [checkBladeburnerAPIAccess](./bitburner.bladeburner.checkbladeburnerapiaccess.md)

## Bladeburner.checkBladeburnerAPIAccess() method

Check if you have access to the Bladeburner API.

**Signature:**

```typescript
checkBladeburnerAPIAccess(): boolean;
```
**Returns:**

boolean

true if you have access to the Bladeburner API, false otherwise.

## Remarks

RAM cost: 0 GB
22 changes: 22 additions & 0 deletions markdown/bitburner.bladeburner.iseligible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Bladeburner](./bitburner.bladeburner.md) &gt; [isEligible](./bitburner.bladeburner.iseligible.md)

## Bladeburner.isEligible() method

Check if the player is eligible to join the Bladeburner faction.

**Signature:**

```typescript
isEligible(): boolean;
```
**Returns:**

boolean

True if the player is eligible to join the Bladeburner faction, false otherwise.

## Remarks

RAM cost: 0 GB
3 changes: 2 additions & 1 deletion markdown/bitburner.bladeburner.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ You have to be employed in the Bladeburner division and be in BitNode-7 or have

| Method | Description |
| --- | --- |
| [checkBladeburnerAPIAccess()](./bitburner.bladeburner.checkbladeburnerapiaccess.md) | Check if you have access to the Bladeburner API. |
| [getActionAutolevel(type, name)](./bitburner.bladeburner.getactionautolevel.md) | Get whether an action is set to autolevel. |
| [getActionCountRemaining(type, name)](./bitburner.bladeburner.getactioncountremaining.md) | Get action count remaining. |
| [getActionCurrentLevel(type, name)](./bitburner.bladeburner.getactioncurrentlevel.md) | Get the current level of an action. |
Expand Down Expand Up @@ -49,6 +50,7 @@ You have to be employed in the Bladeburner division and be in BitNode-7 or have
| [getStamina()](./bitburner.bladeburner.getstamina.md) | Get Bladeburner stamina. |
| [getTeamSize(type, name)](./bitburner.bladeburner.getteamsize.md) | Get team size. |
| [inBladeburner()](./bitburner.bladeburner.inbladeburner.md) | Returns whether player is a member of Bladeburner division. Does not require API access. |
| [isEligible()](./bitburner.bladeburner.iseligible.md) | Check if the player is eligible to join the Bladeburner faction. |
| [joinBladeburnerDivision()](./bitburner.bladeburner.joinbladeburnerdivision.md) | Join the Bladeburner division. |
| [joinBladeburnerFaction()](./bitburner.bladeburner.joinbladeburnerfaction.md) | Join the Bladeburner faction. |
| [nextUpdate()](./bitburner.bladeburner.nextupdate.md) | Sleep until the next Bladeburner update has happened. |
Expand All @@ -59,4 +61,3 @@ You have to be employed in the Bladeburner division and be in BitNode-7 or have
| [stopBladeburnerAction()](./bitburner.bladeburner.stopbladeburneraction.md) | Stop current action. |
| [switchCity(city)](./bitburner.bladeburner.switchcity.md) | Travel to another city in Bladeburner. |
| [upgradeSkill(skillName, count)](./bitburner.bladeburner.upgradeskill.md) | Upgrade skill. |

3 changes: 0 additions & 3 deletions markdown/bitburner.ns.settailfontsize.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ RAM cost: 0 GB

This overwrites the tail font size and forces an update of the tail window's contents.

The font size is saved across restarts.

If ran without a filename or pid, this will affect the current script's tail window.

Otherwise, the PID or filename, hostname/ip, and args… arguments can be used to target the tail window from another script. Remember that scripts are uniquely identified by both their names and arguments.

22 changes: 22 additions & 0 deletions markdown/bitburner.stanek.checkstanekapiaccess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Stanek](./bitburner.stanek.md) &gt; [checkStanekAPIAccess](./bitburner.stanek.checkstanekapiaccess.md)

## Stanek.checkStanekAPIAccess() method

Check if Stanek's Gift is installed.

**Signature:**

```typescript
checkStanekAPIAccess(): boolean;
```
**Returns:**

boolean

true if Stanek's Gift is installed, false otherwise.

## Remarks

RAM cost: 0 GB
22 changes: 22 additions & 0 deletions markdown/bitburner.stanek.iseligible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Stanek](./bitburner.stanek.md) &gt; [isEligible](./bitburner.stanek.iseligible.md)

## Stanek.isEligible() method

Check if player is eligible for Stanek's Gift.

**Signature:**

```typescript
isEligible(): boolean;
```
**Returns:**

boolean

true if the player can receive Stanek's Gift.

## Remarks

RAM cost: 0 GB
3 changes: 2 additions & 1 deletion markdown/bitburner.stanek.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ interface Stanek
| [activeFragments()](./bitburner.stanek.activefragments.md) | List of fragments in Stanek's Gift. |
| [canPlaceFragment(rootX, rootY, rotation, fragmentId)](./bitburner.stanek.canplacefragment.md) | Check if fragment can be placed at specified location. |
| [chargeFragment(rootX, rootY)](./bitburner.stanek.chargefragment.md) | Charge a fragment, increasing its power. |
| [checkStanekAPIAccess()](./bitburner.stanek.checkstanekapiaccess.md) | Check if Stanek's Gift is installed. |
| [clearGift()](./bitburner.stanek.cleargift.md) | Clear the board of all fragments. |
| [fragmentDefinitions()](./bitburner.stanek.fragmentdefinitions.md) | List possible fragments. |
| [getFragment(rootX, rootY)](./bitburner.stanek.getfragment.md) | Get placed fragment at location. |
| [giftHeight()](./bitburner.stanek.giftheight.md) | Stanek's Gift height. |
| [giftWidth()](./bitburner.stanek.giftwidth.md) | Stanek's Gift width. |
| [isEligible()](./bitburner.stanek.iseligible.md) | Check if player is eligible for Stanek's Gift. |
| [placeFragment(rootX, rootY, rotation, fragmentId)](./bitburner.stanek.placefragment.md) | Place fragment on Stanek's Gift. |
| [removeFragment(rootX, rootY)](./bitburner.stanek.removefragment.md) | Remove fragment at location. |

74 changes: 39 additions & 35 deletions src/Bladeburner/Bladeburner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ export class Bladeburner implements OperationTeam {
this.joinFaction();
}

isEligible(): boolean {
return this.rank >= BladeburnerConstants.RankNeededForFaction;
}

joinFaction(): Attempt<{ message: string }> {
const faction = Factions[FactionName.Bladeburners];
if (faction.isMember) return { success: true, message: `Already a member of ${FactionName.Bladeburners} faction` };
if (this.rank >= BladeburnerConstants.RankNeededForFaction) {
if (this.isEligible()) {
joinFaction(faction);
return { success: true, message: `Joined ${FactionName.Bladeburners} faction` };
}
Expand Down Expand Up @@ -402,15 +406,15 @@ export class Bladeburner implements OperationTeam {
this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
this.postToConsole(
"When your stamina drops to " +
formatNumberNoSuffix(this.automateThreshLow, 0) +
", you will automatically switch to " +
(this.automateActionLow?.name ?? "Idle") +
". When your stamina recovers to " +
formatNumberNoSuffix(this.automateThreshHigh, 0) +
", you will automatically " +
"switch to " +
(this.automateActionHigh?.name ?? "Idle") +
".",
formatNumberNoSuffix(this.automateThreshLow, 0) +
", you will automatically switch to " +
(this.automateActionLow?.name ?? "Idle") +
". When your stamina recovers to " +
formatNumberNoSuffix(this.automateThreshHigh, 0) +
", you will automatically " +
"switch to " +
(this.automateActionHigh?.name ?? "Idle") +
".",
);
} else if (flag.toLowerCase().includes("en")) {
if (!this.automateActionLow || !this.automateActionHigh) {
Expand Down Expand Up @@ -635,8 +639,8 @@ export class Bladeburner implements OperationTeam {
if (this.logging.events) {
this.log(
"Intelligence indicates that a large number of Synthoids migrated from " +
sourceCityName +
" to some other city",
sourceCityName +
" to some other city",
);
}
} else if (chance <= 0.7) {
Expand Down Expand Up @@ -920,7 +924,7 @@ export class Bladeburner implements OperationTeam {
} else if (!isOperation && this.logging.contracts) {
this.log(
`${person.whoAmI()}: ${action.name} contract successfully completed! Gained ` +
`${formatBigNumber(gain)} rank and ${formatMoney(moneyGain)}.`,
`${formatBigNumber(gain)} rank and ${formatMoney(moneyGain)}.`,
);
}
}
Expand Down Expand Up @@ -1069,17 +1073,17 @@ export class Bladeburner implements OperationTeam {
if (this.logging.general) {
this.log(
`${person.whoAmI()}: ` +
"Training completed. Gained: " +
formatExp(strExpGain) +
" str exp, " +
formatExp(defExpGain) +
" def exp, " +
formatExp(dexExpGain) +
" dex exp, " +
formatExp(agiExpGain) +
" agi exp, " +
formatBigNumber(staminaGain) +
" max stamina.",
"Training completed. Gained: " +
formatExp(strExpGain) +
" str exp, " +
formatExp(defExpGain) +
" def exp, " +
formatExp(dexExpGain) +
" dex exp, " +
formatExp(agiExpGain) +
" agi exp, " +
formatBigNumber(staminaGain) +
" max stamina.",
);
}
break;
Expand Down Expand Up @@ -1107,9 +1111,9 @@ export class Bladeburner implements OperationTeam {
if (this.logging.general) {
this.log(
`${person.whoAmI()}: ` +
`Field analysis completed. Gained ${formatBigNumber(rankGain)} rank, ` +
`${formatExp(hackingExpGain)} hacking exp, and ` +
`${formatExp(charismaExpGain)} charisma exp.`,
`Field analysis completed. Gained ${formatBigNumber(rankGain)} rank, ` +
`${formatExp(hackingExpGain)} hacking exp, and ` +
`${formatExp(charismaExpGain)} charisma exp.`,
);
}
break;
Expand All @@ -1123,9 +1127,9 @@ export class Bladeburner implements OperationTeam {
if (this.logging.general) {
this.log(
`${person.whoAmI()}: ` +
"Successfully recruited a team member! Gained " +
formatExp(expGain) +
" charisma exp.",
"Successfully recruited a team member! Gained " +
formatExp(expGain) +
" charisma exp.",
);
}
} else {
Expand All @@ -1134,9 +1138,9 @@ export class Bladeburner implements OperationTeam {
if (this.logging.general) {
this.log(
`${person.whoAmI()}: ` +
"Failed to recruit a team member. Gained " +
formatExp(expGain) +
" charisma exp.",
"Failed to recruit a team member. Gained " +
formatExp(expGain) +
" charisma exp.",
);
}
}
Expand Down Expand Up @@ -1289,8 +1293,8 @@ export class Bladeburner implements OperationTeam {
// Min value of maxStamina is an arbitrarily small positive value. It must not be 0 to avoid NaN stamina penalty.
const maxStamina = clampNumber(
(baseStamina + this.staminaBonus) *
this.getSkillMult(BladeburnerMultName.Stamina) *
Player.mults.bladeburner_max_stamina,
this.getSkillMult(BladeburnerMultName.Stamina) *
Player.mults.bladeburner_max_stamina,
1e-9,
);
if (this.maxStamina === maxStamina) {
Expand Down
4 changes: 4 additions & 0 deletions src/Netscript/RamCostGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const go = {

// Bladeburner API
const bladeburner = {
checkBladeburnerAPIAccess: 0,
inBladeburner: RamCostConstants.BladeburnerApiBase / 4,
getContractNames: 0,
getOperationNames: 0,
Expand Down Expand Up @@ -317,6 +318,7 @@ const bladeburner = {
getCity: RamCostConstants.BladeburnerApiBase,
switchCity: RamCostConstants.BladeburnerApiBase,
getStamina: RamCostConstants.BladeburnerApiBase,
isEligible: 0,
joinBladeburnerFaction: RamCostConstants.BladeburnerApiBase,
joinBladeburnerDivision: RamCostConstants.BladeburnerApiBase,
getBonusTime: 0,
Expand Down Expand Up @@ -363,6 +365,7 @@ const sleeve = {

// Stanek API
const stanek = {
checkStanekAPIAccess: 0,
giftWidth: RamCostConstants.StanekWidth,
giftHeight: RamCostConstants.StanekHeight,
chargeFragment: RamCostConstants.StanekCharge,
Expand All @@ -373,6 +376,7 @@ const stanek = {
placeFragment: RamCostConstants.StanekPlace,
getFragment: RamCostConstants.StanekFragmentAt,
removeFragment: RamCostConstants.StanekDeleteAt,
isEligible: 0,
acceptGift: RamCostConstants.StanekAcceptGift,
} as const;

Expand Down
Loading

0 comments on commit 7adf5c1

Please sign in to comment.