mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
V0.51.3 (#845)
v0.51.3 - 2021-04-16 Y'all broke it on the first day (hydroflame) ------- Passive faction reputation * Reworked, from 1 rep / 2 minute. Now is a complicated percentage of the reputation you'd gain working for them. It's not op but it feels a bit more useful. Netscript * print/tprint now take any number of arguments. * print/tprint will now print object as json. * print/tprint now handle passing in an undefined argument properly. Casino * Cannot bet negative money anymore. * Roulette max bet is a bit higher. * Coin Flip has a small cooldown. * All buttons reject unstrusted mouse events. Documentation * Changed a message that said nsjs only works on Chrome. Bugfix * hacknet.maxNumNodes now works for both nodes and servers. * Fixed a bug where the popup boxes would contain data from previous popup boxes. * .js files will also have the export async function boilerplate. Misc. * turned off autocomplete for the terminal text input. * Fixed an issue on Windows+Firefox where pressing up on the terminal would bring the cursor to the begining of the line. (Issue #836) * Hacknet node names is easier to handle for screen readers. * Money spent on classes is now tracked independently of work money. * running coding contract from the terminal will display its name.
This commit is contained in:
parent
80b703639e
commit
4e5ebcfe6f
4
dist/engine.bundle.js
vendored
4
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/engineStyle.bundle.js
vendored
2
dist/engineStyle.bundle.js
vendored
@ -1,2 +1,2 @@
|
|||||||
!function(n){function t(t){for(var e,i,f=t[0],c=t[1],l=t[2],p=0,s=[];p<f.length;p++)i=f[p],u[i]&&s.push(u[i][0]),u[i]=0;for(e in c)Object.prototype.hasOwnProperty.call(c,e)&&(n[e]=c[e]);for(a&&a(t);s.length;)s.shift()();return r.push.apply(r,l||[]),o()}function o(){for(var n,t=0;t<r.length;t++){for(var o=r[t],e=!0,f=1;f<o.length;f++){var c=o[f];0!==u[c]&&(e=!1)}e&&(r.splice(t--,1),n=i(i.s=o[0]))}return n}var e={},u={1:0},r=[];function i(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=n,i.c=e,i.d=function(n,t,o){i.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},i.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},i.t=function(n,t){if(1&t&&(n=i(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var e in n)i.d(o,e,function(t){return n[t]}.bind(null,e));return o},i.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return i.d(t,"a",t),t},i.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},i.p="";var f=window.webpackJsonp=window.webpackJsonp||[],c=f.push.bind(f);f.push=t,f=f.slice();for(var l=0;l<f.length;l++)t(f[l]);var a=c;r.push([398,0]),o()}({341:function(n,t,o){},343:function(n,t,o){},345:function(n,t,o){},347:function(n,t,o){},349:function(n,t,o){},351:function(n,t,o){},353:function(n,t,o){},355:function(n,t,o){},357:function(n,t,o){},359:function(n,t,o){},361:function(n,t,o){},363:function(n,t,o){},365:function(n,t,o){},367:function(n,t,o){},369:function(n,t,o){},371:function(n,t,o){},373:function(n,t,o){},375:function(n,t,o){},377:function(n,t,o){},379:function(n,t,o){},381:function(n,t,o){},383:function(n,t,o){},385:function(n,t,o){},387:function(n,t,o){},389:function(n,t,o){},391:function(n,t,o){},393:function(n,t,o){},395:function(n,t,o){},398:function(n,t,o){"use strict";o.r(t);o(397),o(395),o(393),o(391),o(389),o(387),o(385),o(383),o(381),o(379),o(377),o(375),o(373),o(371),o(369),o(367),o(365),o(363),o(361),o(359),o(357),o(355),o(353),o(351),o(349),o(347),o(345),o(343),o(341)}});
|
!function(n){function t(t){for(var e,i,f=t[0],c=t[1],l=t[2],p=0,s=[];p<f.length;p++)i=f[p],u[i]&&s.push(u[i][0]),u[i]=0;for(e in c)Object.prototype.hasOwnProperty.call(c,e)&&(n[e]=c[e]);for(a&&a(t);s.length;)s.shift()();return r.push.apply(r,l||[]),o()}function o(){for(var n,t=0;t<r.length;t++){for(var o=r[t],e=!0,f=1;f<o.length;f++){var c=o[f];0!==u[c]&&(e=!1)}e&&(r.splice(t--,1),n=i(i.s=o[0]))}return n}var e={},u={1:0},r=[];function i(t){if(e[t])return e[t].exports;var o=e[t]={i:t,l:!1,exports:{}};return n[t].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=n,i.c=e,i.d=function(n,t,o){i.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},i.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},i.t=function(n,t){if(1&t&&(n=i(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var e in n)i.d(o,e,function(t){return n[t]}.bind(null,e));return o},i.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return i.d(t,"a",t),t},i.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},i.p="";var f=window.webpackJsonp=window.webpackJsonp||[],c=f.push.bind(f);f.push=t,f=f.slice();for(var l=0;l<f.length;l++)t(f[l]);var a=c;r.push([400,0]),o()}({343:function(n,t,o){},345:function(n,t,o){},347:function(n,t,o){},349:function(n,t,o){},351:function(n,t,o){},353:function(n,t,o){},355:function(n,t,o){},357:function(n,t,o){},359:function(n,t,o){},361:function(n,t,o){},363:function(n,t,o){},365:function(n,t,o){},367:function(n,t,o){},369:function(n,t,o){},371:function(n,t,o){},373:function(n,t,o){},375:function(n,t,o){},377:function(n,t,o){},379:function(n,t,o){},381:function(n,t,o){},383:function(n,t,o){},385:function(n,t,o){},387:function(n,t,o){},389:function(n,t,o){},391:function(n,t,o){},393:function(n,t,o){},395:function(n,t,o){},397:function(n,t,o){},400:function(n,t,o){"use strict";o.r(t);o(399),o(397),o(395),o(393),o(391),o(389),o(387),o(385),o(383),o(381),o(379),o(377),o(375),o(373),o(371),o(369),o(367),o(365),o(363),o(361),o(359),o(357),o(355),o(353),o(351),o(349),o(347),o(345),o(343)}});
|
||||||
//# sourceMappingURL=engineStyle.bundle.js.map
|
//# sourceMappingURL=engineStyle.bundle.js.map
|
26
dist/vendor.bundle.js
vendored
26
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -3,6 +3,47 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
v0.51.3 - 2021-04-16 Y'all broke it on the first day (hydroflame)
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
**Passive faction reputation**
|
||||||
|
|
||||||
|
* Reworked, from 1 rep / 2 minute. Now is a complicated percentage of the
|
||||||
|
reputation you'd gain working for them. It's not op but it feels a bit
|
||||||
|
more useful.
|
||||||
|
|
||||||
|
**Netscript**
|
||||||
|
|
||||||
|
* print/tprint now take any number of arguments.
|
||||||
|
* print/tprint will now print object as json.
|
||||||
|
* print/tprint now handle passing in an undefined argument properly.
|
||||||
|
|
||||||
|
**Casino**
|
||||||
|
|
||||||
|
* Cannot bet negative money anymore.
|
||||||
|
* Roulette max bet is a bit higher.
|
||||||
|
* Coin Flip has a small cooldown.
|
||||||
|
* All buttons reject unstrusted mouse events.
|
||||||
|
|
||||||
|
**Documentation**
|
||||||
|
|
||||||
|
* Changed a message that said nsjs only works on Chrome.
|
||||||
|
|
||||||
|
**Bugfix**
|
||||||
|
|
||||||
|
* hacknet.maxNumNodes now works for both nodes and servers.
|
||||||
|
* Fixed a bug where the popup boxes would contain data from previous popup boxes.
|
||||||
|
* .js files will also have the 'export async function' boilerplate.
|
||||||
|
|
||||||
|
**Misc.**
|
||||||
|
|
||||||
|
* turned off web form autocomplete for the terminal text input.
|
||||||
|
* Fixed an issue on Windows+Firefox where pressing up on the terminal would
|
||||||
|
bring the cursor to the begining of the line. (Issue #836)
|
||||||
|
* Hacknet node names is easier to handle for screen readers.
|
||||||
|
* Money spent on classes is now tracked independently of work money.
|
||||||
|
* running coding contract from the terminal will display its name.
|
||||||
|
|
||||||
v0.51.2 - 2021-04-09 Vegas, Baby! (hydroflame)
|
v0.51.2 - 2021-04-09 Vegas, Baby! (hydroflame)
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ documentation_title = '{0} Documentation'.format(project)
|
|||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.51'
|
version = '0.51'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.51.2'
|
release = '0.51.3'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
print() Netscript Function
|
print() Netscript Function
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
.. js:function:: print(x)
|
.. js:function:: print(args...)
|
||||||
|
|
||||||
:RAM cost: 0 GB
|
:RAM cost: 0 GB
|
||||||
:param x: Value to be printed.
|
:param args: Values to be printed.
|
||||||
|
|
||||||
Prints a value or a variable to the script's logs.
|
Prints any number of values to the script's logs.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: javascript
|
.. code-block:: javascript
|
||||||
|
|
||||||
print("Hello world!"); // Prints "Hello world!" in the logs.
|
print("Hello world!"); // Prints "Hello world!" in the logs.
|
||||||
|
print({a:5}); // Prints '{"a":5}' in the logs.
|
@ -1,15 +1,16 @@
|
|||||||
tprint() Netscript Function
|
tprint() Netscript Function
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
.. js:function:: tprint(x)
|
.. js:function:: tprint(args...)
|
||||||
|
|
||||||
:RAM cost: 0 GB
|
:RAM cost: 0 GB
|
||||||
:param x: Value to be printed
|
:param args: Values to be printed
|
||||||
|
|
||||||
Prints a value or a variable to the Terminal.
|
Prints any number of values to the Terminal.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: javascript
|
.. code-block:: javascript
|
||||||
|
|
||||||
tprint("Hello world!"); // Prints "Hello world!" to the terminal.
|
tprint("Hello world!"); // Prints "Hello world!" to the terminal.
|
||||||
|
tprint({a:5}); // Prints '{"a":5}' to the terminal.
|
@ -65,6 +65,6 @@ Here is a short summary of the differences between Netscript 1.0 and Netscript 2
|
|||||||
|
|
||||||
* Supports (almost) all features of modern JavaScript
|
* Supports (almost) all features of modern JavaScript
|
||||||
* Extremely fast - code is executed as an Async Function
|
* Extremely fast - code is executed as an Async Function
|
||||||
* Currently only works with Google Chrome browser
|
* Works on most modern browsers.
|
||||||
* Each script becomes a module and therefore all instances of that script can easily
|
* Each script becomes a module and therefore all instances of that script can easily
|
||||||
share data between each other (essentially global/static variables)
|
share data between each other (essentially global/static variables)
|
||||||
|
@ -177,7 +177,7 @@
|
|||||||
<table id="terminal">
|
<table id="terminal">
|
||||||
<tr id="terminal-input">
|
<tr id="terminal-input">
|
||||||
<td id="terminal-input-td" tabindex="2">$
|
<td id="terminal-input-td" tabindex="2">$
|
||||||
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;"/>
|
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;" autocomplete="off"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -121,5 +121,5 @@
|
|||||||
"watch": "webpack --watch --mode production",
|
"watch": "webpack --watch --mode production",
|
||||||
"watch:dev": "webpack --watch --mode development"
|
"watch:dev": "webpack --watch --mode development"
|
||||||
},
|
},
|
||||||
"version": "0.51.1"
|
"version": "0.51.3"
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { StdButton } from "../ui/React/StdButton";
|
import { StdButton } from "../ui/React/StdButton";
|
||||||
import { BadRNG } from "./RNG";
|
import { BadRNG } from "./RNG";
|
||||||
import { Game } from "./Game";
|
import { Game } from "./Game";
|
||||||
|
import { trusted } from "./utils";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
p: IPlayer;
|
p: IPlayer;
|
||||||
@ -18,8 +19,10 @@ type IState = {
|
|||||||
investment: number;
|
investment: number;
|
||||||
result: any;
|
result: any;
|
||||||
status: string;
|
status: string;
|
||||||
|
playLock: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const minPlay = 0;
|
||||||
const maxPlay = 10e3;
|
const maxPlay = 10e3;
|
||||||
|
|
||||||
export class CoinFlip extends Game<IProps, IState> {
|
export class CoinFlip extends Game<IProps, IState> {
|
||||||
@ -31,6 +34,7 @@ export class CoinFlip extends Game<IProps, IState> {
|
|||||||
investment: 1000,
|
investment: 1000,
|
||||||
result: <span> </span>,
|
result: <span> </span>,
|
||||||
status: '',
|
status: '',
|
||||||
|
playLock: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.play = this.play.bind(this);
|
this.play = this.play.bind(this);
|
||||||
@ -40,11 +44,14 @@ export class CoinFlip extends Game<IProps, IState> {
|
|||||||
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
||||||
let investment: number = parseInt(e.currentTarget.value);
|
let investment: number = parseInt(e.currentTarget.value);
|
||||||
if (isNaN(investment)) {
|
if (isNaN(investment)) {
|
||||||
investment = 1000;
|
investment = minPlay;
|
||||||
}
|
}
|
||||||
if (investment > maxPlay) {
|
if (investment > maxPlay) {
|
||||||
investment = maxPlay;
|
investment = maxPlay;
|
||||||
}
|
}
|
||||||
|
if (investment < minPlay) {
|
||||||
|
investment = minPlay;
|
||||||
|
}
|
||||||
this.setState({investment: investment});
|
this.setState({investment: investment});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +68,9 @@ export class CoinFlip extends Game<IProps, IState> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
result: <span className={correct ? "text" : "failure"}>{letter}</span>,
|
result: <span className={correct ? "text" : "failure"}>{letter}</span>,
|
||||||
status: correct ? " win!" : "lose!",
|
status: correct ? " win!" : "lose!",
|
||||||
|
playLock: true,
|
||||||
});
|
});
|
||||||
|
setTimeout(()=>this.setState({playLock: false}), 250);
|
||||||
if (correct) {
|
if (correct) {
|
||||||
this.win(this.props.p, this.state.investment);
|
this.win(this.props.p, this.state.investment);
|
||||||
} else {
|
} else {
|
||||||
@ -81,8 +90,8 @@ export class CoinFlip extends Game<IProps, IState> {
|
|||||||
+———————+<br />
|
+———————+<br />
|
||||||
</pre>
|
</pre>
|
||||||
<span className="text">Play for: </span><input type="number" className='text-input' onChange={this.updateInvestment} value={this.state.investment} /><br />
|
<span className="text">Play for: </span><input type="number" className='text-input' onChange={this.updateInvestment} value={this.state.investment} /><br />
|
||||||
<StdButton onClick={() => this.play('H')} text={"Head!"} />
|
<StdButton onClick={trusted(() => this.play('H'))} text={"Head!"} disabled={this.state.playLock} />
|
||||||
<StdButton onClick={() => this.play('T')} text={"Tail!"} />
|
<StdButton onClick={trusted(() => this.play('T'))} text={"Tail!"} disabled={this.state.playLock} />
|
||||||
<h1>{this.state.status}</h1>
|
<h1>{this.state.status}</h1>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { StdButton } from "../ui/React/StdButton";
|
import { StdButton } from "../ui/React/StdButton";
|
||||||
import { Money } from "../ui/React/Money";
|
import { Money } from "../ui/React/Money";
|
||||||
import { Game } from "./Game";
|
import { Game } from "./Game";
|
||||||
import { WHRNG } from "./RNG";
|
import { WHRNG } from "./RNG";
|
||||||
|
import { trusted } from "./utils";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
p: IPlayer;
|
p: IPlayer;
|
||||||
@ -19,7 +20,8 @@ type IState = {
|
|||||||
strategy: Strategy;
|
strategy: Strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxPlay = 1e6;
|
const minPlay = 0;
|
||||||
|
const maxPlay = 1e7;
|
||||||
|
|
||||||
function isRed(n: number): boolean {
|
function isRed(n: number): boolean {
|
||||||
return [1, 3, 5, 7, 9, 12, 14, 16, 18, 19,
|
return [1, 3, 5, 7, 9, 12, 14, 16, 18, 19,
|
||||||
@ -165,10 +167,13 @@ export class Roulette extends Game<IProps, IState> {
|
|||||||
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
||||||
let investment: number = parseInt(e.currentTarget.value);
|
let investment: number = parseInt(e.currentTarget.value);
|
||||||
if (isNaN(investment)) {
|
if (isNaN(investment)) {
|
||||||
investment = 1000;
|
investment = minPlay;
|
||||||
}
|
}
|
||||||
if (investment > maxPlay) {
|
if (investment > maxPlay) {
|
||||||
investment = maxPlay
|
investment = maxPlay;
|
||||||
|
}
|
||||||
|
if (investment < minPlay) {
|
||||||
|
investment = minPlay;
|
||||||
}
|
}
|
||||||
this.setState({investment: investment});
|
this.setState({investment: investment});
|
||||||
}
|
}
|
||||||
@ -226,62 +231,62 @@ export class Roulette extends Game<IProps, IState> {
|
|||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><StdButton text={"3"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(3))} /></td>
|
<td><StdButton text={"3"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(3)))} /></td>
|
||||||
<td><StdButton text={"6"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(6))} /></td>
|
<td><StdButton text={"6"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(6)))} /></td>
|
||||||
<td><StdButton text={"9"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(9))} /></td>
|
<td><StdButton text={"9"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(9)))} /></td>
|
||||||
<td><StdButton text={"12"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(12))} /></td>
|
<td><StdButton text={"12"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(12)))} /></td>
|
||||||
<td><StdButton text={"15"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(15))} /></td>
|
<td><StdButton text={"15"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(15)))} /></td>
|
||||||
<td><StdButton text={"18"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(18))} /></td>
|
<td><StdButton text={"18"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(18)))} /></td>
|
||||||
<td><StdButton text={"21"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(21))} /></td>
|
<td><StdButton text={"21"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(21)))} /></td>
|
||||||
<td><StdButton text={"24"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(24))} /></td>
|
<td><StdButton text={"24"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(24)))} /></td>
|
||||||
<td><StdButton text={"27"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(27))} /></td>
|
<td><StdButton text={"27"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(27)))} /></td>
|
||||||
<td><StdButton text={"30"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(30))} /></td>
|
<td><StdButton text={"30"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(30)))} /></td>
|
||||||
<td><StdButton text={"33"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(33))} /></td>
|
<td><StdButton text={"33"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(33)))} /></td>
|
||||||
<td><StdButton text={"36"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(36))} /></td>
|
<td><StdButton text={"36"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(36)))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><StdButton text={"2"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(2))} /></td>
|
<td><StdButton text={"2"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(2)))} /></td>
|
||||||
<td><StdButton text={"5"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(5))} /></td>
|
<td><StdButton text={"5"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(5)))} /></td>
|
||||||
<td><StdButton text={"8"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(8))} /></td>
|
<td><StdButton text={"8"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(8)))} /></td>
|
||||||
<td><StdButton text={"11"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(11))} /></td>
|
<td><StdButton text={"11"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(11)))} /></td>
|
||||||
<td><StdButton text={"14"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(14))} /></td>
|
<td><StdButton text={"14"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(14)))} /></td>
|
||||||
<td><StdButton text={"17"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(17))} /></td>
|
<td><StdButton text={"17"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(17)))} /></td>
|
||||||
<td><StdButton text={"20"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(20))} /></td>
|
<td><StdButton text={"20"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(20)))} /></td>
|
||||||
<td><StdButton text={"23"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(23))} /></td>
|
<td><StdButton text={"23"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(23)))} /></td>
|
||||||
<td><StdButton text={"26"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(26))} /></td>
|
<td><StdButton text={"26"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(26)))} /></td>
|
||||||
<td><StdButton text={"29"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(29))} /></td>
|
<td><StdButton text={"29"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(29)))} /></td>
|
||||||
<td><StdButton text={"32"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(32))} /></td>
|
<td><StdButton text={"32"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(32)))} /></td>
|
||||||
<td><StdButton text={"35"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(35))} /></td>
|
<td><StdButton text={"35"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(35)))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><StdButton text={"1"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(1))} /></td>
|
<td><StdButton text={"1"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(1)))} /></td>
|
||||||
<td><StdButton text={"4"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(4))} /></td>
|
<td><StdButton text={"4"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(4)))} /></td>
|
||||||
<td><StdButton text={"7"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(7))} /></td>
|
<td><StdButton text={"7"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(7)))} /></td>
|
||||||
<td><StdButton text={"10"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(10))} /></td>
|
<td><StdButton text={"10"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(10)))} /></td>
|
||||||
<td><StdButton text={"13"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(13))} /></td>
|
<td><StdButton text={"13"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(13)))} /></td>
|
||||||
<td><StdButton text={"16"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(16))} /></td>
|
<td><StdButton text={"16"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(16)))} /></td>
|
||||||
<td><StdButton text={"19"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(19))} /></td>
|
<td><StdButton text={"19"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(19)))} /></td>
|
||||||
<td><StdButton text={"22"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(22))} /></td>
|
<td><StdButton text={"22"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(22)))} /></td>
|
||||||
<td><StdButton text={"25"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(25))} /></td>
|
<td><StdButton text={"25"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(25)))} /></td>
|
||||||
<td><StdButton text={"28"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(28))} /></td>
|
<td><StdButton text={"28"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(28)))} /></td>
|
||||||
<td><StdButton text={"31"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(31))} /></td>
|
<td><StdButton text={"31"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(31)))} /></td>
|
||||||
<td><StdButton text={"34"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(34))} /></td>
|
<td><StdButton text={"34"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(34)))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={4}><StdButton text={"1 to 12"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Third1)} /></td>
|
<td colSpan={4}><StdButton text={"1 to 12"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Third1))} /></td>
|
||||||
<td colSpan={4}><StdButton text={"13 to 24"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Third2)} /></td>
|
<td colSpan={4}><StdButton text={"13 to 24"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Third2))} /></td>
|
||||||
<td colSpan={4}><StdButton text={"25 to 36"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Third3)} /></td>
|
<td colSpan={4}><StdButton text={"25 to 36"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Third3))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={2}><StdButton text={"Red"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Red)} /></td>
|
<td colSpan={2}><StdButton text={"Red"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Red))} /></td>
|
||||||
<td colSpan={2}><StdButton text={"Black"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Black)} /></td>
|
<td colSpan={2}><StdButton text={"Black"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Black))} /></td>
|
||||||
<td colSpan={2}><StdButton text={"Odd"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Odd)} /></td>
|
<td colSpan={2}><StdButton text={"Odd"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Odd))} /></td>
|
||||||
<td colSpan={2}><StdButton text={"Even"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Even)} /></td>
|
<td colSpan={2}><StdButton text={"Even"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Even))} /></td>
|
||||||
<td colSpan={2}><StdButton text={"High"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.High)} /></td>
|
<td colSpan={2}><StdButton text={"High"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.High))} /></td>
|
||||||
<td colSpan={2}><StdButton text={"Low"} disabled={!this.state.canPlay} onClick={()=>this.play(strategies.Low)} /></td>
|
<td colSpan={2}><StdButton text={"Low"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Low))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><StdButton text={"0"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(0))} /></td>
|
<td><StdButton text={"0"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(Single(0)))} /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -4,7 +4,8 @@ import { IPlayer } from "../PersonObjects/IPlayer";
|
|||||||
import { StdButton } from "../ui/React/StdButton";
|
import { StdButton } from "../ui/React/StdButton";
|
||||||
import { Money } from "../ui/React/Money";
|
import { Money } from "../ui/React/Money";
|
||||||
import { WHRNG } from "./RNG";
|
import { WHRNG } from "./RNG";
|
||||||
import { Game } from "./Game";
|
import { Game } from "./Game";
|
||||||
|
import { trusted } from "./utils";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
p: IPlayer;
|
p: IPlayer;
|
||||||
@ -57,6 +58,7 @@ const payLines = [
|
|||||||
[[1, 0], [2, 1], [2, 2], [2, 3], [1, 4]],
|
[[1, 0], [2, 1], [2, 2], [2, 3], [1, 4]],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const minPlay = 0;
|
||||||
const maxPlay = 1e6;
|
const maxPlay = 1e6;
|
||||||
|
|
||||||
export class SlotMachine extends Game<IProps, IState> {
|
export class SlotMachine extends Game<IProps, IState> {
|
||||||
@ -184,11 +186,14 @@ export class SlotMachine extends Game<IProps, IState> {
|
|||||||
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
||||||
let investment: number = parseInt(e.currentTarget.value);
|
let investment: number = parseInt(e.currentTarget.value);
|
||||||
if (isNaN(investment)) {
|
if (isNaN(investment)) {
|
||||||
investment = 1000;
|
investment = minPlay;
|
||||||
}
|
}
|
||||||
if (investment > maxPlay) {
|
if (investment > maxPlay) {
|
||||||
investment = maxPlay;
|
investment = maxPlay;
|
||||||
}
|
}
|
||||||
|
if (investment < minPlay) {
|
||||||
|
investment = minPlay;
|
||||||
|
}
|
||||||
this.setState({investment: investment});
|
this.setState({investment: investment});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +210,7 @@ export class SlotMachine extends Game<IProps, IState> {
|
|||||||
+———————————————————————+<br />
|
+———————————————————————+<br />
|
||||||
</pre>
|
</pre>
|
||||||
<input type="number" className='text-input' onChange={this.updateInvestment} placeholder={"Amount to play"} value={this.state.investment} disabled={!this.state.canPlay} />
|
<input type="number" className='text-input' onChange={this.updateInvestment} placeholder={"Amount to play"} value={this.state.investment} disabled={!this.state.canPlay} />
|
||||||
<StdButton onClick={this.play} text={"Spin!"} disabled={!this.state.canPlay} />
|
<StdButton onClick={trusted(this.play)} text={"Spin!"} disabled={!this.state.canPlay} />
|
||||||
<h1>{this.state.status}</h1>
|
<h1>{this.state.status}</h1>
|
||||||
<h2>Pay lines</h2>
|
<h2>Pay lines</h2>
|
||||||
<pre>
|
<pre>
|
||||||
|
8
src/Casino/utils.ts
Normal file
8
src/Casino/utils.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export function trusted(f: () => void): (event: React.MouseEvent<HTMLElement, MouseEvent>) => any {
|
||||||
|
return function(event: React.MouseEvent<HTMLElement, MouseEvent>): any {
|
||||||
|
if(!event.isTrusted) return;
|
||||||
|
f();
|
||||||
|
};
|
||||||
|
}
|
@ -181,6 +181,9 @@ export class CodingContract {
|
|||||||
return new Promise<CodingContractResult>((resolve: Function, reject: Function) => {
|
return new Promise<CodingContractResult>((resolve: Function, reject: Function) => {
|
||||||
const contractType: CodingContractType = CodingContractTypes[this.type];
|
const contractType: CodingContractType = CodingContractTypes[this.type];
|
||||||
const popupId: string = `coding-contract-prompt-popup-${this.fn}`;
|
const popupId: string = `coding-contract-prompt-popup-${this.fn}`;
|
||||||
|
const title: HTMLElement = createElement("h1", {
|
||||||
|
innerHTML: this.type,
|
||||||
|
});
|
||||||
const txt: HTMLElement = createElement("p", {
|
const txt: HTMLElement = createElement("p", {
|
||||||
innerHTML: ["You are attempting to solve a Coding Contract. You have",
|
innerHTML: ["You are attempting to solve a Coding Contract. You have",
|
||||||
`${this.getMaxNumTries() - this.tries} tries remaining,`,
|
`${this.getMaxNumTries() - this.tries} tries remaining,`,
|
||||||
@ -225,7 +228,7 @@ export class CodingContract {
|
|||||||
innerText: "Cancel",
|
innerText: "Cancel",
|
||||||
});
|
});
|
||||||
const lineBreak: HTMLElement = createElement("br");
|
const lineBreak: HTMLElement = createElement("br");
|
||||||
createPopup(popupId, [txt, lineBreak, lineBreak, answerInput, solveBtn, cancelBtn]);
|
createPopup(popupId, [title, lineBreak, txt, lineBreak, lineBreak, answerInput, solveBtn, cancelBtn]);
|
||||||
answerInput.focus();
|
answerInput.focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
import { IMap } from "./types";
|
import { IMap } from "./types";
|
||||||
|
|
||||||
export let CONSTANTS: IMap<any> = {
|
export let CONSTANTS: IMap<any> = {
|
||||||
Version: "0.51.2",
|
Version: "0.51.3",
|
||||||
|
|
||||||
/** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
/** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||||
* and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
* and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||||
* the player will have this level assuming no multipliers. Multipliers can cause skills to go above this.
|
* the player will have this level assuming no multipliers. Multipliers can cause skills to go above this.
|
||||||
*/
|
*/
|
||||||
MaxSkillLevel: 975,
|
MaxSkillLevel: 975,
|
||||||
|
|
||||||
// Milliseconds per game cycle
|
// Milliseconds per game cycle
|
||||||
MilliPerCycle: 200,
|
MilliPerCycle: 200,
|
||||||
@ -218,7 +218,7 @@ export let CONSTANTS: IMap<any> = {
|
|||||||
CrimeHeist: "pull off the ultimate heist",
|
CrimeHeist: "pull off the ultimate heist",
|
||||||
|
|
||||||
// Coding Contract
|
// Coding Contract
|
||||||
// TODO Move this into Coding contract impelmentation?
|
// TODO: Move this into Coding contract implementation?
|
||||||
CodingContractBaseFactionRepGain: 2500,
|
CodingContractBaseFactionRepGain: 2500,
|
||||||
CodingContractBaseCompanyRepGain: 4000,
|
CodingContractBaseCompanyRepGain: 4000,
|
||||||
CodingContractBaseMoneyGain: 75e6,
|
CodingContractBaseMoneyGain: 75e6,
|
||||||
@ -228,16 +228,39 @@ export let CONSTANTS: IMap<any> = {
|
|||||||
|
|
||||||
LatestUpdate:
|
LatestUpdate:
|
||||||
`
|
`
|
||||||
v0.51.2 - 2021-04-09 Vegas, Baby! (hydroflame)
|
v0.51.3 - 2021-04-16 Y'all broke it on the first day (hydroflame)
|
||||||
-------
|
-------
|
||||||
|
|
||||||
New location: The Iker Molina Casino
|
Passive faction reputation
|
||||||
* A casino opened in Aevum. However the house is rumored to cheat. If only
|
* Reworked, from 1 rep / 2 minute. Now is a complicated percentage of the
|
||||||
we could give them a taste of their own medicine.
|
reputation you'd gain working for them. It's not op but it feels a bit
|
||||||
|
more useful.
|
||||||
|
|
||||||
|
Netscript
|
||||||
|
* print/tprint now take any number of arguments.
|
||||||
|
* print/tprint will now print object as json.
|
||||||
|
* print/tprint now handle passing in an undefined argument properly.
|
||||||
|
|
||||||
|
Casino
|
||||||
|
* Cannot bet negative money anymore.
|
||||||
|
* Roulette max bet is a bit higher.
|
||||||
|
* Coin Flip has a small cooldown.
|
||||||
|
* All buttons reject unstrusted mouse events.
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
* Changed a message that said nsjs only works on Chrome.
|
||||||
|
|
||||||
|
Bugfix
|
||||||
|
* hacknet.maxNumNodes now works for both nodes and servers.
|
||||||
|
* Fixed a bug where the popup boxes would contain data from previous popup boxes.
|
||||||
|
* .js files will also have the export async function boilerplate.
|
||||||
|
|
||||||
Misc.
|
Misc.
|
||||||
* Link to discord added under options
|
* turned off autocomplete for the terminal text input.
|
||||||
* 'getMemberInformation' doc updated, oops
|
* Fixed an issue on Windows+Firefox where pressing up on the terminal would
|
||||||
* tech vendor now handle max ram and cores.
|
bring the cursor to the begining of the line. (Issue #836)
|
||||||
|
* Hacknet node names is easier to handle for screen readers.
|
||||||
|
* Money spent on classes is now tracked independently of work money.
|
||||||
|
* running coding contract from the terminal will display its name.
|
||||||
`
|
`
|
||||||
}
|
}
|
@ -15,6 +15,11 @@ import { Factions } from "./Factions";
|
|||||||
import { HackingMission, setInMission } from "../Missions";
|
import { HackingMission, setInMission } from "../Missions";
|
||||||
import { Player } from "../Player";
|
import { Player } from "../Player";
|
||||||
import { Settings } from "../Settings/Settings";
|
import { Settings } from "../Settings/Settings";
|
||||||
|
import {
|
||||||
|
getHackingWorkRepGain,
|
||||||
|
getFactionSecurityWorkRepGain,
|
||||||
|
getFactionFieldWorkRepGain,
|
||||||
|
} from "../PersonObjects/formulas/reputation";
|
||||||
|
|
||||||
import { Page, routing } from "../ui/navigationTracking";
|
import { Page, routing } from "../ui/navigationTracking";
|
||||||
import { dialogBoxCreate } from "../../utils/DialogBox";
|
import { dialogBoxCreate } from "../../utils/DialogBox";
|
||||||
@ -235,15 +240,24 @@ export function getNextNeurofluxLevel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function processPassiveFactionRepGain(numCycles) {
|
export function processPassiveFactionRepGain(numCycles) {
|
||||||
var numTimesGain = (numCycles / 600) * Player.faction_rep_mult;
|
for (const name in Factions) {
|
||||||
for (var name in Factions) {
|
if (name === Player.currentWorkFactionName) continue;
|
||||||
if (Factions.hasOwnProperty(name)) {
|
if (!Factions.hasOwnProperty(name)) continue;
|
||||||
var faction = Factions[name];
|
const faction = Factions[name];
|
||||||
|
if (!faction.isMember) continue;
|
||||||
|
// 0 favor = 1%/s
|
||||||
|
// 50 favor = 6%/s
|
||||||
|
// 100 favor = 11%/s
|
||||||
|
const favorMult = Math.min(0.1, (faction.favor / 1000) + 0.01);
|
||||||
|
// Find the best of all possible favor gain, minimum 1 rep / 2 minute.
|
||||||
|
const hRep = getHackingWorkRepGain(Player, faction);
|
||||||
|
const sRep = getFactionSecurityWorkRepGain(Player, faction);
|
||||||
|
const fRep = getFactionFieldWorkRepGain(Player, faction);
|
||||||
|
const rate = Math.max(hRep * favorMult, sRep * favorMult, fRep * favorMult, 1/120);
|
||||||
|
|
||||||
//TODO Get hard value of 1 rep per "rep gain cycle"" for now..
|
faction.playerReputation += rate *
|
||||||
//maybe later make this based on
|
(numCycles) *
|
||||||
//a player's 'status' like how powerful they are and how much money they have
|
Player.faction_rep_mult *
|
||||||
if (faction.isMember) {faction.playerReputation += (numTimesGain * BitNodeMultipliers.FactionPassiveRepGain);}
|
BitNodeMultipliers.FactionPassiveRepGain;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -686,13 +686,29 @@ function NetscriptFunctions(workerScript) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const argsToString = function(args) {
|
||||||
|
let out = '';
|
||||||
|
for(let arg of args) {
|
||||||
|
if(typeof arg === 'object') {
|
||||||
|
out += JSON.stringify(arg);
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out += `${arg}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hacknet : {
|
hacknet : {
|
||||||
numNodes : function() {
|
numNodes : function() {
|
||||||
return Player.hacknetNodes.length;
|
return Player.hacknetNodes.length;
|
||||||
},
|
},
|
||||||
maxNumNodes : function() {
|
maxNumNodes : function() {
|
||||||
return MaxNumberHacknetServers;
|
if (hasHacknetServers()) {
|
||||||
|
return HacknetServerConstants.MaxServers;
|
||||||
|
}
|
||||||
|
return Infinity;
|
||||||
},
|
},
|
||||||
purchaseNode : function() {
|
purchaseNode : function() {
|
||||||
return purchaseHacknet();
|
return purchaseHacknet();
|
||||||
@ -944,18 +960,17 @@ function NetscriptFunctions(workerScript) {
|
|||||||
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);
|
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
print: function(args){
|
print: function(){
|
||||||
if (args === undefined) {
|
if (arguments.length === 0) {
|
||||||
throw makeRuntimeErrorMsg("print", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("print", "Takes at least 1 argument.");
|
||||||
}
|
}
|
||||||
workerScript.print(args.toString());
|
workerScript.print(argsToString(arguments));
|
||||||
},
|
},
|
||||||
tprint: function(args) {
|
tprint: function() {
|
||||||
if (args === undefined || args == null) {
|
if (arguments.length === 0) {
|
||||||
throw makeRuntimeErrorMsg("tprint", "Takes 1 argument.");
|
throw makeRuntimeErrorMsg("tprint", "Takes at least 1 argument.");
|
||||||
}
|
}
|
||||||
var x = args.toString();
|
post(`${workerScript.scriptRef.filename}: ${argsToString(arguments)}`);
|
||||||
post(`${workerScript.scriptRef.filename}: ${args.toString()}`);
|
|
||||||
},
|
},
|
||||||
clearLog: function() {
|
clearLog: function() {
|
||||||
workerScript.scriptRef.clearLog();
|
workerScript.scriptRef.clearLog();
|
||||||
|
@ -30,6 +30,11 @@ import { LocationName } from "../../Locations/data/LocationNames";
|
|||||||
import { Sleeve } from "../../PersonObjects/Sleeve/Sleeve";
|
import { Sleeve } from "../../PersonObjects/Sleeve/Sleeve";
|
||||||
import { calculateSkill as calculateSkillF } from "../formulas/skill";
|
import { calculateSkill as calculateSkillF } from "../formulas/skill";
|
||||||
import { calculateIntelligenceBonus } from "../formulas/intelligence";
|
import { calculateIntelligenceBonus } from "../formulas/intelligence";
|
||||||
|
import {
|
||||||
|
getHackingWorkRepGain,
|
||||||
|
getFactionSecurityWorkRepGain,
|
||||||
|
getFactionFieldWorkRepGain,
|
||||||
|
} from '../formulas/reputation';
|
||||||
import {
|
import {
|
||||||
AllServers,
|
AllServers,
|
||||||
AddToAllServers,
|
AddToAllServers,
|
||||||
@ -857,7 +862,7 @@ export function startFactionFieldWork(faction) {
|
|||||||
this.workDexExpGainRate = .1 * this.dexterity_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workDexExpGainRate = .1 * this.dexterity_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workAgiExpGainRate = .1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workAgiExpGainRate = .1 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workChaExpGainRate = .1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workChaExpGainRate = .1 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workRepGainRate = this.getFactionFieldWorkRepGain();
|
this.workRepGainRate = getFactionFieldWorkRepGain(this);
|
||||||
|
|
||||||
this.factionWorkType = CONSTANTS.FactionWorkField;
|
this.factionWorkType = CONSTANTS.FactionWorkField;
|
||||||
this.currentWorkFactionDescription = "carrying out field missions"
|
this.currentWorkFactionDescription = "carrying out field missions"
|
||||||
@ -874,7 +879,7 @@ export function startFactionSecurityWork(faction) {
|
|||||||
this.workDexExpGainRate = 0.15 * this.dexterity_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workDexExpGainRate = 0.15 * this.dexterity_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workAgiExpGainRate = 0.15 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workAgiExpGainRate = 0.15 * this.agility_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workChaExpGainRate = 0.00 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
this.workChaExpGainRate = 0.00 * this.charisma_exp_mult * BitNodeMultipliers.FactionWorkExpGain;
|
||||||
this.workRepGainRate = this.getFactionSecurityWorkRepGain();
|
this.workRepGainRate = getFactionSecurityWorkRepGain(this);
|
||||||
|
|
||||||
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
|
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
|
||||||
this.currentWorkFactionDescription = "performing security detail"
|
this.currentWorkFactionDescription = "performing security detail"
|
||||||
@ -883,29 +888,23 @@ export function startFactionSecurityWork(faction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function workForFaction(numCycles) {
|
export function workForFaction(numCycles) {
|
||||||
var faction = Factions[this.currentWorkFactionName];
|
const faction = Factions[this.currentWorkFactionName];
|
||||||
|
|
||||||
//Constantly update the rep gain rate
|
//Constantly update the rep gain rate
|
||||||
switch (this.factionWorkType) {
|
switch (this.factionWorkType) {
|
||||||
case CONSTANTS.FactionWorkHacking:
|
case CONSTANTS.FactionWorkHacking:
|
||||||
this.workRepGainRate = (this.hacking_skill + this.intelligence) / CONSTANTS.MaxSkillLevel * this.faction_rep_mult * this.getIntelligenceBonus(0.5);
|
this.workRepGainRate = getHackingWorkRepGain(this, faction);
|
||||||
break;
|
break;
|
||||||
case CONSTANTS.FactionWorkField:
|
case CONSTANTS.FactionWorkField:
|
||||||
this.workRepGainRate = this.getFactionFieldWorkRepGain();
|
this.workRepGainRate = getFactionFieldWorkRepGain(this, faction);
|
||||||
break;
|
break;
|
||||||
case CONSTANTS.FactionWorkSecurity:
|
case CONSTANTS.FactionWorkSecurity:
|
||||||
this.workRepGainRate = this.getFactionSecurityWorkRepGain();
|
this.workRepGainRate = getFactionSecurityWorkRepGain(this, faction);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update reputation gain rate to account for faction favor
|
|
||||||
var favorMult = 1 + (faction.favor / 100);
|
|
||||||
if (isNaN(favorMult)) {favorMult = 1;}
|
|
||||||
this.workRepGainRate *= favorMult;
|
|
||||||
this.workRepGainRate *= BitNodeMultipliers.FactionWorkRepGain;
|
|
||||||
|
|
||||||
//Cap the number of cycles being processed to whatever would put you at limit (20 hours)
|
//Cap the number of cycles being processed to whatever would put you at limit (20 hours)
|
||||||
var overMax = false;
|
var overMax = false;
|
||||||
if (this.timeWorked + (Engine._idleSpeed * numCycles) >= CONSTANTS.MillisecondsPer20Hours) {
|
if (this.timeWorked + (Engine._idleSpeed * numCycles) >= CONSTANTS.MillisecondsPer20Hours) {
|
||||||
@ -1116,25 +1115,25 @@ export function getWorkRepGain() {
|
|||||||
return jobPerformance * this.company_rep_mult * favorMult;
|
return jobPerformance * this.company_rep_mult * favorMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFactionSecurityWorkRepGain() {
|
// export function getFactionSecurityWorkRepGain() {
|
||||||
var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
// var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
||||||
this.strength / CONSTANTS.MaxSkillLevel +
|
// this.strength / CONSTANTS.MaxSkillLevel +
|
||||||
this.defense / CONSTANTS.MaxSkillLevel +
|
// this.defense / CONSTANTS.MaxSkillLevel +
|
||||||
this.dexterity / CONSTANTS.MaxSkillLevel +
|
// this.dexterity / CONSTANTS.MaxSkillLevel +
|
||||||
this.agility / CONSTANTS.MaxSkillLevel) / 4.5;
|
// this.agility / CONSTANTS.MaxSkillLevel) / 4.5;
|
||||||
return t * this.faction_rep_mult;
|
// return t * this.faction_rep_mult;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export function getFactionFieldWorkRepGain() {
|
// export function getFactionFieldWorkRepGain() {
|
||||||
var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
// var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
||||||
this.strength / CONSTANTS.MaxSkillLevel +
|
// this.strength / CONSTANTS.MaxSkillLevel +
|
||||||
this.defense / CONSTANTS.MaxSkillLevel +
|
// this.defense / CONSTANTS.MaxSkillLevel +
|
||||||
this.dexterity / CONSTANTS.MaxSkillLevel +
|
// this.dexterity / CONSTANTS.MaxSkillLevel +
|
||||||
this.agility / CONSTANTS.MaxSkillLevel +
|
// this.agility / CONSTANTS.MaxSkillLevel +
|
||||||
this.charisma / CONSTANTS.MaxSkillLevel +
|
// this.charisma / CONSTANTS.MaxSkillLevel +
|
||||||
this.intelligence / CONSTANTS.MaxSkillLevel) / 5.5;
|
// this.intelligence / CONSTANTS.MaxSkillLevel) / 5.5;
|
||||||
return t * this.faction_rep_mult;
|
// return t * this.faction_rep_mult;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Creating a Program */
|
/* Creating a Program */
|
||||||
export function startCreateProgramWork(programName, time, reqLevel) {
|
export function startCreateProgramWork(programName, time, reqLevel) {
|
||||||
|
36
src/PersonObjects/formulas/reputation.ts
Normal file
36
src/PersonObjects/formulas/reputation.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { IPlayer } from '../IPlayer';
|
||||||
|
import { Faction } from '../../Faction/Faction';
|
||||||
|
import { CONSTANTS } from '../../Constants';
|
||||||
|
import { BitNodeMultipliers } from '../../BitNode/BitNodeMultipliers';
|
||||||
|
|
||||||
|
function mult(f: Faction): number {
|
||||||
|
var favorMult = 1 + (f.favor / 100);
|
||||||
|
if (isNaN(favorMult)) {favorMult = 1;}
|
||||||
|
return favorMult * BitNodeMultipliers.FactionWorkRepGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getHackingWorkRepGain(p: IPlayer, f: Faction): number {
|
||||||
|
return (p.hacking_skill + p.intelligence) /
|
||||||
|
CONSTANTS.MaxSkillLevel * p.faction_rep_mult *
|
||||||
|
p.getIntelligenceBonus(0.25) * mult(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFactionSecurityWorkRepGain(p: IPlayer, f: Faction): number {
|
||||||
|
var t = 0.9 * (p.hacking_skill / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.strength / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.defense / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.dexterity / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.agility / CONSTANTS.MaxSkillLevel) / 4.5;
|
||||||
|
return t * p.faction_rep_mult * mult(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFactionFieldWorkRepGain(p: IPlayer, f: Faction): number {
|
||||||
|
var t = 0.9 * (p.hacking_skill / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.strength / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.defense / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.dexterity / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.agility / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.charisma / CONSTANTS.MaxSkillLevel +
|
||||||
|
p.intelligence / CONSTANTS.MaxSkillLevel) / 5.5;
|
||||||
|
return t * p.faction_rep_mult * mult(f);
|
||||||
|
}
|
472
src/Terminal.jsx
472
src/Terminal.jsx
@ -108,7 +108,7 @@ import React from "react";
|
|||||||
|
|
||||||
|
|
||||||
function postNetburnerText() {
|
function postNetburnerText() {
|
||||||
post("Bitburner v" + CONSTANTS.Version);
|
post("Bitburner v" + CONSTANTS.Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function that checks if an argument (which is a string) is a valid number
|
// Helper function that checks if an argument (which is a string) is a valid number
|
||||||
@ -123,16 +123,16 @@ function getTerminalInput() {
|
|||||||
|
|
||||||
// Defines key commands in terminal
|
// Defines key commands in terminal
|
||||||
$(document).keydown(function(event) {
|
$(document).keydown(function(event) {
|
||||||
// Terminal
|
// Terminal
|
||||||
if (routing.isOn(Page.Terminal)) {
|
if (routing.isOn(Page.Terminal)) {
|
||||||
var terminalInput = document.getElementById("terminal-input-text-box");
|
var terminalInput = document.getElementById("terminal-input-text-box");
|
||||||
if (terminalInput != null && !event.ctrlKey && !event.shiftKey && !Terminal.contractOpen) {terminalInput.focus();}
|
if (terminalInput != null && !event.ctrlKey && !event.shiftKey && !Terminal.contractOpen) {terminalInput.focus();}
|
||||||
|
|
||||||
if (event.keyCode === KEY.ENTER) {
|
if (event.keyCode === KEY.ENTER) {
|
||||||
event.preventDefault(); // Prevent newline from being entered in Script Editor
|
event.preventDefault(); // Prevent newline from being entered in Script Editor
|
||||||
const command = getTerminalInput();
|
const command = getTerminalInput();
|
||||||
const dir = Terminal.currDir;
|
const dir = Terminal.currDir;
|
||||||
post(
|
post(
|
||||||
"<span class='prompt'>[" +
|
"<span class='prompt'>[" +
|
||||||
(FconfSettings.ENABLE_TIMESTAMPS ? getTimestamp() + " " : "") +
|
(FconfSettings.ENABLE_TIMESTAMPS ? getTimestamp() + " " : "") +
|
||||||
Player.getCurrentServer().hostname +
|
Player.getCurrentServer().hostname +
|
||||||
@ -142,20 +142,20 @@ $(document).keydown(function(event) {
|
|||||||
if (command.length > 0) {
|
if (command.length > 0) {
|
||||||
Terminal.resetTerminalInput(); // Clear input first
|
Terminal.resetTerminalInput(); // Clear input first
|
||||||
Terminal.executeCommands(command);
|
Terminal.executeCommands(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode === KEY.C && event.ctrlKey) {
|
if (event.keyCode === KEY.C && event.ctrlKey) {
|
||||||
if (Engine._actionInProgress) {
|
if (Engine._actionInProgress) {
|
||||||
// Cancel action
|
// Cancel action
|
||||||
post("Cancelling...");
|
post("Cancelling...");
|
||||||
Engine._actionInProgress = false;
|
Engine._actionInProgress = false;
|
||||||
Terminal.finishAction(true);
|
Terminal.finishAction(true);
|
||||||
} else if (FconfSettings.ENABLE_BASH_HOTKEYS) {
|
} else if (FconfSettings.ENABLE_BASH_HOTKEYS) {
|
||||||
// Dont prevent default so it still copies
|
// Dont prevent default so it still copies
|
||||||
Terminal.resetTerminalInput(); // Clear Terminal
|
Terminal.resetTerminalInput(); // Clear Terminal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode === KEY.L && event.ctrlKey) {
|
if (event.keyCode === KEY.L && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -183,7 +183,7 @@ $(document).keydown(function(event) {
|
|||||||
}
|
}
|
||||||
var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex];
|
var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex];
|
||||||
terminalInput.value = prevCommand;
|
terminalInput.value = prevCommand;
|
||||||
setTimeoutRef(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0);
|
setTimeoutRef(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode === KEY.DOWNARROW ||
|
if (event.keyCode === KEY.DOWNARROW ||
|
||||||
@ -295,44 +295,44 @@ $(document).keydown(function(event) {
|
|||||||
// ^k clears line after cursor
|
// ^k clears line after cursor
|
||||||
// ^u clears line before cursor
|
// ^u clears line before cursor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Keep terminal in focus
|
// Keep terminal in focus
|
||||||
let terminalCtrlPressed = false, shiftKeyPressed = false;
|
let terminalCtrlPressed = false, shiftKeyPressed = false;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if (routing.isOn(Page.Terminal)) {
|
if (routing.isOn(Page.Terminal)) {
|
||||||
$('.terminal-input').focus();
|
$('.terminal-input').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keydown(function(e) {
|
$(document).keydown(function(e) {
|
||||||
if (routing.isOn(Page.Terminal)) {
|
if (routing.isOn(Page.Terminal)) {
|
||||||
if (e.which == KEY.CTRL) {
|
if (e.which == KEY.CTRL) {
|
||||||
terminalCtrlPressed = true;
|
terminalCtrlPressed = true;
|
||||||
} else if (e.shiftKey) {
|
} else if (e.shiftKey) {
|
||||||
shiftKeyPressed = true;
|
shiftKeyPressed = true;
|
||||||
} else if (terminalCtrlPressed || shiftKeyPressed || Terminal.contractOpen) {
|
} else if (terminalCtrlPressed || shiftKeyPressed || Terminal.contractOpen) {
|
||||||
// Don't focus
|
// Don't focus
|
||||||
} else {
|
} else {
|
||||||
var inputTextBox = document.getElementById("terminal-input-text-box");
|
var inputTextBox = document.getElementById("terminal-input-text-box");
|
||||||
if (inputTextBox != null) {inputTextBox.focus();}
|
if (inputTextBox != null) {inputTextBox.focus();}
|
||||||
|
|
||||||
terminalCtrlPressed = false;
|
terminalCtrlPressed = false;
|
||||||
shiftKeyPressed = false;
|
shiftKeyPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).keyup(function(e) {
|
$(document).keyup(function(e) {
|
||||||
if (routing.isOn(Page.Terminal)) {
|
if (routing.isOn(Page.Terminal)) {
|
||||||
if (e.which == KEY.CTRL) {
|
if (e.which == KEY.CTRL) {
|
||||||
terminalCtrlPressed = false;
|
terminalCtrlPressed = false;
|
||||||
}
|
}
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
shiftKeyPressed = false;
|
shiftKeyPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let Terminal = {
|
let Terminal = {
|
||||||
@ -361,14 +361,14 @@ let Terminal = {
|
|||||||
if (FconfSettings.WRAP_INPUT) {
|
if (FconfSettings.WRAP_INPUT) {
|
||||||
document.getElementById("terminal-input-td").innerHTML =
|
document.getElementById("terminal-input-td").innerHTML =
|
||||||
`<div id='terminal-input-header' class='prompt'>[${Player.getCurrentServer().hostname} ~${dir}]$ </div>` +
|
`<div id='terminal-input-header' class='prompt'>[${Player.getCurrentServer().hostname} ~${dir}]$ </div>` +
|
||||||
`<textarea type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" value=\"${input}\"/>`;
|
`<textarea type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" value=\"${input}\" autocomplete="off" />`;
|
||||||
|
|
||||||
// Auto re-size the line element as it wraps
|
// Auto re-size the line element as it wraps
|
||||||
autosize(document.getElementById("terminal-input-text-box"));
|
autosize(document.getElementById("terminal-input-text-box"));
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("terminal-input-td").innerHTML =
|
document.getElementById("terminal-input-td").innerHTML =
|
||||||
`<div id='terminal-input-header' class='prompt'>[${Player.getCurrentServer().hostname} ~${dir}]$ </div>` +
|
`<div id='terminal-input-header' class='prompt'>[${Player.getCurrentServer().hostname} ~${dir}]$ </div>` +
|
||||||
`<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" value=\"${input}\"/>`;
|
`<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" value=\"${input}\" autocomplete="off" />`;
|
||||||
}
|
}
|
||||||
const hdr = document.getElementById("terminal-input-header");
|
const hdr = document.getElementById("terminal-input-header");
|
||||||
hdr.style.display = "inline";
|
hdr.style.display = "inline";
|
||||||
@ -512,16 +512,16 @@ let Terminal = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Complete the hack/analyze command
|
// Complete the hack/analyze command
|
||||||
finishHack: function(cancelled = false) {
|
finishHack: function(cancelled = false) {
|
||||||
if (cancelled == false) {
|
if (cancelled == false) {
|
||||||
var server = Player.getCurrentServer();
|
var server = Player.getCurrentServer();
|
||||||
|
|
||||||
// Calculate whether hack was successful
|
// Calculate whether hack was successful
|
||||||
var hackChance = calculateHackingChance(server, Player);
|
var hackChance = calculateHackingChance(server, Player);
|
||||||
var rand = Math.random();
|
var rand = Math.random();
|
||||||
var expGainedOnSuccess = calculateHackingExpGain(server, Player);
|
var expGainedOnSuccess = calculateHackingExpGain(server, Player);
|
||||||
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
||||||
if (rand < hackChance) { // Success!
|
if (rand < hackChance) { // Success!
|
||||||
if (SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
if (SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
||||||
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip) {
|
SpecialServerIps[SpecialServerNames.WorldDaemon] == server.ip) {
|
||||||
if (Player.bitNodeN == null) {
|
if (Player.bitNodeN == null) {
|
||||||
@ -531,26 +531,26 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
server.manuallyHacked = true;
|
server.manuallyHacked = true;
|
||||||
var moneyGained = calculatePercentMoneyHacked(server, Player);
|
var moneyGained = calculatePercentMoneyHacked(server, Player);
|
||||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
|
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
|
||||||
|
|
||||||
if (moneyGained <= 0) {moneyGained = 0;} // Safety check
|
if (moneyGained <= 0) {moneyGained = 0;} // Safety check
|
||||||
|
|
||||||
server.moneyAvailable -= moneyGained;
|
server.moneyAvailable -= moneyGained;
|
||||||
Player.gainMoney(moneyGained);
|
Player.gainMoney(moneyGained);
|
||||||
Player.recordMoneySource(moneyGained, "hacking");
|
Player.recordMoneySource(moneyGained, "hacking");
|
||||||
Player.gainHackingExp(expGainedOnSuccess)
|
Player.gainHackingExp(expGainedOnSuccess)
|
||||||
Player.gainIntelligenceExp(expGainedOnSuccess / CONSTANTS.IntelligenceTerminalHackBaseExpGain);
|
Player.gainIntelligenceExp(expGainedOnSuccess / CONSTANTS.IntelligenceTerminalHackBaseExpGain);
|
||||||
|
|
||||||
server.fortify(CONSTANTS.ServerFortifyAmount);
|
server.fortify(CONSTANTS.ServerFortifyAmount);
|
||||||
|
|
||||||
postElement(<>Hack successful! Gained {Money(moneyGained)} and {numeralWrapper.formatExp(expGainedOnSuccess)} hacking exp</>);
|
postElement(<>Hack successful! Gained {Money(moneyGained)} and {numeralWrapper.formatExp(expGainedOnSuccess)} hacking exp</>);
|
||||||
} else { // Failure
|
} else { // Failure
|
||||||
// Player only gains 25% exp for failure? TODO Can change this later to balance
|
// Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||||
Player.gainHackingExp(expGainedOnFailure)
|
Player.gainHackingExp(expGainedOnFailure)
|
||||||
post(`Failed to hack ${server.hostname}. Gained ${numeralWrapper.formatExp(expGainedOnFailure)} hacking exp`);
|
post(`Failed to hack ${server.hostname}. Gained ${numeralWrapper.formatExp(expGainedOnFailure)} hacking exp`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
// Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
||||||
$("#hack-progress-bar").attr('id', "old-hack-progress-bar");
|
$("#hack-progress-bar").attr('id', "old-hack-progress-bar");
|
||||||
@ -559,55 +559,55 @@ let Terminal = {
|
|||||||
$('input[class=terminal-input]').prop('disabled', false);
|
$('input[class=terminal-input]').prop('disabled', false);
|
||||||
|
|
||||||
Terminal.hackFlag = false;
|
Terminal.hackFlag = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
finishAnalyze: function(cancelled = false) {
|
finishAnalyze: function(cancelled = false) {
|
||||||
if (cancelled == false) {
|
if (cancelled == false) {
|
||||||
let currServ = Player.getCurrentServer();
|
let currServ = Player.getCurrentServer();
|
||||||
const isHacknet = currServ instanceof HacknetServer;
|
const isHacknet = currServ instanceof HacknetServer;
|
||||||
post(currServ.hostname + ": ");
|
post(currServ.hostname + ": ");
|
||||||
post("Organization name: " + currServ.organizationName);
|
post("Organization name: " + currServ.organizationName);
|
||||||
var rootAccess = "";
|
var rootAccess = "";
|
||||||
if (currServ.hasAdminRights) {rootAccess = "YES";}
|
if (currServ.hasAdminRights) {rootAccess = "YES";}
|
||||||
else {rootAccess = "NO";}
|
else {rootAccess = "NO";}
|
||||||
post("Root Access: " + rootAccess);
|
post("Root Access: " + rootAccess);
|
||||||
if (!isHacknet) { post("Required hacking skill: " + currServ.requiredHackingSkill); }
|
if (!isHacknet) { post("Required hacking skill: " + currServ.requiredHackingSkill); }
|
||||||
post("Server security level: " + numeralWrapper.formatServerSecurity(currServ.hackDifficulty));
|
post("Server security level: " + numeralWrapper.formatServerSecurity(currServ.hackDifficulty));
|
||||||
post("Chance to hack: " + numeralWrapper.formatPercentage(calculateHackingChance(currServ, Player)));
|
post("Chance to hack: " + numeralWrapper.formatPercentage(calculateHackingChance(currServ, Player)));
|
||||||
post("Time to hack: " + convertTimeMsToTimeElapsedString(calculateHackingTime(currServ, Player)*1000));
|
post("Time to hack: " + convertTimeMsToTimeElapsedString(calculateHackingTime(currServ, Player)*1000));
|
||||||
postElement(<>Total money available on server: {Money(currServ.moneyAvailable)}</>);
|
postElement(<>Total money available on server: {Money(currServ.moneyAvailable)}</>);
|
||||||
if (!isHacknet) { post("Required number of open ports for NUKE: " + currServ.numOpenPortsRequired); }
|
if (!isHacknet) { post("Required number of open ports for NUKE: " + currServ.numOpenPortsRequired); }
|
||||||
|
|
||||||
if (currServ.sshPortOpen) {
|
if (currServ.sshPortOpen) {
|
||||||
post("SSH port: Open")
|
post("SSH port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SSH port: Closed")
|
post("SSH port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currServ.ftpPortOpen) {
|
if (currServ.ftpPortOpen) {
|
||||||
post("FTP port: Open")
|
post("FTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("FTP port: Closed")
|
post("FTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currServ.smtpPortOpen) {
|
if (currServ.smtpPortOpen) {
|
||||||
post("SMTP port: Open")
|
post("SMTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SMTP port: Closed")
|
post("SMTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currServ.httpPortOpen) {
|
if (currServ.httpPortOpen) {
|
||||||
post("HTTP port: Open")
|
post("HTTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("HTTP port: Closed")
|
post("HTTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currServ.sqlPortOpen) {
|
if (currServ.sqlPortOpen) {
|
||||||
post("SQL port: Open")
|
post("SQL port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SQL port: Closed")
|
post("SQL port: Closed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Terminal.analyzeFlag = false;
|
Terminal.analyzeFlag = false;
|
||||||
|
|
||||||
// Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
// Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
||||||
@ -728,7 +728,7 @@ let Terminal = {
|
|||||||
return args;
|
return args;
|
||||||
},
|
},
|
||||||
|
|
||||||
executeCommand : function(command) {
|
executeCommand : function(command) {
|
||||||
if (Terminal.hackFlag || Terminal.analyzeFlag) {
|
if (Terminal.hackFlag || Terminal.analyzeFlag) {
|
||||||
postError(`Cannot execute command (${command}) while an action is in progress`);
|
postError(`Cannot execute command (${command}) while an action is in progress`);
|
||||||
return;
|
return;
|
||||||
@ -743,8 +743,8 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only split the first space
|
// Only split the first space
|
||||||
var commandArray = Terminal.parseCommandArguments(command);
|
var commandArray = Terminal.parseCommandArguments(command);
|
||||||
if (commandArray.length == 0) { return; }
|
if (commandArray.length == 0) { return; }
|
||||||
|
|
||||||
/****************** Interactive Tutorial Terminal Commands ******************/
|
/****************** Interactive Tutorial Terminal Commands ******************/
|
||||||
if (ITutorial.isRunning) {
|
if (ITutorial.isRunning) {
|
||||||
@ -820,7 +820,7 @@ let Terminal = {
|
|||||||
Terminal.startHack();
|
Terminal.startHack();
|
||||||
iTutorialNextStep();
|
iTutorialNextStep();
|
||||||
} else {post("Bad command. Please follow the tutorial");}
|
} else {post("Bad command. Please follow the tutorial");}
|
||||||
break;
|
break;
|
||||||
case iTutorialSteps.TerminalCreateScript:
|
case iTutorialSteps.TerminalCreateScript:
|
||||||
if (commandArray.length == 2 &&
|
if (commandArray.length == 2 &&
|
||||||
commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") {
|
commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") {
|
||||||
@ -865,7 +865,7 @@ let Terminal = {
|
|||||||
|
|
||||||
/* Command parser */
|
/* Command parser */
|
||||||
var s = Player.getCurrentServer();
|
var s = Player.getCurrentServer();
|
||||||
switch (commandArray[0].toLowerCase()) {
|
switch (commandArray[0].toLowerCase()) {
|
||||||
case "alias":
|
case "alias":
|
||||||
if (commandArray.length === 1) {
|
if (commandArray.length === 1) {
|
||||||
printAliases();
|
printAliases();
|
||||||
@ -887,13 +887,13 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
postError('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
|
postError('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
|
||||||
break;
|
break;
|
||||||
case "analyze":
|
case "analyze":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
post("Incorrect usage of analyze command. Usage: analyze");
|
post("Incorrect usage of analyze command. Usage: analyze");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Terminal.startAnalyze();
|
Terminal.startAnalyze();
|
||||||
break;
|
break;
|
||||||
case "buy":
|
case "buy":
|
||||||
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
||||||
executeDarkwebTerminalCommand(commandArray);
|
executeDarkwebTerminalCommand(commandArray);
|
||||||
@ -908,10 +908,10 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const filename = Terminal.getFilepath(commandArray[1]);
|
const filename = Terminal.getFilepath(commandArray[1]);
|
||||||
if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) {
|
if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) {
|
||||||
postError("Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)");
|
postError("Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.endsWith(".msg") || filename.endsWith(".lit")) {
|
if (filename.endsWith(".msg") || filename.endsWith(".lit")) {
|
||||||
for (let i = 0; i < s.messages.length; ++i) {
|
for (let i = 0; i < s.messages.length; ++i) {
|
||||||
@ -996,17 +996,17 @@ let Terminal = {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "clear":
|
case "clear":
|
||||||
case "cls":
|
case "cls":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of clear/cls command. Usage: clear/cls");
|
postError("Incorrect usage of clear/cls command. Usage: clear/cls");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$("#terminal tr:not(:last)").remove();
|
$("#terminal tr:not(:last)").remove();
|
||||||
postNetburnerText();
|
postNetburnerText();
|
||||||
break;
|
break;
|
||||||
case "connect": {
|
case "connect": {
|
||||||
// Disconnect from current server in terminal and connect to new one
|
// Disconnect from current server in terminal and connect to new one
|
||||||
if (commandArray.length !== 2) {
|
if (commandArray.length !== 2) {
|
||||||
postError("Incorrect usage of connect command. Usage: connect [ip/hostname]");
|
postError("Incorrect usage of connect command. Usage: connect [ip/hostname]");
|
||||||
return;
|
return;
|
||||||
@ -1022,7 +1022,7 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
postError("Host not found");
|
postError("Host not found");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "download": {
|
case "download": {
|
||||||
try {
|
try {
|
||||||
@ -1102,35 +1102,35 @@ let Terminal = {
|
|||||||
post(result);
|
post(result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "free":
|
case "free":
|
||||||
Terminal.executeFreeCommand(commandArray);
|
Terminal.executeFreeCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
case "hack": {
|
case "hack": {
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of hack command. Usage: hack");
|
postError("Incorrect usage of hack command. Usage: hack");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Hack the current PC (usually for money)
|
// Hack the current PC (usually for money)
|
||||||
// You can't hack your home pc or servers you purchased
|
// You can't hack your home pc or servers you purchased
|
||||||
if (s.purchasedByPlayer) {
|
if (s.purchasedByPlayer) {
|
||||||
postError("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers");
|
postError("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers");
|
||||||
} else if (s.hasAdminRights == false ) {
|
} else if (s.hasAdminRights == false ) {
|
||||||
postError("You do not have admin rights for this machine! Cannot hack");
|
postError("You do not have admin rights for this machine! Cannot hack");
|
||||||
} else if (s.requiredHackingSkill > Player.hacking_skill) {
|
} else if (s.requiredHackingSkill > Player.hacking_skill) {
|
||||||
postError("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
|
postError("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
|
||||||
} else if (s instanceof HacknetServer) {
|
} else if (s instanceof HacknetServer) {
|
||||||
postError("Cannot hack this type of Server")
|
postError("Cannot hack this type of Server")
|
||||||
} else {
|
} else {
|
||||||
Terminal.startHack();
|
Terminal.startHack();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "help":
|
case "help":
|
||||||
if (commandArray.length !== 1 && commandArray.length !== 2) {
|
if (commandArray.length !== 1 && commandArray.length !== 2) {
|
||||||
postError("Incorrect usage of help command. Usage: help");
|
postError("Incorrect usage of help command. Usage: help");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (commandArray.length === 1) {
|
if (commandArray.length === 1) {
|
||||||
post(TerminalHelpText);
|
post(TerminalHelpText);
|
||||||
} else {
|
} else {
|
||||||
var cmd = commandArray[1];
|
var cmd = commandArray[1];
|
||||||
@ -1141,9 +1141,9 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
post(txt);
|
post(txt);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "home":
|
case "home":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of home command. Usage: home");
|
postError("Incorrect usage of home command. Usage: home");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1153,24 +1153,24 @@ let Terminal = {
|
|||||||
post("Connected to home");
|
post("Connected to home");
|
||||||
Terminal.currDir = "/";
|
Terminal.currDir = "/";
|
||||||
Terminal.resetTerminalInput();
|
Terminal.resetTerminalInput();
|
||||||
break;
|
break;
|
||||||
case "hostname":
|
case "hostname":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of hostname command. Usage: hostname");
|
postError("Incorrect usage of hostname command. Usage: hostname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
post(Player.getCurrentServer().hostname);
|
post(Player.getCurrentServer().hostname);
|
||||||
break;
|
break;
|
||||||
case "ifconfig":
|
case "ifconfig":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of ifconfig command. Usage: ifconfig");
|
postError("Incorrect usage of ifconfig command. Usage: ifconfig");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
post(Player.getCurrentServer().ip);
|
post(Player.getCurrentServer().ip);
|
||||||
break;
|
break;
|
||||||
case "kill": {
|
case "kill": {
|
||||||
Terminal.executeKillCommand(commandArray);
|
Terminal.executeKillCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "killall": {
|
case "killall": {
|
||||||
for (let i = s.runningScripts.length - 1; i >= 0; --i) {
|
for (let i = s.runningScripts.length - 1; i >= 0; --i) {
|
||||||
@ -1180,9 +1180,9 @@ let Terminal = {
|
|||||||
post("Killing all running scripts");
|
post("Killing all running scripts");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "ls": {
|
case "ls": {
|
||||||
Terminal.executeListCommand(commandArray);
|
Terminal.executeListCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "lscpu": {
|
case "lscpu": {
|
||||||
post(Player.getCurrentServer().cpuCores + " Core(s)");
|
post(Player.getCurrentServer().cpuCores + " Core(s)");
|
||||||
@ -1269,25 +1269,25 @@ let Terminal = {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "nano":
|
case "nano":
|
||||||
Terminal.executeNanoCommand(commandArray);
|
Terminal.executeNanoCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
case "ps":
|
case "ps":
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of ps command. Usage: ps");
|
postError("Incorrect usage of ps command. Usage: ps");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < s.runningScripts.length; i++) {
|
for (let i = 0; i < s.runningScripts.length; i++) {
|
||||||
let rsObj = s.runningScripts[i];
|
let rsObj = s.runningScripts[i];
|
||||||
let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`;
|
let res = `(PID - ${rsObj.pid}) ${rsObj.filename}`;
|
||||||
for (let j = 0; j < rsObj.args.length; ++j) {
|
for (let j = 0; j < rsObj.args.length; ++j) {
|
||||||
res += (" " + rsObj.args[j].toString());
|
res += (" " + rsObj.args[j].toString());
|
||||||
}
|
}
|
||||||
post(res);
|
post(res);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "rm": {
|
case "rm": {
|
||||||
if (commandArray.length !== 2) {
|
if (commandArray.length !== 2) {
|
||||||
postError("Incorrect number of arguments. Usage: rm [program/script]");
|
postError("Incorrect number of arguments. Usage: rm [program/script]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1299,14 +1299,14 @@ let Terminal = {
|
|||||||
if (!status.res) {
|
if (!status.res) {
|
||||||
postError(status.msg);
|
postError(status.msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "run":
|
case "run":
|
||||||
// Run a program or a script
|
// Run a program or a script
|
||||||
if (commandArray.length < 2) {
|
if (commandArray.length < 2) {
|
||||||
postError("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");
|
postError("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");
|
||||||
} else {
|
} else {
|
||||||
var executableName = commandArray[1];
|
var executableName = commandArray[1];
|
||||||
|
|
||||||
// Secret Music player!
|
// Secret Music player!
|
||||||
if (executableName === "musicplayer") {
|
if (executableName === "musicplayer") {
|
||||||
@ -1314,19 +1314,19 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if its a script or just a program/executable
|
// Check if its a script or just a program/executable
|
||||||
if (isScriptFilename(executableName)) {
|
if (isScriptFilename(executableName)) {
|
||||||
Terminal.runScript(commandArray);
|
Terminal.runScript(commandArray);
|
||||||
} else if (executableName.endsWith(".cct")) {
|
} else if (executableName.endsWith(".cct")) {
|
||||||
Terminal.runContract(executableName);
|
Terminal.runContract(executableName);
|
||||||
} else {
|
} else {
|
||||||
Terminal.runProgram(commandArray);
|
Terminal.runProgram(commandArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "scan":
|
case "scan":
|
||||||
Terminal.executeScanCommand(commandArray);
|
Terminal.executeScanCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
case "scan-analyze":
|
case "scan-analyze":
|
||||||
if (commandArray.length === 1) {
|
if (commandArray.length === 1) {
|
||||||
Terminal.executeScanAnalyzeCommand(1);
|
Terminal.executeScanAnalyzeCommand(1);
|
||||||
@ -1362,7 +1362,7 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* eslint-disable no-case-declarations */
|
/* eslint-disable no-case-declarations */
|
||||||
case "scp":
|
case "scp":
|
||||||
Terminal.executeScpCommand(commandArray);
|
Terminal.executeScpCommand(commandArray);
|
||||||
break;
|
break;
|
||||||
/* eslint-enable no-case-declarations */
|
/* eslint-enable no-case-declarations */
|
||||||
@ -1378,7 +1378,7 @@ let Terminal = {
|
|||||||
post("You do NOT have root access to this machine");
|
post("You do NOT have root access to this machine");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "tail": {
|
case "tail": {
|
||||||
try {
|
try {
|
||||||
if (commandArray.length < 2) {
|
if (commandArray.length < 2) {
|
||||||
postError("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]...");
|
postError("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]...");
|
||||||
@ -1407,7 +1407,7 @@ let Terminal = {
|
|||||||
Terminal.postThrownError(e);
|
Terminal.postThrownError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "theme": {
|
case "theme": {
|
||||||
let args = commandArray.slice(1);
|
let args = commandArray.slice(1);
|
||||||
@ -1455,11 +1455,11 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "top": {
|
case "top": {
|
||||||
if (commandArray.length !== 1) {
|
if (commandArray.length !== 1) {
|
||||||
postError("Incorrect usage of top command. Usage: top");
|
postError("Incorrect usage of top command. Usage: top");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
const scriptWidth = 40;
|
const scriptWidth = 40;
|
||||||
@ -1477,29 +1477,29 @@ let Terminal = {
|
|||||||
|
|
||||||
const headers = `${scriptTxt}${spacesAfterScriptTxt}${pidTxt}${spacesAfterPidTxt}${threadsTxt}${spacesAfterThreadsTxt}${ramTxt}`;
|
const headers = `${scriptTxt}${spacesAfterScriptTxt}${pidTxt}${spacesAfterPidTxt}${threadsTxt}${spacesAfterThreadsTxt}${ramTxt}`;
|
||||||
|
|
||||||
post(headers);
|
post(headers);
|
||||||
|
|
||||||
let currRunningScripts = s.runningScripts;
|
let currRunningScripts = s.runningScripts;
|
||||||
// Iterate through scripts on current server
|
// Iterate through scripts on current server
|
||||||
for (let i = 0; i < currRunningScripts.length; i++) {
|
for (let i = 0; i < currRunningScripts.length; i++) {
|
||||||
let script = currRunningScripts[i];
|
let script = currRunningScripts[i];
|
||||||
|
|
||||||
// Calculate name padding
|
// Calculate name padding
|
||||||
const numSpacesScript = Math.max(0, scriptWidth - script.filename.length);
|
const numSpacesScript = Math.max(0, scriptWidth - script.filename.length);
|
||||||
const spacesScript = " ".repeat(numSpacesScript);
|
const spacesScript = " ".repeat(numSpacesScript);
|
||||||
|
|
||||||
// Calculate PID padding
|
// Calculate PID padding
|
||||||
const numSpacesPid = Math.max(0, pidWidth - (script.pid + "").length);
|
const numSpacesPid = Math.max(0, pidWidth - (script.pid + "").length);
|
||||||
const spacesPid = " ".repeat(numSpacesPid);
|
const spacesPid = " ".repeat(numSpacesPid);
|
||||||
|
|
||||||
// Calculate thread padding
|
// Calculate thread padding
|
||||||
const numSpacesThread = Math.max(0, threadsWidth - (script.threads + "").length);
|
const numSpacesThread = Math.max(0, threadsWidth - (script.threads + "").length);
|
||||||
const spacesThread = " ".repeat(numSpacesThread);
|
const spacesThread = " ".repeat(numSpacesThread);
|
||||||
|
|
||||||
// Calculate and transform RAM usage
|
// Calculate and transform RAM usage
|
||||||
const ramUsage = numeralWrapper.formatRAM(getRamUsageFromRunningScript(script) * script.threads);
|
const ramUsage = numeralWrapper.formatRAM(getRamUsageFromRunningScript(script) * script.threads);
|
||||||
|
|
||||||
const entry = [
|
const entry = [
|
||||||
script.filename,
|
script.filename,
|
||||||
spacesScript,
|
spacesScript,
|
||||||
script.pid,
|
script.pid,
|
||||||
@ -1508,9 +1508,9 @@ let Terminal = {
|
|||||||
spacesThread,
|
spacesThread,
|
||||||
ramUsage
|
ramUsage
|
||||||
].join("");
|
].join("");
|
||||||
post(entry);
|
post(entry);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "unalias": {
|
case "unalias": {
|
||||||
if (commandArray.length !== 2) {
|
if (commandArray.length !== 2) {
|
||||||
@ -1555,10 +1555,10 @@ let Terminal = {
|
|||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
postError(`Command ${commandArray[0]} not found`);
|
postError(`Command ${commandArray[0]} not found`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
connectToServer: function(ip) {
|
connectToServer: function(ip) {
|
||||||
var serv = getServer(ip);
|
var serv = getServer(ip);
|
||||||
@ -1783,7 +1783,7 @@ let Terminal = {
|
|||||||
const script = Terminal.getScript(filename);
|
const script = Terminal.getScript(filename);
|
||||||
if (script == null) {
|
if (script == null) {
|
||||||
let code = ""
|
let code = ""
|
||||||
if(filename.endsWith(".ns")) {
|
if(filename.endsWith(".ns") || filename.endsWith(".js")) {
|
||||||
code = `export async function main(ns) {
|
code = `export async function main(ns) {
|
||||||
|
|
||||||
}`;
|
}`;
|
||||||
@ -2003,24 +2003,24 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// First called when the "run [program]" command is called. Checks to see if you
|
// First called when the "run [program]" command is called. Checks to see if you
|
||||||
// have the executable and, if you do, calls the executeProgram() function
|
// have the executable and, if you do, calls the executeProgram() function
|
||||||
runProgram: function(commandArray) {
|
runProgram: function(commandArray) {
|
||||||
if (commandArray.length < 2) { return; }
|
if (commandArray.length < 2) { return; }
|
||||||
|
|
||||||
// Check if you have the program on your computer. If you do, execute it, otherwise
|
// Check if you have the program on your computer. If you do, execute it, otherwise
|
||||||
// display an error message
|
// display an error message
|
||||||
const programName = commandArray[1];
|
const programName = commandArray[1];
|
||||||
|
|
||||||
if (Player.hasProgram(programName)) {
|
if (Player.hasProgram(programName)) {
|
||||||
Terminal.executeProgram(commandArray);
|
Terminal.executeProgram(commandArray);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)");
|
post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)");
|
||||||
},
|
},
|
||||||
|
|
||||||
// Contains the implementations of all possible programs
|
// Contains the implementations of all possible programs
|
||||||
executeProgram: function(commandArray) {
|
executeProgram: function(commandArray) {
|
||||||
if (commandArray.length < 2) { return; }
|
if (commandArray.length < 2) { return; }
|
||||||
|
|
||||||
var s = Player.getCurrentServer();
|
var s = Player.getCurrentServer();
|
||||||
@ -2173,7 +2173,7 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
programHandlers[programName](s, splitArgs);
|
programHandlers[programName](s, splitArgs);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a filename, returns that file's full path. This takes into account
|
* Given a filename, returns that file's full path. This takes into account
|
||||||
@ -2271,13 +2271,13 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
runScript: function(commandArray) {
|
runScript: function(commandArray) {
|
||||||
if (commandArray.length < 2) {
|
if (commandArray.length < 2) {
|
||||||
dialogBoxCreate(`Bug encountered with Terminal.runScript(). Command array has a length of less than 2: ${commandArray}`);
|
dialogBoxCreate(`Bug encountered with Terminal.runScript(). Command array has a length of less than 2: ${commandArray}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = Player.getCurrentServer();
|
const server = Player.getCurrentServer();
|
||||||
|
|
||||||
let numThreads = 1;
|
let numThreads = 1;
|
||||||
const args = [];
|
const args = [];
|
||||||
@ -2307,23 +2307,23 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the script exists and if it does run it
|
// Check if the script exists and if it does run it
|
||||||
for (var i = 0; i < server.scripts.length; i++) {
|
for (var i = 0; i < server.scripts.length; i++) {
|
||||||
if (server.scripts[i].filename === scriptName) {
|
if (server.scripts[i].filename === scriptName) {
|
||||||
// Check for admin rights and that there is enough RAM availble to run
|
// Check for admin rights and that there is enough RAM availble to run
|
||||||
var script = server.scripts[i];
|
var script = server.scripts[i];
|
||||||
var ramUsage = script.ramUsage * numThreads;
|
var ramUsage = script.ramUsage * numThreads;
|
||||||
var ramAvailable = server.maxRam - server.ramUsed;
|
var ramAvailable = server.maxRam - server.ramUsed;
|
||||||
|
|
||||||
if (server.hasAdminRights == false) {
|
if (server.hasAdminRights == false) {
|
||||||
post("Need root access to run script");
|
post("Need root access to run script");
|
||||||
return;
|
return;
|
||||||
} else if (ramUsage > ramAvailable){
|
} else if (ramUsage > ramAvailable){
|
||||||
post("This machine does not have enough RAM to run this script with " +
|
post("This machine does not have enough RAM to run this script with " +
|
||||||
numThreads + " threads. Script requires " + ramUsage + "GB of RAM");
|
numThreads + " threads. Script requires " + ramUsage + "GB of RAM");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// Able to run script
|
// Able to run script
|
||||||
var runningScriptObj = new RunningScript(script, args);
|
var runningScriptObj = new RunningScript(script, args);
|
||||||
runningScriptObj.threads = numThreads;
|
runningScriptObj.threads = numThreads;
|
||||||
|
|
||||||
@ -2333,12 +2333,12 @@ let Terminal = {
|
|||||||
postError(`Failed to start script`);
|
postError(`Failed to start script`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post("ERROR: No such script");
|
post("ERROR: No such script");
|
||||||
},
|
},
|
||||||
|
|
||||||
runContract: async function(contractName) {
|
runContract: async function(contractName) {
|
||||||
// There's already an opened contract
|
// There's already an opened contract
|
||||||
|
@ -777,7 +777,7 @@ const Engine = {
|
|||||||
createProgramNotifications: 10,
|
createProgramNotifications: 10,
|
||||||
augmentationsNotifications: 10,
|
augmentationsNotifications: 10,
|
||||||
checkFactionInvitations: 100,
|
checkFactionInvitations: 100,
|
||||||
passiveFactionGrowth: 600,
|
passiveFactionGrowth: 5,
|
||||||
messages: 150,
|
messages: 150,
|
||||||
mechanicProcess: 5, // Processes certain mechanics (Corporation, Bladeburner)
|
mechanicProcess: 5, // Processes certain mechanics (Corporation, Bladeburner)
|
||||||
contractGeneration: 3000, // Generate Coding Contracts
|
contractGeneration: 3000, // Generate Coding Contracts
|
||||||
@ -911,9 +911,9 @@ const Engine = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Engine.Counters.passiveFactionGrowth <= 0) {
|
if (Engine.Counters.passiveFactionGrowth <= 0) {
|
||||||
var adjustedCycles = Math.floor((600 - Engine.Counters.passiveFactionGrowth));
|
var adjustedCycles = Math.floor((5 - Engine.Counters.passiveFactionGrowth));
|
||||||
processPassiveFactionRepGain(adjustedCycles);
|
processPassiveFactionRepGain(adjustedCycles);
|
||||||
Engine.Counters.passiveFactionGrowth = 600;
|
Engine.Counters.passiveFactionGrowth = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Engine.Counters.messages <= 0) {
|
if (Engine.Counters.messages <= 0) {
|
||||||
|
@ -179,7 +179,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
|
|||||||
<table id="terminal">
|
<table id="terminal">
|
||||||
<tr id="terminal-input">
|
<tr id="terminal-input">
|
||||||
<td id="terminal-input-td" tabindex="2">$
|
<td id="terminal-input-td" tabindex="2">$
|
||||||
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;" />
|
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;" autocomplete="off" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user