Refactoring mostly done, still a few bugs and test to do.

This commit is contained in:
Olivier Gagnon 2021-08-16 19:44:21 -04:00
parent 8d550157bc
commit 99afb156fa
7 changed files with 1846 additions and 1948 deletions

File diff suppressed because it is too large Load Diff

@ -1,6 +1,7 @@
import { IActionIdentifier } from "./IActionIdentifier";
import { City } from "./City";
import { Skill } from "./Skill";
import { IAction } from "./IAction";
import { IPlayer } from "../PersonObjects/IPlayer";
import { WorkerScript } from "../Netscript/WorkerScript";
@ -74,4 +75,31 @@ export interface IBladeburner {
getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number;
setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number;
joinBladeburnerFactionNetscriptFn(workerScript: WorkerScript): boolean;
}
getActionIdFromTypeAndName(type: string, name: string): IActionIdentifier | null;
executeStartConsoleCommand(player: IPlayer, args: string[]): void;
executeSkillConsoleCommand(args: string[]): void;
executeLogConsoleCommand(args: string[]): void;
executeHelpConsoleCommand(args: string[]): void;
executeAutomateConsoleCommand(args: string[]): void;
parseCommandArguments(command: string): string[];
executeConsoleCommand(player: IPlayer, command: string): void;
triggerMigration(sourceCityName: string): void;
triggerPotentialMigration(sourceCityName: string, chance: number): void;
randomEvent(): void;
gainActionStats(player: IPlayer, action: IAction, success: boolean): void;
getDiplomacyEffectiveness(player: IPlayer): number;
getRecruitmentSuccessChance(player: IPlayer): number;
getRecruitmentTime(player: IPlayer): number;
resetSkillMultipliers(): void;
updateSkillMultipliers(): void;
completeOperation(success: boolean): void;
getActionObject(actionId: IActionIdentifier): IAction | null;
completeContract(success: boolean): void;
completeAction(player: IPlayer): void;
changeRank(player: IPlayer, change: number): void;
processAction(player: IPlayer, seconds: number): void;
calculateStaminaGainPerSecond(player: IPlayer): number;
calculateMaxStamina(player: IPlayer): void;
create(): void;
process(player: IPlayer): void;
}

@ -10,7 +10,6 @@ import { createPopup } from "../../ui/React/createPopup";
import { TeamSizePopup } from "./TeamSizePopup";
import { IBladeburner } from "../IBladeburner";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { startAction } from "../Bladeburner";
interface IProps {
bladeburner: IBladeburner;
@ -35,7 +34,7 @@ export function BlackOpElem(props: IProps): React.ReactElement {
function onStart() {
props.bladeburner.action.type = ActionTypes.BlackOperation;
props.bladeburner.action.name = props.action.name;
startAction(props.bladeburner, props.player, props.bladeburner.action);
props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}

@ -9,7 +9,6 @@ import { stealthIcon, killIcon } from "../data/Icons";
import { BladeburnerConstants } from "../data/Constants";
import { IBladeburner } from "../IBladeburner";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { startAction } from "../Bladeburner";
interface IProps {
bladeburner: IBladeburner;
@ -29,19 +28,19 @@ export function ContractElem(props: IProps): React.ReactElement {
function onStart() {
props.bladeburner.action.type = ActionTypes.Contract;
props.bladeburner.action.name = props.action.name;
startAction(props.bladeburner, props.player, props.bladeburner.action);
props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}
function increaseLevel() {
++props.action.level;
if (isActive) startAction(props.bladeburner, props.player, props.bladeburner.action);
if (isActive) props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}
function decreaseLevel() {
--props.action.level;
if (isActive) startAction(props.bladeburner, props.player, props.bladeburner.action);
if (isActive) props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}

@ -10,8 +10,6 @@ import { BladeburnerConstants } from "../data/Constants";
import { IBladeburner } from "../IBladeburner";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { startAction } from "../Bladeburner";
interface IProps {
bladeburner: IBladeburner;
player: IPlayer;
@ -26,7 +24,7 @@ export function GeneralActionElem(props: IProps): React.ReactElement {
function onStart() {
props.bladeburner.action.type = ActionTypes[(props.action.name as string)];
props.bladeburner.action.name = props.action.name;
startAction(props.bladeburner, props.player, props.bladeburner.action);
props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}

@ -11,7 +11,6 @@ import { createPopup } from "../../ui/React/createPopup";
import { TeamSizePopup } from "./TeamSizePopup";
import { IBladeburner } from "../IBladeburner";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { startAction } from "../Bladeburner";
interface IProps {
bladeburner: IBladeburner;
@ -31,7 +30,7 @@ export function OperationElem(props: IProps): React.ReactElement {
function onStart() {
props.bladeburner.action.type = ActionTypes.Operation;
props.bladeburner.action.name = props.action.name;
startAction(props.bladeburner, props.player, props.bladeburner.action);
props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}
@ -46,13 +45,13 @@ export function OperationElem(props: IProps): React.ReactElement {
function increaseLevel() {
++props.action.level;
if (isActive) startAction(props.bladeburner, props.player, props.bladeburner.action);
if (isActive) props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}
function decreaseLevel() {
--props.action.level;
if (isActive) startAction(props.bladeburner, props.player, props.bladeburner.action);
if (isActive) props.bladeburner.startAction(props.player, props.bladeburner.action);
setRerender(old => !old);
}

@ -884,7 +884,7 @@ const Engine = {
}
if (Player.bladeburner instanceof Bladeburner) {
try {
ProcessBladeburner(Player.bladeburner, Player);
Player.bladeburner.process(Player);
} catch(e) {
exceptionAlert("Exception caught in Bladeburner.process(): " + e);
}