Merge pull request #1748 from danielyxie/dev

v1.0.2
This commit is contained in:
hydroflame 2021-11-19 15:50:51 -05:00 committed by GitHub
commit 7764afaf31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 225 additions and 86 deletions

26
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -3,6 +3,21 @@
Changelog
=========
v1.0.2 - 2021-11-17 It's the little things (hydroflame)
-------------------------------------------------------
** Breaking (very small I promise!) **
* buy / sell now return getAskPrice / getBidPrice instead of just price.
This should help solve some inconsistencies.
** Misc. **
* scripts logs are colorized. Start your log with SUCCESS, ERROR, FAIL, WARN, INFO.
* documentation for scp not say string | string[]
* Donation link updated.
* nerf noodle bar
v1.0.1 - 2021-11-17 New documentation (hydroflame)
--------------------------------------------------

@ -66,7 +66,7 @@ documentation_title = '{0} Documentation'.format(project)
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.0.1'
release = '1.0.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
{
"name": "bitburner",
"license": "SEE LICENSE IN license.txt",
"version": "1.0.1",
"version": "1.0.2",
"main": "electron-main.js",
"author": {
"name": "Daniel Xie"

@ -115,8 +115,8 @@ export const CONSTANTS: {
TotalNumBitNodes: number;
LatestUpdate: string;
} = {
VersionString: "1.0.1",
VersionNumber: 4,
VersionString: "1.0.2",
VersionNumber: 5,
// Speed (in ms) at which the main loop is updated
_idleSpeed: 200,
@ -283,55 +283,19 @@ export const CONSTANTS: {
TotalNumBitNodes: 24,
LatestUpdate: `
v1.0.1 - 2021-11-17 New documentation (hydroflame)
--------------------------------------------------
v1.0.2 - 2021-11-17 It's the little things (hydroflame)
-------------------------------------------------------
** Documentation **
** Breaking (very small I promise!) **
* The new documentation for the netscript API is available at
https://github.com/danielyxie/bitburner/blob/dev/markdown/bitburner.ns.md
This documentation is used in-game to validate the code, in-editor to autocomplete, and
for users to reference. This is a huge quality of life improvements for me.
** Reputation **
* Fixed favor not affecting faction work reputation gain (Yeah, I know right?)
** Hacknet **
* Servers are now considerd "purchasedByPlayers"
** Script Editor **
* solarized themes now work.
** Corporation **
* Dividends are now much more taxed.
* The 2 upgrades that reduced taxes are now much stronger.
* buy / sell now return getAskPrice / getBidPrice instead of just price.
This should help solve some inconsistencies.
** Misc. **
* Starting / Stopping scripts on hashnet servers immediately updates their hash rate (instead of on the next tick)
* Hacknet has tooltip showing what the result of the upgrade would be.
* Augmentations page displayes current price multiplier as well as explains the mechanic.
* Terminal now is 25x stronger.
* Tail boxes use pre-wrap for it's lines.
* Tail boxes allow you to rerun dead scripts.
* Tail boxes can no longer open the same one twice.
* Terminal now autocompletes through aliases.
* Make alter reality harder.
* Fix bladeburner cancelling actions when manually starting anything with Simulacrum.
* Buying hash upgrade to increase uni class or gym training will apply to current class.
* Internally the game no longer uses the decimal library.
* Fix an issue where 'download *' would generate weird windows files.
* Timestamps can be set to any format in the options.
* Fix typo in documentation share popup.
* Remove bunch of debug log.
* Fix typo in corporation handbook literature.
* Fix typo in documentation
* Fix duplicate SF -1 exploit. (Yeah, an exploit of exploits, now were meta)
* Fix offline hacking earning being attributed to hacknet.
* scripts logs are colorized. Start your log with SUCCESS, ERROR, FAIL, WARN, INFO.
* documentation for scp not say string | string[]
* Donation link updated.
* nerf noodle bar
`,
};

@ -670,10 +670,45 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
if (args.length === 0) {
throw makeRuntimeErrorMsg("tprint", "Takes at least 1 argument.");
}
Terminal.print(`${workerScript.scriptRef.filename}: ${argsToString(args)}`);
const str = argsToString(args);
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("SUCCESS")) {
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("WARN")) {
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("INFO")) {
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
},
tprintf: function (format: any, ...args: any): any {
Terminal.print(vsprintf(format, args));
const str = vsprintf(format, args);
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {
Terminal.error(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("SUCCESS")) {
Terminal.success(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("WARN")) {
Terminal.warn(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
if (str.startsWith("INFO")) {
Terminal.info(`${workerScript.scriptRef.filename}: ${str}`);
return;
}
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
},
clearLog: function (): any {
workerScript.scriptRef.clearLog();

@ -127,7 +127,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
checkTixApiAccess("buy");
const stock = getStockFromSymbol(symbol, "buy");
const res = buyStock(stock, shares, workerScript, {});
return res ? stock.price : 0;
return res ? stock.getAskPrice() : 0;
},
sell: function (symbol: any, shares: any): any {
helper.updateDynamicRam("sell", getRamCost("stock", "sell"));
@ -135,7 +135,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const stock = getStockFromSymbol(symbol, "sell");
const res = sellStock(stock, shares, workerScript, {});
return res ? stock.price : 0;
return res ? stock.getBidPrice() : 0;
},
short: function (symbol: any, shares: any): any {
helper.updateDynamicRam("short", getRamCost("stock", "short"));

@ -872,7 +872,6 @@ export function startFactionFieldWork(this: IPlayer, router: IRouter, faction: F
this.workAgiExpGainRate = 0.1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
this.workChaExpGainRate = 0.1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
console.log(this.workRepGainRate);
this.factionWorkType = CONSTANTS.FactionWorkField;
this.currentWorkFactionDescription = "carrying out field missions";
@ -907,7 +906,6 @@ export function workForFaction(this: IPlayer, numCycles: number): boolean {
break;
case CONSTANTS.FactionWorkField:
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
console.log(this.workRepGainRate);
break;
case CONSTANTS.FactionWorkSecurity:
this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction);
@ -1484,7 +1482,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
if (this.committingCrimeThruSingFn && ws !== null) {
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
ws.scriptRef.log(
"Crime successful! Gained " +
"SUCCESS: Crime successful! Gained " +
numeralWrapper.formatMoney(this.workMoneyGained) +
", " +
numeralWrapper.formatExp(this.workHackExpGained) +
@ -1536,7 +1534,7 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string {
if (this.committingCrimeThruSingFn && ws !== null) {
if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) {
ws.scriptRef.log(
"Crime failed! Gained " +
"FAIL: Crime failed! Gained " +
numeralWrapper.formatExp(this.workHackExpGained) +
" hack exp, " +
numeralWrapper.formatExp(this.workStrExpGained) +

@ -4069,12 +4069,7 @@ export interface NS extends Singularity {
* @param destination - Host of the destination server, which is the server to which the file will be copied.
* @returns True if the script/literature file is successfully copied over and false otherwise. If the files argument is an array then this function will return true if at least one of the files in the array is successfully copied.
*/
scp(
files: string[],
source: string,
// tslint:disable-next-line:unified-signatures
destination: string,
): Promise<boolean>;
scp(files: string | string[], source: string, destination: string): Promise<boolean>;
/**
* List files on a server.

@ -106,6 +106,9 @@ interface IDefaultSettings {
primarylight: string;
primary: string;
primarydark: string;
successlight: string;
success: string;
successdark: string;
errorlight: string;
error: string;
errordark: string;
@ -182,6 +185,9 @@ export const defaultSettings: IDefaultSettings = {
primarylight: "#0f0",
primary: "#0c0",
primarydark: "#090",
successlight: "#0f0",
success: "#0c0",
successdark: "#090",
errorlight: "#f00",
error: "#c00",
errordark: "#900",
@ -246,6 +252,9 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
primarylight: defaultSettings.theme.primarylight,
primary: defaultSettings.theme.primary,
primarydark: defaultSettings.theme.primarydark,
successlight: defaultSettings.theme.successlight,
success: defaultSettings.theme.success,
successdark: defaultSettings.theme.successdark,
errorlight: defaultSettings.theme.errorlight,
error: defaultSettings.theme.error,
errordark: defaultSettings.theme.errordark,

@ -8,11 +8,8 @@ import { formatTime } from "../utils/helpers/formatTime";
export class Output {
text: string;
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined;
constructor(
text: string,
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined,
) {
color: "primary" | "error" | "success" | "info" | "warn";
constructor(text: string, color: "primary" | "error" | "success" | "info" | "warn") {
if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text;
this.text = text;
this.color = color;
@ -72,6 +69,9 @@ export interface ITerminal {
print(s: string): void;
printRaw(node: React.ReactNode): void;
error(s: string): void;
success(s: string): void;
info(s: string): void;
warn(s: string): void;
clear(): void;
startAnalyze(): void;

@ -113,6 +113,18 @@ export class Terminal implements ITerminal {
this.append(new Output(s, "error"));
}
success(s: string): void {
this.append(new Output(s, "success"));
}
info(s: string): void {
this.append(new Output(s, "info"));
}
warn(s: string): void {
this.append(new Output(s, "warn"));
}
startHack(player: IPlayer): void {
// Hacking through Terminal should be faster than hacking through a script
const server = player.getCurrentServer();

@ -43,6 +43,37 @@ const useStyles = makeStyles((theme: Theme) =>
padding: theme.spacing(0),
height: "100%",
},
success: {
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
margin: theme.spacing(0),
color: theme.colors.success,
},
error: {
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
margin: theme.spacing(0),
color: theme.palette.error.main,
},
primary: {
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
margin: theme.spacing(0),
color: theme.palette.primary.main,
},
info: {
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
margin: theme.spacing(0),
color: theme.palette.info.main,
},
warning: {
whiteSpace: "pre-wrap",
overflowWrap: "anywhere",
margin: theme.spacing(0),
color: theme.palette.warning.main,
},
}),
);
@ -80,6 +111,23 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
setTimeout(doScroll, 50);
}, []);
function lineClass(s: string): string {
if (s === "error") {
return classes.error;
}
if (s === "success") {
return classes.success;
}
if (s === "info") {
return classes.info;
}
if (s === "warn") {
return classes.warning;
}
return classes.primary;
}
const classes = useStyles();
return (
<>
@ -89,7 +137,7 @@ export function TerminalRoot({ terminal, router, player }: IProps): React.ReactE
if (item instanceof Output)
return (
<ListItem key={i} classes={{ root: classes.nopadding }}>
<Typography classes={{ root: classes.preformatted }} color={item.color} paragraph={false}>
<Typography classes={{ root: lineClass(item.color) }} paragraph={false}>
{item.text}
</Typography>
</ListItem>

@ -493,6 +493,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
}}
value={timestampFormat}
onChange={handleTimestampFormatChange}
placeholder="yyyy-MM-dd hh:mm:ss"
/>
</span>
</Tooltip>

@ -14,6 +14,7 @@ import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
import { workerScripts } from "../../Netscript/WorkerScripts";
import { startWorkerScript } from "../../NetscriptWorker";
import { GetServer } from "../../Server/AllServers";
import { Theme } from "@mui/material";
let layerCounter = 0;
@ -65,7 +66,7 @@ interface IProps {
onClose: () => void;
}
const useStyles = makeStyles(() =>
const useStyles = makeStyles((theme: Theme) =>
createStyles({
logs: {
overflowY: "scroll",
@ -74,6 +75,21 @@ const useStyles = makeStyles(() =>
display: "flex",
flexDirection: "column-reverse",
},
success: {
color: theme.colors.success,
},
error: {
color: theme.palette.error.main,
},
primary: {
color: theme.palette.primary.main,
},
info: {
color: theme.palette.info.main,
},
warning: {
color: theme.palette.warning.main,
},
}),
);
@ -117,6 +133,22 @@ function LogWindow(props: IProps): React.ReactElement {
return t.slice(0, maxLength - 3) + "...";
}
function lineClass(s: string): string {
if (s.startsWith("ERROR") || s.startsWith("FAIL")) {
return classes.error;
}
if (s.startsWith("SUCCESS")) {
return classes.success;
}
if (s.startsWith("WARN")) {
return classes.warning;
}
if (s.startsWith("INFO")) {
return classes.info;
}
return classes.primary;
}
return (
<Draggable handle=".drag">
<Paper
@ -162,7 +194,7 @@ function LogWindow(props: IProps): React.ReactElement {
<Box>
{props.script.logs.map(
(line: string, i: number): JSX.Element => (
<Typography key={i}>
<Typography key={i} className={lineClass(line)}>
{line}
<br />
</Typography>

@ -18,6 +18,9 @@ declare module "@mui/material/styles" {
backgroundprimary: React.CSSProperties["color"];
backgroundsecondary: React.CSSProperties["color"];
button: React.CSSProperties["color"];
successlight: React.CSSProperties["color"];
success: React.CSSProperties["color"];
successdark: React.CSSProperties["color"];
};
}
interface ThemeOptions {
@ -32,6 +35,9 @@ declare module "@mui/material/styles" {
backgroundprimary: React.CSSProperties["color"];
backgroundsecondary: React.CSSProperties["color"];
button: React.CSSProperties["color"];
successlight: React.CSSProperties["color"];
success: React.CSSProperties["color"];
successdark: React.CSSProperties["color"];
};
}
}
@ -51,6 +57,9 @@ export function refreshTheme(): void {
backgroundprimary: Settings.theme.backgroundprimary,
backgroundsecondary: Settings.theme.backgroundsecondary,
button: Settings.theme.button,
successlight: Settings.theme.successlight,
success: Settings.theme.success,
successdark: Settings.theme.successdark,
},
palette: {
primary: {

@ -132,6 +132,27 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
defaultColor={defaultSettings.theme["primarydark"]}
/>
<br />
<ColorEditor
name="successlight"
onColorChange={onColorChange}
color={customTheme["successlight"]}
defaultColor={defaultSettings.theme["successlight"]}
/>
<ColorEditor
name="success"
onColorChange={onColorChange}
color={customTheme["success"]}
defaultColor={defaultSettings.theme["success"]}
/>
<ColorEditor
name="successdark"
onColorChange={onColorChange}
color={customTheme["successdark"]}
defaultColor={defaultSettings.theme["successdark"]}
/>
<br />
<ColorEditor
name="errorlight"