mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
Address feedback
This commit is contained in:
parent
300a93f27f
commit
5c2db27f87
@ -7,6 +7,7 @@ import { NewBus, NewISocket, NewOSocket } from "./NewDevices";
|
||||
import { startRoaming } from "./glitches/roaming";
|
||||
import { startRust } from "./glitches/rust";
|
||||
import { startSegmentation } from "./glitches/segmentation";
|
||||
import { startBattery } from "./glitches/battery";
|
||||
|
||||
export interface Myrian {
|
||||
vulns: number;
|
||||
@ -33,6 +34,7 @@ export const loadMyrian = (save: string) => {
|
||||
startRoaming();
|
||||
startRust();
|
||||
startSegmentation();
|
||||
startBattery();
|
||||
if (!save) return;
|
||||
const savedMyrian = JSON.parse(save);
|
||||
Object.assign(myrian, savedMyrian);
|
||||
|
@ -23,7 +23,7 @@ const makeExpFunction = (p: Partial<DeviceScale>) => {
|
||||
export const upgradeMaxContentCost = makeExpFunction({
|
||||
[DeviceType.Bus]: [8, 0.5, 2, 0],
|
||||
[DeviceType.ISocket]: [4, 1, 5, 0],
|
||||
[DeviceType.Reducer]: [Infinity, 1, -1, 4095],
|
||||
[DeviceType.Reducer]: [256, 1, -3, 512],
|
||||
[DeviceType.Cache]: [1.2, 10, 0, 63],
|
||||
});
|
||||
|
||||
@ -53,15 +53,15 @@ export const upgradeInstallLvlCost = makeExpFunction({
|
||||
});
|
||||
|
||||
export const upgradeMaxEnergyCost = makeExpFunction({
|
||||
[DeviceType.Bus]: [2, 1, 3, 0],
|
||||
[DeviceType.Battery]: [1.1, 1, 3, 8],
|
||||
[DeviceType.Bus]: [1.1, 1, -8, 16],
|
||||
[DeviceType.Battery]: [1.1, 1, -16, 8],
|
||||
});
|
||||
|
||||
export const installDeviceCost = makeExpFunction({
|
||||
[DeviceType.Bus]: [4, 0.5, 2, 0],
|
||||
[DeviceType.ISocket]: [2, 1, 4, 0],
|
||||
[DeviceType.OSocket]: [4, 1, 3, 0],
|
||||
[DeviceType.Reducer]: [1.5, 1, 2, 0],
|
||||
[DeviceType.Cache]: [1.2, 10, 0, 63],
|
||||
[DeviceType.Reducer]: [5, 0.5, 1, 0],
|
||||
[DeviceType.Cache]: [1.2, 5, 0, 18],
|
||||
[DeviceType.Battery]: [1.2, 10, 0, 63],
|
||||
});
|
||||
|
@ -28,16 +28,16 @@ export const giltchMultCoefficients: Record<Glitch, number> = {
|
||||
export const glitchMult = (glitch: Glitch, lvl: number) => 1 + lvl * giltchMultCoefficients[glitch];
|
||||
|
||||
// move hinderance
|
||||
export const frictionMult = (lvl: number) => Math.pow(1.25, lvl);
|
||||
export const frictionMult = (lvl: number) => Math.pow(2.5, lvl);
|
||||
|
||||
// transfer slow down
|
||||
export const isolationMult = (lvl: number) => Math.pow(2, lvl);
|
||||
export const isolationMult = (lvl: number) => Math.pow(8, lvl);
|
||||
|
||||
// install/uninstall slow down
|
||||
export const virtualizationMult = (lvl: number) => Math.pow(3, lvl);
|
||||
export const virtualizationMult = (lvl: number) => Math.pow(5, lvl);
|
||||
|
||||
// reduce slow down
|
||||
export const jammingMult = (lvl: number) => Math.pow(1.3, lvl);
|
||||
export const jammingMult = (lvl: number) => Math.pow(2.5, lvl);
|
||||
|
||||
// energy loss
|
||||
export const magnetismLoss = (lvl: number) => lvl;
|
||||
|
@ -5,7 +5,7 @@ export const moveSpeed = (level: number) => 1000 / (level + 10);
|
||||
export const reduceSpeed = (level: number) => 50000 / (level + 10);
|
||||
|
||||
// speed to transfer components between devices
|
||||
export const transferSpeed = (level: number) => 1000 / (level + 10);
|
||||
export const transferSpeed = (level: number) => 4000 / (level + 10);
|
||||
|
||||
// speed to install / uninstall devices and tweak ISockets
|
||||
export const installSpeed = (level: number) => 100000 / (level + 10);
|
||||
|
@ -23,9 +23,17 @@ export const distanceCoord2D = (a: Device, coord: [number, number]) =>
|
||||
export const adjacent = (a: Device, b: Device) => distance(a, b) === 1;
|
||||
export const adjacentCoord2D = (a: Device, coord: [number, number]) => distanceCoord2D(a, coord) === 1;
|
||||
|
||||
export const makeContentMap = (content: Component[]) =>
|
||||
content.reduce((acc, c) => ({ ...acc, [c]: (acc[c] ?? 0) + 1 }), {} as Record<Component, number>);
|
||||
|
||||
export const inventoryMatches = (a: Component[], b: Component[]) => {
|
||||
if (a.length != b.length) return false;
|
||||
return a.every((i) => b.includes(i));
|
||||
const aMap = makeContentMap(a);
|
||||
const bMap = makeContentMap(b);
|
||||
|
||||
return (
|
||||
(Object.keys(aMap) as Component[]).every((k) => aMap[k] === bMap[k]) &&
|
||||
Object.keys(aMap).length === Object.keys(aMap).length
|
||||
);
|
||||
};
|
||||
|
||||
const vulnsMap: Record<Component, number> = {
|
||||
|
@ -137,6 +137,32 @@ export function NetscriptMyrian(): InternalAPI<IMyrian> {
|
||||
bus.isBusy = false;
|
||||
});
|
||||
},
|
||||
formatContent: (ctx) => (_device) => {
|
||||
const deviceID = helpers.deviceID(ctx, "device", _device);
|
||||
|
||||
const device = findDevice(deviceID);
|
||||
if (!device) {
|
||||
helpers.log(ctx, () => `device ${deviceID} not found`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isDeviceContainer(device)) {
|
||||
helpers.log(ctx, () => `device ${deviceID} is not a container`);
|
||||
return false;
|
||||
}
|
||||
|
||||
device.content = [];
|
||||
|
||||
if (isDeviceISocket(device)) {
|
||||
const cooldown = emissionSpeed(device.emissionLvl);
|
||||
device.cooldownUntil = Date.now() + cooldown;
|
||||
setTimeout(() => {
|
||||
device.content = new Array(device.maxContent).fill(device.emitting);
|
||||
}, cooldown);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
transfer:
|
||||
(ctx) =>
|
||||
async (_from, _to, _input, _output): Promise<boolean> => {
|
||||
|
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -5375,6 +5375,12 @@ interface Myrian {
|
||||
*/
|
||||
moveBus(bus: DeviceID, coord: [number, number]): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Delete the entire content of a device, typically used for debugging.
|
||||
* @returns true if the formatting succeeded, false otherwise.
|
||||
*/
|
||||
formatContent(device: DeviceID): boolean;
|
||||
|
||||
/**
|
||||
* Transfer components between devices, one of them must be a bus.
|
||||
* @remarks
|
||||
|
Loading…
Reference in New Issue
Block a user