mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-13 19:10:06 +02:00
Fix hostname generation being weird about dash 0 added
This commit is contained in:
@@ -280,15 +280,15 @@ export class Sleeve extends Person {
|
||||
return true;
|
||||
}
|
||||
|
||||
hasAugmentation(aug: string): boolean {
|
||||
return this.augmentations.some((a) => a.name === aug);
|
||||
}
|
||||
|
||||
tryBuyAugmentation(p: IPlayer, aug: Augmentation): boolean {
|
||||
if (!p.canAfford(aug.baseCost)) {
|
||||
return false;
|
||||
}
|
||||
if (!p.canAfford(aug.baseCost)) return false;
|
||||
|
||||
// Verify that this sleeve does not already have that augmentation.
|
||||
if (this.augmentations.some((a) => a.name === aug.name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.hasAugmentation(aug.name)) return false;
|
||||
|
||||
p.loseMoney(aug.baseCost, "sleeves");
|
||||
this.installAugmentation(aug);
|
||||
@@ -296,11 +296,6 @@ export class Sleeve extends Person {
|
||||
}
|
||||
|
||||
upgradeMemory(n: number): void {
|
||||
if (n < 0) {
|
||||
console.warn(`Sleeve.upgradeMemory() called with negative value: ${n}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.memory = Math.min(100, Math.round(this.memory + n));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,32 +5,24 @@ import { IPlayer } from "../IPlayer";
|
||||
|
||||
import { Augmentation } from "../../Augmentation/Augmentation";
|
||||
import { StaticAugmentations } from "../../Augmentation/StaticAugmentations";
|
||||
import { Faction } from "../../Faction/Faction";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { Multipliers } from "../Multipliers";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
|
||||
export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentation[] {
|
||||
// You can only purchase Augmentations that are actually available from
|
||||
// your factions. I.e. you must be in a faction that has the Augmentation
|
||||
// and you must also have enough rep in that faction in order to purchase it.
|
||||
|
||||
const ownedAugNames: string[] = sleeve.augmentations.map((e) => {
|
||||
return e.name;
|
||||
});
|
||||
const ownedAugNames = sleeve.augmentations.map((e) => e.name);
|
||||
const availableAugs: Augmentation[] = [];
|
||||
|
||||
// Helper function that helps filter out augs that are already owned
|
||||
// and augs that aren't allowed for sleeves
|
||||
function isAvailableForSleeve(aug: Augmentation): boolean {
|
||||
if (ownedAugNames.includes(aug.name)) {
|
||||
return false;
|
||||
}
|
||||
if (availableAugs.includes(aug)) {
|
||||
return false;
|
||||
}
|
||||
if (aug.isSpecial) {
|
||||
return false;
|
||||
}
|
||||
if (ownedAugNames.includes(aug.name)) return false;
|
||||
if (availableAugs.includes(aug)) return false;
|
||||
if (aug.isSpecial) return false;
|
||||
|
||||
type MultKey = keyof Multipliers;
|
||||
const validMults: MultKey[] = [
|
||||
@@ -53,9 +45,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
|
||||
"work_money",
|
||||
];
|
||||
for (const mult of validMults) {
|
||||
if (aug.mults[mult] !== 1) {
|
||||
return true;
|
||||
}
|
||||
if (aug.mults[mult] !== 1) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -68,9 +58,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
|
||||
|
||||
for (const augName of Object.keys(StaticAugmentations)) {
|
||||
const aug = StaticAugmentations[augName];
|
||||
if (!isAvailableForSleeve(aug)) {
|
||||
continue;
|
||||
}
|
||||
if (!isAvailableForSleeve(aug)) continue;
|
||||
|
||||
if (fac.playerReputation > aug.getCost(p).repCost) {
|
||||
availableAugs.push(aug);
|
||||
@@ -79,22 +67,14 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
|
||||
}
|
||||
|
||||
for (const facName of p.factions) {
|
||||
if (facName === FactionNames.Bladeburners) {
|
||||
continue;
|
||||
}
|
||||
if (facName === FactionNames.Netburners) {
|
||||
continue;
|
||||
}
|
||||
const fac: Faction | null = Factions[facName];
|
||||
if (fac == null) {
|
||||
continue;
|
||||
}
|
||||
if (facName === FactionNames.Bladeburners) continue;
|
||||
if (facName === FactionNames.Netburners) continue;
|
||||
const fac = Factions[facName];
|
||||
if (!fac) continue;
|
||||
|
||||
for (const augName of fac.augmentations) {
|
||||
const aug: Augmentation = StaticAugmentations[augName];
|
||||
if (!isAvailableForSleeve(aug)) {
|
||||
continue;
|
||||
}
|
||||
const aug = StaticAugmentations[augName];
|
||||
if (!isAvailableForSleeve(aug)) continue;
|
||||
|
||||
if (fac.playerReputation > aug.getCost(p).repCost) {
|
||||
availableAugs.push(aug);
|
||||
@@ -102,5 +82,14 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat
|
||||
}
|
||||
}
|
||||
|
||||
// Add the stanek sleeve aug
|
||||
if (
|
||||
!ownedAugNames.includes(AugmentationNames.UnnamedAug1) &&
|
||||
p.factions.includes(FactionNames.ChurchOfTheMachineGod)
|
||||
) {
|
||||
const aug = StaticAugmentations[AugmentationNames.UnnamedAug1];
|
||||
availableAugs.push(aug);
|
||||
}
|
||||
|
||||
return availableAugs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user