mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
Merge branch 'danielyxie:dev' into dev
This commit is contained in:
commit
010d3bfaef
@ -106,6 +106,21 @@ Fork and clone the repo
|
||||
# Makes sure you always start from `danielyxie/dev` to avoid merge conflicts.
|
||||
```
|
||||
|
||||
### Running locally.
|
||||
|
||||
Install
|
||||
|
||||
- `npm` (maybe via `nvm`)
|
||||
- Github Desktop (windows only)
|
||||
- Visual Studio code (optional)
|
||||
|
||||
Inside the root of the repo run
|
||||
`npm install` to install all the dependencies
|
||||
`npm run start:dev` to launch the game in dev mode.
|
||||
|
||||
After that you can open any browser and naviguate to `localhost:8000` and play the game.
|
||||
Saving a file will reload the game automatically.
|
||||
|
||||
#### Submitting a Pull Request
|
||||
|
||||
When submitting a pull request with your code contributions, please abide by
|
||||
|
24
dist/vendor.bundle.js
vendored
24
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
35
doc/source/netscript/advancedfunctions/inject_html.rst
Normal file
35
doc/source/netscript/advancedfunctions/inject_html.rst
Normal file
@ -0,0 +1,35 @@
|
||||
Injecting HTML in the game
|
||||
==========================
|
||||
|
||||
Bitburner uses React and Material-UI to render everything. Modifying the UI is possible but
|
||||
not officially supported.
|
||||
|
||||
To automatically enter commands in the terminal (only works if looking at the terminal):
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
// Acquire a reference to the terminal text field
|
||||
const terminalInput = document.getElementById("terminal-input");
|
||||
|
||||
// Set the value to the command you want to run.
|
||||
terminalInput.value="home;connect n00dles;home;connect n00dles;home;";
|
||||
|
||||
// Get a reference to the React event handler.
|
||||
const handler = Object.keys(terminalInput)[1];
|
||||
|
||||
// Perform an onChange event to set some internal values.
|
||||
terminalInput[handler].onChange({target:terminalInput});
|
||||
|
||||
// Simulate an enter press
|
||||
terminalInput[handler].onKeyDown({keyCode:13,preventDefault:()=>null});
|
||||
|
||||
|
||||
To add lines to the terminal (only works if looking at the terminal):
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
// Acquire a reference to the terminal list of lines.
|
||||
const list = document.getElementById("generic-react-container").querySelector("ul");
|
||||
|
||||
// Inject some HTML.
|
||||
list.insertAdjacentHTML('beforeend',`<li><p color=lime>whatever custom html</p></li>`)
|
@ -11,3 +11,5 @@ they contain spoilers for the game.
|
||||
getBitNodeMultipliers() <advancedfunctions/getBitNodeMultipliers>
|
||||
getServer() <advancedfunctions/getServer>
|
||||
autocomplete() <advancedfunctions/autocomplete>
|
||||
atExit() <advancedfunctions/atExit>
|
||||
Injecting HTML <advancedfunctions/inject_html.rst>
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -153,7 +153,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
|
||||
<Typography>This industry uses the following equation for it's production: </Typography>
|
||||
<br />
|
||||
<Typography>
|
||||
<IndustryProductEquation division={division} />
|
||||
<IndustryProductEquation key={division.name} division={division} />
|
||||
</Typography>
|
||||
<br />
|
||||
<Typography>
|
||||
|
@ -143,8 +143,8 @@ export class Sleeve extends Person {
|
||||
* Commit crimes
|
||||
*/
|
||||
commitCrime(p: IPlayer, crimeKey: string): boolean {
|
||||
const crime: Crime | null = Crimes[crimeKey];
|
||||
if (!(crime instanceof Crime)) {
|
||||
const crime: Crime | null = Crimes[crimeKey] || Object.values(Crimes).find((crime) => crime.name === crimeKey);
|
||||
if (!crime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ export class Sleeve extends Person {
|
||||
|
||||
this.currentTaskLocation = String(this.gainRatesForTask.money);
|
||||
|
||||
this.crimeType = crimeKey;
|
||||
this.crimeType = crime.name;
|
||||
this.currentTaskMaxTime = crime.time;
|
||||
this.currentTask = SleeveTaskType.Crime;
|
||||
return true;
|
||||
@ -179,8 +179,8 @@ export class Sleeve extends Person {
|
||||
if (this.currentTask === SleeveTaskType.Crime) {
|
||||
// For crimes, all experience and money is gained at the end
|
||||
if (this.currentTaskTime >= this.currentTaskMaxTime) {
|
||||
const crime: Crime | null = Crimes[this.crimeType];
|
||||
if (!(crime instanceof Crime)) {
|
||||
const crime: Crime | undefined = Object.values(Crimes).find((crime) => crime.name === this.crimeType);
|
||||
if (!crime) {
|
||||
console.error(`Invalid data stored in sleeve.crimeType: ${this.crimeType}`);
|
||||
this.resetTaskStatus();
|
||||
return retValue;
|
||||
|
@ -104,14 +104,17 @@ export function SleeveElem(props: IProps): React.ReactElement {
|
||||
);
|
||||
break;
|
||||
}
|
||||
case SleeveTaskType.Crime:
|
||||
case SleeveTaskType.Crime: {
|
||||
const crime = Object.values(Crimes).find((crime) => crime.name === props.sleeve.crimeType);
|
||||
if (!crime) throw new Error("crime should not be undefined");
|
||||
desc = (
|
||||
<>
|
||||
This sleeve is currently attempting to {Crimes[props.sleeve.crimeType].type} (Success Rate:{" "}
|
||||
{numeralWrapper.formatPercentage(Crimes[props.sleeve.crimeType].successRate(props.sleeve))}).
|
||||
This sleeve is currently attempting to {crime.type} (Success Rate:{" "}
|
||||
{numeralWrapper.formatPercentage(crime.successRate(props.sleeve))}).
|
||||
</>
|
||||
);
|
||||
break;
|
||||
}
|
||||
case SleeveTaskType.Class:
|
||||
desc = <>This sleeve is currently studying/taking a course at {props.sleeve.currentTaskLocation}.</>;
|
||||
break;
|
||||
|
@ -122,7 +122,7 @@ const tasks: {
|
||||
};
|
||||
},
|
||||
"Commit Crime": (): ITaskDetails => {
|
||||
return { first: Object.keys(Crimes), second: () => ["------"] };
|
||||
return { first: Object.values(Crimes).map((crime) => crime.name), second: () => ["------"] };
|
||||
},
|
||||
"Take University Course": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
|
||||
let universities: string[] = [];
|
||||
|
Loading…
Reference in New Issue
Block a user