mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 20:37:05 +02:00
API: Add types for parameters of gym-university-bladeburner API (#1591)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { BladeOperationName } from "@enums";
|
||||
import { BladeburnerOperationName } from "@enums";
|
||||
import { Operation } from "../Actions/Operation";
|
||||
import { getRandomIntInclusive } from "../../utils/helpers/getRandomIntInclusive";
|
||||
import { LevelableActionClass } from "../Actions/LevelableAction";
|
||||
import { assertLoadingType } from "../../utils/TypeAssertion";
|
||||
|
||||
export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
export function createOperations(): Record<BladeburnerOperationName, Operation> {
|
||||
return {
|
||||
[BladeOperationName.investigation]: new Operation({
|
||||
name: BladeOperationName.investigation,
|
||||
[BladeburnerOperationName.Investigation]: new Operation({
|
||||
name: BladeburnerOperationName.Investigation,
|
||||
desc:
|
||||
"As a field agent, investigate and identify Synthoid populations, movements, and operations.\n\n" +
|
||||
"Successful Investigation ops will increase the accuracy of your synthoid data.\n\n" +
|
||||
@@ -39,8 +39,8 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
growthFunction: () => getRandomIntInclusive(10, 40) / 10,
|
||||
maxCount: 100,
|
||||
}),
|
||||
[BladeOperationName.undercover]: new Operation({
|
||||
name: BladeOperationName.undercover,
|
||||
[BladeburnerOperationName.Undercover]: new Operation({
|
||||
name: BladeburnerOperationName.Undercover,
|
||||
desc:
|
||||
"Conduct undercover operations to identify hidden and underground Synthoid communities and organizations.\n\n" +
|
||||
"Successful Undercover ops will increase the accuracy of your synthoid data.",
|
||||
@@ -72,8 +72,8 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
growthFunction: () => getRandomIntInclusive(10, 40) / 10,
|
||||
maxCount: 100,
|
||||
}),
|
||||
[BladeOperationName.sting]: new Operation({
|
||||
name: BladeOperationName.sting,
|
||||
[BladeburnerOperationName.Sting]: new Operation({
|
||||
name: BladeburnerOperationName.Sting,
|
||||
desc: "Conduct a sting operation to bait and capture particularly notorious Synthoid criminals.",
|
||||
baseDifficulty: 650,
|
||||
difficultyFac: 1.04,
|
||||
@@ -102,8 +102,8 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
isStealth: true,
|
||||
growthFunction: () => getRandomIntInclusive(3, 40) / 10,
|
||||
}),
|
||||
[BladeOperationName.raid]: new Operation({
|
||||
name: BladeOperationName.raid,
|
||||
[BladeburnerOperationName.Raid]: new Operation({
|
||||
name: BladeburnerOperationName.Raid,
|
||||
desc:
|
||||
"Lead an assault on a known Synthoid community. Note that there must be an existing Synthoid community in your " +
|
||||
"current city in order for this Operation to be successful.",
|
||||
@@ -138,8 +138,8 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
return LevelableActionClass.prototype.getAvailability.call(this, bladeburner);
|
||||
},
|
||||
}),
|
||||
[BladeOperationName.stealthRetirement]: new Operation({
|
||||
name: BladeOperationName.stealthRetirement,
|
||||
[BladeburnerOperationName.StealthRetirement]: new Operation({
|
||||
name: BladeburnerOperationName.StealthRetirement,
|
||||
desc:
|
||||
"Lead a covert operation to retire Synthoids. The objective is to complete the task without drawing any " +
|
||||
"attention. Stealth and discretion are key.",
|
||||
@@ -171,8 +171,8 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
isKill: true,
|
||||
growthFunction: () => getRandomIntInclusive(1, 20) / 10,
|
||||
}),
|
||||
[BladeOperationName.assassination]: new Operation({
|
||||
name: BladeOperationName.assassination,
|
||||
[BladeburnerOperationName.Assassination]: new Operation({
|
||||
name: BladeburnerOperationName.Assassination,
|
||||
desc:
|
||||
"Assassinate Synthoids that have been identified as important, high-profile social and political leaders in the " +
|
||||
"Synthoid communities.",
|
||||
@@ -207,12 +207,12 @@ export function createOperations(): Record<BladeOperationName, Operation> {
|
||||
};
|
||||
}
|
||||
|
||||
export function loadOperationsData(data: unknown, operations: Record<BladeOperationName, Operation>) {
|
||||
export function loadOperationsData(data: unknown, operations: Record<BladeburnerOperationName, Operation>) {
|
||||
// loading data as "unknown" and typechecking it down is probably not necessary
|
||||
// but this will prevent crashes even with malformed savedata
|
||||
if (!data || typeof data !== "object") return;
|
||||
assertLoadingType<Record<BladeOperationName, unknown>>(data);
|
||||
for (const operationName of Object.values(BladeOperationName)) {
|
||||
assertLoadingType<Record<BladeburnerOperationName, unknown>>(data);
|
||||
for (const operationName of Object.values(BladeburnerOperationName)) {
|
||||
const loadedOperation = data[operationName];
|
||||
if (!(loadedOperation instanceof Operation)) continue;
|
||||
operations[operationName].loadData(loadedOperation);
|
||||
|
||||
Reference in New Issue
Block a user