mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-15 20:10:08 +02:00
DEVMENU: Easier to add/remove sleeves (#908)
This commit is contained in:
@@ -464,6 +464,19 @@ export class Sleeve extends Person implements SleevePerson {
|
||||
}
|
||||
}
|
||||
|
||||
static recalculateNumOwned() {
|
||||
const numSleeves =
|
||||
Math.min(3, Player.sourceFileLvl(10) + (Player.bitNodeN === 10 ? 1 : 0)) + Player.sleevesFromCovenant;
|
||||
while (Player.sleeves.length > numSleeves) {
|
||||
const destroyedSleeve = Player.sleeves.pop();
|
||||
// This should not happen, but avoid an infinite loop in case sleevesFromCovenent or sf10 level are somehow negative
|
||||
if (!destroyedSleeve) return;
|
||||
// Stop work, to prevent destroyed sleeves from continuing their tasks in the void
|
||||
destroyedSleeve.stopWork();
|
||||
}
|
||||
while (Player.sleeves.length < numSleeves) Player.sleeves.push(new Sleeve());
|
||||
}
|
||||
|
||||
whoAmI(): string {
|
||||
return "Sleeve";
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export function CovenantPurchasesRoot(props: IProps): React.ReactElement {
|
||||
if (Player.canAfford(purchaseCost())) {
|
||||
Player.loseMoney(purchaseCost(), "sleeves");
|
||||
Player.sleevesFromCovenant += 1;
|
||||
Player.sleeves.push(new Sleeve());
|
||||
Sleeve.recalculateNumOwned();
|
||||
rerender();
|
||||
} else {
|
||||
dialogBoxCreate(`You cannot afford to purchase a Duplicate Sleeve`);
|
||||
|
||||
Reference in New Issue
Block a user