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
+11 -9
View File
@@ -25,8 +25,8 @@ import {
UniversityClassType,
CompanyName,
FactionName,
BladeActionType,
BladeGeneralActionName,
BladeburnerActionType,
BladeburnerGeneralActionName,
AugmentationName,
} from "@enums";
@@ -482,7 +482,7 @@ export class Sleeve extends Person implements SleevePerson {
case "Training":
this.startWork(
new SleeveBladeburnerWork({
actionId: { type: BladeActionType.general, name: BladeGeneralActionName.training },
actionId: { type: BladeburnerActionType.General, name: BladeburnerGeneralActionName.Training },
}),
);
return true;
@@ -490,28 +490,28 @@ export class Sleeve extends Person implements SleevePerson {
case "Field Analysis":
this.startWork(
new SleeveBladeburnerWork({
actionId: { type: BladeActionType.general, name: BladeGeneralActionName.fieldAnalysis },
actionId: { type: BladeburnerActionType.General, name: BladeburnerGeneralActionName.FieldAnalysis },
}),
);
return true;
case "Recruitment":
this.startWork(
new SleeveBladeburnerWork({
actionId: { type: BladeActionType.general, name: BladeGeneralActionName.recruitment },
actionId: { type: BladeburnerActionType.General, name: BladeburnerGeneralActionName.Recruitment },
}),
);
return true;
case "Diplomacy":
this.startWork(
new SleeveBladeburnerWork({
actionId: { type: BladeActionType.general, name: BladeGeneralActionName.diplomacy },
actionId: { type: BladeburnerActionType.General, name: BladeburnerGeneralActionName.Diplomacy },
}),
);
return true;
case "Hyperbolic Regeneration Chamber":
this.startWork(
new SleeveBladeburnerWork({
actionId: { type: BladeActionType.general, name: BladeGeneralActionName.hyperbolicRegen },
actionId: { type: BladeburnerActionType.General, name: BladeburnerGeneralActionName.HyperbolicRegen },
}),
);
return true;
@@ -523,8 +523,10 @@ export class Sleeve extends Person implements SleevePerson {
this.startWork(new SleeveSupportWork());
return true;
case "Take on contracts":
if (!getEnumHelper("BladeContractName").isMember(contract)) return false;
this.startWork(new SleeveBladeburnerWork({ actionId: { type: BladeActionType.contract, name: contract } }));
if (!getEnumHelper("BladeburnerContractName").isMember(contract)) return false;
this.startWork(
new SleeveBladeburnerWork({ actionId: { type: BladeburnerActionType.Contract, name: contract } }),
);
return true;
}
return false;
@@ -2,7 +2,7 @@ import type { Sleeve } from "../Sleeve";
import type { ActionIdentifier } from "../../../Bladeburner/Types";
import type { PromisePair } from "../../../Types/Promises";
import { Player } from "@player";
import { BladeActionType, BladeGeneralActionName } from "@enums";
import { BladeburnerActionType, BladeburnerGeneralActionName } from "@enums";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../../../utils/JSONReviver";
import { applySleeveGains, SleeveWorkClass, SleeveWorkType } from "./Work";
import { CONSTANTS } from "../../../Constants";
@@ -12,7 +12,7 @@ import { loadActionIdentifier } from "../../../Bladeburner/utils/loadActionIdent
import { invalidWork } from "../../../Work/InvalidWork";
interface SleeveBladeburnerWorkParams {
actionId: ActionIdentifier & { type: BladeActionType.general | BladeActionType.contract };
actionId: ActionIdentifier & { type: BladeburnerActionType.General | BladeburnerActionType.Contract };
}
export const isSleeveBladeburnerWork = (w: SleeveWorkClass | null): w is SleeveBladeburnerWork =>
@@ -22,12 +22,15 @@ export class SleeveBladeburnerWork extends SleeveWorkClass {
type: SleeveWorkType.BLADEBURNER = SleeveWorkType.BLADEBURNER;
tasksCompleted = 0;
cyclesWorked = 0;
actionId: ActionIdentifier & { type: BladeActionType.general | BladeActionType.contract };
actionId: ActionIdentifier & { type: BladeburnerActionType.General | BladeburnerActionType.Contract };
nextCompletionPair: PromisePair<void> = { promise: null, resolve: null };
constructor(params?: SleeveBladeburnerWorkParams) {
super();
this.actionId = params?.actionId ?? { type: BladeActionType.general, name: BladeGeneralActionName.fieldAnalysis };
this.actionId = params?.actionId ?? {
type: BladeburnerActionType.General,
name: BladeburnerGeneralActionName.FieldAnalysis,
};
}
cyclesNeeded(sleeve: Sleeve): number {
@@ -48,13 +51,13 @@ export class SleeveBladeburnerWork extends SleeveWorkClass {
process(sleeve: Sleeve, cycles: number) {
if (!Player.bladeburner) return sleeve.stopWork();
this.cyclesWorked += cycles;
if (this.actionId.type === BladeActionType.contract) {
if (this.actionId.type === BladeburnerActionType.Contract) {
const action = Player.bladeburner.getActionObject(this.actionId);
if (action.count < 1) return sleeve.stopWork();
}
while (this.cyclesWorked >= this.cyclesNeeded(sleeve)) {
if (this.actionId.type === BladeActionType.contract) {
if (this.actionId.type === BladeburnerActionType.Contract) {
const action = Player.bladeburner.getActionObject(this.actionId);
if (action.count < 1) return sleeve.stopWork();
}
+6 -6
View File
@@ -5,8 +5,8 @@ import { MenuItem, Select, SelectChangeEvent } from "@mui/material";
import { Player } from "@player";
import {
BladeActionType,
BladeContractName,
BladeburnerActionType,
BladeburnerContractName,
CityName,
FactionName,
FactionWorkType,
@@ -96,19 +96,19 @@ function possibleFactions(sleeve: Sleeve): string[] {
});
}
function possibleContracts(sleeve: Sleeve): BladeContractName[] | ["------"] {
function possibleContracts(sleeve: Sleeve): BladeburnerContractName[] | ["------"] {
const bb = Player.bladeburner;
if (bb === null) {
return ["------"];
}
let contracts = Object.values(BladeContractName);
let contracts = Object.values(BladeburnerContractName);
for (const otherSleeve of Player.sleeves) {
if (sleeve === otherSleeve) {
continue;
}
if (
otherSleeve.currentWork?.type === SleeveWorkType.BLADEBURNER &&
otherSleeve.currentWork.actionId.type === BladeActionType.contract
otherSleeve.currentWork.actionId.type === BladeburnerActionType.Contract
) {
const w = otherSleeve.currentWork;
contracts = contracts.filter((x) => x != w.actionId.name);
@@ -262,7 +262,7 @@ function getABC(sleeve: Sleeve): [string, string, string] {
return ["Work for Faction", work.factionName, workNames[work.factionWorkType] ?? ""];
}
case SleeveWorkType.BLADEBURNER:
if (work.actionId.type === BladeActionType.contract) {
if (work.actionId.type === BladeburnerActionType.Contract) {
return ["Perform Bladeburner Actions", "Take on contracts", work.actionId.name];
}
return ["Perform Bladeburner Actions", work.actionId.name, "------"];