API: Add types for parameters of gym-university-bladeburner API (Fix merging error) (#1596)

* API: Add types for parameters of gym-university-bladeburner API
* Fix merging error
This commit is contained in:
catloversg
2024-08-18 04:08:55 +07:00
committed by GitHub
parent 5b2a4eafcb
commit cacecda72f
67 changed files with 1047 additions and 471 deletions
+17 -17
View File
@@ -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);