mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Blade is fully converted to React but now it needs refactoring.
This commit is contained in:
parent
4865563f26
commit
8d550157bc
@ -1,240 +0,0 @@
|
|||||||
import { Augmentations } from "./Augmentation/Augmentations";
|
|
||||||
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
|
||||||
import { BitNodeMultipliers } from "./BitNode/BitNodeMultipliers";
|
|
||||||
import { Engine } from "./engine";
|
|
||||||
import { Faction } from "./Faction/Faction";
|
|
||||||
import { Factions, factionExists } from "./Faction/Factions";
|
|
||||||
import { joinFaction, displayFactionContent } from "./Faction/FactionHelpers";
|
|
||||||
import { Player } from "./Player";
|
|
||||||
import { hackWorldDaemon, redPillFlag } from "./RedPill";
|
|
||||||
import { calculateHospitalizationCost } from "./Hospital/Hospital";
|
|
||||||
|
|
||||||
import { Page, routing } from "./ui/navigationTracking";
|
|
||||||
import { numeralWrapper } from "./ui/numeralFormat";
|
|
||||||
|
|
||||||
import { dialogBoxCreate } from "../utils/DialogBox";
|
|
||||||
import {
|
|
||||||
Reviver,
|
|
||||||
Generic_toJSON,
|
|
||||||
Generic_fromJSON,
|
|
||||||
} from "../utils/JSONReviver";
|
|
||||||
import { setTimeoutRef } from "./utils/SetTimeoutRef";
|
|
||||||
import {
|
|
||||||
formatNumber,
|
|
||||||
convertTimeMsToTimeElapsedString,
|
|
||||||
} from "../utils/StringHelperFunctions";
|
|
||||||
|
|
||||||
import { Settings } from "./Settings/Settings";
|
|
||||||
import { City } from "./Bladeburner/City";
|
|
||||||
import { BladeburnerConstants } from "./Bladeburner/data/Constants";
|
|
||||||
import { Skill } from "./Bladeburner/Skill";
|
|
||||||
import { Skills } from "./Bladeburner/Skills";
|
|
||||||
import { Operation } from "./Bladeburner/Operation";
|
|
||||||
import { BlackOperation } from "./Bladeburner/BlackOperation";
|
|
||||||
import { BlackOperations } from "./Bladeburner/BlackOperations";
|
|
||||||
import { Contract } from "./Bladeburner/Contract";
|
|
||||||
import { GeneralActions } from "./Bladeburner/GeneralActions";
|
|
||||||
import { ActionTypes } from "./Bladeburner/data/ActionTypes";
|
|
||||||
import { ActionIdentifier } from "./Bladeburner/ActionIdentifier";
|
|
||||||
|
|
||||||
import { addOffset } from "../utils/helpers/addOffset";
|
|
||||||
import { clearObject } from "../utils/helpers/clearObject";
|
|
||||||
import { createProgressBarText } from "../utils/helpers/createProgressBarText";
|
|
||||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
|
||||||
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
|
||||||
import { getTimestamp } from "../utils/helpers/getTimestamp";
|
|
||||||
import { KEY } from "../utils/helpers/keyCodes";
|
|
||||||
|
|
||||||
import { removeChildrenFromElement } from "../utils/uiHelpers/removeChildrenFromElement";
|
|
||||||
import { appendLineBreaks } from "../utils/uiHelpers/appendLineBreaks";
|
|
||||||
import { createElement } from "../utils/uiHelpers/createElement";
|
|
||||||
import { createPopup } from "../utils/uiHelpers/createPopup";
|
|
||||||
import { removeElement } from "../utils/uiHelpers/removeElement";
|
|
||||||
import { removeElementById } from "../utils/uiHelpers/removeElementById";
|
|
||||||
|
|
||||||
import { Stats } from "./Bladeburner/ui/Stats";
|
|
||||||
import { AllPages } from "./Bladeburner/ui/AllPages";
|
|
||||||
import { Console } from "./Bladeburner/ui/Console";
|
|
||||||
import { Root } from "./Bladeburner/ui/Root";
|
|
||||||
|
|
||||||
import { StatsTable } from "./ui/React/StatsTable";
|
|
||||||
import { CopyableText } from "./ui/React/CopyableText";
|
|
||||||
import { Money } from "./ui/React/Money";
|
|
||||||
import React from "react";
|
|
||||||
import ReactDOM from "react-dom";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getActionIdFromTypeAndName,
|
|
||||||
executeStartConsoleCommand,
|
|
||||||
executeSkillConsoleCommand,
|
|
||||||
executeLogConsoleCommand,
|
|
||||||
executeHelpConsoleCommand,
|
|
||||||
executeAutomateConsoleCommand,
|
|
||||||
parseCommandArguments,
|
|
||||||
executeConsoleCommand,
|
|
||||||
executeConsoleCommands,
|
|
||||||
triggerMigration,
|
|
||||||
triggerPotentialMigration,
|
|
||||||
randomEvent,
|
|
||||||
gainActionStats,
|
|
||||||
getDiplomacyEffectiveness,
|
|
||||||
getRecruitmentSuccessChance,
|
|
||||||
getRecruitmentTime,
|
|
||||||
resetSkillMultipliers,
|
|
||||||
updateSkillMultipliers,
|
|
||||||
resetAction,
|
|
||||||
getActionObject,
|
|
||||||
completeOperation,
|
|
||||||
completeContract,
|
|
||||||
completeAction,
|
|
||||||
processAction,
|
|
||||||
startAction,
|
|
||||||
calculateStaminaGainPerSecond,
|
|
||||||
calculateMaxStamina,
|
|
||||||
create,
|
|
||||||
prestige,
|
|
||||||
storeCycles,
|
|
||||||
getCurrentCity,
|
|
||||||
upgradeSkill,
|
|
||||||
postToConsole,
|
|
||||||
log,
|
|
||||||
calculateStaminaPenalty,
|
|
||||||
getTypeAndNameFromActionId,
|
|
||||||
getContractNamesNetscriptFn,
|
|
||||||
getOperationNamesNetscriptFn,
|
|
||||||
getBlackOpNamesNetscriptFn,
|
|
||||||
getGeneralActionNamesNetscriptFn,
|
|
||||||
getSkillNamesNetscriptFn,
|
|
||||||
startActionNetscriptFn,
|
|
||||||
getActionTimeNetscriptFn,
|
|
||||||
getActionEstimatedSuccessChanceNetscriptFn,
|
|
||||||
getActionCountRemainingNetscriptFn,
|
|
||||||
getSkillLevelNetscriptFn,
|
|
||||||
getSkillUpgradeCostNetscriptFn,
|
|
||||||
upgradeSkillNetscriptFn,
|
|
||||||
getTeamSizeNetscriptFn,
|
|
||||||
setTeamSizeNetscriptFn,
|
|
||||||
joinBladeburnerFactionNetscriptFn,
|
|
||||||
} from "./Bladeburner/Bladeburner";
|
|
||||||
|
|
||||||
function Bladeburner(params={}) {
|
|
||||||
this.numHosp = 0; // Number of hospitalizations
|
|
||||||
this.moneyLost = 0; // Money lost due to hospitalizations
|
|
||||||
this.rank = 0;
|
|
||||||
this.maxRank = 0; // Used to determine skill points
|
|
||||||
|
|
||||||
this.skillPoints = 0;
|
|
||||||
this.totalSkillPoints = 0;
|
|
||||||
|
|
||||||
this.teamSize = 0; // Number of team members
|
|
||||||
this.teamLost = 0; // Number of team members lost
|
|
||||||
|
|
||||||
this.storedCycles = 0;
|
|
||||||
|
|
||||||
this.randomEventCounter = getRandomInt(240, 600); // 4-10 minutes
|
|
||||||
|
|
||||||
// These times are in seconds
|
|
||||||
this.actionTimeToComplete = 0; // 0 or -1 is an infinite running action (like training)
|
|
||||||
this.actionTimeCurrent = 0;
|
|
||||||
this.actionTimeOverflow = 0;
|
|
||||||
|
|
||||||
// ActionIdentifier Object
|
|
||||||
var idleActionType = ActionTypes["Idle"];
|
|
||||||
this.action = new ActionIdentifier({type:idleActionType});
|
|
||||||
|
|
||||||
this.cities = {};
|
|
||||||
for (var i = 0; i < BladeburnerConstants.CityNames.length; ++i) {
|
|
||||||
this.cities[BladeburnerConstants.CityNames[i]] = new City({name: BladeburnerConstants.CityNames[i]});
|
|
||||||
}
|
|
||||||
this.city = BladeburnerConstants.CityNames[2]; // Sector-12
|
|
||||||
|
|
||||||
// Map of SkillNames -> level
|
|
||||||
this.skills = {};
|
|
||||||
this.skillMultipliers = {};
|
|
||||||
updateSkillMultipliers(this); // Calls resetSkillMultipliers()
|
|
||||||
|
|
||||||
// Max Stamina is based on stats and Bladeburner-specific bonuses
|
|
||||||
this.staminaBonus = 0; // Gained from training
|
|
||||||
this.maxStamina = 0;
|
|
||||||
calculateMaxStamina(this, Player);
|
|
||||||
this.stamina = this.maxStamina;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contracts and Operations objects. These objects have unique
|
|
||||||
* properties because they are randomized in each instance and have stats like
|
|
||||||
* successes/failures, so they need to be saved/loaded by the game.
|
|
||||||
*/
|
|
||||||
this.contracts = {};
|
|
||||||
this.operations = {};
|
|
||||||
|
|
||||||
// Object that contains name of all Black Operations that have been completed
|
|
||||||
this.blackops = {};
|
|
||||||
|
|
||||||
// Flags for whether these actions should be logged to console
|
|
||||||
this.logging = {
|
|
||||||
general:true,
|
|
||||||
contracts:true,
|
|
||||||
ops:true,
|
|
||||||
blackops:true,
|
|
||||||
events:true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simple automation values
|
|
||||||
this.automateEnabled = false;
|
|
||||||
this.automateActionHigh = 0;
|
|
||||||
this.automateThreshHigh = 0; //Stamina Threshold
|
|
||||||
this.automateActionLow = 0;
|
|
||||||
this.automateThreshLow = 0; //Stamina Threshold
|
|
||||||
|
|
||||||
// Console command history
|
|
||||||
this.consoleHistory = [];
|
|
||||||
this.consoleLogs = [
|
|
||||||
"Bladeburner Console",
|
|
||||||
"Type 'help' to see console commands",
|
|
||||||
];
|
|
||||||
|
|
||||||
// Initialization
|
|
||||||
if (params.new) create(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bladeburner.prototype.prestige = function() { prestige(this); }
|
|
||||||
Bladeburner.prototype.storeCycles = function(numCycles=1) { storeCycles(this, numCycles); }
|
|
||||||
Bladeburner.prototype.calculateStaminaPenalty = function() { return calculateStaminaPenalty(this); }
|
|
||||||
Bladeburner.prototype.getCurrentCity = function() { return getCurrentCity(this); }
|
|
||||||
Bladeburner.prototype.upgradeSkill = function(skill) { upgradeSkill(this, skill); }
|
|
||||||
// Bladeburner Console Window
|
|
||||||
Bladeburner.prototype.postToConsole = function(input, saveToLogs=true) { postToConsole(this, input, saveToLogs); }
|
|
||||||
Bladeburner.prototype.log = function(input) { log(this, input); }
|
|
||||||
// Handles a potential series of commands (comm1; comm2; comm3;)
|
|
||||||
Bladeburner.prototype.executeConsoleCommands = function(commands) { executeConsoleCommands(this, Player, commands); }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////// Netscript Fns /////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Bladeburner.prototype.getTypeAndNameFromActionId = function(actionId) { getTypeAndNameFromActionId(this, actionId); }
|
|
||||||
Bladeburner.prototype.getContractNamesNetscriptFn = function() { getContractNamesNetscriptFn(this); }
|
|
||||||
Bladeburner.prototype.getOperationNamesNetscriptFn = function() { getOperationNamesNetscriptFn(this); }
|
|
||||||
Bladeburner.prototype.getBlackOpNamesNetscriptFn = function() { getBlackOpNamesNetscriptFn(this); }
|
|
||||||
Bladeburner.prototype.getGeneralActionNamesNetscriptFn = function() { getGeneralActionNamesNetscriptFn(this); }
|
|
||||||
Bladeburner.prototype.getSkillNamesNetscriptFn = function() { getSkillNamesNetscriptFn(this); }
|
|
||||||
Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) { startActionNetscriptFn(this, Player, type, name, workerScript); }
|
|
||||||
Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) { getActionTimeNetscriptFn(this, Player, type, name, workerScript); }
|
|
||||||
Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) { getActionEstimatedSuccessChanceNetscriptFn(this, Player, type, name, workerScript); }
|
|
||||||
Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) { getActionCountRemainingNetscriptFn(this, Player, type, name, workerScript); }
|
|
||||||
Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) { getSkillLevelNetscriptFn(this, skillName, workerScript); }
|
|
||||||
Bladeburner.prototype.getSkillUpgradeCostNetscriptFn = function(skillName, workerScript) { getSkillUpgradeCostNetscriptFn(this, skillName, workerScript); }
|
|
||||||
Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) { upgradeSkillNetscriptFn(this, skillName, workerScript); }
|
|
||||||
Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript) { getTeamSizeNetscriptFn(this, type, name, workerScript); }
|
|
||||||
Bladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) { setTeamSizeNetscriptFn(this, type, name, size, workerScript); }
|
|
||||||
Bladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) { joinBladeburnerFactionNetscriptFn(this, workerScript); }
|
|
||||||
|
|
||||||
Bladeburner.prototype.toJSON = function() {
|
|
||||||
return Generic_toJSON("Bladeburner", this);
|
|
||||||
}
|
|
||||||
Bladeburner.fromJSON = function(value) {
|
|
||||||
return Generic_fromJSON(Bladeburner, value.data);
|
|
||||||
}
|
|
||||||
Reviver.constructors.Bladeburner = Bladeburner;
|
|
||||||
|
|
||||||
export { Bladeburner };
|
|
@ -2,6 +2,11 @@
|
|||||||
Here we have a bunch of functions converted to typescript, eventually they
|
Here we have a bunch of functions converted to typescript, eventually they
|
||||||
will go back into a Bladeburner class.
|
will go back into a Bladeburner class.
|
||||||
*/
|
*/
|
||||||
|
import {
|
||||||
|
Reviver,
|
||||||
|
Generic_toJSON,
|
||||||
|
Generic_fromJSON,
|
||||||
|
} from "../../utils/JSONReviver";
|
||||||
import { IBladeburner } from "./IBladeburner";
|
import { IBladeburner } from "./IBladeburner";
|
||||||
import { IActionIdentifier } from "./IActionIdentifier";
|
import { IActionIdentifier } from "./IActionIdentifier";
|
||||||
import { ActionIdentifier } from "./ActionIdentifier";
|
import { ActionIdentifier } from "./ActionIdentifier";
|
||||||
@ -36,6 +41,197 @@ import { getTimestamp } from "../../utils/helpers/getTimestamp";
|
|||||||
import { joinFaction } from "../Faction/FactionHelpers";
|
import { joinFaction } from "../Faction/FactionHelpers";
|
||||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||||
|
|
||||||
|
export class Bladeburner implements IBladeburner {
|
||||||
|
numHosp: number = 0;
|
||||||
|
moneyLost: number = 0;
|
||||||
|
rank: number = 0;
|
||||||
|
maxRank: number = 0;
|
||||||
|
|
||||||
|
skillPoints: number = 0;
|
||||||
|
totalSkillPoints: number = 0;
|
||||||
|
|
||||||
|
teamSize: number = 0;
|
||||||
|
teamLost: number = 0;
|
||||||
|
hpLost: number = 0;
|
||||||
|
|
||||||
|
storedCycles: number = 0;
|
||||||
|
|
||||||
|
randomEventCounter: number = getRandomInt(240, 600);
|
||||||
|
|
||||||
|
actionTimeToComplete: number = 0;
|
||||||
|
actionTimeCurrent: number = 0;
|
||||||
|
actionTimeOverflow: number = 0;
|
||||||
|
|
||||||
|
action: IActionIdentifier = new ActionIdentifier({type: ActionTypes["Idle"]});
|
||||||
|
|
||||||
|
cities: any = {};
|
||||||
|
city: string = BladeburnerConstants.CityNames[2];
|
||||||
|
skills: any = {};
|
||||||
|
skillMultipliers: any = {};
|
||||||
|
staminaBonus: number = 0;
|
||||||
|
maxStamina: number = 0;
|
||||||
|
stamina: number = 0;
|
||||||
|
contracts: any = {};
|
||||||
|
operations: any = {};
|
||||||
|
blackops: any = {};
|
||||||
|
logging: any = {
|
||||||
|
general:true,
|
||||||
|
contracts:true,
|
||||||
|
ops:true,
|
||||||
|
blackops:true,
|
||||||
|
events:true,
|
||||||
|
};
|
||||||
|
automateEnabled: boolean = false;
|
||||||
|
automateActionHigh: IActionIdentifier = new ActionIdentifier({type: ActionTypes["Idle"]});
|
||||||
|
automateThreshHigh: number = 0;
|
||||||
|
automateActionLow: IActionIdentifier = new ActionIdentifier({type: ActionTypes["Idle"]});
|
||||||
|
automateThreshLow: number = 0;
|
||||||
|
consoleHistory: string[] = [];
|
||||||
|
consoleLogs: string[] = [
|
||||||
|
"Bladeburner Console",
|
||||||
|
"Type 'help' to see console commands",
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor(player?: IPlayer) {
|
||||||
|
for (var i = 0; i < BladeburnerConstants.CityNames.length; ++i) {
|
||||||
|
this.cities[BladeburnerConstants.CityNames[i]] = new City(BladeburnerConstants.CityNames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSkillMultipliers(this); // Calls resetSkillMultipliers()
|
||||||
|
|
||||||
|
// Max Stamina is based on stats and Bladeburner-specific bonuses
|
||||||
|
if(player)
|
||||||
|
calculateMaxStamina(this, player);
|
||||||
|
this.stamina = this.maxStamina;
|
||||||
|
create(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentCity(): City {
|
||||||
|
return getCurrentCity(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateStaminaPenalty(): number {
|
||||||
|
return calculateStaminaPenalty(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
startAction(player: IPlayer, action: IActionIdentifier): void {
|
||||||
|
startAction(this, player, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
upgradeSkill(skill: Skill): void {
|
||||||
|
upgradeSkill(this, skill);
|
||||||
|
}
|
||||||
|
|
||||||
|
executeConsoleCommands(player: IPlayer, command: string): void {
|
||||||
|
executeConsoleCommands(this, player, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
postToConsole(input: string, saveToLogs?: boolean): void {
|
||||||
|
postToConsole(this, input, saveToLogs);
|
||||||
|
}
|
||||||
|
|
||||||
|
log(input: string): void {
|
||||||
|
log(this, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetAction(): void {
|
||||||
|
resetAction(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearConsole(): void {
|
||||||
|
clearConsole(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
prestige(): void {
|
||||||
|
prestige(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
storeCycles(numCycles?: number): void {
|
||||||
|
storeCycles(this, numCycles);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTypeAndNameFromActionId(actionId: IActionIdentifier): {type: string, name: string} {
|
||||||
|
return getTypeAndNameFromActionId(this, actionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
getContractNamesNetscriptFn(): string[] {
|
||||||
|
return getContractNamesNetscriptFn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getOperationNamesNetscriptFn(): string[] {
|
||||||
|
return getOperationNamesNetscriptFn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getBlackOpNamesNetscriptFn(): string[] {
|
||||||
|
return getBlackOpNamesNetscriptFn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getGeneralActionNamesNetscriptFn(): string[] {
|
||||||
|
return getGeneralActionNamesNetscriptFn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSkillNamesNetscriptFn(): string[] {
|
||||||
|
return getSkillNamesNetscriptFn(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
startActionNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): boolean {
|
||||||
|
return startActionNetscriptFn(this, player, type, name, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getActionTimeNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number {
|
||||||
|
return getActionTimeNetscriptFn(this, player, type, name, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getActionEstimatedSuccessChanceNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number {
|
||||||
|
return getActionEstimatedSuccessChanceNetscriptFn(this, player, type, name, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getActionCountRemainingNetscriptFn(type: string, name: string, workerScript: WorkerScript): number {
|
||||||
|
return getActionCountRemainingNetscriptFn(this, type, name, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number {
|
||||||
|
return getSkillLevelNetscriptFn(this, skillName, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getSkillUpgradeCostNetscriptFn(skillName: string, workerScript: WorkerScript): number {
|
||||||
|
return getSkillUpgradeCostNetscriptFn(this, skillName, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean {
|
||||||
|
return upgradeSkillNetscriptFn(this, skillName, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number {
|
||||||
|
return getTeamSizeNetscriptFn(this, type, name, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number {
|
||||||
|
return setTeamSizeNetscriptFn(this, type, name, size, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
joinBladeburnerFactionNetscriptFn(workerScript: WorkerScript): boolean {
|
||||||
|
return joinBladeburnerFactionNetscriptFn(this, workerScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize the current object to a JSON save state.
|
||||||
|
*/
|
||||||
|
toJSON(): any {
|
||||||
|
return Generic_toJSON("Bladeburner", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiatizes a Bladeburner object from a JSON save state.
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
|
static fromJSON(value: any): Bladeburner {
|
||||||
|
return Generic_fromJSON(Bladeburner, value.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reviver.constructors.Bladeburner = Bladeburner;
|
||||||
|
|
||||||
export function getActionIdFromTypeAndName(bladeburner: IBladeburner, type: string = "", name: string = ""): IActionIdentifier | null {
|
export function getActionIdFromTypeAndName(bladeburner: IBladeburner, type: string = "", name: string = ""): IActionIdentifier | null {
|
||||||
if (type === "" || name === "") {return null;}
|
if (type === "" || name === "") {return null;}
|
||||||
const action = new ActionIdentifier();
|
const action = new ActionIdentifier();
|
||||||
@ -134,7 +330,7 @@ export function executeStartConsoleCommand(bladeburner: IBladeburner, player: IP
|
|||||||
if (GeneralActions[name] != null) {
|
if (GeneralActions[name] != null) {
|
||||||
bladeburner.action.type = ActionTypes[name];
|
bladeburner.action.type = ActionTypes[name];
|
||||||
bladeburner.action.name = name;
|
bladeburner.action.name = name;
|
||||||
startAction(bladeburner,player, bladeburner.action);
|
startAction(bladeburner, player, bladeburner.action);
|
||||||
} else {
|
} else {
|
||||||
bladeburner.postToConsole("Invalid action name specified: " + args[2]);
|
bladeburner.postToConsole("Invalid action name specified: " + args[2]);
|
||||||
}
|
}
|
||||||
@ -144,7 +340,7 @@ export function executeStartConsoleCommand(bladeburner: IBladeburner, player: IP
|
|||||||
if (bladeburner.contracts[name] != null) {
|
if (bladeburner.contracts[name] != null) {
|
||||||
bladeburner.action.type = ActionTypes.Contract;
|
bladeburner.action.type = ActionTypes.Contract;
|
||||||
bladeburner.action.name = name;
|
bladeburner.action.name = name;
|
||||||
startAction(bladeburner,player, bladeburner.action);
|
startAction(bladeburner, player, bladeburner.action);
|
||||||
} else {
|
} else {
|
||||||
bladeburner.postToConsole("Invalid contract name specified: " + args[2]);
|
bladeburner.postToConsole("Invalid contract name specified: " + args[2]);
|
||||||
}
|
}
|
||||||
@ -1602,7 +1798,7 @@ export function log(bladeburner: IBladeburner, input: string) {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////// Netscript Fns /////////////////////////////////
|
//////////////////////////////// Netscript Fns /////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
export function getTypeAndNameFromActionId(bladeburner: IBladeburner, actionId: IActionIdentifier) {
|
export function getTypeAndNameFromActionId(bladeburner: IBladeburner, actionId: IActionIdentifier): {type: string, name: string} {
|
||||||
const res = {type: '', name: ''};
|
const res = {type: '', name: ''};
|
||||||
const types = Object.keys(ActionTypes);
|
const types = Object.keys(ActionTypes);
|
||||||
for (let i = 0; i < types.length; ++i) {
|
for (let i = 0; i < types.length; ++i) {
|
||||||
@ -1616,19 +1812,19 @@ export function getTypeAndNameFromActionId(bladeburner: IBladeburner, actionId:
|
|||||||
res.name = actionId.name != null ? actionId.name : "Idle";
|
res.name = actionId.name != null ? actionId.name : "Idle";
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
export function getContractNamesNetscriptFn(bladeburner: IBladeburner) {
|
export function getContractNamesNetscriptFn(bladeburner: IBladeburner): string[] {
|
||||||
return Object.keys(bladeburner.contracts);
|
return Object.keys(bladeburner.contracts);
|
||||||
}
|
}
|
||||||
export function getOperationNamesNetscriptFn(bladeburner: IBladeburner) {
|
export function getOperationNamesNetscriptFn(bladeburner: IBladeburner): string[] {
|
||||||
return Object.keys(bladeburner.operations);
|
return Object.keys(bladeburner.operations);
|
||||||
}
|
}
|
||||||
export function getBlackOpNamesNetscriptFn(bladeburner: IBladeburner) {
|
export function getBlackOpNamesNetscriptFn(bladeburner: IBladeburner): string[] {
|
||||||
return Object.keys(BlackOperations);
|
return Object.keys(BlackOperations);
|
||||||
}
|
}
|
||||||
export function getGeneralActionNamesNetscriptFn(bladeburner: IBladeburner) {
|
export function getGeneralActionNamesNetscriptFn(bladeburner: IBladeburner): string[] {
|
||||||
return Object.keys(GeneralActions);
|
return Object.keys(GeneralActions);
|
||||||
}
|
}
|
||||||
export function getSkillNamesNetscriptFn(bladeburner: IBladeburner) {
|
export function getSkillNamesNetscriptFn(bladeburner: IBladeburner): string[] {
|
||||||
return Object.keys(Skills);
|
return Object.keys(Skills);
|
||||||
}
|
}
|
||||||
export function startActionNetscriptFn(bladeburner: IBladeburner, player: IPlayer, type: string, name: string, workerScript: WorkerScript) {
|
export function startActionNetscriptFn(bladeburner: IBladeburner, player: IPlayer, type: string, name: string, workerScript: WorkerScript) {
|
||||||
|
@ -1,23 +1,32 @@
|
|||||||
import { IActionIdentifier } from "./IActionIdentifier";
|
import { IActionIdentifier } from "./IActionIdentifier";
|
||||||
import { City } from "./City";
|
import { City } from "./City";
|
||||||
import { Skill } from "./Skill";
|
import { Skill } from "./Skill";
|
||||||
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
|
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||||
|
|
||||||
export interface IBladeburner {
|
export interface IBladeburner {
|
||||||
numHosp: number;
|
numHosp: number;
|
||||||
moneyLost: number;
|
moneyLost: number;
|
||||||
rank: number;
|
rank: number;
|
||||||
maxRank: number;
|
maxRank: number;
|
||||||
|
|
||||||
skillPoints: number;
|
skillPoints: number;
|
||||||
totalSkillPoints: number;
|
totalSkillPoints: number;
|
||||||
|
|
||||||
teamSize: number;
|
teamSize: number;
|
||||||
teamLost: number;
|
teamLost: number;
|
||||||
hpLost: number;
|
hpLost: number;
|
||||||
|
|
||||||
storedCycles: number;
|
storedCycles: number;
|
||||||
|
|
||||||
randomEventCounter: number;
|
randomEventCounter: number;
|
||||||
|
|
||||||
actionTimeToComplete: number;
|
actionTimeToComplete: number;
|
||||||
actionTimeCurrent: number;
|
actionTimeCurrent: number;
|
||||||
actionTimeOverflow: number;
|
actionTimeOverflow: number;
|
||||||
|
|
||||||
action: IActionIdentifier;
|
action: IActionIdentifier;
|
||||||
|
|
||||||
cities: any;
|
cities: any;
|
||||||
city: string;
|
city: string;
|
||||||
skills: any;
|
skills: any;
|
||||||
@ -39,11 +48,30 @@ export interface IBladeburner {
|
|||||||
|
|
||||||
getCurrentCity(): City;
|
getCurrentCity(): City;
|
||||||
calculateStaminaPenalty(): number;
|
calculateStaminaPenalty(): number;
|
||||||
startAction(action: IActionIdentifier): void;
|
startAction(player: IPlayer, action: IActionIdentifier): void;
|
||||||
upgradeSkill(skill: Skill): void;
|
upgradeSkill(skill: Skill): void;
|
||||||
executeConsoleCommands(command: string): void;
|
executeConsoleCommands(player: IPlayer, command: string): void;
|
||||||
postToConsole(input: string, saveToLogs?: boolean): void;
|
postToConsole(input: string, saveToLogs?: boolean): void;
|
||||||
log(input: string): void;
|
log(input: string): void;
|
||||||
resetAction(): void;
|
resetAction(): void;
|
||||||
clearConsole(): void;
|
clearConsole(): void;
|
||||||
}
|
|
||||||
|
prestige(): void;
|
||||||
|
storeCycles(numCycles?: number): void;
|
||||||
|
getTypeAndNameFromActionId(actionId: IActionIdentifier): {type: string, name: string};
|
||||||
|
getContractNamesNetscriptFn(): string[];
|
||||||
|
getOperationNamesNetscriptFn(): string[];
|
||||||
|
getBlackOpNamesNetscriptFn(): string[];
|
||||||
|
getGeneralActionNamesNetscriptFn(): string[];
|
||||||
|
getSkillNamesNetscriptFn(): string[];
|
||||||
|
startActionNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): boolean;
|
||||||
|
getActionTimeNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number;
|
||||||
|
getActionEstimatedSuccessChanceNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number;
|
||||||
|
getActionCountRemainingNetscriptFn(type: string, name: string, workerScript: WorkerScript): number;
|
||||||
|
getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number;
|
||||||
|
getSkillUpgradeCostNetscriptFn(skillName: string, workerScript: WorkerScript): number;
|
||||||
|
upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean;
|
||||||
|
getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number;
|
||||||
|
setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number;
|
||||||
|
joinBladeburnerFactionNetscriptFn(workerScript: WorkerScript): boolean;
|
||||||
|
}
|
||||||
|
@ -50,7 +50,7 @@ export function Console(props: IProps): React.ReactElement {
|
|||||||
event.currentTarget.value = "";
|
event.currentTarget.value = "";
|
||||||
if (command.length > 0) {
|
if (command.length > 0) {
|
||||||
props.bladeburner.postToConsole("> " + command);
|
props.bladeburner.postToConsole("> " + command);
|
||||||
props.bladeburner.executeConsoleCommands(command);
|
props.bladeburner.executeConsoleCommands(props.player, command);
|
||||||
setConsoleHistoryIndex(props.bladeburner.consoleHistory.length);
|
setConsoleHistoryIndex(props.bladeburner.consoleHistory.length);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import { AllServers } from "./Server/AllServers";
|
|||||||
import { GetServerByHostname } from "./Server/ServerHelpers";
|
import { GetServerByHostname } from "./Server/ServerHelpers";
|
||||||
import { hackWorldDaemon } from "./RedPill";
|
import { hackWorldDaemon } from "./RedPill";
|
||||||
import { StockMarket } from "./StockMarket/StockMarket";
|
import { StockMarket } from "./StockMarket/StockMarket";
|
||||||
import { Bladeburner } from "./Bladeburner";
|
import { Bladeburner } from "./Bladeburner/Bladeburner";
|
||||||
import { Stock } from "./StockMarket/Stock";
|
import { Stock } from "./StockMarket/Stock";
|
||||||
import { Engine } from "./engine";
|
import { Engine } from "./engine";
|
||||||
import { saveObject } from "./SaveObject";
|
import { saveObject } from "./SaveObject";
|
||||||
|
@ -13,7 +13,7 @@ import { prestigeAugmentation } from "./Prestige";
|
|||||||
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
||||||
import { BitNodeMultipliers } from "./BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "./BitNode/BitNodeMultipliers";
|
||||||
import { findCrime } from "./Crime/CrimeHelpers";
|
import { findCrime } from "./Crime/CrimeHelpers";
|
||||||
import { Bladeburner } from "./Bladeburner";
|
import { Bladeburner } from "./Bladeburner/Bladeburner";
|
||||||
import { Company } from "./Company/Company";
|
import { Company } from "./Company/Company";
|
||||||
import { Companies } from "./Company/Companies";
|
import { Companies } from "./Company/Companies";
|
||||||
import { CompanyPosition } from "./Company/CompanyPosition";
|
import { CompanyPosition } from "./Company/CompanyPosition";
|
||||||
@ -4046,7 +4046,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
return true; // Already member
|
return true; // Already member
|
||||||
} else if (Player.strength >= 100 && Player.defense >= 100 &&
|
} else if (Player.strength >= 100 && Player.defense >= 100 &&
|
||||||
Player.dexterity >= 100 && Player.agility >= 100) {
|
Player.dexterity >= 100 && Player.agility >= 100) {
|
||||||
Player.bladeburner = new Bladeburner({new:true});
|
Player.bladeburner = new Bladeburner();
|
||||||
workerScript.log("joinBladeburnerDivision", "You have been accepted into the Bladeburner division");
|
workerScript.log("joinBladeburnerDivision", "You have been accepted into the Bladeburner division");
|
||||||
|
|
||||||
const worldHeader = document.getElementById("world-menu-header");
|
const worldHeader = document.getElementById("world-menu-header");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Bladeburner } from "../../Bladeburner";
|
import { Bladeburner } from "../../Bladeburner/Bladeburner";
|
||||||
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
|
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
|
||||||
|
|
||||||
export function canAccessBladeburner() {
|
export function canAccessBladeburner() {
|
||||||
@ -13,5 +13,5 @@ export function inBladeburner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function startBladeburner() {
|
export function startBladeburner() {
|
||||||
this.bladeburner = new Bladeburner({ new: true });
|
this.bladeburner = new Bladeburner(this);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
} from "./Augmentation/AugmentationHelpers";
|
} from "./Augmentation/AugmentationHelpers";
|
||||||
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
||||||
import { initBitNodeMultipliers } from "./BitNode/BitNode";
|
import { initBitNodeMultipliers } from "./BitNode/BitNode";
|
||||||
import { Bladeburner } from "./Bladeburner";
|
import { Bladeburner } from "./Bladeburner/Bladeburner";
|
||||||
import { writeCinematicText } from "./CinematicText";
|
import { writeCinematicText } from "./CinematicText";
|
||||||
import { Companies, initCompanies } from "./Company/Companies";
|
import { Companies, initCompanies } from "./Company/Companies";
|
||||||
import { resetIndustryResearchTrees } from "./Corporation/IndustryData";
|
import { resetIndustryResearchTrees } from "./Corporation/IndustryData";
|
||||||
|
@ -17,7 +17,7 @@ import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
|||||||
import {
|
import {
|
||||||
initBitNodeMultipliers,
|
initBitNodeMultipliers,
|
||||||
} from "./BitNode/BitNode";
|
} from "./BitNode/BitNode";
|
||||||
import { Bladeburner } from "./Bladeburner";
|
import { Bladeburner } from "./Bladeburner/Bladeburner";
|
||||||
import { process as ProcessBladeburner } from "./Bladeburner/Bladeburner";
|
import { process as ProcessBladeburner } from "./Bladeburner/Bladeburner";
|
||||||
import { CharacterOverviewComponent } from "./ui/React/CharacterOverview";
|
import { CharacterOverviewComponent } from "./ui/React/CharacterOverview";
|
||||||
import { cinematicTextFlag } from "./CinematicText";
|
import { cinematicTextFlag } from "./CinematicText";
|
||||||
|
Loading…
Reference in New Issue
Block a user