mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
ts convertion
This commit is contained in:
parent
b8faa9dc0b
commit
47f54a11c3
@ -10,7 +10,7 @@ import { Money } from "../ui/React/Money";
|
|||||||
|
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
||||||
|
|
||||||
interface IConstructorParams {
|
export interface IConstructorParams {
|
||||||
info: string | JSX.Element;
|
info: string | JSX.Element;
|
||||||
stats?: JSX.Element;
|
stats?: JSX.Element;
|
||||||
isSpecial?: boolean;
|
isSpecial?: boolean;
|
||||||
|
3
src/Augmentation/AugmentationHelpers.d.ts
vendored
3
src/Augmentation/AugmentationHelpers.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
export declare function isRepeatableAug(aug: Augmentation): boolean;
|
|
||||||
export declare function installAugmentations(): void;
|
|
||||||
export declare function applyAugmentation(aug: Augmentation, reapply?: boolean): void;
|
|
@ -1,6 +1,6 @@
|
|||||||
import { Augmentation } from "./Augmentation";
|
import { Augmentation, IConstructorParams } from "./Augmentation";
|
||||||
import { Augmentations } from "./Augmentations";
|
import { Augmentations } from "./Augmentations";
|
||||||
import { PlayerOwnedAugmentation } from "./PlayerOwnedAugmentation";
|
import { PlayerOwnedAugmentation, IPlayerOwnedAugmentation } from "./PlayerOwnedAugmentation";
|
||||||
import { AugmentationNames } from "./data/AugmentationNames";
|
import { AugmentationNames } from "./data/AugmentationNames";
|
||||||
|
|
||||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||||
@ -18,13 +18,13 @@ import { WHRNG } from "../Casino/RNG";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
function AddToAugmentations(aug) {
|
function AddToAugmentations(aug: Augmentation): void {
|
||||||
var name = aug.name;
|
const name = aug.name;
|
||||||
Augmentations[name] = aug;
|
Augmentations[name] = aug;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomBonus() {
|
function getRandomBonus(): any {
|
||||||
var bonuses = [
|
const bonuses = [
|
||||||
{
|
{
|
||||||
bonuses: {
|
bonuses: {
|
||||||
hacking_chance_mult: 1.25,
|
hacking_chance_mult: 1.25,
|
||||||
@ -124,7 +124,7 @@ function initAugmentations() {
|
|||||||
//Time-Based Augment Test
|
//Time-Based Augment Test
|
||||||
const randomBonuses = getRandomBonus();
|
const randomBonuses = getRandomBonus();
|
||||||
|
|
||||||
const UnstableCircadianModulatorParams = {
|
const UnstableCircadianModulatorParams: IConstructorParams = {
|
||||||
name: AugmentationNames.UnstableCircadianModulator,
|
name: AugmentationNames.UnstableCircadianModulator,
|
||||||
moneyCost: 5e9,
|
moneyCost: 5e9,
|
||||||
repCost: 3.625e5,
|
repCost: 3.625e5,
|
||||||
@ -133,7 +133,7 @@ function initAugmentations() {
|
|||||||
"unpredictable results based on your circadian rhythm.",
|
"unpredictable results based on your circadian rhythm.",
|
||||||
};
|
};
|
||||||
Object.keys(randomBonuses.bonuses).forEach(
|
Object.keys(randomBonuses.bonuses).forEach(
|
||||||
(key) => (UnstableCircadianModulatorParams[key] = randomBonuses.bonuses[key]),
|
(key) => ((UnstableCircadianModulatorParams as any)[key] = randomBonuses.bonuses[key]),
|
||||||
);
|
);
|
||||||
const UnstableCircadianModulator = new Augmentation(UnstableCircadianModulatorParams);
|
const UnstableCircadianModulator = new Augmentation(UnstableCircadianModulatorParams);
|
||||||
|
|
||||||
@ -2359,7 +2359,7 @@ function initAugmentations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Resets an Augmentation during (re-initizliation)
|
//Resets an Augmentation during (re-initizliation)
|
||||||
function resetAugmentation(newAugObject) {
|
function resetAugmentation(newAugObject: Augmentation): void {
|
||||||
if (!(newAugObject instanceof Augmentation)) {
|
if (!(newAugObject instanceof Augmentation)) {
|
||||||
throw new Error("Invalid argument 'newAugObject' passed into resetAugmentation");
|
throw new Error("Invalid argument 'newAugObject' passed into resetAugmentation");
|
||||||
}
|
}
|
||||||
@ -2370,18 +2370,16 @@ function resetAugmentation(newAugObject) {
|
|||||||
AddToAugmentations(newAugObject);
|
AddToAugmentations(newAugObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyAugmentation(aug, reapply = false) {
|
function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void {
|
||||||
Augmentations[aug.name].owned = true;
|
Augmentations[aug.name].owned = true;
|
||||||
|
|
||||||
const augObj = Augmentations[aug.name];
|
const augObj = Augmentations[aug.name];
|
||||||
|
|
||||||
// Apply multipliers
|
// Apply multipliers
|
||||||
for (const mult in augObj.mults) {
|
for (const mult in augObj.mults) {
|
||||||
if (Player[mult] == null) {
|
const v = Player.getMult(mult) * augObj.mults[mult];
|
||||||
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
|
Player.setMult(mult, v);
|
||||||
} else {
|
console.log(`${mult} ${v}`);
|
||||||
Player[mult] *= augObj.mults[mult];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special logic for NeuroFlux Governor
|
// Special logic for NeuroFlux Governor
|
||||||
@ -2445,11 +2443,11 @@ function installAugmentations() {
|
|||||||
prestigeAugmentation();
|
prestigeAugmentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
function augmentationExists(name) {
|
function augmentationExists(name: string) {
|
||||||
return Augmentations.hasOwnProperty(name);
|
return Augmentations.hasOwnProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRepeatableAug(aug) {
|
export function isRepeatableAug(aug: Augmentation): boolean {
|
||||||
const augName = aug instanceof Augmentation ? aug.name : aug;
|
const augName = aug instanceof Augmentation ? aug.name : aug;
|
||||||
|
|
||||||
if (augName === AugmentationNames.NeuroFluxGovernor) {
|
if (augName === AugmentationNames.NeuroFluxGovernor) {
|
1
src/Message/MessageHelpers.d.ts
vendored
1
src/Message/MessageHelpers.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare function showMessage(msg: Message): void;
|
|
@ -11,7 +11,7 @@ import { dialogBoxCreate } from "../../utils/DialogBox";
|
|||||||
import { Reviver } from "../../utils/JSONReviver";
|
import { Reviver } from "../../utils/JSONReviver";
|
||||||
|
|
||||||
//Sends message to player, including a pop up
|
//Sends message to player, including a pop up
|
||||||
function sendMessage(msg, forced = false) {
|
function sendMessage(msg: Message, forced = false): void {
|
||||||
msg.recvd = true;
|
msg.recvd = true;
|
||||||
if (forced || !Settings.SuppressMessages) {
|
if (forced || !Settings.SuppressMessages) {
|
||||||
showMessage(msg);
|
showMessage(msg);
|
||||||
@ -19,7 +19,7 @@ function sendMessage(msg, forced = false) {
|
|||||||
addMessageToServer(msg, "home");
|
addMessageToServer(msg, "home");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(msg) {
|
function showMessage(msg: Message): void {
|
||||||
var txt =
|
var txt =
|
||||||
"Message received from unknown sender: <br><br>" +
|
"Message received from unknown sender: <br><br>" +
|
||||||
"<i>" +
|
"<i>" +
|
||||||
@ -32,14 +32,16 @@ function showMessage(msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Adds a message to a server
|
//Adds a message to a server
|
||||||
function addMessageToServer(msg, serverHostname) {
|
function addMessageToServer(msg: Message, serverHostname: string): void {
|
||||||
var server = GetServerByHostname(serverHostname);
|
var server = GetServerByHostname(serverHostname);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
console.warn(`Could not find server ${serverHostname}`);
|
console.warn(`Could not find server ${serverHostname}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < server.messages.length; ++i) {
|
for (var i = 0; i < server.messages.length; ++i) {
|
||||||
if (server.messages[i].filename === msg.filename) {
|
const msg = server.messages[i];
|
||||||
|
if (typeof msg === "string") continue;
|
||||||
|
if (msg.filename === msg.filename) {
|
||||||
return; //Already exists
|
return; //Already exists
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,13 +97,13 @@ function checkForMessagesToSend() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddToAllMessages(msg) {
|
function AddToAllMessages(msg: Message): void {
|
||||||
Messages[msg.filename] = msg;
|
Messages[msg.filename] = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Messages = {};
|
let Messages: { [key: string]: Message | undefined } = {};
|
||||||
|
|
||||||
function loadMessages(saveString) {
|
function loadMessages(saveString: string): void {
|
||||||
Messages = JSON.parse(saveString, Reviver);
|
Messages = JSON.parse(saveString, Reviver);
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +201,7 @@ export interface IPlayer {
|
|||||||
inGang(): boolean;
|
inGang(): boolean;
|
||||||
isQualified(company: Company, position: CompanyPosition): boolean;
|
isQualified(company: Company, position: CompanyPosition): boolean;
|
||||||
loseMoney(money: number): void;
|
loseMoney(money: number): void;
|
||||||
reapplyAllAugmentations(resetMultipliers: boolean): void;
|
reapplyAllAugmentations(resetMultipliers?: boolean): void;
|
||||||
reapplyAllSourceFiles(): void;
|
reapplyAllSourceFiles(): void;
|
||||||
regenerateHp(amt: number): void;
|
regenerateHp(amt: number): void;
|
||||||
recordMoneySource(amt: number, source: string): void;
|
recordMoneySource(amt: number, source: string): void;
|
||||||
@ -272,4 +272,6 @@ export interface IPlayer {
|
|||||||
commitCrime(numCycles: number): boolean;
|
commitCrime(numCycles: number): boolean;
|
||||||
checkForFactionInvitations(): void;
|
checkForFactionInvitations(): void;
|
||||||
setBitNodeNumber(n: number): void;
|
setBitNodeNumber(n: number): void;
|
||||||
|
getMult(name: string): number;
|
||||||
|
setMult(name: string, mult: number): void;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
inGang: () => boolean;
|
inGang: () => boolean;
|
||||||
isQualified: (company: Company, position: CompanyPosition) => boolean;
|
isQualified: (company: Company, position: CompanyPosition) => boolean;
|
||||||
loseMoney: (money: number) => void;
|
loseMoney: (money: number) => void;
|
||||||
reapplyAllAugmentations: (resetMultipliers: boolean) => void;
|
reapplyAllAugmentations: (resetMultipliers?: boolean) => void;
|
||||||
reapplyAllSourceFiles: () => void;
|
reapplyAllSourceFiles: () => void;
|
||||||
regenerateHp: (amt: number) => void;
|
regenerateHp: (amt: number) => void;
|
||||||
recordMoneySource: (amt: number, source: string) => void;
|
recordMoneySource: (amt: number, source: string) => void;
|
||||||
@ -279,6 +279,8 @@ export class PlayerObject implements IPlayer {
|
|||||||
commitCrime: (numCycles: number) => boolean;
|
commitCrime: (numCycles: number) => boolean;
|
||||||
checkForFactionInvitations: () => void;
|
checkForFactionInvitations: () => void;
|
||||||
setBitNodeNumber: (n: number) => void;
|
setBitNodeNumber: (n: number) => void;
|
||||||
|
getMult: (name: string) => number;
|
||||||
|
setMult: (name: string, mult: number) => void;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
//Skills and stats
|
//Skills and stats
|
||||||
@ -570,6 +572,9 @@ export class PlayerObject implements IPlayer {
|
|||||||
this.factionWorkType = "";
|
this.factionWorkType = "";
|
||||||
this.committingCrimeThruSingFn = false;
|
this.committingCrimeThruSingFn = false;
|
||||||
this.singFnCrimeWorkerScript = null;
|
this.singFnCrimeWorkerScript = null;
|
||||||
|
|
||||||
|
this.getMult = generalMethods.getMult;
|
||||||
|
this.setMult = generalMethods.setMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2625,3 +2625,13 @@ export function getIntelligenceBonus(this: IPlayer, weight: number) {
|
|||||||
export function getCasinoWinnings(this: IPlayer) {
|
export function getCasinoWinnings(this: IPlayer) {
|
||||||
return this.moneySourceA.casino;
|
return this.moneySourceA.casino;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMult(this: IPlayer, name: string): number {
|
||||||
|
if (!this.hasOwnProperty(name)) return 1;
|
||||||
|
return (this as any)[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setMult(this: IPlayer, name: string, mult: number): void {
|
||||||
|
if (!this.hasOwnProperty(name)) return;
|
||||||
|
(this as any)[name] = mult;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user