mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
few fixes
This commit is contained in:
parent
6c24ed69a2
commit
1cecfa7108
@ -151,7 +151,7 @@ You may have noticed that every new ns2 file will contains the following comment
|
||||
* @param {NS} ns
|
||||
**/
|
||||
|
||||
This command is used to help the text editor autocomplete functions in the Netscript API. You can enabling it by pressing ctrl+space after `ns.`
|
||||
This comment is used to help the text editor autocomplete functions in the Netscript API. You can enabling it by pressing ctrl+space after `ns.`
|
||||
|
||||
.. image:: autocomplete.png
|
||||
|
||||
|
@ -34,7 +34,7 @@ Let's assume Port 1 starts out empty (no data inside). We'll represent the port
|
||||
Now assume we ran the following simple script::
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
write(1, i); //Writes the value of i to port 1
|
||||
writePort(1, i); //Writes the value of i to port 1
|
||||
}
|
||||
|
||||
After this script executes, our script will contain every number from 0 through 9, as so::
|
||||
@ -44,7 +44,7 @@ After this script executes, our script will contain every number from 0 through
|
||||
Then, assume we run the following script::
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
print(read(1)); //Reads a value from port 1 and then prints it
|
||||
print(readPort(1)); //Reads a value from port 1 and then prints it
|
||||
}
|
||||
|
||||
This script above will read the first three values from port 1 and then print them to the script's log. The log will end up looking like::
|
||||
@ -69,7 +69,7 @@ The :js:func:`getPortHandle` Netscript function can be used to get a handle to a
|
||||
This handle allows you to access several new port-related functions and the
|
||||
port's underlying data structure, which is just a JavaScript array. The functions are:
|
||||
|
||||
.. js:method:: NetscriptPort.write(data)
|
||||
.. js:method:: NetscriptPort.writePort(data)
|
||||
|
||||
:param data: Data to write to the port
|
||||
:returns: If the port is full, the item that is removed from the port is returned.
|
||||
@ -77,7 +77,7 @@ port's underlying data structure, which is just a JavaScript array. The function
|
||||
|
||||
Writes `data` to the port. Works the same as the Netscript function `write`.
|
||||
|
||||
.. js:method:: NetscriptPort.tryWrite(data)
|
||||
.. js:method:: NetscriptPort.tryWritePort(data)
|
||||
|
||||
:param data: Data to try to write to the port
|
||||
:returns: True if the data is successfully written to the port, and false otherwise.
|
||||
@ -85,7 +85,7 @@ port's underlying data structure, which is just a JavaScript array. The function
|
||||
Attempts to write `data` to the Netscript port. If the port is full, the data will
|
||||
not be written. Otherwise, the data will be written normally.
|
||||
|
||||
.. js::method:: NetscriptPort.read()
|
||||
.. js::method:: NetscriptPort.readPort()
|
||||
|
||||
:returns: The data read from the port. If the port is empty, "NULL PORT DATA" is returned
|
||||
|
||||
|
@ -2,7 +2,7 @@ import * as React from "react";
|
||||
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { Money } from "../ui/React/Money";
|
||||
import { Game } from "./Game";
|
||||
import { Game, reachedLimit } from "./Game";
|
||||
import { Deck } from "./CardDeck/Deck";
|
||||
import { Hand } from "./CardDeck/Hand";
|
||||
import { InputAdornment } from "@mui/material";
|
||||
@ -70,7 +70,7 @@ export class Blackjack extends Game<Props, State> {
|
||||
};
|
||||
|
||||
startGame = (): void => {
|
||||
if (!this.canStartGame()) {
|
||||
if (!this.canStartGame() || reachedLimit(this.props.p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,11 +217,18 @@ export class Blackjack extends Game<Props, State> {
|
||||
};
|
||||
|
||||
finishGame = (result: Result): void => {
|
||||
const gains = result === Result.DealerWon ? 0 : // We took away the bet at the start, don't need to take more
|
||||
result === Result.Tie ? this.state.bet : // We took away the bet at the start, give it back
|
||||
result === Result.PlayerWon ? 2 * this.state.bet : // Give back their bet plus their winnings
|
||||
result === Result.PlayerWonByBlackjack ? 2.5 * this.state.bet : // Blackjack pays out 1.5x bet!
|
||||
(() => { throw new Error(`Unexpected result: ${result}`); })(); // This can't happen, right?
|
||||
const gains =
|
||||
result === Result.DealerWon
|
||||
? 0 // We took away the bet at the start, don't need to take more
|
||||
: result === Result.Tie
|
||||
? this.state.bet // We took away the bet at the start, give it back
|
||||
: result === Result.PlayerWon
|
||||
? 2 * this.state.bet // Give back their bet plus their winnings
|
||||
: result === Result.PlayerWonByBlackjack
|
||||
? 2.5 * this.state.bet // Blackjack pays out 1.5x bet!
|
||||
: (() => {
|
||||
throw new Error(`Unexpected result: ${result}`);
|
||||
})(); // This can't happen, right?
|
||||
this.win(this.props.p, gains);
|
||||
this.setState({
|
||||
gameInProgress: false,
|
||||
@ -345,7 +352,7 @@ export class Blackjack extends Game<Props, State> {
|
||||
)}
|
||||
|
||||
{/* Main game part. Displays both if the game is in progress OR if there's a result so you can see
|
||||
* the cards that led to that result. */}
|
||||
* the cards that led to that result. */}
|
||||
{(gameInProgress || result !== Result.Pending) && (
|
||||
<>
|
||||
<Box display="flex">
|
||||
@ -355,10 +362,12 @@ export class Blackjack extends Game<Props, State> {
|
||||
<ReactCard card={card} key={i} />
|
||||
))}
|
||||
|
||||
<Typography>Count: {
|
||||
playerHandValues.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||
.reduce((prev, curr) => [prev, ' or ', curr])
|
||||
}</Typography>
|
||||
<Typography>
|
||||
Count:{" "}
|
||||
{playerHandValues
|
||||
.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||
.reduce((prev, curr) => [prev, " or ", curr])}
|
||||
</Typography>
|
||||
</Paper>
|
||||
</Box>
|
||||
|
||||
@ -374,10 +383,12 @@ export class Blackjack extends Game<Props, State> {
|
||||
|
||||
{!gameInProgress && (
|
||||
<>
|
||||
<Typography>Count: {
|
||||
dealerHandValues.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||
.reduce((prev, curr) => [prev, ' or ', curr])
|
||||
}</Typography>
|
||||
<Typography>
|
||||
Count:{" "}
|
||||
{dealerHandValues
|
||||
.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||
.reduce((prev, curr) => [prev, " or ", curr])}
|
||||
</Typography>
|
||||
</>
|
||||
)}
|
||||
</Paper>
|
||||
|
@ -47,9 +47,7 @@ export async function main(ns) {
|
||||
router.toScriptEditor(filepath, txt.text);
|
||||
}
|
||||
} else {
|
||||
terminal.error(
|
||||
"Invalid file. Only scripts (.script, .ns, .js), text files (.txt), or .fconf can be edited with nano",
|
||||
);
|
||||
terminal.error("Invalid file. Only scripts (.script, .ns, .js), or text files (.txt) can be edited with nano");
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -112,7 +112,6 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
|
||||
<TextField value={"Text field"} />
|
||||
</Paper>
|
||||
<br />
|
||||
<Typography>Warning: Editing the theme is very slow.</Typography>
|
||||
<ColorEditor
|
||||
name="primarylight"
|
||||
onColorChange={onColorChange}
|
||||
|
Loading…
Reference in New Issue
Block a user