mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-04 14:47:53 +02: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:
+16
-7
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
import * as React from "react";
|
||||
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { StdButton } from "../ui/React/StdButton";
|
||||
import { BadRNG } from "./RNG";
|
||||
import { Game } from "./Game";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { StdButton } from "../ui/React/StdButton";
|
||||
import { BadRNG } from "./RNG";
|
||||
import { Game } from "./Game";
|
||||
import { trusted } from "./utils";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
@@ -18,8 +19,10 @@ type IState = {
|
||||
investment: number;
|
||||
result: any;
|
||||
status: string;
|
||||
playLock: boolean;
|
||||
}
|
||||
|
||||
const minPlay = 0;
|
||||
const maxPlay = 10e3;
|
||||
|
||||
export class CoinFlip extends Game<IProps, IState> {
|
||||
@@ -31,6 +34,7 @@ export class CoinFlip extends Game<IProps, IState> {
|
||||
investment: 1000,
|
||||
result: <span> </span>,
|
||||
status: '',
|
||||
playLock: false,
|
||||
};
|
||||
|
||||
this.play = this.play.bind(this);
|
||||
@@ -40,11 +44,14 @@ export class CoinFlip extends Game<IProps, IState> {
|
||||
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
||||
let investment: number = parseInt(e.currentTarget.value);
|
||||
if (isNaN(investment)) {
|
||||
investment = 1000;
|
||||
investment = minPlay;
|
||||
}
|
||||
if (investment > maxPlay) {
|
||||
investment = maxPlay;
|
||||
}
|
||||
if (investment < minPlay) {
|
||||
investment = minPlay;
|
||||
}
|
||||
this.setState({investment: investment});
|
||||
}
|
||||
|
||||
@@ -61,7 +68,9 @@ export class CoinFlip extends Game<IProps, IState> {
|
||||
this.setState({
|
||||
result: <span className={correct ? "text" : "failure"}>{letter}</span>,
|
||||
status: correct ? " win!" : "lose!",
|
||||
playLock: true,
|
||||
});
|
||||
setTimeout(()=>this.setState({playLock: false}), 250);
|
||||
if (correct) {
|
||||
this.win(this.props.p, this.state.investment);
|
||||
} else {
|
||||
@@ -81,8 +90,8 @@ export class CoinFlip extends Game<IProps, IState> {
|
||||
+———————+<br />
|
||||
</pre>
|
||||
<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={() => this.play('T')} text={"Tail!"} />
|
||||
<StdButton onClick={trusted(() => this.play('H'))} text={"Head!"} disabled={this.state.playLock} />
|
||||
<StdButton onClick={trusted(() => this.play('T'))} text={"Tail!"} disabled={this.state.playLock} />
|
||||
<h1>{this.state.status}</h1>
|
||||
</>
|
||||
}
|
||||
|
||||
+59
-54
@@ -1,10 +1,11 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { StdButton } from "../ui/React/StdButton";
|
||||
import { Money } from "../ui/React/Money";
|
||||
import { Game } from "./Game";
|
||||
import { WHRNG } from "./RNG";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { StdButton } from "../ui/React/StdButton";
|
||||
import { Money } from "../ui/React/Money";
|
||||
import { Game } from "./Game";
|
||||
import { WHRNG } from "./RNG";
|
||||
import { trusted } from "./utils";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
@@ -19,7 +20,8 @@ type IState = {
|
||||
strategy: Strategy;
|
||||
}
|
||||
|
||||
const maxPlay = 1e6;
|
||||
const minPlay = 0;
|
||||
const maxPlay = 1e7;
|
||||
|
||||
function isRed(n: number): boolean {
|
||||
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>) {
|
||||
let investment: number = parseInt(e.currentTarget.value);
|
||||
if (isNaN(investment)) {
|
||||
investment = 1000;
|
||||
investment = minPlay;
|
||||
}
|
||||
if (investment > maxPlay) {
|
||||
investment = maxPlay
|
||||
investment = maxPlay;
|
||||
}
|
||||
if (investment < minPlay) {
|
||||
investment = minPlay;
|
||||
}
|
||||
this.setState({investment: investment});
|
||||
}
|
||||
@@ -226,62 +231,62 @@ export class Roulette extends Game<IProps, IState> {
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><StdButton text={"3"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(3))} /></td>
|
||||
<td><StdButton text={"6"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(6))} /></td>
|
||||
<td><StdButton text={"9"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(9))} /></td>
|
||||
<td><StdButton text={"12"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(12))} /></td>
|
||||
<td><StdButton text={"15"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(15))} /></td>
|
||||
<td><StdButton text={"18"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(18))} /></td>
|
||||
<td><StdButton text={"21"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(21))} /></td>
|
||||
<td><StdButton text={"24"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(24))} /></td>
|
||||
<td><StdButton text={"27"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(27))} /></td>
|
||||
<td><StdButton text={"30"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(30))} /></td>
|
||||
<td><StdButton text={"33"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(33))} /></td>
|
||||
<td><StdButton text={"36"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(36))} /></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={trusted(()=>this.play(Single(6)))} /></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={trusted(()=>this.play(Single(12)))} /></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={trusted(()=>this.play(Single(18)))} /></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={trusted(()=>this.play(Single(24)))} /></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={trusted(()=>this.play(Single(30)))} /></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={trusted(()=>this.play(Single(36)))} /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><StdButton text={"2"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(2))} /></td>
|
||||
<td><StdButton text={"5"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(5))} /></td>
|
||||
<td><StdButton text={"8"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(8))} /></td>
|
||||
<td><StdButton text={"11"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(11))} /></td>
|
||||
<td><StdButton text={"14"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(14))} /></td>
|
||||
<td><StdButton text={"17"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(17))} /></td>
|
||||
<td><StdButton text={"20"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(20))} /></td>
|
||||
<td><StdButton text={"23"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(23))} /></td>
|
||||
<td><StdButton text={"26"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(26))} /></td>
|
||||
<td><StdButton text={"29"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(29))} /></td>
|
||||
<td><StdButton text={"32"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(32))} /></td>
|
||||
<td><StdButton text={"35"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(35))} /></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={trusted(()=>this.play(Single(5)))} /></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={trusted(()=>this.play(Single(11)))} /></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={trusted(()=>this.play(Single(17)))} /></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={trusted(()=>this.play(Single(23)))} /></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={trusted(()=>this.play(Single(29)))} /></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={trusted(()=>this.play(Single(35)))} /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><StdButton text={"1"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(1))} /></td>
|
||||
<td><StdButton text={"4"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(4))} /></td>
|
||||
<td><StdButton text={"7"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(7))} /></td>
|
||||
<td><StdButton text={"10"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(10))} /></td>
|
||||
<td><StdButton text={"13"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(13))} /></td>
|
||||
<td><StdButton text={"16"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(16))} /></td>
|
||||
<td><StdButton text={"19"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(19))} /></td>
|
||||
<td><StdButton text={"22"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(22))} /></td>
|
||||
<td><StdButton text={"25"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(25))} /></td>
|
||||
<td><StdButton text={"28"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(28))} /></td>
|
||||
<td><StdButton text={"31"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(31))} /></td>
|
||||
<td><StdButton text={"34"} disabled={!this.state.canPlay} onClick={()=>this.play(Single(34))} /></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={trusted(()=>this.play(Single(4)))} /></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={trusted(()=>this.play(Single(10)))} /></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={trusted(()=>this.play(Single(16)))} /></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={trusted(()=>this.play(Single(22)))} /></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={trusted(()=>this.play(Single(28)))} /></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={trusted(()=>this.play(Single(34)))} /></td>
|
||||
</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={"13 to 24"} disabled={!this.state.canPlay} onClick={()=>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={"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={trusted(()=>this.play(strategies.Third2))} /></td>
|
||||
<td colSpan={4}><StdButton text={"25 to 36"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Third3))} /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colSpan={2}><StdButton text={"Red"} disabled={!this.state.canPlay} onClick={()=>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={"Odd"} disabled={!this.state.canPlay} onClick={()=>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={"High"} disabled={!this.state.canPlay} onClick={()=>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={"Red"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Red))} /></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={trusted(()=>this.play(strategies.Odd))} /></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={trusted(()=>this.play(strategies.High))} /></td>
|
||||
<td colSpan={2}><StdButton text={"Low"} disabled={!this.state.canPlay} onClick={trusted(()=>this.play(strategies.Low))} /></td>
|
||||
</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>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -4,7 +4,8 @@ import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { StdButton } from "../ui/React/StdButton";
|
||||
import { Money } from "../ui/React/Money";
|
||||
import { WHRNG } from "./RNG";
|
||||
import { Game } from "./Game";
|
||||
import { Game } from "./Game";
|
||||
import { trusted } from "./utils";
|
||||
|
||||
type IProps = {
|
||||
p: IPlayer;
|
||||
@@ -57,6 +58,7 @@ const payLines = [
|
||||
[[1, 0], [2, 1], [2, 2], [2, 3], [1, 4]],
|
||||
];
|
||||
|
||||
const minPlay = 0;
|
||||
const maxPlay = 1e6;
|
||||
|
||||
export class SlotMachine extends Game<IProps, IState> {
|
||||
@@ -184,11 +186,14 @@ export class SlotMachine extends Game<IProps, IState> {
|
||||
updateInvestment(e: React.FormEvent<HTMLInputElement>) {
|
||||
let investment: number = parseInt(e.currentTarget.value);
|
||||
if (isNaN(investment)) {
|
||||
investment = 1000;
|
||||
investment = minPlay;
|
||||
}
|
||||
if (investment > maxPlay) {
|
||||
investment = maxPlay;
|
||||
}
|
||||
if (investment < minPlay) {
|
||||
investment = minPlay;
|
||||
}
|
||||
this.setState({investment: investment});
|
||||
}
|
||||
|
||||
@@ -205,7 +210,7 @@ export class SlotMachine extends Game<IProps, IState> {
|
||||
+———————————————————————+<br />
|
||||
</pre>
|
||||
<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>
|
||||
<h2>Pay lines</h2>
|
||||
<pre>
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user