diff --git a/src/Bladeburner/ActionIdentifier.ts b/src/Bladeburner/ActionIdentifier.ts index 9368bb874..cab31083f 100644 --- a/src/Bladeburner/ActionIdentifier.ts +++ b/src/Bladeburner/ActionIdentifier.ts @@ -1,4 +1,3 @@ -import { IActionIdentifier } from "./IActionIdentifier"; import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; interface IParams { @@ -6,7 +5,7 @@ interface IParams { type?: number; } -export class ActionIdentifier implements IActionIdentifier { +export class ActionIdentifier { name = ""; type = -1; diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index a7dff6eb2..1c88a4678 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -1,5 +1,4 @@ import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver"; -import { IActionIdentifier } from "./IActionIdentifier"; import { ActionIdentifier } from "./ActionIdentifier"; import { ActionTypes } from "./data/ActionTypes"; import { Growths } from "./data/Growths"; @@ -66,7 +65,7 @@ export class Bladeburner { actionTimeCurrent = 0; actionTimeOverflow = 0; - action: IActionIdentifier = new ActionIdentifier({ + action: ActionIdentifier = new ActionIdentifier({ type: ActionTypes["Idle"], }); @@ -88,11 +87,11 @@ export class Bladeburner { events: true, }; automateEnabled = false; - automateActionHigh: IActionIdentifier = new ActionIdentifier({ + automateActionHigh: ActionIdentifier = new ActionIdentifier({ type: ActionTypes["Idle"], }); automateThreshHigh = 0; - automateActionLow: IActionIdentifier = new ActionIdentifier({ + automateActionLow: ActionIdentifier = new ActionIdentifier({ type: ActionTypes["Idle"], }); automateThreshLow = 0; @@ -124,7 +123,7 @@ export class Bladeburner { return Math.min(1, this.stamina / (0.5 * this.maxStamina)); } - canAttemptBlackOp(actionId: IActionIdentifier): BlackOpsAttempt { + canAttemptBlackOp(actionId: ActionIdentifier): BlackOpsAttempt { // Safety measure - don't repeat BlackOps that are already done if (this.blackops[actionId.name] != null) { return { error: "Tried to start a Black Operation that had already been completed" }; @@ -162,7 +161,7 @@ export class Bladeburner { } /** This function is only for the player. Sleeves use their own functions to perform blade work. */ - startAction(actionId: IActionIdentifier): void { + startAction(actionId: ActionIdentifier): void { if (actionId == null) return; this.action = actionId; this.actionTimeCurrent = 0; @@ -309,7 +308,7 @@ export class Bladeburner { } // working on - getActionIdFromTypeAndName(type = "", name = ""): IActionIdentifier | null { + getActionIdFromTypeAndName(type = "", name = ""): ActionIdentifier | null { if (type === "" || name === "") { return null; } @@ -1201,7 +1200,7 @@ export class Bladeburner { } } - getActionObject(actionId: IActionIdentifier): Action | null { + getActionObject(actionId: ActionIdentifier): Action | null { /** * Given an ActionIdentifier object, returns the corresponding * GeneralAction, Contract, Operation, or BlackOperation object @@ -1231,7 +1230,7 @@ export class Bladeburner { } } - completeContract(success: boolean, actionIdent: IActionIdentifier): void { + completeContract(success: boolean, actionIdent: ActionIdentifier): void { if (actionIdent.type !== ActionTypes.Contract) { throw new Error("completeContract() called even though current action is not a Contract"); } @@ -1256,7 +1255,7 @@ export class Bladeburner { } } - completeAction(person: Person, actionIdent: IActionIdentifier, isPlayer = true): ITaskTracker { + completeAction(person: Person, actionIdent: ActionIdentifier, isPlayer = true): ITaskTracker { let retValue = createTaskTracker(); switch (actionIdent.type) { case ActionTypes["Contract"]: @@ -2060,7 +2059,7 @@ export class Bladeburner { } } - getTypeAndNameFromActionId(actionId: IActionIdentifier): { + getTypeAndNameFromActionId(actionId: ActionIdentifier): { type: string; name: string; } { diff --git a/src/Bladeburner/IActionIdentifier.ts b/src/Bladeburner/IActionIdentifier.ts deleted file mode 100644 index 3d2414e36..000000000 --- a/src/Bladeburner/IActionIdentifier.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IActionIdentifier { - name: string; - type: number; -} diff --git a/src/Bladeburner/ui/StartButton.tsx b/src/Bladeburner/ui/StartButton.tsx index b92f2b592..b7ff5489c 100644 --- a/src/Bladeburner/ui/StartButton.tsx +++ b/src/Bladeburner/ui/StartButton.tsx @@ -5,6 +5,7 @@ import { BlackOperation } from "../BlackOperation"; import { Player } from "../../Player"; import Button from "@mui/material/Button"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; +import { ActionIdentifier } from "../ActionIdentifier"; interface IProps { bladeburner: Bladeburner; @@ -13,7 +14,7 @@ interface IProps { rerender: () => void; } export function StartButton(props: IProps): React.ReactElement { - const action = props.bladeburner.getActionObject({ name: props.name, type: props.type }); + const action = props.bladeburner.getActionObject(new ActionIdentifier({ name: props.name, type: props.type })); if (action == null) { throw new Error("Failed to get Operation Object for: " + props.name); } diff --git a/src/CotMG/BaseGift.ts b/src/CotMG/BaseGift.ts new file mode 100644 index 000000000..9c6460679 --- /dev/null +++ b/src/CotMG/BaseGift.ts @@ -0,0 +1,29 @@ +import { ActiveFragment } from "./ActiveFragment"; + +export class BaseGift { + fragments: ActiveFragment[]; + _width?: number; + _height?: number; + + constructor(width?: number, height?: number, fragments: ActiveFragment[] = []) { + this.fragments = fragments; + this._width = width; + this._height = height; + } + + width(): number { + return this._width || 4; + } + height(): number { + return this._height || 4; + } + fragmentAt(worldX: number, worldY: number): ActiveFragment | undefined { + for (const aFrag of this.fragments) { + if (aFrag.fullAt(worldX, worldY)) { + return aFrag; + } + } + + return undefined; + } +} diff --git a/src/CotMG/DummyGift.ts b/src/CotMG/DummyGift.ts deleted file mode 100644 index 22de183a3..000000000 --- a/src/CotMG/DummyGift.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { ActiveFragment } from "./ActiveFragment"; -import { IStaneksGift } from "./IStaneksGift"; - -export class DummyGift implements IStaneksGift { - storedCycles = 0; - fragments: ActiveFragment[] = []; - _width: number; - _height: number; - - constructor(width: number, height: number, fragments: ActiveFragment[]) { - this.fragments = fragments; - this._width = width; - this._height = height; - } - - width(): number { - return this._width; - } - height(): number { - return this._height; - } - charge(): void { - throw new Error("unimplemented for dummy gift"); - } - process(): void { - throw new Error("unimplemented for dummy gift"); - } - effect(): number { - throw new Error("unimplemented for dummy gift"); - } - canPlace(): boolean { - throw new Error("unimplemented for dummy gift"); - } - place(): boolean { - throw new Error("unimplemented for dummy gift"); - } - findFragment(): ActiveFragment | undefined { - throw new Error("unimplemented for dummy gift"); - } - fragmentAt(worldX: number, worldY: number): ActiveFragment | undefined { - for (const aFrag of this.fragments) { - if (aFrag.fullAt(worldX, worldY)) { - return aFrag; - } - } - - return undefined; - } - delete(): boolean { - throw new Error("unimplemented for dummy gift"); - } - clear(): void { - throw new Error("unimplemented for dummy gift"); - } - count(): number { - throw new Error("unimplemented for dummy gift"); - } - inBonus(): boolean { - throw new Error("unimplemented for dummy gift"); - } - prestigeAugmentation(): void { - throw new Error("unimplemented for dummy gift"); - } - prestigeSourceFile(): void { - throw new Error("unimplemented for dummy gift"); - } -} diff --git a/src/CotMG/Helper.tsx b/src/CotMG/Helper.tsx index 854f6e0be..661c1948b 100644 --- a/src/CotMG/Helper.tsx +++ b/src/CotMG/Helper.tsx @@ -1,9 +1,9 @@ import { Reviver } from "../utils/JSONReviver"; +import { BaseGift } from "./BaseGift"; -import { IStaneksGift } from "./IStaneksGift"; import { StaneksGift } from "./StaneksGift"; -export let staneksGift: IStaneksGift = new StaneksGift(); +export let staneksGift = new StaneksGift(); export function loadStaneksGift(saveString: string): void { if (saveString) { @@ -23,7 +23,7 @@ export function zeros(width: number, height: number): number[][] { return array; } -export function calculateGrid(gift: IStaneksGift): number[][] { +export function calculateGrid(gift: BaseGift): number[][] { const newgrid = zeros(gift.width(), gift.height()) as unknown as number[][]; for (let i = 0; i < gift.width(); i++) { for (let j = 0; j < gift.height(); j++) { diff --git a/src/CotMG/IStaneksGift.ts b/src/CotMG/IStaneksGift.ts deleted file mode 100644 index 9dbc2c329..000000000 --- a/src/CotMG/IStaneksGift.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ActiveFragment } from "./ActiveFragment"; -import { Fragment } from "./Fragment"; - -export interface IStaneksGift { - storedCycles: number; - fragments: ActiveFragment[]; - width(): number; - height(): number; - charge(fragment: ActiveFragment, threads: number): void; - process(n: number): void; - effect(fragment: ActiveFragment): number; - canPlace(x: number, y: number, rotation: number, fragment: Fragment): boolean; - place(x: number, y: number, rotation: number, fragment: Fragment): boolean; - findFragment(rootX: number, rootY: number): ActiveFragment | undefined; - fragmentAt(rootX: number, rootY: number): ActiveFragment | undefined; - delete(rootX: number, rootY: number): boolean; - clear(): void; - count(fragment: Fragment): number; - inBonus(): boolean; - prestigeAugmentation(): void; - prestigeSourceFile(): void; -} diff --git a/src/CotMG/StaneksGift.ts b/src/CotMG/StaneksGift.ts index 876f9e41d..a914c4b6e 100644 --- a/src/CotMG/StaneksGift.ts +++ b/src/CotMG/StaneksGift.ts @@ -2,7 +2,7 @@ import { FactionNames } from "../Faction/data/FactionNames"; import { Fragment } from "./Fragment"; import { ActiveFragment } from "./ActiveFragment"; import { FragmentType } from "./FragmentType"; -import { IStaneksGift } from "./IStaneksGift"; +import { BaseGift } from "./BaseGift"; import { Factions } from "../Faction/Factions"; import { CalculateEffect } from "./formulas/effect"; import { StaneksGiftEvents } from "./StaneksGiftEvents"; @@ -14,9 +14,11 @@ import { Player } from "../Player"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; import { defaultMultipliers, mergeMultipliers, Multipliers, scaleMultipliers } from "../PersonObjects/Multipliers"; -export class StaneksGift implements IStaneksGift { +export class StaneksGift extends BaseGift { storedCycles = 0; - fragments: ActiveFragment[] = []; + constructor() { + super(); + } baseSize(): number { return StanekConstants.BaseSize + BitNodeMultipliers.StaneksGiftExtraSize + Player.sourceFileLvl(13); @@ -95,16 +97,6 @@ export class StaneksGift implements IStaneksGift { return this.fragments.find((f) => f.x === rootX && f.y === rootY); } - fragmentAt(worldX: number, worldY: number): ActiveFragment | undefined { - for (const aFrag of this.fragments) { - if (aFrag.fullAt(worldX, worldY)) { - return aFrag; - } - } - - return undefined; - } - count(fragment: Fragment): number { let amt = 0; for (const aFrag of this.fragments) { diff --git a/src/CotMG/ui/ActiveFragmentSummary.tsx b/src/CotMG/ui/ActiveFragmentSummary.tsx index 5eb8c4c03..75495a5be 100644 --- a/src/CotMG/ui/ActiveFragmentSummary.tsx +++ b/src/CotMG/ui/ActiveFragmentSummary.tsx @@ -1,6 +1,6 @@ import React from "react"; import { ActiveFragment } from "../ActiveFragment"; -import { IStaneksGift } from "../IStaneksGift"; +import { StaneksGift } from "../StaneksGift"; import { FragmentType, Effect } from "../FragmentType"; import { numeralWrapper } from "../../ui/numeralFormat"; @@ -10,7 +10,7 @@ import Table from "@mui/material/Table"; import { TableBody, TableCell, TableRow } from "@mui/material"; type IProps = { - gift: IStaneksGift; + gift: StaneksGift; }; function formatEffect(effect: number, type: FragmentType): string { diff --git a/src/CotMG/ui/DummyGrid.tsx b/src/CotMG/ui/DummyGrid.tsx index 94dbbda89..ad2b675e8 100644 --- a/src/CotMG/ui/DummyGrid.tsx +++ b/src/CotMG/ui/DummyGrid.tsx @@ -1,7 +1,7 @@ import { Box, Table } from "@mui/material"; import * as React from "react"; import { ActiveFragment } from "../ActiveFragment"; -import { DummyGift } from "../DummyGift"; +import { BaseGift } from "../BaseGift"; import { Grid } from "./Grid"; import { zeros } from "../Helper"; @@ -12,7 +12,7 @@ interface IProps { } export function DummyGrid(props: IProps): React.ReactElement { - const gift = new DummyGift(props.width, props.height, props.fragments); + const gift = new BaseGift(props.width, props.height, props.fragments); const ghostGrid = zeros(props.width, props.height); return ( diff --git a/src/CotMG/ui/FragmentInspector.tsx b/src/CotMG/ui/FragmentInspector.tsx index 3582c3b55..0c089a4d3 100644 --- a/src/CotMG/ui/FragmentInspector.tsx +++ b/src/CotMG/ui/FragmentInspector.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import { ActiveFragment } from "../ActiveFragment"; -import { IStaneksGift } from "../IStaneksGift"; +import { StaneksGift } from "../StaneksGift"; import { FragmentType, Effect } from "../FragmentType"; import { numeralWrapper } from "../../ui/numeralFormat"; @@ -8,7 +8,7 @@ import Paper from "@mui/material/Paper"; import Typography from "@mui/material/Typography"; type IProps = { - gift: IStaneksGift; + gift: StaneksGift; fragment: ActiveFragment | undefined; x: number; y: number; diff --git a/src/CotMG/ui/FragmentSelector.tsx b/src/CotMG/ui/FragmentSelector.tsx index 4a0af8967..3940e3599 100644 --- a/src/CotMG/ui/FragmentSelector.tsx +++ b/src/CotMG/ui/FragmentSelector.tsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import { Fragments, Fragment, NoneFragment, DeleteFragment } from "../Fragment"; import { FragmentType, Effect } from "../FragmentType"; -import { IStaneksGift } from "../IStaneksGift"; +import { StaneksGift } from "../StaneksGift"; import { FragmentPreview } from "./FragmentPreview"; import { numeralWrapper } from "../../ui/numeralFormat"; @@ -11,7 +11,7 @@ import Typography from "@mui/material/Typography"; import Box from "@mui/material/Box"; type IOptionProps = { - gift: IStaneksGift; + gift: StaneksGift; fragment: Fragment; selectFragment: (fragment: Fragment) => void; }; @@ -46,7 +46,7 @@ function FragmentOption(props: IOptionProps): React.ReactElement { } type IProps = { - gift: IStaneksGift; + gift: StaneksGift; selectFragment: (fragment: Fragment) => void; }; diff --git a/src/CotMG/ui/Grid.tsx b/src/CotMG/ui/Grid.tsx index 78dd13b98..82efcdf09 100644 --- a/src/CotMG/ui/Grid.tsx +++ b/src/CotMG/ui/Grid.tsx @@ -2,14 +2,14 @@ import { TableBody, TableRow } from "@mui/material"; import * as React from "react"; import { ActiveFragment } from "../ActiveFragment"; import { calculateGrid } from "../Helper"; -import { IStaneksGift } from "../IStaneksGift"; +import { BaseGift } from "../BaseGift"; import { Cell } from "./Cell"; interface IProps { width: number; height: number; ghostGrid: number[][]; - gift: IStaneksGift; + gift: BaseGift; enter(i: number, j: number): void; click(i: number, j: number): void; } diff --git a/src/CotMG/ui/MainBoard.tsx b/src/CotMG/ui/MainBoard.tsx index 21ddecbc6..a320dee53 100644 --- a/src/CotMG/ui/MainBoard.tsx +++ b/src/CotMG/ui/MainBoard.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { Fragment, NoneFragment } from "../Fragment"; import { FragmentType } from "../FragmentType"; -import { IStaneksGift } from "../IStaneksGift"; +import { StaneksGift } from "../StaneksGift"; import { FragmentInspector } from "./FragmentInspector"; import { FragmentSelector } from "./FragmentSelector"; import Box from "@mui/material/Box"; @@ -14,7 +14,7 @@ import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; interface IProps { - gift: IStaneksGift; + gift: StaneksGift; } export function MainBoard(props: IProps): React.ReactElement { diff --git a/src/CotMG/ui/StaneksGiftRoot.tsx b/src/CotMG/ui/StaneksGiftRoot.tsx index eaacc58ad..d4c091ff8 100644 --- a/src/CotMG/ui/StaneksGiftRoot.tsx +++ b/src/CotMG/ui/StaneksGiftRoot.tsx @@ -3,7 +3,7 @@ import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFuncti import { CONSTANTS } from "../../Constants"; import { StaneksGiftEvents } from "../StaneksGiftEvents"; import { MainBoard } from "./MainBoard"; -import { IStaneksGift } from "../IStaneksGift"; +import { StaneksGift } from "../StaneksGift"; import { Info } from "@mui/icons-material"; import { dialogBoxCreate } from "../../ui/React/DialogBox"; import Typography from "@mui/material/Typography"; @@ -13,7 +13,7 @@ import { DummyGrid } from "./DummyGrid"; import Container from "@mui/material/Container"; type IProps = { - staneksGift: IStaneksGift; + staneksGift: StaneksGift; }; export function StaneksGiftRoot({ staneksGift }: IProps): React.ReactElement { diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index 73b8b0a50..d42cc2e39 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -178,4 +178,4 @@ export class PlayerObject extends Person { } } -Reviver.constructors.PlayerObject = PlayerObject; \ No newline at end of file +Reviver.constructors.PlayerObject = PlayerObject; diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index f27c3bd50..490d92739 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -23,10 +23,7 @@ import { CityName } from "../../Locations/data/CityNames"; import { LocationName } from "../../Locations/data/LocationNames"; import { Sleeve } from "../Sleeve/Sleeve"; import { isSleeveCompanyWork } from "../Sleeve/Work/SleeveCompanyWork"; -import { - calculateSkillProgress as calculateSkillProgressF, - ISkillProgress, -} from "../formulas/skill"; +import { calculateSkillProgress as calculateSkillProgressF, ISkillProgress } from "../formulas/skill"; import { GetServer, AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers"; import { Server } from "../../Server/Server"; import { safetlyCreateUniqueServer } from "../../Server/ServerHelpers";