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
|
* @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
|
.. 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::
|
Now assume we ran the following simple script::
|
||||||
|
|
||||||
for (i = 0; i < 10; ++i) {
|
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::
|
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::
|
Then, assume we run the following script::
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
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::
|
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
|
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:
|
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
|
:param data: Data to write to the port
|
||||||
:returns: If the port is full, the item that is removed from the port is returned.
|
: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`.
|
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
|
:param data: Data to try to write to the port
|
||||||
:returns: True if the data is successfully written to the port, and false otherwise.
|
: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
|
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.
|
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
|
: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 { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { Money } from "../ui/React/Money";
|
import { Money } from "../ui/React/Money";
|
||||||
import { Game } from "./Game";
|
import { Game, reachedLimit } from "./Game";
|
||||||
import { Deck } from "./CardDeck/Deck";
|
import { Deck } from "./CardDeck/Deck";
|
||||||
import { Hand } from "./CardDeck/Hand";
|
import { Hand } from "./CardDeck/Hand";
|
||||||
import { InputAdornment } from "@mui/material";
|
import { InputAdornment } from "@mui/material";
|
||||||
@ -70,7 +70,7 @@ export class Blackjack extends Game<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
startGame = (): void => {
|
startGame = (): void => {
|
||||||
if (!this.canStartGame()) {
|
if (!this.canStartGame() || reachedLimit(this.props.p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,11 +217,18 @@ export class Blackjack extends Game<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
finishGame = (result: Result): void => {
|
finishGame = (result: Result): void => {
|
||||||
const gains = result === Result.DealerWon ? 0 : // We took away the bet at the start, don't need to take more
|
const gains =
|
||||||
result === Result.Tie ? this.state.bet : // We took away the bet at the start, give it back
|
result === Result.DealerWon
|
||||||
result === Result.PlayerWon ? 2 * this.state.bet : // Give back their bet plus their winnings
|
? 0 // We took away the bet at the start, don't need to take more
|
||||||
result === Result.PlayerWonByBlackjack ? 2.5 * this.state.bet : // Blackjack pays out 1.5x bet!
|
: result === Result.Tie
|
||||||
(() => { throw new Error(`Unexpected result: ${result}`); })(); // This can't happen, right?
|
? 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.win(this.props.p, gains);
|
||||||
this.setState({
|
this.setState({
|
||||||
gameInProgress: false,
|
gameInProgress: false,
|
||||||
@ -355,10 +362,12 @@ export class Blackjack extends Game<Props, State> {
|
|||||||
<ReactCard card={card} key={i} />
|
<ReactCard card={card} key={i} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
<Typography>Count: {
|
<Typography>
|
||||||
playerHandValues.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
Count:{" "}
|
||||||
.reduce((prev, curr) => [prev, ' or ', curr])
|
{playerHandValues
|
||||||
}</Typography>
|
.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||||
|
.reduce((prev, curr) => [prev, " or ", curr])}
|
||||||
|
</Typography>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
@ -374,10 +383,12 @@ export class Blackjack extends Game<Props, State> {
|
|||||||
|
|
||||||
{!gameInProgress && (
|
{!gameInProgress && (
|
||||||
<>
|
<>
|
||||||
<Typography>Count: {
|
<Typography>
|
||||||
dealerHandValues.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
Count:{" "}
|
||||||
.reduce((prev, curr) => [prev, ' or ', curr])
|
{dealerHandValues
|
||||||
}</Typography>
|
.map<React.ReactNode>((value, i) => <span key={i}>{value}</span>)
|
||||||
|
.reduce((prev, curr) => [prev, " or ", curr])}
|
||||||
|
</Typography>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Paper>
|
</Paper>
|
||||||
|
@ -47,9 +47,7 @@ export async function main(ns) {
|
|||||||
router.toScriptEditor(filepath, txt.text);
|
router.toScriptEditor(filepath, txt.text);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
terminal.error(
|
terminal.error("Invalid file. Only scripts (.script, .ns, .js), or text files (.txt) can be edited with nano");
|
||||||
"Invalid file. Only scripts (.script, .ns, .js), text files (.txt), or .fconf can be edited with nano",
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -112,7 +112,6 @@ export function ThemeEditorModal(props: IProps): React.ReactElement {
|
|||||||
<TextField value={"Text field"} />
|
<TextField value={"Text field"} />
|
||||||
</Paper>
|
</Paper>
|
||||||
<br />
|
<br />
|
||||||
<Typography>Warning: Editing the theme is very slow.</Typography>
|
|
||||||
<ColorEditor
|
<ColorEditor
|
||||||
name="primarylight"
|
name="primarylight"
|
||||||
onColorChange={onColorChange}
|
onColorChange={onColorChange}
|
||||||
|
Loading…
Reference in New Issue
Block a user