mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
v0.34.5. Also adding webpack config and package-lock.json
This commit is contained in:
parent
85ccb294dd
commit
779ce25ae5
@ -1,7 +1,7 @@
|
||||
#cmpy-mgmt-container p,
|
||||
#cmpy-mgmt-container a,
|
||||
#cmpy-mgmt-container div {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
|
||||
@ -123,9 +123,10 @@
|
||||
.cmpy-mgmt-upgrade-div {
|
||||
display:inline-block;
|
||||
border:1px solid white;
|
||||
margin:4px;
|
||||
padding:12px;
|
||||
margin:2px;
|
||||
padding:6px;
|
||||
border-radius:25px;
|
||||
font-size:"12px";
|
||||
color:var(--my-font-color);
|
||||
}
|
||||
|
||||
|
@ -222,8 +222,26 @@ a:link, a:visited {
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
/* Similar to a normal tooltip except its positioned on the left of the elemnt
|
||||
rather than the right to avoid exceeding the elements normal width */
|
||||
.tooltip .tooltiptextleft {
|
||||
visibility: hidden;
|
||||
width: 300px;
|
||||
background-color: var(--my-background-color);
|
||||
border: 2px solid var(--my-highlight-color);;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 4px;
|
||||
left: 40%;
|
||||
bottom:-10%;
|
||||
|
||||
position: absolute;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.tooltip:hover .tooltiptext,
|
||||
.tooltip:hover .tooltiptexthigh {
|
||||
.tooltip:hover .tooltiptexthigh,
|
||||
.tooltip:hover .tooltiptextleft {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
|
2563
dist/bundle.js
vendored
2563
dist/bundle.js
vendored
File diff suppressed because it is too large
Load Diff
BIN
doc/build/doctrees/environment.pickle
vendored
BIN
doc/build/doctrees/environment.pickle
vendored
Binary file not shown.
BIN
doc/build/doctrees/netscript.doctree
vendored
BIN
doc/build/doctrees/netscript.doctree
vendored
Binary file not shown.
BIN
doc/build/doctrees/netscriptfunctions.doctree
vendored
BIN
doc/build/doctrees/netscriptfunctions.doctree
vendored
Binary file not shown.
Binary file not shown.
BIN
doc/build/doctrees/netscriptmisc.doctree
vendored
Normal file
BIN
doc/build/doctrees/netscriptmisc.doctree
vendored
Normal file
Binary file not shown.
Binary file not shown.
1
doc/build/html/_sources/netscript.rst.txt
vendored
1
doc/build/html/_sources/netscript.rst.txt
vendored
@ -23,3 +23,4 @@ to reach out to the developer!
|
||||
Hacknet Node API <netscripthacknetnodeapi>
|
||||
Trade Information eXchange (TIX) API <netscriptixapi>
|
||||
Singularity Functions <netscriptsingularityfunctions>
|
||||
Miscellaneous <netscriptmisc>
|
||||
|
@ -12,7 +12,7 @@ hack
|
||||
.. js:function:: hack(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server to hack
|
||||
:returns: True if the hack is successful, false otherwise
|
||||
:returns: The amount of money stolen if the hack is successful, and zero otherwise
|
||||
|
||||
Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends
|
||||
on your hacking level and the target server's security level. In order to hack a server you must first gain root access
|
||||
@ -72,10 +72,9 @@ weaken
|
||||
sleep
|
||||
^^^^^
|
||||
|
||||
.. js:function:: sleep(n[, log=true])
|
||||
.. js:function:: sleep(n)
|
||||
|
||||
:param number n: Number of milliseconds to sleep
|
||||
:param boolean log: Optional boolean specifying whether or not to log the action
|
||||
|
||||
Suspends the script for n milliseconds.
|
||||
|
||||
@ -97,6 +96,39 @@ tprint
|
||||
|
||||
Prints a value or a variable to the Terminal
|
||||
|
||||
clearLog
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: clearLog()
|
||||
|
||||
Clears the script's logs
|
||||
|
||||
disableLog
|
||||
^^^^^^^^^^
|
||||
|
||||
.. js:function:: disableLog(fn)
|
||||
|
||||
:param string fn: Name of function for which to disable logging
|
||||
|
||||
Disables logging for the given function. Logging can be disabled for
|
||||
all functions by passing 'ALL' as the argument.
|
||||
|
||||
Note that this does not completely remove all logging functionality.
|
||||
This only stops a function from logging
|
||||
when the function is successful. If the function fails, it will still log the reason for failure.
|
||||
|
||||
Notable functions that cannot have their logs disabled: run, exec, exit
|
||||
|
||||
enableLog
|
||||
^^^^^^^^^
|
||||
|
||||
.. js:function:: enableLog(fn)
|
||||
|
||||
:param string fn: Name of function for which to enable logging
|
||||
|
||||
Re-enables logging for the given function. If 'ALL' is passed into this function
|
||||
as an argument, then it will revert the effects of disableLog('ALL')
|
||||
|
||||
scan
|
||||
^^^^
|
||||
|
||||
@ -304,7 +336,8 @@ killall
|
||||
|
||||
:param string hostname/ip: IP or hostname of the server on which to kill all scripts
|
||||
|
||||
Kills all running scripts on the specified server. This function will always return true.
|
||||
Kills all running scripts on the specified server. This function returns true if any scripts were killed, and
|
||||
false otherwise. In other words, it will return true if there are any scripts running on the target server.
|
||||
|
||||
|
||||
exit
|
||||
@ -346,9 +379,10 @@ scp
|
||||
ls
|
||||
^^
|
||||
|
||||
.. js:function:: ls(hostname/ip)
|
||||
.. js:function:: ls(hostname/ip, [grep])
|
||||
|
||||
:param string hostname/ip: Hostname or IP of the target server
|
||||
:param string grep: a substring to search for in the filename
|
||||
|
||||
Returns an array with the filenames of all files on the specified server (as strings). The returned array
|
||||
is sorted in alphabetic order
|
||||
@ -639,15 +673,6 @@ getPurchasedServers
|
||||
|
||||
Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
||||
|
||||
round
|
||||
^^^^^
|
||||
|
||||
.. js:function:: round(n)
|
||||
|
||||
:param number n: Number to round
|
||||
|
||||
Returns the argument *n* rounded to the nearest integer. If the argument passed in is not a number, then the function will return 0.
|
||||
|
||||
write
|
||||
^^^^^
|
||||
|
||||
@ -684,6 +709,18 @@ read
|
||||
If the argument *port/fn* is a string, then it specifies the name of a text file (.txt) and this function will return the data in the specified text file. If
|
||||
the text file does not exist, an empty string will be returned.
|
||||
|
||||
peek
|
||||
^^^^
|
||||
|
||||
.. js:function:: peek(port)
|
||||
|
||||
:param number port: Port to peek. Must be an integer between 1 and 10
|
||||
|
||||
This function is used to peek at the data from a port. It returns the first element in the specified port
|
||||
without removing that element. If the port is empty, the string "NULL PORT DATA" will be returned.
|
||||
|
||||
Read about how `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_.
|
||||
|
||||
clear
|
||||
^^^^^
|
||||
|
||||
@ -697,6 +734,16 @@ clear
|
||||
|
||||
If the *port/fn* argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.
|
||||
|
||||
rm
|
||||
^^
|
||||
|
||||
.. js:function:: rm(fn)
|
||||
|
||||
:param string fn: Filename of file to remove. Must include the extension
|
||||
:returns: True if it successfully deletes the file, and false otherwise
|
||||
|
||||
Removes the specified file from the current server. This function works for every file type except message (.msg) files.
|
||||
|
||||
scriptRunning
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
|
@ -2,9 +2,6 @@ Netscript Loops and Conditionals
|
||||
================================
|
||||
|
||||
|
||||
Loops and Conditionals
|
||||
----------------------
|
||||
|
||||
Netscript loops and conditionals are the same as Javascript. However, the one caveat is that when declaring variables such as the
|
||||
iterator for traversing a loop, you should not use the 'var' or 'let' keyword. For reference, you can see the Javascript
|
||||
documentation for loops/conditionals here:
|
||||
|
37
doc/build/html/_sources/netscriptmisc.rst.txt
vendored
Normal file
37
doc/build/html/_sources/netscriptmisc.rst.txt
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
Netscript Miscellaneous
|
||||
=======================
|
||||
|
||||
|
||||
Comments
|
||||
--------
|
||||
Netscript supports comments using the same syntax as `Javascript comments <https://www.w3schools.com/js/js_comments.asp>`_.
|
||||
Comments are not evaluated as code, and can be used to document and/or explain code::
|
||||
|
||||
//This is a comment and will not get executed even though its in the code
|
||||
/* Multi
|
||||
* line
|
||||
* comment */
|
||||
print("This code will actually get executed");
|
||||
|
||||
Javascript Math Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Math Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_ is
|
||||
supported in Netscript and is used in the same way::
|
||||
|
||||
numThreads = Math.floor(getServerRam("foodnstuff")[1] / 3.4);
|
||||
|
||||
Javascript Date Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Date Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_ is supported in Netscript.
|
||||
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:
|
||||
|
||||
* now()
|
||||
* UTC()
|
||||
* Parse()
|
||||
* Maybe some others I don't know about
|
||||
|
||||
Example::
|
||||
|
||||
time = Date.now();
|
18
doc/build/html/genindex.html
vendored
18
doc/build/html/genindex.html
vendored
@ -102,6 +102,8 @@
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#clear">clear() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#clearLog">clearLog() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptsingularityfunctions.html#createProgram">createProgram() (built-in function)</a>
|
||||
</li>
|
||||
@ -112,6 +114,10 @@
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#deleteServer">deleteServer() (built-in function)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#disableLog">disableLog() (built-in function)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@ -119,10 +125,12 @@
|
||||
<h2 id="E">E</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#exec">exec() (built-in function)</a>
|
||||
<li><a href="netscriptfunctions.html#enableLog">enableLog() (built-in function)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#exec">exec() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#exit">exit() (built-in function)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
@ -317,16 +325,18 @@
|
||||
<h2 id="P">P</h2>
|
||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#peek">peek() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptixapi.html#placeOrder">placeOrder() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#print">print() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#prompt">prompt() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptsingularityfunctions.html#purchaseAugmentation">purchaseAugmentation() (built-in function)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptsingularityfunctions.html#purchaseAugmentation">purchaseAugmentation() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#purchaseHacknetNode">purchaseHacknetNode() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptsingularityfunctions.html#purchaseProgram">purchaseProgram() (built-in function)</a>
|
||||
@ -347,7 +357,7 @@
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="netscriptfunctions.html#round">round() (built-in function)</a>
|
||||
<li><a href="netscriptfunctions.html#rm">rm() (built-in function)</a>
|
||||
</li>
|
||||
<li><a href="netscriptfunctions.html#run">run() (built-in function)</a>
|
||||
</li>
|
||||
|
17
doc/build/html/index.html
vendored
17
doc/build/html/index.html
vendored
@ -75,10 +75,7 @@ secrets that you've been searching for.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptloopsandconditionals.html#loops-and-conditionals">Loops and Conditionals</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li>
|
||||
@ -87,6 +84,9 @@ secrets that you've been searching for.</p>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#clearlog">clearLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#disablelog">disableLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#enablelog">enableLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li>
|
||||
@ -123,10 +123,11 @@ secrets that you've been searching for.</p>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#round">round</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#peek">peek</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#rm">rm</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li>
|
||||
@ -194,6 +195,12 @@ secrets that you've been searching for.</p>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#comments">Comments</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#javascript-math-module">Javascript Math Module</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="netscriptmisc.html#javascript-date-module">Javascript Date Module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
18
doc/build/html/netscript.html
vendored
18
doc/build/html/netscript.html
vendored
@ -76,10 +76,7 @@ to reach out to the developer!</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html#loops-and-conditionals">Loops and Conditionals</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#hack">hack</a></li>
|
||||
@ -88,6 +85,9 @@ to reach out to the developer!</p>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#sleep">sleep</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#print">print</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#tprint">tprint</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#clearlog">clearLog</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#disablelog">disableLog</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#enablelog">enableLog</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scan">scan</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#nuke">nuke</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#brutessh">brutessh</a></li>
|
||||
@ -124,10 +124,11 @@ to reach out to the developer!</p>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#purchaseserver">purchaseServer</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#deleteserver">deleteServer</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getpurchasedservers">getPurchasedServers</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#round">round</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#write">write</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#read">read</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#peek">peek</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#clear">clear</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#rm">rm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptrunning">scriptRunning</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#scriptkill">scriptKill</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html#getscriptram">getScriptRam</a></li>
|
||||
@ -195,6 +196,12 @@ to reach out to the developer!</p>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html#installaugmentations">installAugmentations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#comments">Comments</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#javascript-math-module">Javascript Math Module</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html#javascript-date-module">Javascript Date Module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -218,6 +225,7 @@ to reach out to the developer!</p>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
138
doc/build/html/netscriptfunctions.html
vendored
138
doc/build/html/netscriptfunctions.html
vendored
@ -70,7 +70,7 @@ This includes information such as function signatures, what they do, and their r
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True if the hack is successful, false otherwise</p>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">The amount of money stolen if the hack is successful, and zero otherwise</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -158,14 +158,13 @@ root access to the target server, but there is no required hacking level to run
|
||||
<h2>sleep<a class="headerlink" href="#sleep" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<code class="descname">sleep</code><span class="sig-paren">(</span><em>n</em><span class="optional">[</span>, <em>log=true</em><span class="optional">]</span><span class="sig-paren">)</span></dt>
|
||||
<code class="descname">sleep</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>n</strong> (<em>number</em>) -- Number of milliseconds to sleep</li>
|
||||
<li><strong>log</strong> (<em>boolean</em>) -- Optional boolean specifying whether or not to log the action</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@ -214,6 +213,61 @@ root access to the target server, but there is no required hacking level to run
|
||||
<p>Prints a value or a variable to the Terminal</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="clearlog">
|
||||
<h2>clearLog<a class="headerlink" href="#clearlog" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="clearLog">
|
||||
<code class="descname">clearLog</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#clearLog" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Clears the script's logs</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="disablelog">
|
||||
<h2>disableLog<a class="headerlink" href="#disablelog" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="disableLog">
|
||||
<code class="descname">disableLog</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="headerlink" href="#disableLog" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>fn</strong> (<em>string</em>) -- Name of function for which to disable logging</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Disables logging for the given function. Logging can be disabled for
|
||||
all functions by passing 'ALL' as the argument.</p>
|
||||
<p>Note that this does not completely remove all logging functionality.
|
||||
This only stops a function from logging
|
||||
when the function is successful. If the function fails, it will still log the reason for failure.</p>
|
||||
<p>Notable functions that cannot have their logs disabled: run, exec, exit</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="enablelog">
|
||||
<h2>enableLog<a class="headerlink" href="#enablelog" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="enableLog">
|
||||
<code class="descname">enableLog</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="headerlink" href="#enableLog" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>fn</strong> (<em>string</em>) -- Name of function for which to enable logging</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Re-enables logging for the given function. If 'ALL' is passed into this function
|
||||
as an argument, then it will revert the effects of disableLog('ALL')</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="scan">
|
||||
<h2>scan<a class="headerlink" href="#scan" title="Permalink to this headline">¶</a></h2>
|
||||
@ -544,7 +598,8 @@ is not the same as <em>foo.script</em> run with the argument 2, even though they
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Kills all running scripts on the specified server. This function will always return true.</p>
|
||||
<p>Kills all running scripts on the specified server. This function returns true if any scripts were killed, and
|
||||
false otherwise. In other words, it will return true if there are any scripts running on the target server.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
@ -599,13 +654,14 @@ then this function will return true if at least one of the files in the array is
|
||||
<h2>ls<a class="headerlink" href="#ls" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<code class="descname">ls</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="sig-paren">)</span></dt>
|
||||
<code class="descname">ls</code><span class="sig-paren">(</span><em>hostname/ip</em><span class="optional">[</span>, <em>grep</em><span class="optional">]</span><span class="sig-paren">)</span></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>hostname/ip</strong> (<em>string</em>) -- Hostname or IP of the target server</li>
|
||||
<li><strong>grep</strong> (<em>string</em>) -- a substring to search for in the filename</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@ -1078,26 +1134,6 @@ then IPs will be returned. If this argument is omitted then it is true by defaul
|
||||
<p>Returns an array with either the hostnames or IPs of all of the servers you have purchased.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="round">
|
||||
<h2>round<a class="headerlink" href="#round" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<code class="descname">round</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>n</strong> (<em>number</em>) -- Number to round</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Returns the argument <em>n</em> rounded to the nearest integer. If the argument passed in is not a number, then the function will return 0.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="write">
|
||||
<h2>write<a class="headerlink" href="#write" title="Permalink to this headline">¶</a></h2>
|
||||
@ -1152,6 +1188,28 @@ will remove the first element from that queue and return it. If the queue is emp
|
||||
the text file does not exist, an empty string will be returned.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="peek">
|
||||
<h2>peek<a class="headerlink" href="#peek" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<code class="descname">peek</code><span class="sig-paren">(</span><em>port</em><span class="sig-paren">)</span></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
||||
<li><strong>port</strong> (<em>number</em>) -- Port to peek. Must be an integer between 1 and 10</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>This function is used to peek at the data from a port. It returns the first element in the specified port
|
||||
without removing that element. If the port is empty, the string "NULL PORT DATA" will be returned.</p>
|
||||
<p>Read about how <a class="reference external" href="http://bitburner.wikia.com/wiki/Netscript_Ports">Netscript Ports work here</a>.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="clear">
|
||||
<h2>clear<a class="headerlink" href="#clear" title="Permalink to this headline">¶</a></h2>
|
||||
@ -1174,6 +1232,29 @@ the text file does not exist, an empty string will be returned.</p>
|
||||
<p>If the <em>port/fn</em> argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="rm">
|
||||
<h2>rm<a class="headerlink" href="#rm" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<code class="descname">rm</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span></dt>
|
||||
<dd><table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>fn</strong> (<em>string</em>) -- Filename of file to remove. Must include the extension</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True if it successfully deletes the file, and false otherwise</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Removes the specified file from the current server. This function works for every file type except message (.msg) files.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="scriptrunning">
|
||||
<h2>scriptRunning<a class="headerlink" href="#scriptrunning" title="Permalink to this headline">¶</a></h2>
|
||||
@ -1505,6 +1586,9 @@ you create in functions such as <a class="reference external" href="https://deve
|
||||
<li class="toctree-l3"><a class="reference internal" href="#sleep">sleep</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#print">print</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#tprint">tprint</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#clearlog">clearLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#disablelog">disableLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#enablelog">enableLog</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#scan">scan</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#nuke">nuke</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#brutessh">brutessh</a></li>
|
||||
@ -1541,10 +1625,11 @@ you create in functions such as <a class="reference external" href="https://deve
|
||||
<li class="toctree-l3"><a class="reference internal" href="#purchaseserver">purchaseServer</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#deleteserver">deleteServer</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#getpurchasedservers">getPurchasedServers</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#round">round</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#write">write</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#read">read</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#peek">peek</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#clear">clear</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#rm">rm</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#scriptrunning">scriptRunning</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#scriptkill">scriptKill</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#getscriptram">getScriptRam</a></li>
|
||||
@ -1566,6 +1651,7 @@ you create in functions such as <a class="reference external" href="https://deve
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -53,8 +53,6 @@
|
||||
|
||||
<div class="section" id="netscript-loops-and-conditionals">
|
||||
<h1>Netscript Loops and Conditionals<a class="headerlink" href="#netscript-loops-and-conditionals" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="loops-and-conditionals">
|
||||
<h2>Loops and Conditionals<a class="headerlink" href="#loops-and-conditionals" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Netscript loops and conditionals are the same as Javascript. However, the one caveat is that when declaring variables such as the
|
||||
iterator for traversing a loop, you should not use the 'var' or 'let' keyword. For reference, you can see the Javascript
|
||||
documentation for loops/conditionals here:</p>
|
||||
@ -86,7 +84,6 @@ Otherwise, the money available on the server will be grown using the grow() Nets
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -101,16 +98,14 @@ Otherwise, the money available on the server will be grown using the grow() Nets
|
||||
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Loops and Conditionals</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#loops-and-conditionals">Loops and Conditionals</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Loops and Conditionals</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
161
doc/build/html/netscriptmisc.html
vendored
Normal file
161
doc/build/html/netscriptmisc.html
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="English">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Netscript Miscellaneous — Bitburner 1.0 documentation</title>
|
||||
<link rel="stylesheet" href="_static/agogo.css" type="text/css" />
|
||||
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: './',
|
||||
VERSION: '1.0',
|
||||
COLLAPSE_INDEX: false,
|
||||
FILE_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="prev" title="Netscript Singularity Functions" href="netscriptsingularityfunctions.html" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="header-wrapper" role="banner">
|
||||
<div class="header">
|
||||
<div class="headertitle"><a
|
||||
href="index.html">Bitburner 1.0 documentation</a></div>
|
||||
<div class="rel" role="navigation" aria-label="related navigation">
|
||||
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
|
||||
accesskey="P">previous</a> |
|
||||
<a href="genindex.html" title="General Index"
|
||||
accesskey="I">index</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<div class="content">
|
||||
<div class="document">
|
||||
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<div class="section" id="netscript-miscellaneous">
|
||||
<h1>Netscript Miscellaneous<a class="headerlink" href="#netscript-miscellaneous" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="comments">
|
||||
<h2>Comments<a class="headerlink" href="#comments" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Netscript supports comments using the same syntax as <a class="reference external" href="https://www.w3schools.com/js/js_comments.asp">Javascript comments</a>.
|
||||
Comments are not evaluated as code, and can be used to document and/or explain code:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">//</span><span class="n">This</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">comment</span> <span class="ow">and</span> <span class="n">will</span> <span class="ow">not</span> <span class="n">get</span> <span class="n">executed</span> <span class="n">even</span> <span class="n">though</span> <span class="n">its</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">code</span>
|
||||
<span class="o">/*</span> <span class="n">Multi</span>
|
||||
<span class="o">*</span> <span class="n">line</span>
|
||||
<span class="o">*</span> <span class="n">comment</span> <span class="o">*/</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"This code will actually get executed"</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="javascript-math-module">
|
||||
<h2>Javascript Math Module<a class="headerlink" href="#javascript-math-module" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math">Javascript Math Module</a> is
|
||||
supported in Netscript and is used in the same way:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">numThreads</span> <span class="o">=</span> <span class="n">Math</span><span class="o">.</span><span class="n">floor</span><span class="p">(</span><span class="n">getServerRam</span><span class="p">(</span><span class="s2">"foodnstuff"</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="mf">3.4</span><span class="p">);</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="javascript-date-module">
|
||||
<h2>Javascript Date Module<a class="headerlink" href="#javascript-date-module" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date">Javascript Date Module</a> is supported in Netscript.
|
||||
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:</p>
|
||||
<ul class="simple">
|
||||
<li>now()</li>
|
||||
<li>UTC()</li>
|
||||
<li>Parse()</li>
|
||||
<li>Maybe some others I don't know about</li>
|
||||
</ul>
|
||||
<p>Example:</p>
|
||||
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">time</span> <span class="o">=</span> <span class="n">Date</span><span class="o">.</span><span class="n">now</span><span class="p">();</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<h3>Table Of Contents</h3>
|
||||
<p class="caption"><span class="caption-text">Contents:</span></p>
|
||||
<ul class="current">
|
||||
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Miscellaneous</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#comments">Comments</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#javascript-math-module">Javascript Math Module</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#javascript-date-module">Javascript Date Module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div role="search">
|
||||
<h3 style="margin-top: 1.5em;">Search</h3>
|
||||
<form class="search" action="search.html" method="get">
|
||||
<input type="text" name="q" />
|
||||
<input type="submit" value="Go" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-wrapper">
|
||||
<div class="footer">
|
||||
<div class="left">
|
||||
<div role="navigation" aria-label="related navigaton">
|
||||
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
|
||||
>previous</a> |
|
||||
<a href="genindex.html" title="General Index"
|
||||
>index</a>
|
||||
</div>
|
||||
<div role="note" aria-label="source link">
|
||||
<br/>
|
||||
<a href="_sources/netscriptmisc.rst.txt"
|
||||
rel="nofollow">Show Source</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2017, Bitburner.
|
||||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.4.
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -24,6 +24,7 @@
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="next" title="Netscript Miscellaneous" href="netscriptmisc.html" />
|
||||
<link rel="prev" title="Netscript Trade Information eXchange (TIX) API" href="netscriptixapi.html" />
|
||||
</head>
|
||||
<body>
|
||||
@ -34,6 +35,8 @@
|
||||
<div class="rel" role="navigation" aria-label="related navigation">
|
||||
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
|
||||
accesskey="P">previous</a> |
|
||||
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
|
||||
accesskey="N">next</a> |
|
||||
<a href="genindex.html" title="General Index"
|
||||
accesskey="I">index</a>
|
||||
</div>
|
||||
@ -696,6 +699,7 @@ This script will be run with no arguments and 1 thread. It must be located on yo
|
||||
<li class="toctree-l3"><a class="reference internal" href="#installaugmentations">installAugmentations</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -720,6 +724,8 @@ This script will be run with no arguments and 1 thread. It must be located on yo
|
||||
<div role="navigation" aria-label="related navigaton">
|
||||
<a href="netscriptixapi.html" title="Netscript Trade Information eXchange (TIX) API"
|
||||
>previous</a> |
|
||||
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
|
||||
>next</a> |
|
||||
<a href="genindex.html" title="General Index"
|
||||
>index</a>
|
||||
</div>
|
||||
|
BIN
doc/build/html/objects.inv
vendored
BIN
doc/build/html/objects.inv
vendored
Binary file not shown.
2
doc/build/html/searchindex.js
vendored
2
doc/build/html/searchindex.js
vendored
File diff suppressed because one or more lines are too long
43
doc/source/.tags
Normal file
43
doc/source/.tags
Normal file
@ -0,0 +1,43 @@
|
||||
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
||||
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
||||
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
||||
!_TAG_PROGRAM_VERSION 5.8 //
|
||||
author .\conf.py /^author = 'Bitburner'$/;" v
|
||||
copyright .\conf-guzzle.py /^copyright = u'2017, Daniel Xie'$/;" v
|
||||
copyright .\conf.py /^copyright = '2017, Bitburner'$/;" v
|
||||
exclude_patterns .\conf-guzzle.py /^exclude_patterns = ['_build']$/;" v
|
||||
exclude_patterns .\conf.py /^exclude_patterns = []$/;" v
|
||||
extensions .\conf-guzzle.py /^extensions = []$/;" v
|
||||
extensions .\conf.py /^extensions = ['sphinx.ext.autodoc',$/;" v
|
||||
guzzle_sphinx_theme .\conf-guzzle.py /^import guzzle_sphinx_theme$/;" i
|
||||
html_show_sourcelink .\conf-guzzle.py /^html_show_sourcelink = False$/;" v
|
||||
html_static_path .\conf.py /^html_static_path = ['ystatic']$/;" v
|
||||
html_theme .\conf-guzzle.py /^html_theme = 'guzzle_sphinx_theme'$/;" v
|
||||
html_theme .\conf.py /^html_theme = 'agogo'$/;" v
|
||||
html_theme_options .\conf-guzzle.py /^html_theme_options = {$/;" v
|
||||
html_theme_path .\conf-guzzle.py /^html_theme_path = guzzle_sphinx_theme.html_theme_path()$/;" v
|
||||
htmlhelp_basename .\conf.py /^htmlhelp_basename = 'Bitburnerdoc'$/;" v
|
||||
intersphinx_mapping .\conf.py /^intersphinx_mapping = {'https:\/\/docs.python.org\/': None}$/;" v
|
||||
language .\conf.py /^language = 'English'$/;" v
|
||||
latex_documents .\conf.py /^latex_documents = [$/;" v
|
||||
latex_elements .\conf.py /^latex_elements = {$/;" v
|
||||
man_pages .\conf.py /^man_pages = [$/;" v
|
||||
master_doc .\conf-guzzle.py /^master_doc = 'index'$/;" v
|
||||
master_doc .\conf.py /^master_doc = 'index'$/;" v
|
||||
os .\conf-guzzle.py /^import sys, os, subprocess$/;" i
|
||||
project .\conf-guzzle.py /^project = u'Bitburner'$/;" v
|
||||
project .\conf.py /^project = 'Bitburner'$/;" v
|
||||
pygments_style .\conf.py /^pygments_style = 'sphinx'$/;" v
|
||||
release .\conf.py /^release = '1.0'$/;" v
|
||||
source_suffix .\conf-guzzle.py /^source_suffix = '.rst'$/;" v
|
||||
source_suffix .\conf.py /^source_suffix = '.rst'$/;" v
|
||||
subprocess .\conf-guzzle.py /^import sys, os, subprocess$/;" i
|
||||
sys .\conf-guzzle.py /^import sys, os, subprocess$/;" i
|
||||
templates_path .\conf-guzzle.py /^templates_path = ['_templates']$/;" v
|
||||
templates_path .\conf.py /^templates_path = ['ytemplates']$/;" v
|
||||
texinfo_documents .\conf.py /^texinfo_documents = [$/;" v
|
||||
todo_include_todos .\conf.py /^todo_include_todos = True$/;" v
|
||||
version .\conf-guzzle.py /^version = '1.0.0'$/;" v
|
||||
version .\conf.py /^version = '1.0'$/;" v
|
@ -23,3 +23,4 @@ to reach out to the developer!
|
||||
Hacknet Node API <netscripthacknetnodeapi>
|
||||
Trade Information eXchange (TIX) API <netscriptixapi>
|
||||
Singularity Functions <netscriptsingularityfunctions>
|
||||
Miscellaneous <netscriptmisc>
|
||||
|
@ -12,7 +12,7 @@ hack
|
||||
.. js:function:: hack(hostname/ip)
|
||||
|
||||
:param string hostname/ip: IP or hostname of the target server to hack
|
||||
:returns: True if the hack is successful, false otherwise
|
||||
:returns: The amount of money stolen if the hack is successful, and zero otherwise
|
||||
|
||||
Function that is used to try and hack servers to steal money and gain hacking experience. The runtime for this command depends
|
||||
on your hacking level and the target server's security level. In order to hack a server you must first gain root access
|
||||
@ -72,10 +72,9 @@ weaken
|
||||
sleep
|
||||
^^^^^
|
||||
|
||||
.. js:function:: sleep(n[, log=true])
|
||||
.. js:function:: sleep(n)
|
||||
|
||||
:param number n: Number of milliseconds to sleep
|
||||
:param boolean log: Optional boolean specifying whether or not to log the action
|
||||
|
||||
Suspends the script for n milliseconds.
|
||||
|
||||
@ -97,6 +96,39 @@ tprint
|
||||
|
||||
Prints a value or a variable to the Terminal
|
||||
|
||||
clearLog
|
||||
^^^^^^^^
|
||||
|
||||
.. js:function:: clearLog()
|
||||
|
||||
Clears the script's logs
|
||||
|
||||
disableLog
|
||||
^^^^^^^^^^
|
||||
|
||||
.. js:function:: disableLog(fn)
|
||||
|
||||
:param string fn: Name of function for which to disable logging
|
||||
|
||||
Disables logging for the given function. Logging can be disabled for
|
||||
all functions by passing 'ALL' as the argument.
|
||||
|
||||
Note that this does not completely remove all logging functionality.
|
||||
This only stops a function from logging
|
||||
when the function is successful. If the function fails, it will still log the reason for failure.
|
||||
|
||||
Notable functions that cannot have their logs disabled: run, exec, exit
|
||||
|
||||
enableLog
|
||||
^^^^^^^^^
|
||||
|
||||
.. js:function:: enableLog(fn)
|
||||
|
||||
:param string fn: Name of function for which to enable logging
|
||||
|
||||
Re-enables logging for the given function. If 'ALL' is passed into this function
|
||||
as an argument, then it will revert the effects of disableLog('ALL')
|
||||
|
||||
scan
|
||||
^^^^
|
||||
|
||||
@ -304,7 +336,8 @@ killall
|
||||
|
||||
:param string hostname/ip: IP or hostname of the server on which to kill all scripts
|
||||
|
||||
Kills all running scripts on the specified server. This function will always return true.
|
||||
Kills all running scripts on the specified server. This function returns true if any scripts were killed, and
|
||||
false otherwise. In other words, it will return true if there are any scripts running on the target server.
|
||||
|
||||
|
||||
exit
|
||||
@ -640,15 +673,6 @@ getPurchasedServers
|
||||
|
||||
Returns an array with either the hostnames or IPs of all of the servers you have purchased.
|
||||
|
||||
round
|
||||
^^^^^
|
||||
|
||||
.. js:function:: round(n)
|
||||
|
||||
:param number n: Number to round
|
||||
|
||||
Returns the argument *n* rounded to the nearest integer. If the argument passed in is not a number, then the function will return 0.
|
||||
|
||||
write
|
||||
^^^^^
|
||||
|
||||
@ -685,6 +709,18 @@ read
|
||||
If the argument *port/fn* is a string, then it specifies the name of a text file (.txt) and this function will return the data in the specified text file. If
|
||||
the text file does not exist, an empty string will be returned.
|
||||
|
||||
peek
|
||||
^^^^
|
||||
|
||||
.. js:function:: peek(port)
|
||||
|
||||
:param number port: Port to peek. Must be an integer between 1 and 10
|
||||
|
||||
This function is used to peek at the data from a port. It returns the first element in the specified port
|
||||
without removing that element. If the port is empty, the string "NULL PORT DATA" will be returned.
|
||||
|
||||
Read about how `Netscript Ports work here <http://bitburner.wikia.com/wiki/Netscript_Ports>`_.
|
||||
|
||||
clear
|
||||
^^^^^
|
||||
|
||||
@ -698,6 +734,16 @@ clear
|
||||
|
||||
If the *port/fn* argument is a string, then it specifies the name of a text file (.txt) and will delete all data from that text file.
|
||||
|
||||
rm
|
||||
^^
|
||||
|
||||
.. js:function:: rm(fn)
|
||||
|
||||
:param string fn: Filename of file to remove. Must include the extension
|
||||
:returns: True if it successfully deletes the file, and false otherwise
|
||||
|
||||
Removes the specified file from the current server. This function works for every file type except message (.msg) files.
|
||||
|
||||
scriptRunning
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
|
@ -2,9 +2,6 @@ Netscript Loops and Conditionals
|
||||
================================
|
||||
|
||||
|
||||
Loops and Conditionals
|
||||
----------------------
|
||||
|
||||
Netscript loops and conditionals are the same as Javascript. However, the one caveat is that when declaring variables such as the
|
||||
iterator for traversing a loop, you should not use the 'var' or 'let' keyword. For reference, you can see the Javascript
|
||||
documentation for loops/conditionals here:
|
||||
|
37
doc/source/netscriptmisc.rst
Normal file
37
doc/source/netscriptmisc.rst
Normal file
@ -0,0 +1,37 @@
|
||||
Netscript Miscellaneous
|
||||
=======================
|
||||
|
||||
|
||||
Comments
|
||||
--------
|
||||
Netscript supports comments using the same syntax as `Javascript comments <https://www.w3schools.com/js/js_comments.asp>`_.
|
||||
Comments are not evaluated as code, and can be used to document and/or explain code::
|
||||
|
||||
//This is a comment and will not get executed even though its in the code
|
||||
/* Multi
|
||||
* line
|
||||
* comment */
|
||||
print("This code will actually get executed");
|
||||
|
||||
Javascript Math Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Math Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_ is
|
||||
supported in Netscript and is used in the same way::
|
||||
|
||||
numThreads = Math.floor(getServerRam("foodnstuff")[1] / 3.4);
|
||||
|
||||
Javascript Date Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Date Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_ is supported in Netscript.
|
||||
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:
|
||||
|
||||
* now()
|
||||
* UTC()
|
||||
* Parse()
|
||||
* Maybe some others I don't know about
|
||||
|
||||
Example::
|
||||
|
||||
time = Date.now();
|
@ -870,7 +870,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="200" min="25"
|
||||
<input type ="range" max="250" min="25"
|
||||
step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="100">
|
||||
</input>
|
||||
<em id="settingsNSExecTimeRangeValLabel" style="font-style: normal;"></em>
|
||||
|
2498
package-lock.json
generated
Normal file
2498
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
import {Engine} from "./engine.js";
|
||||
import {showLiterature} from "./Literature.js";
|
||||
import {Locations} from "./Location.js";
|
||||
import {Player} from "./Player.js";
|
||||
|
||||
@ -11,7 +12,7 @@ import {getRandomInt, removeElementById,
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver.js";
|
||||
import numeral from "../utils/numeral.min.js";
|
||||
import {formatNumber, isString} from "../utils/StringHelperFunctions.js";
|
||||
import {formatNumber, isString, generateRandomString} from "../utils/StringHelperFunctions.js";
|
||||
import {yesNoBoxCreate, yesNoTxtInpBoxCreate,
|
||||
yesNoBoxGetYesButton, yesNoBoxGetNoButton,
|
||||
yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,
|
||||
@ -51,7 +52,7 @@ Reviver.constructors.CorporationState = CorporationState;
|
||||
|
||||
/* Constants */
|
||||
var TOTALSHARES = 1e9; //Total number of shares you have at your company
|
||||
var CyclesPerMarketCycle = 100;
|
||||
var CyclesPerMarketCycle = 75;
|
||||
var CyclesPerIndustryStateCycle = CyclesPerMarketCycle / companyStates.length;
|
||||
var SecsPerMarketCycle = CyclesPerMarketCycle / 5;
|
||||
var Cities = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
|
||||
@ -352,7 +353,7 @@ Product.prototype.finishProduct = function(employeeProd, industry) {
|
||||
this.calculateRating(industry);
|
||||
var advMult = 1 + (Math.pow(this.advCost, 0.1) / 100);
|
||||
console.log("advMult: " + advMult);
|
||||
this.mku = 100 / (advMult * this.qlt * (busRatio + mgmtRatio));
|
||||
this.mku = 100 / (advMult * Math.pow((this.qlt + 0.001), 0.9) * (busRatio + mgmtRatio));
|
||||
this.dmd = industry.awareness === 0 ? 20 : Math.min(100, advMult * (100 * (industry.popularity / industry.awareness)));
|
||||
this.cmp = getRandomInt(0, 70);
|
||||
|
||||
@ -440,33 +441,47 @@ var IndustryStartingCosts = {
|
||||
|
||||
var IndustryDescriptions = {
|
||||
Energy: "Engage in the production and distribution of energy.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Energy).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Energy).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Utilities: "Distributes water and provides wastewater services.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Utilities).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Utilities).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Agriculture: "Cultive crops and breed livestock to produce food.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Agriculture).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Agriculture).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: YES",
|
||||
Fishing: "Produce food through the breeding and processing of fish and fish products<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Fishing).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Fishing).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Mining: "Extract and process metals from the earth.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Mining).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Mining).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Food: "Create your own restaurants all around the world.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Food).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Food).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: YES",
|
||||
Tobacco: "Create and distribute tobacco and tobacco-related products.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Tobacco).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Tobacco).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: YES",
|
||||
Chemical: "Product industrial chemicals<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Chemical).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Chemical).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Pharmaceutical: "Discover, develop, and create new pharmaceutical drugs.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Pharmaceutical).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Pharmaceutical).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Computer: "Develop and manufacture new computer hardware and networking infrastructures.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Computer).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Computer).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Robotics: "Develop and create robots.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Robotics).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Robotics).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
Software: "Develop computer software and create AI Cores.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Software).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Software).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: YES",
|
||||
Healthcare: "Create and manage hospitals.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Healthcare).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.Healthcare).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
RealEstate: "Develop and manuage real estate properties.<br><br>" +
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.RealEstate).format("$0.000a"),
|
||||
"Starting cost: " + numeral(IndustryStartingCosts.RealEstate).format("$0.000a") + "<br>" +
|
||||
"Recommended starting Industry: NO",
|
||||
}
|
||||
|
||||
var ProductRatingWeights = {
|
||||
@ -624,7 +639,7 @@ Industry.prototype.init = function() {
|
||||
this.sciFac = 0.7;
|
||||
this.robFac = 0.05;
|
||||
this.aiFac = 0.3;
|
||||
this.advFac = 0.2;
|
||||
this.advFac = 0.07;
|
||||
this.reqMats = {
|
||||
"Hardware": 0.1,
|
||||
"Metal": 0.25,
|
||||
@ -637,7 +652,7 @@ Industry.prototype.init = function() {
|
||||
this.sciFac = 0.6;
|
||||
this.robFac = 0.3;
|
||||
this.aiFac = 0.3;
|
||||
this.advFac = 0.2;
|
||||
this.advFac = 0.07;
|
||||
this.reqMats = {
|
||||
"Hardware": 0.1,
|
||||
"Metal": 0.2,
|
||||
@ -650,7 +665,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.2;
|
||||
this.robFac = 0.3;
|
||||
this.aiFac = 0.3;
|
||||
this.advFac = 0.05;
|
||||
this.advFac = 0.04;
|
||||
this.reqMats = {
|
||||
"Water": 0.5,
|
||||
"Energy": 0.5,
|
||||
@ -663,7 +678,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.35;
|
||||
this.robFac = 0.5;
|
||||
this.aiFac = 0.2;
|
||||
this.advFac = 0.15;
|
||||
this.advFac = 0.06;
|
||||
this.reqMats = {
|
||||
"Energy": 0.5,
|
||||
}
|
||||
@ -675,7 +690,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.4;
|
||||
this.robFac = 0.5;
|
||||
this.aiFac = 0.5;
|
||||
this.advFac = 0.05;
|
||||
this.advFac = 0.04;
|
||||
this.reqMats = {
|
||||
"Energy": 0.8,
|
||||
}
|
||||
@ -687,7 +702,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.15;
|
||||
this.robFac = 0.3;
|
||||
this.aiFac = 0.25;
|
||||
this.advFac = 0.75;
|
||||
this.advFac = 0.25;
|
||||
this.reFac = 0.05;
|
||||
this.reqMats = {
|
||||
"Food": 0.5,
|
||||
@ -702,7 +717,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.15;
|
||||
this.robFac = 0.2;
|
||||
this.aiFac = 0.15;
|
||||
this.advFac = 0.6;
|
||||
this.advFac = 0.2;
|
||||
this.reqMats = {
|
||||
"Plants": 1,
|
||||
"Water": 0.2,
|
||||
@ -715,7 +730,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.2;
|
||||
this.robFac = 0.25;
|
||||
this.aiFac = 0.2;
|
||||
this.advFac = 0.1;
|
||||
this.advFac = 0.05;
|
||||
this.reqMats = {
|
||||
"Plants": 1,
|
||||
"Energy": 0.5,
|
||||
@ -729,7 +744,7 @@ Industry.prototype.init = function() {
|
||||
this.hwFac = 0.15;
|
||||
this.robFac = 0.25;
|
||||
this.aiFac = 0.2;
|
||||
this.advFac = 0.55;
|
||||
this.advFac = 0.15;
|
||||
this.reqMats = {
|
||||
"Chemicals": 2,
|
||||
"Energy": 1,
|
||||
@ -744,7 +759,7 @@ Industry.prototype.init = function() {
|
||||
this.sciFac = 0.65;
|
||||
this.robFac = 0.4;
|
||||
this.aiFac = 0.2;
|
||||
this.advFac = 0.5;
|
||||
this.advFac = 0.17;
|
||||
this.reqMats = {
|
||||
"Metal": 2.5,
|
||||
"Energy": 1,
|
||||
@ -756,7 +771,7 @@ Industry.prototype.init = function() {
|
||||
this.reFac = 0.35;
|
||||
this.sciFac = 0.7;
|
||||
this.aiFac = 0.4;
|
||||
this.advFac = 0.6;
|
||||
this.advFac = 0.2;
|
||||
this.hwFac = 0.2;
|
||||
this.reqMats = {
|
||||
"Hardware": 5,
|
||||
@ -767,7 +782,7 @@ Industry.prototype.init = function() {
|
||||
break;
|
||||
case Industries.Software:
|
||||
this.sciFac = 0.7;
|
||||
this.advFac = 0.5;
|
||||
this.advFac = 0.18;
|
||||
this.hwFac = 0.25;
|
||||
this.reFac = 0.1;
|
||||
this.aiFac = 0.1;
|
||||
@ -782,7 +797,10 @@ Industry.prototype.init = function() {
|
||||
case Industries.Healthcare:
|
||||
//reFac is unique for this bc it diminishes greatly per city. Handle this separately in code?
|
||||
this.sciFac = 0.75;
|
||||
this.advFac = 0.3;
|
||||
this.advFac = 0.1;
|
||||
this.hwFac = 0.1;
|
||||
this.robFac = 0.1;
|
||||
this.aiFac = 0.1;
|
||||
this.reqMats = {
|
||||
"Robots": 10,
|
||||
"AICores": 5,
|
||||
@ -794,7 +812,9 @@ Industry.prototype.init = function() {
|
||||
case Industries.RealEstate:
|
||||
this.robFac = 0.6;
|
||||
this.aiFac = 0.6;
|
||||
this.advFac = 0.65;
|
||||
this.advFac = 0.25;
|
||||
this.sciFac = 0.05;
|
||||
this.hwFac = 0.05;
|
||||
this.reqMats = {
|
||||
"Metal": 20,
|
||||
"Energy": 10,
|
||||
@ -1027,18 +1047,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
|
||||
var mat = warehouse.materials[this.prodMats[0]];
|
||||
//Calculate the maximum production of this material based
|
||||
//on the office's productivity
|
||||
var total = office.employeeProd[EmployeePositions.Operations] +
|
||||
office.employeeProd[EmployeePositions.Engineer] +
|
||||
office.employeeProd[EmployeePositions.Management], ratio;
|
||||
if (total === 0) {
|
||||
ratio = 0;
|
||||
} else {
|
||||
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
|
||||
(office.employeeProd[EmployeePositions.Engineer] / total) *
|
||||
(office.employeeProd[EmployeePositions.Management] / total);
|
||||
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
|
||||
}
|
||||
var maxProd = 2 * ratio * Math.pow(total, 0.3), prod;
|
||||
var maxProd = this.getOfficeProductivity(office) * this.prodMult * company.getProductionMultiplier(), prod;
|
||||
|
||||
if (mat.prdman[0]) {
|
||||
//Production is manually limited
|
||||
@ -1046,7 +1055,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
|
||||
} else {
|
||||
prod = maxProd;
|
||||
}
|
||||
prod *= (SecsPerMarketCycle * marketCycles * this.prodMult * company.getProductionMultiplier()); //Convert production from per second to per market cycle
|
||||
prod *= (SecsPerMarketCycle * marketCycles); //Convert production from per second to per market cycle
|
||||
//Calculate net change in warehouse storage making
|
||||
//the produced materials will cost
|
||||
var totalMatSize = 0;
|
||||
@ -1153,10 +1162,12 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
|
||||
markup = mat.bCost / sCost;
|
||||
}
|
||||
}
|
||||
var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
|
||||
var maxSell = (mat.qlt + .001) * mat.dmd * (100 - mat.cmp)/100 * markup * businessFactor *
|
||||
Math.pow(this.awareness + 1, 0.05) * Math.pow(this.popularity + 1, 0.07) * company.getSalesMultiplier() *
|
||||
(this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01));
|
||||
//var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
|
||||
var businessFactor = this.getBusinessFactor(office); //Business employee productivity
|
||||
var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity
|
||||
var marketFactor = this.getMarketFactor(mat); //Competition + demand
|
||||
var maxSell = (mat.qlt + .001) * marketFactor * markup * businessFactor *
|
||||
company.getSalesMultiplier() * advertisingFactor;
|
||||
|
||||
var sellAmt;
|
||||
if (mat.sllman[1] !== -1) {
|
||||
@ -1286,18 +1297,7 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
|
||||
case "PRODUCTION":
|
||||
//Calculate the maximum production of this material based
|
||||
//on the office's productivity
|
||||
var total = office.employeeProd[EmployeePositions.Operations] +
|
||||
office.employeeProd[EmployeePositions.Engineer] +
|
||||
office.employeeProd[EmployeePositions.Management], ratio;
|
||||
if (total === 0) {
|
||||
ratio = 0;
|
||||
} else {
|
||||
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
|
||||
(office.employeeProd[EmployeePositions.Engineer] / total) *
|
||||
(office.employeeProd[EmployeePositions.Management] / total);
|
||||
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
|
||||
}
|
||||
var maxProd = ratio * Math.pow(total, 0.2) *
|
||||
var maxProd = this.getOfficeProductivity(office, {forProduct:true}) *
|
||||
corporation.getProductionMultiplier() * this.prodMult, prod;
|
||||
|
||||
//Account for whether production is manually limited
|
||||
@ -1308,7 +1308,6 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
|
||||
}
|
||||
prod *= (SecsPerMarketCycle * marketCycles);
|
||||
|
||||
|
||||
//Calculate net change in warehouse storage making the Products will cost
|
||||
var netStorageSize = product.siz;
|
||||
for (var reqMatName in product.reqMats) {
|
||||
@ -1370,10 +1369,12 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
|
||||
markup = markupLimit / (product.sCost - product.pCost);
|
||||
}
|
||||
}
|
||||
var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
|
||||
var maxSell = Math.pow(product.rat, 0.95) * product.dmd * (1-(product.cmp/100)) * corporation.getSalesMultiplier() *
|
||||
markup * businessFactor * Math.pow(this.awareness + 1, 0.05) * Math.pow(this.popularity + 1, 0.07) *
|
||||
(this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01)) ;
|
||||
//var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
|
||||
var businessFactor = this.getBusinessFactor(office); //Business employee productivity
|
||||
var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity
|
||||
var getMarketFactor = this.getMarketFactor(product); //Competition + demand
|
||||
var maxSell = Math.pow(product.rat, 0.9) * marketFactor * corporation.getSalesMultiplier() *
|
||||
markup * businessFactor * advertisingFactor;
|
||||
var sellAmt;
|
||||
if (product.sllman[city][0] && product.sllman[city][1] > 0) {
|
||||
//Sell amount is manually limited
|
||||
@ -1444,6 +1445,51 @@ Industry.prototype.upgrade = function(upgrade, refs) {
|
||||
}
|
||||
}
|
||||
|
||||
//Returns how much of a material can be produced based of office productivity (employee stats)
|
||||
Industry.prototype.getOfficeProductivity = function(office, params) {
|
||||
var total = office.employeeProd[EmployeePositions.Operations] +
|
||||
office.employeeProd[EmployeePositions.Engineer] +
|
||||
office.employeeProd[EmployeePositions.Management], ratio;
|
||||
if (total === 0) {
|
||||
ratio = 0;
|
||||
} else {
|
||||
ratio = (office.employeeProd[EmployeePositions.Operations] / total) *
|
||||
(office.employeeProd[EmployeePositions.Engineer] / total) *
|
||||
(office.employeeProd[EmployeePositions.Management] / total);
|
||||
ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees
|
||||
}
|
||||
if (params && params.forProduct) {
|
||||
return ratio * Math.pow(total, 0.2);
|
||||
} else {
|
||||
return 2 * ratio * Math.pow(total, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
//Returns a multiplier based on the office' 'Business' employees that affects sales
|
||||
Industry.prototype.getBusinessFactor = function(office) {
|
||||
var ratioMult = 1;
|
||||
if (office.employeeProd["total"] > 0) {
|
||||
ratioMult = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]);
|
||||
}
|
||||
return ratioMult * Math.pow(1 + office.employeeProd[EmployeePositions.Business], 0.1);
|
||||
}
|
||||
|
||||
//Returns a set of multipliers based on the Industry's awareness, popularity, and advFac. This
|
||||
//multiplier affects sales. The result is:
|
||||
// [Total sales mult, total awareness mult, total pop mult, awareness/pop ratio mult]
|
||||
Industry.prototype.getAdvertisingFactors = function() {
|
||||
var awarenessFac = Math.pow(this.awareness + 1, this.advFac);
|
||||
var popularityFac = Math.pow(this.popularity + 1, this.advFac);
|
||||
var ratioFac = (this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01));
|
||||
var totalFac = awarenessFac * popularityFac * ratioFac;
|
||||
return [totalFac, awarenessFac, popularityFac, ratioFac];
|
||||
}
|
||||
|
||||
//Returns a multiplier based on a materials demand and competition that affects sales
|
||||
Industry.prototype.getMarketFactor = function(mat) {
|
||||
return mat.dmd * (100 - mat.cmp)/100;
|
||||
}
|
||||
|
||||
Industry.prototype.toJSON = function() {
|
||||
return Generic_toJSON("Industry", this);
|
||||
}
|
||||
@ -1460,7 +1506,8 @@ var EmployeePositions = {
|
||||
Business: "Business",
|
||||
Management: "Management",
|
||||
RandD: "Research & Development",
|
||||
Unassigned:"Unassigned"
|
||||
Training:"Training",
|
||||
Unassigned:"Unassigned",
|
||||
}
|
||||
|
||||
function Employee(params={}) {
|
||||
@ -1499,6 +1546,15 @@ Employee.prototype.process = function(marketCycles=1, office) {
|
||||
this.cha -= det;
|
||||
}
|
||||
|
||||
//Training
|
||||
var trainingEff = gain * Math.random();
|
||||
if (this.pos === EmployeePositions.Training) {
|
||||
//To increase creativity and intelligence special upgrades are needed
|
||||
this.cha += trainingEff;
|
||||
this.exp += trainingEff;
|
||||
this.eff += trainingEff;
|
||||
}
|
||||
|
||||
//Weight based on how full office is
|
||||
//Too many employees = more likely to decrease energy and happiness
|
||||
var officeCapacityWeight = 0.5 * (office.employees.length / office.size - 0.5);
|
||||
@ -1544,6 +1600,7 @@ Employee.prototype.calculateProductivity = function(corporation) {
|
||||
(0.5 * effEff);
|
||||
break;
|
||||
case EmployeePositions.Unassigned:
|
||||
case EmployeePositions.Training:
|
||||
prodMult = 0;
|
||||
break;
|
||||
default:
|
||||
@ -1822,6 +1879,40 @@ OfficeSpace.prototype.hireEmployee = function(employee, parentRefs) {
|
||||
yesNoTxtInpBoxCreate("Give your employee a nickname!");
|
||||
}
|
||||
|
||||
OfficeSpace.prototype.hireRandomEmployee = function(parentRefs) {
|
||||
var company = parentRefs.corporation, division = parentRefs.division;
|
||||
if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;}
|
||||
|
||||
//Generate three random employees (meh, decent, amazing)
|
||||
var mult = getRandomInt(76, 100)/100;
|
||||
var int = getRandomInt(50, 100),
|
||||
cha = getRandomInt(50, 100),
|
||||
exp = getRandomInt(50, 100),
|
||||
cre = getRandomInt(50, 100),
|
||||
eff = getRandomInt(50, 100),
|
||||
sal = 2.2 * (int + cha + exp + cre + eff);
|
||||
|
||||
var emp = new Employee({
|
||||
intelligence: int * mult,
|
||||
charisma: cha * mult,
|
||||
experience: exp * mult,
|
||||
creativity: cre * mult,
|
||||
efficiency: eff * mult,
|
||||
salary: sal * mult,
|
||||
});
|
||||
|
||||
var name = generateRandomString(7);
|
||||
|
||||
for (var i = 0; i < this.employees.length; ++i) {
|
||||
if (this.employees[i].name === name) {
|
||||
return this.hireRandomEmployee(parentRefs);
|
||||
}
|
||||
}
|
||||
emp.name = name;
|
||||
this.employees.push(emp);
|
||||
company.displayDivisionContent(division, currentCityUi);
|
||||
}
|
||||
|
||||
//Finds the first unassigned employee and assigns its to the specified job
|
||||
OfficeSpace.prototype.assignEmployeeToJob = function(job) {
|
||||
for (var i = 0; i < this.employees.length; ++i) {
|
||||
@ -1970,8 +2061,26 @@ Warehouse.prototype.createUI = function(parentRefs) {
|
||||
console.log("ERROR: Invalid state: " + industry.state);
|
||||
break;
|
||||
}
|
||||
|
||||
//Material ratio text for tooltip
|
||||
var reqRatioText = "The exact requirements for production are:<br>";
|
||||
for (var matName in industry.reqMats) {
|
||||
if (industry.reqMats.hasOwnProperty(matName)) {
|
||||
reqRatioText += (industry.reqMats[matName] + " " + matName + "<br>");
|
||||
}
|
||||
}
|
||||
reqRatioText += "in order to create ";
|
||||
if (industry.prodMats.length > 0) {
|
||||
reqRatioText += "one of each produced Material (" + industry.prodMats.join(", ") + ") ";
|
||||
if (industry.makesProducts) {
|
||||
reqRatioText += "or to create one of its Products";
|
||||
}
|
||||
} else if (industry.makesProducts) {
|
||||
reqRatioText += "one of its Products";
|
||||
}
|
||||
|
||||
industryWarehousePanel.appendChild(createElement("p", {
|
||||
innerHTML:reqText,
|
||||
innerHTML:reqText, tooltipleft:reqRatioText
|
||||
}));
|
||||
|
||||
//Materials
|
||||
@ -2550,15 +2659,19 @@ var CorporationUnlockUpgrades = {
|
||||
"This allows you to purchase exactly however many materials you need for production."],
|
||||
|
||||
//Displays each material/product's demand
|
||||
"2": [2, 25e9, "Market Research - Demand",
|
||||
"2": [2, 5e9, "Market Research - Demand",
|
||||
"Mine and analyze market data to determine the demand of all resources. " +
|
||||
"The demand attribute, which affects sales, will be displayed for every material and product."],
|
||||
|
||||
//Display's each material/product's competition
|
||||
"3": [3, 25e9, "Market Data - Competition",
|
||||
"3": [3, 5e9, "Market Data - Competition",
|
||||
"Mine and analyze market data to determine how much competition there is on the market " +
|
||||
"for all resources. The competition attribute, which affects sales, will be displayed for " +
|
||||
"for every material and product."],
|
||||
"4": [4, 10e9, "VeChain",
|
||||
"Use AI and blockchain technology to identify where you can improve your supply chain systems. " +
|
||||
"This upgrade will allow you to view a wide array of useful statistics about your " +
|
||||
"Corporation."]
|
||||
}
|
||||
|
||||
//Corporation Upgrades
|
||||
@ -2656,11 +2769,24 @@ Corporation.prototype.getState = function() {
|
||||
return this.state.getState();
|
||||
}
|
||||
|
||||
var numMarketCyclesPersist = 1;
|
||||
Corporation.prototype.process = function(numCycles=1) {
|
||||
var corp = this;
|
||||
this.storedCycles += numCycles;
|
||||
if (this.storedCycles >= CyclesPerIndustryStateCycle) {
|
||||
var state = this.getState(), marketCycles = 1;
|
||||
var state = this.getState();
|
||||
|
||||
//Determine number of market cycles at the START state
|
||||
if (state === "START") {
|
||||
if (this.storedCycles >= 2*CyclesPerMarketCycle) {
|
||||
//Enough cycles stored for 2+ market cycles
|
||||
numMarketCyclesPersist = Math.floor(this.storedCycles / CyclesPerMarketCycle);
|
||||
} else {
|
||||
numMarketCyclesPersist = 1;
|
||||
}
|
||||
}
|
||||
var marketCycles = numMarketCyclesPersist;
|
||||
|
||||
this.storedCycles -= (marketCycles * CyclesPerIndustryStateCycle);
|
||||
this.divisions.forEach(function(ind) {
|
||||
ind.process(marketCycles, state, corp);
|
||||
@ -2694,13 +2820,13 @@ Corporation.prototype.process = function(numCycles=1) {
|
||||
Corporation.prototype.determineValuation = function() {
|
||||
var val, profit = (this.revenue.minus(this.expenses)).toNumber();
|
||||
if (this.public) {
|
||||
val = this.funds.toNumber() + (profit * 100e3);
|
||||
val = this.funds.toNumber() + (profit * 90e3);
|
||||
val *= (Math.pow(1.1, this.divisions.length));
|
||||
val = Math.max(val, 0);
|
||||
} else {
|
||||
val = 10e9 + Math.max(this.funds.toNumber(), 0) / 3; //Base valuation
|
||||
if (profit > 0) {
|
||||
val += (profit * 400e3);
|
||||
val += (profit * 350e3);
|
||||
val *= (Math.pow(1.1, this.divisions.length));
|
||||
} else {
|
||||
val = 10e9 * Math.pow(1.1, this.divisions.length);
|
||||
@ -2914,7 +3040,8 @@ var companyManagementDiv, companyManagementHeaderTabs, companyManagementPanel,
|
||||
currentCityUi,
|
||||
corporationUnlockUpgrades, corporationUpgrades,
|
||||
industryOverviewPanel, industryOverviewText,
|
||||
industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeManagementUI, industryEmployeeInfo,
|
||||
industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeAutohireButton,
|
||||
industryEmployeeManagementUI, industryEmployeeInfo, industryIndividualEmployeeInfo,
|
||||
industryOfficeUpgradeSizeButton,
|
||||
industryWarehousePanel,
|
||||
headerTabs, cityTabs;
|
||||
@ -3040,12 +3167,15 @@ Corporation.prototype.updateUIHeaderTabs = function() {
|
||||
});
|
||||
|
||||
//Add industry types to selector
|
||||
//Have Agriculture be first as recommended option
|
||||
selector.add(createElement("option", {
|
||||
text:Industries["Agriculture"], value:"Agriculture"
|
||||
}))
|
||||
for (var key in Industries) {
|
||||
if (Industries.hasOwnProperty(key)) {
|
||||
if (key !== "Agriculture" && Industries.hasOwnProperty(key)) {
|
||||
var ind = Industries[key];
|
||||
selector.add(createElement("option", {
|
||||
text: ind,
|
||||
value:key,
|
||||
text: ind,value:key,
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -3147,19 +3277,17 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasHandbook) {
|
||||
companyManagementPanel.appendChild(createElement("a", {
|
||||
class:"a-link-button", innerText:"Get Handbook", display:"inline-block",
|
||||
tooltip:"Get a copy of 'The Complete Handbook for Creating a Successful Corporation.'" +
|
||||
"This is a .lit file that provides some tips/pointers for helping you get started with " +
|
||||
"starting and managing a Corporation.",
|
||||
clickListener:()=>{
|
||||
homeComp.messages.push(handbookFn);
|
||||
this.displayCorporationOverviewContent();
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
}
|
||||
companyManagementPanel.appendChild(createElement("a", {
|
||||
class:"a-link-button", innerText:"Getting Started Guide", display:"inline-block",
|
||||
tooltip:"Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " +
|
||||
"This is a .lit file that guides you through the beginning of setting up a Corporation and " +
|
||||
"provides some tips/pointers for helping you get started with managing it.",
|
||||
clickListener:()=>{
|
||||
if (!hasHandbook) {homeComp.messages.push(handbookFn);}
|
||||
showLiterature(handbookFn);
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
|
||||
//Investors
|
||||
if (this.public) {
|
||||
@ -3180,7 +3308,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
|
||||
type:"number", placeholder:"Shares to sell", margin:"5px",
|
||||
inputListener: ()=> {
|
||||
var numShares = Math.round(input.value);
|
||||
if (isNaN(numShares)) {
|
||||
if (isNaN(numShares) || shares <= 0) {
|
||||
profitIndicator.innerText = "ERROR: Invalid value entered for number of shares to sell"
|
||||
} else if (numShares > this.numShares) {
|
||||
profitIndicator.innerText = "You don't have this many shares to sell!";
|
||||
@ -3194,7 +3322,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
|
||||
class:"a-link-button", innerText:"Sell shares", display:"inline-block",
|
||||
clickListener:()=>{
|
||||
var shares = Math.round(input.value);
|
||||
if (isNaN(shares)) {
|
||||
if (isNaN(shares) || shares <= 0) {
|
||||
dialogBoxCreate("ERROR: Invalid value for number of shares");
|
||||
} else if (shares > this.numShares) {
|
||||
dialogBoxCreate("ERROR: You don't have this many shares to sell");
|
||||
@ -3247,7 +3375,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
|
||||
inputListener: ()=> {
|
||||
var numShares = Math.round(input.value);
|
||||
//TODO add conditional for if player doesn't have enough money
|
||||
if (isNaN(numShares)) {
|
||||
if (isNaN(numShares) || shares <= 0) {
|
||||
costIndicator.innerText = "ERROR: Invalid value entered for number of shares to buyback"
|
||||
} else if (numShares > this.issuedShares) {
|
||||
costIndicator.innerText = "There are not this many shares available to buy back. " +
|
||||
@ -3263,7 +3391,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
|
||||
clickListener:()=>{
|
||||
var shares = Math.round(input.value);
|
||||
var tempStockPrice = this.sharePrice;
|
||||
if (isNaN(shares)) {
|
||||
if (isNaN(shares) || shares <= 0) {
|
||||
dialogBoxCreate("ERROR: Invalid value for number of shares");
|
||||
} else if (shares > this.issuedShares) {
|
||||
dialogBoxCreate("ERROR: There are not this many oustanding shares to buy back");
|
||||
@ -3572,13 +3700,18 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
//Industry overview text
|
||||
industryOverviewText = createElement("p", {});
|
||||
industryOverviewPanel.appendChild(industryOverviewText);
|
||||
industryOverviewPanel.appendChild(createElement("br", {}));
|
||||
|
||||
//Industry overview Purchases & Upgrades
|
||||
var numUpgrades = Object.keys(IndustryUpgrades).length;
|
||||
while (division.upgrades.length < numUpgrades) {division.upgrades.push(0);} //Backwards compatibility
|
||||
|
||||
var industryOverviewUpgrades = createElement("div", {});
|
||||
industryOverviewUpgrades.appendChild(createElement("h1", {innerText:"Purchases & Upgrades", margin:"4px", padding:"4px"}));
|
||||
industryOverviewUpgrades.appendChild(createElement("u", {
|
||||
innerText:"Purchases & Upgrades", margin:"2px", padding:"2px",
|
||||
fontSize:"14px",
|
||||
}));
|
||||
industryOverviewUpgrades.appendChild(createElement("br", {}));
|
||||
for (var i = 0; i < numUpgrades; ++i) {
|
||||
(function(i, corp, division, office) {
|
||||
var upgrade = IndustryUpgrades[i.toString()];
|
||||
@ -3765,10 +3898,10 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
});
|
||||
industryEmployeePanel.appendChild(industryEmployeeText);
|
||||
|
||||
//Hire Employee button
|
||||
industryEmployeeHireButton = createElement("a", {
|
||||
class:"a-link-button",
|
||||
innerText:"Hire Employee",
|
||||
display:"inline-block",
|
||||
class:"a-link-button",display:"inline-block",
|
||||
innerText:"Hire Employee", fontSize:"13px",
|
||||
clickListener:()=>{
|
||||
office.findEmployees({corporation:this, division:division});
|
||||
return false;
|
||||
@ -3776,9 +3909,24 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
});
|
||||
industryEmployeePanel.appendChild(industryEmployeeHireButton);
|
||||
|
||||
//Autohire Employee button
|
||||
industryEmployeeAutohireButton = createElement("a", {
|
||||
class:"a-link-button", display:"inline-block",
|
||||
innerText:"Autohire Employee", fontSize:"13px",
|
||||
tooltip:"Automatically hires an employee and gives him/her a random name",
|
||||
clickListener:()=>{
|
||||
office.hireRandomEmployee({corporation:this, division:division});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
industryEmployeePanel.appendChild(industryEmployeeAutohireButton);
|
||||
|
||||
//Upgrade Office Size button
|
||||
industryEmployeePanel.appendChild(createElement("br", {}));
|
||||
industryOfficeUpgradeSizeButton = createElement("a", {
|
||||
class:"a-link-button", innerText:"Upgrade Office size", display:"inline-block", margin:"6px",
|
||||
class:"a-link-button", innerText:"Upgrade size",
|
||||
display:"inline-block", margin:"6px", fontSize:"13px",
|
||||
tooltip:"Upgrade the office's size so that it can hold more employees!",
|
||||
clickListener:()=>{
|
||||
var popupId = "cmpy-mgmt-upgrade-office-size-popup";
|
||||
var upgradeCost = OfficeInitialCost * Math.pow(1.07, Math.round(office.size / OfficeInitialSize));
|
||||
@ -3821,9 +3969,9 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
industryEmployeePanel.appendChild(industryOfficeUpgradeSizeButton);
|
||||
|
||||
//Throw Office Party
|
||||
industryEmployeePanel.appendChild(createElement("br",{}));
|
||||
industryEmployeePanel.appendChild(createElement("a", {
|
||||
class:"a-link-button", display:"inline-block", innerText:"Throw Office Party",
|
||||
class:"a-link-button", display:"inline-block", innerText:"Throw Party",
|
||||
fontSize:"13px",
|
||||
tooltip:"Throw an office party to increase your employee's morale and happiness",
|
||||
clickListener:()=>{
|
||||
var popupId = "cmpy-mgmt-throw-office-party-popup";
|
||||
@ -3884,6 +4032,7 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
}));
|
||||
|
||||
industryEmployeeManagementUI = createElement("div", {});
|
||||
industryEmployeeInfo = createElement("p", {margin:"4px", padding:"4px"});
|
||||
if (empManualAssignmentModeActive) {
|
||||
//Employees manually assigned
|
||||
industryEmployeeManagementUI.appendChild(createElement("a", {
|
||||
@ -3899,16 +4048,15 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
}));
|
||||
industryEmployeeManagementUI.appendChild(createElement("br", {}));
|
||||
|
||||
industryEmployeeInfo = createElement("div", {margin:"4px", padding:"4px"});
|
||||
|
||||
industryIndividualEmployeeInfo = createElement("div", {margin:"4px", padding:"4px"});
|
||||
var selector = createElement("select", {
|
||||
color: "white", backgroundColor:"black", margin:"4px", padding:"4px",
|
||||
changeListener:()=>{
|
||||
var name = selector.options[selector.selectedIndex].text;
|
||||
for (var i = 0; i < office.employees.length; ++i) {
|
||||
if (office.employees[i].name === name) {
|
||||
removeChildrenFromElement(industryEmployeeInfo);
|
||||
office.employees[i].createUI(industryEmployeeInfo, this);
|
||||
removeChildrenFromElement(industryIndividualEmployeeInfo);
|
||||
office.employees[i].createUI(industryIndividualEmployeeInfo, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -3922,9 +4070,9 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
|
||||
selector.selectedIndex = -1;
|
||||
|
||||
industryEmployeeManagementUI.appendChild(selector);
|
||||
industryEmployeeManagementUI.appendChild(industryEmployeeInfo);
|
||||
|
||||
industryEmployeeManagementUI.appendChild(selector);
|
||||
industryEmployeeManagementUI.appendChild(industryIndividualEmployeeInfo);
|
||||
} else {
|
||||
//Player only manages the number of each occupation, not who gets what job
|
||||
industryEmployeeManagementUI.appendChild(createElement("a", {
|
||||
@ -3940,7 +4088,8 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
industryEmployeeManagementUI.appendChild(createElement("br", {}));
|
||||
|
||||
var opCount = 0, engCount = 0, busCount = 0,
|
||||
mgmtCount = 0, rndCount = 0, unassignedCount = 0;
|
||||
mgmtCount = 0, rndCount = 0, unassignedCount = 0,
|
||||
trainingCount = 0;
|
||||
for (var i = 0; i < office.employees.length; ++i) {
|
||||
switch (office.employees[i].pos) {
|
||||
case EmployeePositions.Operations:
|
||||
@ -3955,6 +4104,8 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
++rndCount; break;
|
||||
case EmployeePositions.Unassigned:
|
||||
++unassignedCount; break;
|
||||
case EmployeePositions.Training:
|
||||
++trainingCount; break;
|
||||
default:
|
||||
console.log("ERROR: Unrecognized employee position: " + office.employees[i].pos);
|
||||
break;
|
||||
@ -3969,19 +4120,25 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
|
||||
industryEmployeeManagementUI.appendChild(createElement("br", {}));
|
||||
|
||||
//General display of employee information (avg morale, avg energy, etc.)
|
||||
industryEmployeeInfo = createElement("p", {margin:"4px", padding:"4px"});
|
||||
industryEmployeeManagementUI.appendChild(industryEmployeeInfo);
|
||||
industryEmployeeManagementUI.appendChild(createElement("br", {}));
|
||||
|
||||
var positions = [EmployeePositions.Operations, EmployeePositions.Engineer,
|
||||
EmployeePositions.Business, EmployeePositions.Management,
|
||||
EmployeePositions.RandD];
|
||||
var counts = [opCount, engCount, busCount, mgmtCount, rndCount];
|
||||
EmployeePositions.RandD, EmployeePositions.Training];
|
||||
var descriptions = ["Manages supply chain operations. Improves production.", //Operations
|
||||
"Develops and maintains products and production systems. Improves production.", //Engineer
|
||||
"Handles sales and finances. Improves sales.", //Business
|
||||
"Leads and oversees employees and office operations. Improves production.", //Management
|
||||
"Research new innovative ways to improve the company. Generates Scientific Research", //RandD
|
||||
"Set employee to training, which will increase some of their stats. Employees in training do not affect any company operations."] //Training
|
||||
var counts = [opCount, engCount, busCount, mgmtCount, rndCount, trainingCount];
|
||||
for (var i = 0; i < positions.length; ++i) {
|
||||
(function(corp, i) {
|
||||
var info = createElement("h2", {
|
||||
display:"inline-block", width:"40%",
|
||||
innerText: positions[i] + "(" + counts[i] + ")"
|
||||
display:"inline-block", width:"40%", fontSize:"15px",
|
||||
innerText: positions[i] + "(" + counts[i] + ")",
|
||||
tooltipleft: descriptions[i]
|
||||
});
|
||||
var plusBtn = createElement("a", {
|
||||
class: unassignedCount > 0 ? "a-link-button" : "a-link-button-inactive",
|
||||
@ -4040,13 +4197,30 @@ Corporation.prototype.updateDivisionContent = function(division) {
|
||||
console.log("ERROR: Invalid 'division' argument in Corporation.updateDivisionContent");
|
||||
return;
|
||||
}
|
||||
var vechain = (this.unlockUpgrades[4] === 1);
|
||||
//Industry Overview Text
|
||||
var profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber(),
|
||||
profitStr = profit >= 0 ? numeral(profit).format("$0.000a") : "-" + numeral(-1 * profit).format("$0.000a");
|
||||
var advertisingInfo = "";
|
||||
if (vechain) {
|
||||
var advertisingFactors = division.getAdvertisingFactors();
|
||||
var awarenessFac = advertisingFactors[1];
|
||||
var popularityFac = advertisingFactors[2];
|
||||
var ratioFac = advertisingFactors[3];
|
||||
var totalAdvertisingFac = advertisingFactors[0];
|
||||
advertisingInfo =
|
||||
"<p class='tooltip'>Advertising Multiplier: x" + formatNumber(totalAdvertisingFac, 3) +
|
||||
"<span class='tooltiptext' style='font-size:12px'>Total multiplier for this industry's sales due to its awareness and popularity<br>" +
|
||||
"Awareness Bonus: x" + formatNumber(awarenessFac, 3) + "<br>" +
|
||||
"Popularity Bonus: x" + formatNumber(popularityFac, 3) + "<br>" +
|
||||
"Ratio Multiplier: x" + formatNumber(ratioFac, 3) + "</span></p><br>"
|
||||
|
||||
}
|
||||
industryOverviewText.innerHTML =
|
||||
"Industry: " + division.type + "<br><br>" +
|
||||
"Awareness: " + formatNumber(division.awareness, 3) + "<br>" +
|
||||
"Popularity: " + formatNumber(division.popularity, 3) + "<br><br>" +
|
||||
"Popularity: " + formatNumber(division.popularity, 3) + "<br>" +
|
||||
advertisingInfo + "<br>" +
|
||||
"Revenue: " + numeral(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s<br>" +
|
||||
"Expenses: " + numeral(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s<br>" +
|
||||
"Profit: " + profitStr + " / s<br><br>" +
|
||||
@ -4065,30 +4239,51 @@ Corporation.prototype.updateDivisionContent = function(division) {
|
||||
"Size: " + office.employees.length + " / " + office.size + " employees";
|
||||
if (office.employees.length >= office.size) {
|
||||
industryEmployeeHireButton.className = "a-link-button-inactive";
|
||||
industryEmployeeAutohireButton.className = "a-link-button-inactive tooltip";
|
||||
} else {
|
||||
industryEmployeeHireButton.className = "a-link-button";
|
||||
industryEmployeeAutohireButton.className = "a-link-button tooltip";
|
||||
}
|
||||
|
||||
if (!empManualAssignmentModeActive) {
|
||||
//Calculate average morale, happiness, and energy
|
||||
var totalMorale = 0, totalHappiness = 0, totalEnergy = 0,
|
||||
avgMorale = 0, avgHappiness = 0, avgEnergy = 0;
|
||||
for (var i = 0; i < office.employees.length; ++i) {
|
||||
totalMorale += office.employees[i].mor;
|
||||
totalHappiness += office.employees[i].hap;
|
||||
totalEnergy += office.employees[i].ene;
|
||||
}
|
||||
if (office.employees.length > 0) {
|
||||
avgMorale = totalMorale / office.employees.length;
|
||||
avgHappiness = totalHappiness / office.employees.length;
|
||||
avgEnergy = totalEnergy / office.employees.length;
|
||||
}
|
||||
industryEmployeeInfo.innerHTML =
|
||||
"Avg Employee Morale: " + formatNumber(avgMorale, 3) + "<br>" +
|
||||
"Avg Employee Happiness: " + formatNumber(avgHappiness, 3) + "<br>" +
|
||||
"Avg Employee Energy: " + formatNumber(avgEnergy, 3);
|
||||
//Employee Overview stats
|
||||
//Calculate average morale, happiness, and energy
|
||||
var totalMorale = 0, totalHappiness = 0, totalEnergy = 0,
|
||||
avgMorale = 0, avgHappiness = 0, avgEnergy = 0;
|
||||
for (var i = 0; i < office.employees.length; ++i) {
|
||||
totalMorale += office.employees[i].mor;
|
||||
totalHappiness += office.employees[i].hap;
|
||||
totalEnergy += office.employees[i].ene;
|
||||
}
|
||||
if (office.employees.length > 0) {
|
||||
avgMorale = totalMorale / office.employees.length;
|
||||
avgHappiness = totalHappiness / office.employees.length;
|
||||
avgEnergy = totalEnergy / office.employees.length;
|
||||
}
|
||||
industryEmployeeInfo.innerHTML =
|
||||
"Avg Employee Morale: " + formatNumber(avgMorale, 3) + "<br>" +
|
||||
"Avg Employee Happiness: " + formatNumber(avgHappiness, 3) + "<br>" +
|
||||
"Avg Employee Energy: " + formatNumber(avgEnergy, 3);
|
||||
if (vechain) { //VeChain - Statistics
|
||||
industryEmployeeInfo.appendChild(createElement("br", {}));
|
||||
industryEmployeeInfo.appendChild(createElement("p", {
|
||||
innerText:"Material Production: " + formatNumber(division.getOfficeProductivity(office), 3),
|
||||
tooltip: "The base amount of material this office can produce. Does not include " +
|
||||
"production multipliers from upgrades and materials. This value is based off " +
|
||||
"the productivity of your Operations, Engineering, and Management employees"
|
||||
}));
|
||||
industryEmployeeInfo.appendChild(createElement("br", {}));
|
||||
industryEmployeeInfo.appendChild(createElement("p", {
|
||||
innerText:"Product Production: " + formatNumber(division.getOfficeProductivity(office, {forProduct:true}), 3),
|
||||
tooltip: "The base amount of any given Product this office can produce. Does not include " +
|
||||
"production multipliers from upgrades and materials. This value is based off " +
|
||||
"the productivity of your Operations, Engineering, and Management employees"
|
||||
}));
|
||||
industryEmployeeInfo.appendChild(createElement("br", {}));
|
||||
industryEmployeeInfo.appendChild(createElement("p", {
|
||||
innerText: "Business Multiplier: x" + formatNumber(division.getBusinessFactor(office), 3),
|
||||
tooltip: "The effect this office's 'Business' employees has on boosting sales"
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
//Warehouse
|
||||
var warehouse = division.warehouses[currentCityUi];
|
||||
@ -4140,8 +4335,10 @@ Corporation.prototype.clearUI = function() {
|
||||
industryEmployeePanel = null;
|
||||
industryEmployeeText = null;
|
||||
industryEmployeeHireButton = null;
|
||||
industryEmployeeAutohireButton = null;
|
||||
industryEmployeeManagementUI = null;
|
||||
industryEmployeeInfo = null;
|
||||
industryIndividualEmployeeInfo = null;
|
||||
|
||||
industryOfficeUpgradeSizeButton = null;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
let CONSTANTS = {
|
||||
Version: "0.34.4",
|
||||
Version: "0.34.5",
|
||||
|
||||
//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
|
||||
@ -380,9 +380,9 @@ let CONSTANTS = {
|
||||
"the execution of a script is when it saves/loads. </strong><br><br>",
|
||||
TutorialNetscriptText: "Netscript is a programming language implemented for this game. The language has " +
|
||||
"your basic programming constructs and several built-in commands that are used to hack. <br><br>" +
|
||||
"<u><h1>Official Wiki and Documentation</h1></u><br>" +
|
||||
"<a href='https://bitburner.wikia.com/wiki/Netscript' target='_blank'>Check out Bitburner's wiki for the official Netscript documentation</a>" +
|
||||
". The wiki documentation will contain more details and " +
|
||||
"<u><h1>Official Documentation</h1></u><br>" +
|
||||
"<a href='https://bitburner.readthedocs.io/en/latest/index.html' target='_blank'>Check out Bitburner's official Netscript documentation</a>" +
|
||||
". This official documentation will contain more details and " +
|
||||
"code examples than this documentation page. Also, it can be opened up in another tab/window for convenience!<br><br>" +
|
||||
"<u><h1> Variables and data types </h1></u><br>" +
|
||||
"The following data types are supported by Netscript: <br>" +
|
||||
@ -440,13 +440,10 @@ let CONSTANTS = {
|
||||
"either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " +
|
||||
" A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " +
|
||||
"For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. A successful hack() on " +
|
||||
"a server will raise that server's security level by 0.002. Returns true if the hack is successful and " +
|
||||
"false otherwise. <br>" +
|
||||
"a server will raise that server's security level by 0.002. Returns the amount of money stolen if the hack is successful and " +
|
||||
"0 if the hack fails. <br>" +
|
||||
"Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
|
||||
"<i><u>sleep(n, log=true)</u></i><br>Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " +
|
||||
"whether or not the function should log the sleep action. If this argument is true, then calling this function will write " +
|
||||
"'Sleeping for N milliseconds' to the script's logs. If it's false, then this function will not log anything. " +
|
||||
"If this argument is not specified then it will be true by default. <br>Example: sleep(5000);<br><br>" +
|
||||
"<i><u>sleep(n)</u></i><br>Suspends the script for n milliseconds.<br>Example: sleep(5000);<br><br>" +
|
||||
"<i><u>grow(hostname/ip)</u></i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
|
||||
"must be a string with either the IP or hostname of the target server. The runtime for this command depends on your hacking level and the target server's security level. " +
|
||||
"When grow() completes, the money available on a target server will be increased by a certain, fixed percentage. This percentage " +
|
||||
@ -466,6 +463,13 @@ let CONSTANTS = {
|
||||
"<i><u>print(x)</u></i><br>Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ). <br><br>" +
|
||||
"<i><u>tprint(x)</u></i><br>Prints a value or a variable to the Terminal<br><br>" +
|
||||
"<i><u>clearLog()</u></i><br>Clears the script's logs. <br><br>" +
|
||||
"<i><u>disableLog(fn)</u></i><br>Disables logging for the given function. Logging can be disabled for every function " +
|
||||
"by passing 'ALL' as an argument.<br><br>" +
|
||||
"Note that this does not completely remove all logging functionality. This only stops a function from logging " +
|
||||
"when the function is successful. If the function fails, it will still log the reason for failure.<br><br>" +
|
||||
"Notable functions that cannot have their logs disabled: run, exec, exit<br><br>" +
|
||||
"<i><u>enableLog(fn)</u></i><br>Re-enables logging for the given function. If 'ALL' is passed into this function " +
|
||||
"as an argument, then it will revert the effects of disableLog('ALL')<br><br>" +
|
||||
"<i><u>scan(hostname/ip, [hostnames=true])</u></i><br>Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " +
|
||||
"The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " +
|
||||
"the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " +
|
||||
@ -526,8 +530,8 @@ let CONSTANTS = {
|
||||
"kill('foo.script', getHostname());<br><br>" +
|
||||
"If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:<br><br>" +
|
||||
"kill('foo.script', getHostname(), 1, 'foodnstuff');<br><br>" +
|
||||
"<i><u>killall(hostname/ip)</u></i><br> Kills all running scripts on the specified server. This function takes a single argument which " +
|
||||
"must be a string containing the hostname or IP of the target server. This function will always return true. <br><br>" +
|
||||
"<i><u>killall(hostname/ip)</u></i><br>Kills all running scripts on the specified server. This function takes a single argument which " +
|
||||
"must be a string containing the hostname or IP of the target server. This function returns true if any scripts were killed, and false otherwise.<br><br>" +
|
||||
"<i><u>exit()</u></i><br>Terminates the script immediately<br><br>" +
|
||||
"<i><u>scp(script, [source], destination)</u></i><br>Copies a script or literature (.lit) file to another server. The first argument is a string with " +
|
||||
"the filename of the script or literature file " +
|
||||
@ -651,7 +655,6 @@ let CONSTANTS = {
|
||||
"<i><u>getPurchasedServers([hostname=true])</u></i><br>Returns an array with either the hostname or IPs of all of the servers you " +
|
||||
"have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " +
|
||||
"parameter is not specified, it is true by default and hostnames will be returned<br><br>" +
|
||||
"<i><u>round(n)</u></i><br>Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.<br><br>" +
|
||||
"<i><u>write(port/fn, data='', mode='a')</u></i><br>This function can be used to either write data to a port or to a text file (.txt).<br><br>" +
|
||||
"If the first argument is a number between 1 and 10, then it specifies a port and this function will write data to a port. If the second " +
|
||||
"argument is not specified then it will write an empty string to the port. The third argument, mode, is not used when writing data to a port.<br><br>" +
|
||||
@ -667,6 +670,9 @@ let CONSTANTS = {
|
||||
"then the string 'NULL PORT DATA' will be returned.<br><br>" +
|
||||
"If the first argument is a string, then it specifies the name of a text file and this function will return the data in the " +
|
||||
"specified text file. If the text file does not exist, an empty string will be returned<br><br>" +
|
||||
"<i><u>peek(port)</u></i><br>This function is used to peek data from a port. It returns the first element from the specified " +
|
||||
"Netscript Port without removing that element. If the port is empty, then the string 'NULL PORT DATA' will be returned.<br><br>" +
|
||||
"The argument must be an integer between 1 and 10.<br><br>" +
|
||||
"<i><u>clear(port/fn)</u></i><br>This function is used to clear a Netscript Port or a text file.<br><br>" +
|
||||
"It takes a single argument. If this argument is a number between 1 and 10, then it specifies a port and will clear it (deleting all data from it). " +
|
||||
"If the argument is a string, then it specifies the name of a text file (.txt) and will clear the text file so that it is empty.<br><br>" +
|
||||
@ -1129,26 +1135,38 @@ let CONSTANTS = {
|
||||
"World Stock Exchange account and TIX API Access<br>",
|
||||
|
||||
LatestUpdate:
|
||||
"v0.34.4<br>" +
|
||||
"-Added several new features to Gang UI to make it easier to manage your Gang.<br>" +
|
||||
"-Changed the Gang Member upgrade mechanic. Now, rather than only being able to have " +
|
||||
"one weapon/armor/vehicle/etc., you can purchase all the upgrades for each Gang member " +
|
||||
"and their multipliers will stack. To balance this out, the effects (AKA multipliers) of each Gang member upgrade " +
|
||||
"were reduced.<br>" +
|
||||
"-Added a new script editor option: Max Error Count. This affects how many approximate lines the script editor will " +
|
||||
"process (JSHint) for common errors. Increase this option can affect performance<br>" +
|
||||
"-Game theme colors (set using 'theme' Terminal command) are now saved when re-opening the game<br>" +
|
||||
"-'download' Terminal command now works on scripts<br>" +
|
||||
"-Added stopAction() Singularity function and the spawn() Netscript function<br>" +
|
||||
"-The 'Purchase Augmentations' UI screen will now tell you if you need a certain prerequisite for Augmentations.<br>" +
|
||||
"-Augmentations with prerequisites can now be purchased as long as their prerequisites are puchased (" +
|
||||
"before, you had to actually install the prerequisites before being able to purchase)<br><br>" +
|
||||
"v0.34.5<br>" +
|
||||
"-Corporation Management Changes:<br>" +
|
||||
"---Market Research unlocks are now cheaper<br>" +
|
||||
"---New 'VeChain' upgrade: displays useful statistics about Corporation<br>" +
|
||||
"---Corporation cycles are processed 25% faster<br>" +
|
||||
"---Corporation valuation was lowered by ~10% (this affects stock price and investments)<br>" +
|
||||
"---Rebalanced the effects of advertising. Should now be more effective for every Industry<br>" +
|
||||
"---Fixed several bugs/exploits involving selling and buying back stock shares<br>" +
|
||||
"---You will now receive a Corporation Handbook (.lit file) when starting out BitNode-3. It contains a brief guide to help you get started. " +
|
||||
"This same handbook can be viewed from the Corporation management screen<br>" +
|
||||
"---Slightly decreased the amount by which a Product's sell price can be marked up<br>" +
|
||||
"---Employees can now be assigned to a 'Training' task, during which they will slowly increase several of their stats<br>" +
|
||||
"-Hopefully fixed an exploit with Array.forEach(). If there are any issues with using forEach, let me know<br>" +
|
||||
"-Arguments passed into a script are now passed by value. This means modifying the 'args' array in a script " +
|
||||
"should no longer cause issues<br>" +
|
||||
"-Scripts executed programatically (via run(), exec(), etc.) will now fail if null/undefined is passed in " +
|
||||
"as an argument<br>" +
|
||||
"-Added peek() Netscript function<br>" +
|
||||
"-killall() Netscript function now returns true if any scripts were killed, and false otherwise.<br>" +
|
||||
"-hack() Netscript function now returns the amount of money gained for successful hacks, and 0 for failed hacks<br>" +
|
||||
"-scp Terminal command and Netscript function now work for txt files<br>" +
|
||||
"-Changes courtesy of Wraithan:<br>" +
|
||||
"---Text files are now displayed using 'pre' rather than 'p' elements when using the 'cat' Terminal command. " +
|
||||
"This means tabs are retained and lines don't automatically wrap<br>" +
|
||||
"---ls() Netscript function now returns text files as well<br>"
|
||||
|
||||
"---ls() Netscript function now returns text files as well<br>" +
|
||||
"-Removed round() Netscript function, since you can just use Math.round() instead<br>" +
|
||||
"-Added disableLog() and enableLog() Netscript functions<br>" +
|
||||
"-Removed the 'log' argument from sleep(), since you can now use the new disableLog function<br>" +
|
||||
"-'Netscript Documentation' button on script editor now points to new readthedocs documentation rather than wiki<br>" +
|
||||
"-When working for a faction, your current faction reputation is now displayed<br>" +
|
||||
"-Bug Fix: Hacking Missions should no longer break when dragging an existing connection to another Node<br>" +
|
||||
"-Bug Fix: Fixed RAM usage of getNextHacknetNodeCost() (is not 1.5GB instead of 4GB)<br>"
|
||||
}
|
||||
|
||||
export {CONSTANTS};
|
||||
|
@ -4,7 +4,7 @@ let TerminalHelpText =
|
||||
'alias [-g] [name="value"] Create or display Terminal aliases<br>' +
|
||||
"analyze Get information about the current machine <br>" +
|
||||
"buy [-l/program] Purchase a program through the Dark Web<br>" +
|
||||
"cat [file] Display a .msg or .lit file<br>" +
|
||||
"cat [file] Display a .msg, .lit, or .txt file<br>" +
|
||||
"check [script] [args...] Print a script's logs to Terminal<br>" +
|
||||
"clear Clear all text on the terminal <br>" +
|
||||
"cls See 'clear' command <br>" +
|
||||
@ -27,7 +27,7 @@ let TerminalHelpText =
|
||||
"run [name] [-t] [n] [args...] Execute a program or script<br>" +
|
||||
"scan Prints all immediately-available network connections<br>" +
|
||||
"scan-analyze [d] [-a] Prints info for all servers up to <i>d</i> nodes away<br>" +
|
||||
"scp [file] [server] Copies a script or .lit file to a destination server<br>" +
|
||||
"scp [file] [server] Copies a file to a destination server<br>" +
|
||||
"sudov Shows whether you have root access on this computer<br>" +
|
||||
"tail [script] [args...] Displays dynamic logs for the specified script<br>" +
|
||||
"theme [preset] | bg txt hlgt Change the color scheme of the UI<br>" +
|
||||
@ -65,10 +65,10 @@ let HelpTexts = {
|
||||
"dark web to the Terminal, as well as their costs.<br><br>" +
|
||||
"Otherwise, the name of the program must be passed in as a parameter. This is name is NOT case-sensitive.",
|
||||
cat: "cat [file]<br>" +
|
||||
"Display message files, which are files ending with the '.msg' extension, or a literature file, which " +
|
||||
"are files ending with the '.lit' extension. Examples:<br><br>" +
|
||||
"Display message (.msg), literature (.lit), or text (.txt) files. Examples:<br><br>" +
|
||||
"cat j1.msg<br>" +
|
||||
"cat foo.lit",
|
||||
"cat foo.lit<br>" +
|
||||
"cat servers.txt",
|
||||
check: "check [script name] [args...]<br>" +
|
||||
"Print the logs of the script specified by the script name and arguments to the Terminal. Each argument must be separated by " +
|
||||
"a space. Remember that a running script is uniquely " +
|
||||
@ -171,7 +171,8 @@ let HelpTexts = {
|
||||
"-a flag at the end of the command if you would like to enable that.",
|
||||
scp: "scp [filename] [target server]<br>" +
|
||||
"Copies the specified file from the current server to the target server. " +
|
||||
"This command only works for script files (.script extension) and literature files (.lit extension). " +
|
||||
"This command only works for script files (.script extension), literature files (.lit extension), " +
|
||||
"and text files (.txt extension). " +
|
||||
"The second argument passed in must be the hostname or IP of the target server.",
|
||||
sudov: "sudov<br>" +
|
||||
"Prints whether or not you have root access to the current machine",
|
||||
|
@ -41,17 +41,51 @@ function initLiterature() {
|
||||
|
||||
title = "The Complete Handbook for Creating a Successful Corporation";
|
||||
fn = "corporation-management-handbook.lit";
|
||||
txt = "This is a brief collection of tips/pointers on how to successfully start and manage a Corporation.<br><br>" +
|
||||
"-Purchasing Hardware, Robots, AI Cores, and Real Estate can potentially increase your production. " +
|
||||
"The effects of these depend on what industry you are in.<br><br>" +
|
||||
"-In order to optimize your production, you will need a good balance of Operators, Managers, and Engineers<br><br>" +
|
||||
"-Different employees excel in different jobs. For example, the highly intelligent employees will probably do best " +
|
||||
"if they are assigned to do Engineering work or Research & Development.<br><br>" +
|
||||
"-If your employees have low morale, energy, or happiness, their production will greatly suffer.<br><br>" +
|
||||
"-Tech is important, but don't neglect sales! Having several Businessmen can boost your sales and your bottom line.<br><br>" +
|
||||
"-Don't forget to advertise your company. You won't have any business if nobody knows you.<br><br>" +
|
||||
"-Having company awareness is great, but what's really important is your company's popularity. Try to keep " +
|
||||
"your popularity as high as possible to see the biggest benefit for your sales<br><br>";
|
||||
txt = "<u>Getting Started with Corporations</u><br>" +
|
||||
"To get started, visit the City Hall in Sector-12 in order to create a Corporation. This requires " +
|
||||
"$150b of your own money, but this $150b will get put into your Corporation's funds. " +
|
||||
"After creating your Corporation, you will see it listed as one of the locations in the city. Click on " +
|
||||
"your Corporation in order to manage it.<br><br>" +
|
||||
"Your Corporation can have many different divisions, each in a different Industry. There are many different " +
|
||||
"types of Industries, each with different properties. To create your first division, click the " +
|
||||
"'Expand into new Industry' button at the top of the management UI. The Agriculture " +
|
||||
"and Software industries are recommended for your first division.<br><br>" +
|
||||
"The first thing you'll need to do is hire some employees. Employees can be assigned to five different positions. " +
|
||||
"Each position has a different effect on various aspects of your Corporation. It is recommended to have at least " +
|
||||
"one employee at each position.<br><br>" +
|
||||
"Each industry uses some combination of Materials in order to produce other Materials and/or create Products. " +
|
||||
"Specific information about this is displayed in each of your divisions' UI.<br><br>" +
|
||||
"Products are special, industry-specific objects. They are different than Materials because you " +
|
||||
"must manually choose to develop them, and you can choose to develop any number of Products. Developing " +
|
||||
"a Product takes time, but a Product typically generates significantly more revenue than any Material. " +
|
||||
"Not all industries allow you to create Products. To create a Product, look for a button " +
|
||||
"in the top-left panel of the division UI (e.g. For the Software Industry, the button says 'Develop Software').<br><br>" +
|
||||
"To get your supply chain system started, " +
|
||||
"purchase the Materials that your industry needs to produce other Materials/Products. This can be done " +
|
||||
"by clicking the 'Buy' button next to the corresponding Material(s). After you have the required Materials, " +
|
||||
"you will immediately start production. The amount of Materials/Products you produce is based on a variety of factors, " +
|
||||
"one of which is your employees and their productivity.<br><br>" +
|
||||
"Once you start producing Materials/Products, you can sell them in order to start earning revenue. This can be done " +
|
||||
"by clicking the 'Sell' button next to the corresponding Material or Product. The amount of Material/Product you sell is dependent " +
|
||||
"on a wide variety of different factors.<br><br>" +
|
||||
"These are the basics of getting your Corporation up and running! Now, you can start purchasing upgrades to improve " +
|
||||
"your bottom line. If you need money, consider looking for seed investors, who will give you money in exchange for stock shares. " +
|
||||
"Otherwise, once you feel you are ready, take your Corporation public! Once your Corporation goes public, you can no longer " +
|
||||
"find investors. Instead, your Corporation will be publicly traded and its stock price will change based on how well " +
|
||||
"it's performing financially. You can then sell your stock shares in order to make money.<br><br>" +
|
||||
"<u>Tips/Pointers</u><br>" +
|
||||
"-Purchasing Hardware, Robots, AI Cores, and Real Estate can potentially increase your production. " +
|
||||
"The effects of these depend on what industry you are in.<br><br>" +
|
||||
"-In order to optimize your production, you will need a good balance of Operators, Managers, and Engineers<br><br>" +
|
||||
"-Different employees excel in different jobs. For example, the highly intelligent employees will probably do best " +
|
||||
"if they are assigned to do Engineering work or Research & Development.<br><br>" +
|
||||
"-If your employees have low morale, energy, or happiness, their production will greatly suffer.<br><br>" +
|
||||
"-Tech is important, but don't neglect sales! Having several Businessmen can boost your sales and your bottom line.<br><br>" +
|
||||
"-Don't forget to advertise your company. You won't have any business if nobody knows you.<br><br>" +
|
||||
"-Having company awareness is great, but what's really important is your company's popularity. Try to keep " +
|
||||
"your popularity as high as possible to see the biggest benefit for your sales<br><br>" +
|
||||
"-Remember, you need to spend money to make money!<br><br>" +
|
||||
"-Corporations do not reset when installing Augmentations, but they do reset when destroying a BitNode";
|
||||
Literatures[fn] = new Literature(title, fn, txt);
|
||||
|
||||
title = "A Green Tomorrow";
|
||||
|
@ -42,7 +42,7 @@ function showMessage(msg) {
|
||||
var txt = "Message received from unknown sender: <br><br>" +
|
||||
"<i>" + msg.msg + "</i><br><br>" +
|
||||
"This message was saved as " + msg.filename + " onto your home computer.";
|
||||
dialogBoxCreate(txt, true);
|
||||
dialogBoxCreate(txt);
|
||||
}
|
||||
|
||||
//Adds a message to a server
|
||||
|
@ -1162,14 +1162,16 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
|
||||
|
||||
var targetNode = null, def, atk;
|
||||
if (nodeObj.conn) {
|
||||
var targetNode;
|
||||
if (nodeObj.conn.target) {
|
||||
if (nodeObj.conn.target != null) {
|
||||
targetNode = this.getNodeFromElement(nodeObj.conn.target);
|
||||
} else {
|
||||
targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
|
||||
}
|
||||
|
||||
if (targetNode.plyrCtrl) {
|
||||
if (targetNode == null) {
|
||||
//Player is in the middle of dragging the connection,
|
||||
//so the target node is null. Do nothing here
|
||||
} else if (targetNode.plyrCtrl) {
|
||||
def = this.playerDef;
|
||||
atk = this.enemyAtk;
|
||||
} else if (targetNode.enmyCtrl) {
|
||||
@ -1186,17 +1188,20 @@ HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
|
||||
var enmyHacking = this.difficulty * CONSTANTS.HackingMissionDifficultyToHacking;
|
||||
switch(nodeObj.action) {
|
||||
case NodeActions.Attack:
|
||||
if (targetNode == null) {break;}
|
||||
if (nodeObj.conn == null) {break;}
|
||||
var dmg = this.calculateAttackDamage(atk, def, plyr ? Player.hacking_skill : enmyHacking);
|
||||
targetNode.hp -= (dmg/5 * numCycles);
|
||||
break;
|
||||
case NodeActions.Scan:
|
||||
if (targetNode == null) {break;}
|
||||
if (nodeObj.conn == null) {break;}
|
||||
var eff = this.calculateScanEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);
|
||||
targetNode.def -= (eff/5 * numCycles);
|
||||
calcStats = true;
|
||||
break;
|
||||
case NodeActions.Weaken:
|
||||
if (targetNode == null) {break;}
|
||||
if (nodeObj.conn == null) {break;}
|
||||
var eff = this.calculateWeakenEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);
|
||||
targetNode.atk -= (eff/5 * numCycles);
|
||||
|
@ -75,19 +75,6 @@ Environment.prototype = {
|
||||
}
|
||||
return res[idx[idx.length-1]] = value;
|
||||
},
|
||||
/*
|
||||
setArrayElement: function(name, idx, value) {
|
||||
var scope = this.lookup(name);
|
||||
if (!scope && this.parent) {
|
||||
console.log("Here");
|
||||
throw new Error("Undefined variable " + name);
|
||||
}
|
||||
var arr = (scope || this).vars[name];
|
||||
if (!(arr.constructor === Array || arr instanceof Array)) {
|
||||
throw new Error("Variable is not an array: " + name);
|
||||
}
|
||||
return (scope || this).vars[name][idx] = value;
|
||||
},*/
|
||||
|
||||
//Creates (or overwrites) a variable in the current scope
|
||||
def: function(name, value) {
|
||||
|
@ -27,7 +27,6 @@ Promise.config({
|
||||
* Returns a promise
|
||||
*/
|
||||
function evaluate(exp, workerScript) {
|
||||
/* return new Promise(function(resolve, reject) {*/
|
||||
return Promise.delay(Settings.CodeInstructionRunTime).then(function() {
|
||||
var env = workerScript.env;
|
||||
if (env.stopFlag) {return Promise.reject(workerScript);}
|
||||
@ -139,6 +138,13 @@ function evaluate(exp, workerScript) {
|
||||
} else if (exp.callee.type == "MemberExpression"){
|
||||
return evaluate(exp.callee.object, workerScript).then(function(object) {
|
||||
try {
|
||||
if (func === "NETSCRIPTFOREACH") {
|
||||
return evaluateForeach(object, args, workerScript).then(function(res) {
|
||||
return Promise.resolve(res);
|
||||
}).catch(function(e) {
|
||||
return Promise.reject(e);
|
||||
});
|
||||
}
|
||||
var res = func.apply(object,args);
|
||||
return Promise.resolve(res);
|
||||
} catch (e) {
|
||||
@ -187,6 +193,9 @@ function evaluate(exp, workerScript) {
|
||||
if (exp.property.name === "constructor") {
|
||||
return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it."));
|
||||
}
|
||||
if (object != null && object instanceof Array && exp.property.name === "forEach") {
|
||||
return "NETSCRIPTFOREACH";
|
||||
}
|
||||
try {
|
||||
return Promise.resolve(object[exp.property.name])
|
||||
} catch (e) {
|
||||
@ -537,35 +546,43 @@ function evaluateFor(exp, workerScript) {
|
||||
}
|
||||
recurse();
|
||||
});
|
||||
/*
|
||||
return evaluate(exp.test, workerScript).then(function(resCond) {
|
||||
if (resCond) {
|
||||
//Execute code (body), update, and then recurse
|
||||
return evaluate(exp.body, workerScript).then(function(resCode) {
|
||||
return evaluate(exp.update, workerScript);
|
||||
}).catch(function(e) {
|
||||
if (e == "CONTINUESTATEMENT" ||
|
||||
(e instanceof WorkerScript && e.errorMessage == "CONTINUESTATEMENT")) {
|
||||
//Continue statement, recurse to next iteration
|
||||
return evaluate(exp.update, workerScript).then(function(resPostloop) {
|
||||
return evaluateFor(exp, workerScript);
|
||||
}).then(function(foo) {
|
||||
return Promise.resolve("endForLoop");
|
||||
}).catch(function(e) {
|
||||
return Promise.reject(e);
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}).then(function(resPostloop) {
|
||||
return evaluateFor(exp, workerScript);
|
||||
}).then(function(foo) {
|
||||
return Promise.resolve("endForLoop");
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve("endForLoop"); //Doesn't need to resolve to any particular value
|
||||
}
|
||||
|
||||
function evaluateForeach(arr, args, workerScript) {
|
||||
console.log("evaluateForeach called");
|
||||
if (!(arr instanceof Array)) {
|
||||
return Promise.reject("Invalid array passed into forEach");
|
||||
}
|
||||
if (!(args instanceof Array) && args.length != 1) {
|
||||
return Promise.reject("Invalid argument passed into forEach");
|
||||
}
|
||||
var func = args[0];
|
||||
if (typeof func !== "function") {
|
||||
return Promise.reject("Invalid function passed into forEach");
|
||||
}
|
||||
console.log(func);
|
||||
return new Promise(function(resolve, reject) {
|
||||
//Don't return a promise so the promise chain is broken on each recursion
|
||||
function recurse(i) {
|
||||
console.log("recurse() called with i: " + i);
|
||||
if (i >= arr.length) {
|
||||
resolve();
|
||||
} else {
|
||||
return Promise.delay(Settings.CodeInstructionRunTime).then(function() {
|
||||
console.log("About to apply function");
|
||||
var res = func.apply(null, [arr[i]]);
|
||||
console.log("Applied function");
|
||||
++i;
|
||||
Promise.resolve(res).then(function(val) {
|
||||
recurse(i);
|
||||
}, reject).catch(function(e) {
|
||||
return Promise.reject(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});*/
|
||||
recurse(0);
|
||||
});
|
||||
}
|
||||
|
||||
function evaluateWhile(exp, workerScript) {
|
||||
@ -703,6 +720,14 @@ function runScriptFromScript(server, scriptname, args, workerScript, threads=1)
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
//'null/undefined' arguments are not allowed
|
||||
for (var i = 0; i < args.length; ++i) {
|
||||
if (args[i] == null) {
|
||||
workerScript.scriptRef.log("ERROR: Cannot execute a script with null/undefined as an argument");
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
}
|
||||
|
||||
//Check if the script exists and if it does run it
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
if (server.scripts[i].filename == scriptname) {
|
||||
|
@ -128,7 +128,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
out.push(entry);
|
||||
}
|
||||
workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {
|
||||
workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
|
||||
}
|
||||
return out;
|
||||
},
|
||||
hack : function(ip){
|
||||
@ -165,8 +167,9 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
|
||||
}
|
||||
|
||||
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
|
||||
//console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
||||
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
|
||||
}
|
||||
return netscriptDelay(hackingTime* 1000, workerScript).then(function() {
|
||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||
var hackChance = scriptCalculateHackingChance(server);
|
||||
@ -192,26 +195,28 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
||||
Player.gainHackingExp(expGainedOnSuccess);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
||||
//console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp");
|
||||
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
||||
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
|
||||
}
|
||||
server.fortify(CONSTANTS.ServerFortifyAmount * threads);
|
||||
return Promise.resolve(true);
|
||||
return Promise.resolve(moneyGained);
|
||||
} else {
|
||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||
//Player only gains 25% exp for failure?
|
||||
Player.gainHackingExp(expGainedOnFailure);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
|
||||
//console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp");
|
||||
workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
|
||||
return Promise.resolve(false);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
||||
workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
|
||||
}
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
});
|
||||
},
|
||||
sleep : function(time,log=true){
|
||||
sleep : function(time){
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
if (time === undefined) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument");
|
||||
}
|
||||
if (log) {
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {
|
||||
workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
|
||||
}
|
||||
return netscriptDelay(time, workerScript).then(function() {
|
||||
@ -245,8 +250,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
|
||||
var growTime = scriptCalculateGrowTime(server);
|
||||
//console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds")
|
||||
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
||||
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")");
|
||||
}
|
||||
return netscriptDelay(growTime, workerScript).then(function() {
|
||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
|
||||
@ -256,9 +262,11 @@ function NetscriptFunctions(workerScript) {
|
||||
if (growthPercentage == 1) {
|
||||
expGain = 0;
|
||||
}
|
||||
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by "
|
||||
+ formatNumber(growthPercentage*100 - 100, 6) + "%. Gained " +
|
||||
formatNumber(expGain, 4) + " hacking exp (t=" + threads +")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
||||
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
|
||||
formatNumber(growthPercentage*100 - 100, 6) + "%. Gained " +
|
||||
formatNumber(expGain, 4) + " hacking exp (t=" + threads +")");
|
||||
}
|
||||
workerScript.scriptRef.onlineExpGained += expGain;
|
||||
Player.gainHackingExp(expGain);
|
||||
return Promise.resolve(growthPercentage);
|
||||
@ -291,15 +299,19 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
|
||||
var weakenTime = scriptCalculateWeakenTime(server);
|
||||
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
||||
formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
||||
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
||||
formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
|
||||
}
|
||||
return netscriptDelay(weakenTime, workerScript).then(function() {
|
||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||
server.weaken(CONSTANTS.ServerWeakenAmount * threads);
|
||||
workerScript.scriptRef.recordWeaken(server.ip, threads);
|
||||
var expGain = scriptCalculateExpGain(server) * threads;
|
||||
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
|
||||
". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
||||
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
|
||||
". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")");
|
||||
}
|
||||
workerScript.scriptRef.onlineExpGained += expGain;
|
||||
Player.gainHackingExp(expGain);
|
||||
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);
|
||||
@ -331,6 +343,16 @@ function NetscriptFunctions(workerScript) {
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
workerScript.scriptRef.clearLog();
|
||||
},
|
||||
disableLog : function(fn) {
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
workerScript.disableLogs[fn] = true;
|
||||
workerScript.scriptRef.log("Disabled logging for " + fn);
|
||||
},
|
||||
enableLog : function(fn) {
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
delete workerScript.disableLogs[fn];
|
||||
workerScript.scriptRef.log("Enabled logging for " + fn);
|
||||
},
|
||||
nuke : function(ip){
|
||||
if (workerScript.checkingRam) {
|
||||
if (workerScript.loadedFns.nuke) {
|
||||
@ -355,10 +377,14 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Not enough ports opened to use NUKE.exe virus");
|
||||
}
|
||||
if (server.hasAdminRights) {
|
||||
workerScript.scriptRef.log("Already have root access to " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
|
||||
workerScript.scriptRef.log("Already have root access to " + server.hostname);
|
||||
}
|
||||
} else {
|
||||
server.hasAdminRights = true;
|
||||
workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
|
||||
workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -384,11 +410,15 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the BruteSSH.exe program!");
|
||||
}
|
||||
if (!server.sshPortOpen) {
|
||||
workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
|
||||
workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
|
||||
}
|
||||
server.sshPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
|
||||
workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -413,11 +443,15 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the FTPCrack.exe program!");
|
||||
}
|
||||
if (!server.ftpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
|
||||
workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
|
||||
}
|
||||
server.ftpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
|
||||
workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -442,11 +476,15 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the relaySMTP.exe program!");
|
||||
}
|
||||
if (!server.smtpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
|
||||
workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
|
||||
}
|
||||
server.smtpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
|
||||
workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -471,11 +509,15 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the HTTPWorm.exe program!");
|
||||
}
|
||||
if (!server.httpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
|
||||
workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
|
||||
}
|
||||
server.httpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
|
||||
workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -500,11 +542,15 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "You do not have the SQLInject.exe program!");
|
||||
}
|
||||
if (!server.sqlPortOpen) {
|
||||
workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
|
||||
workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
|
||||
}
|
||||
server.sqlPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
|
||||
workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -574,7 +620,9 @@ function NetscriptFunctions(workerScript) {
|
||||
setTimeout(()=>{
|
||||
NetscriptFunctions(workerScript).run.apply(this, arguments);
|
||||
}, 20000);
|
||||
workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {
|
||||
workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
|
||||
}
|
||||
NetscriptFunctions(workerScript).exit();
|
||||
},
|
||||
kill : function(filename,ip) {
|
||||
@ -606,10 +654,14 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
var res = killWorkerScript(runningScriptObj, server.ip);
|
||||
if (res) {
|
||||
workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
|
||||
workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget));
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
|
||||
workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + printArray(argsForKillTarget));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -631,11 +683,14 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
var scriptsRunning = (server.runningScripts.length > 0);
|
||||
for (var i = server.runningScripts.length-1; i >= 0; --i) {
|
||||
killWorkerScript(server.runningScripts[i], server.ip);
|
||||
}
|
||||
workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
|
||||
return true;
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
|
||||
workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
|
||||
}
|
||||
return scriptsRunning;
|
||||
},
|
||||
exit : function() {
|
||||
if (workerScript.checkingRam) {
|
||||
@ -678,8 +733,9 @@ function NetscriptFunctions(workerScript) {
|
||||
});
|
||||
return res;
|
||||
}
|
||||
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Error: scp() only works for .script and .lit files");
|
||||
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
|
||||
!scriptname.endsWith("txt")) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Error: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
|
||||
}
|
||||
|
||||
var destServer, currServ;
|
||||
@ -718,6 +774,7 @@ function NetscriptFunctions(workerScript) {
|
||||
for (var i = 0; i < currServ.messages.length; ++i) {
|
||||
if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,12 +785,50 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
for (var i = 0; i < destServer.messages.length; ++i) {
|
||||
if (destServer.messages[i] === scriptname) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
return true; //Already exists
|
||||
}
|
||||
}
|
||||
destServer.messages.push(scriptname);
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Scp for text files
|
||||
if (scriptname.endsWith(".txt")) {
|
||||
var found = false, txtFile;
|
||||
for (var i = 0; i < currServ.textFiles.length; ++i) {
|
||||
if (currServ.textFiles[i].fn === scriptname) {
|
||||
found = true;
|
||||
txtFile = currServ.textFiles[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < destServer.textFiles.length; ++i) {
|
||||
if (destServer.textFiles[i].fn === scriptname) {
|
||||
//Overwrite
|
||||
destServer.textFiles[i].text = txtFile.text;
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
var newFile = new TextFile(txtFile.fn, txtFile.text);
|
||||
destServer.textFiles.push(newFile);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -753,8 +848,10 @@ function NetscriptFunctions(workerScript) {
|
||||
//Overwrite script if it already exists
|
||||
for (var i = 0; i < destServer.scripts.length; ++i) {
|
||||
if (scriptname == destServer.scripts[i].filename) {
|
||||
workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
|
||||
workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
|
||||
workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
|
||||
}
|
||||
var oldScript = destServer.scripts[i];
|
||||
oldScript.code = sourceScript.code;
|
||||
oldScript.ramUsage = sourceScript.ramUsage;
|
||||
@ -769,7 +866,9 @@ function NetscriptFunctions(workerScript) {
|
||||
newScript.ramUsage = sourceScript.ramUsage;
|
||||
newScript.server = destServer.ip;
|
||||
destServer.scripts.push(newScript);
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
ls : function(ip, grep) {
|
||||
@ -907,7 +1006,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
}
|
||||
Player.updateSkillLevels();
|
||||
workerScript.scriptRef.log("getHackingLevel() returned " + Player.hacking_skill);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
|
||||
workerScript.scriptRef.log("getHackingLevel() returned " + Player.hacking_skill);
|
||||
}
|
||||
return Player.hacking_skill;
|
||||
},
|
||||
getHackingMultipliers : function() {
|
||||
@ -956,10 +1057,14 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (server.hostname == "home") {
|
||||
//Return player's money
|
||||
workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2));
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
|
||||
workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + formatNumber(Player.money.toNumber(), 2));
|
||||
}
|
||||
return Player.money.toNumber();
|
||||
}
|
||||
workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
|
||||
workerScript.scriptRef.log("getServerMoneyAvailable() returned " + formatNumber(server.moneyAvailable, 2) + " for " + server.hostname);
|
||||
}
|
||||
return server.moneyAvailable;
|
||||
},
|
||||
getServerSecurityLevel : function(ip){
|
||||
@ -976,7 +1081,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerSecurityLevel() returned " + formatNumber(server.hackDifficulty, 3) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
|
||||
workerScript.scriptRef.log("getServerSecurityLevel() returned " + formatNumber(server.hackDifficulty, 3) + " for " + server.hostname);
|
||||
}
|
||||
return server.hackDifficulty;
|
||||
},
|
||||
getServerBaseSecurityLevel : function(ip){
|
||||
@ -993,7 +1100,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + formatNumber(server.baseDifficulty, 3) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
|
||||
workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + formatNumber(server.baseDifficulty, 3) + " for " + server.hostname);
|
||||
}
|
||||
return server.baseDifficulty;
|
||||
},
|
||||
getServerMinSecurityLevel : function(ip) {
|
||||
@ -1010,7 +1119,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + formatNumber(server.minDifficulty, 3) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
|
||||
workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + formatNumber(server.minDifficulty, 3) + " for " + server.hostname);
|
||||
}
|
||||
return server.minDifficulty;
|
||||
},
|
||||
getServerRequiredHackingLevel : function(ip) {
|
||||
@ -1027,7 +1138,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + formatNumber(server.requiredHackingSkill, 0) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
|
||||
workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + formatNumber(server.requiredHackingSkill, 0) + " for " + server.hostname);
|
||||
}
|
||||
return server.requiredHackingSkill;
|
||||
},
|
||||
getServerMaxMoney : function(ip){
|
||||
@ -1044,7 +1157,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerMaxMoney() returned " + formatNumber(server.moneyMax, 0) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
|
||||
workerScript.scriptRef.log("getServerMaxMoney() returned " + formatNumber(server.moneyMax, 0) + " for " + server.hostname);
|
||||
}
|
||||
return server.moneyMax;
|
||||
},
|
||||
getServerGrowth : function(ip) {
|
||||
@ -1061,7 +1176,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerGrowth() returned " + formatNumber(server.serverGrowth, 0) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
|
||||
workerScript.scriptRef.log("getServerGrowth() returned " + formatNumber(server.serverGrowth, 0) + " for " + server.hostname);
|
||||
}
|
||||
return server.serverGrowth;
|
||||
},
|
||||
getServerNumPortsRequired : function(ip) {
|
||||
@ -1078,7 +1195,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerNumPortsRequired() returned " + formatNumber(server.numOpenPortsRequired, 0) + " for " + server.hostname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
|
||||
workerScript.scriptRef.log("getServerNumPortsRequired() returned " + formatNumber(server.numOpenPortsRequired, 0) + " for " + server.hostname);
|
||||
}
|
||||
return server.numOpenPortsRequired;
|
||||
},
|
||||
getServerRam : function(ip) {
|
||||
@ -1095,7 +1214,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
workerScript.scriptRef.log("getServerRam() returned [" + formatNumber(server.maxRam, 2) + "GB, " + formatNumber(server.ramUsed, 2) + "GB]");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
|
||||
workerScript.scriptRef.log("getServerRam() returned [" + formatNumber(server.maxRam, 2) + "GB, " + formatNumber(server.ramUsed, 2) + "GB]");
|
||||
}
|
||||
return [server.maxRam, server.ramUsed];
|
||||
},
|
||||
serverExists : function(ip) {
|
||||
@ -1177,7 +1298,7 @@ function NetscriptFunctions(workerScript) {
|
||||
return 0;
|
||||
} else {
|
||||
workerScript.loadedFns.getNextHacknetNodeCost = true;
|
||||
return CONSTANTS.ScriptHacknetNodesRamCost;
|
||||
return CONSTANTS.ScriptPurchaseHacknetRamCost;
|
||||
}
|
||||
}
|
||||
return getCostOfNextHacknetNode();
|
||||
@ -1269,8 +1390,10 @@ function NetscriptFunctions(workerScript) {
|
||||
if (Engine.currentPage == Engine.Page.StockMarket) {
|
||||
updateStockPlayerPosition(stock);
|
||||
}
|
||||
workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
|
||||
workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share");
|
||||
}
|
||||
return stock.price;
|
||||
},
|
||||
sellStock : function(symbol, shares) {
|
||||
@ -1312,9 +1435,11 @@ function NetscriptFunctions(workerScript) {
|
||||
if (Engine.currentPage == Engine.Page.StockMarket) {
|
||||
updateStockPlayerPosition(stock);
|
||||
}
|
||||
workerScript.scriptRef.log("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share. Gained " +
|
||||
"$" + formatNumber(gains, 2));
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
|
||||
workerScript.scriptRef.log("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share. Gained " +
|
||||
"$" + formatNumber(gains, 2));
|
||||
}
|
||||
return stock.price;
|
||||
},
|
||||
shortStock(symbol, shares) {
|
||||
@ -1507,7 +1632,9 @@ function NetscriptFunctions(workerScript) {
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
newServ.serversOnNetwork.push(homeComputer.ip);
|
||||
Player.loseMoney(cost);
|
||||
workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2));
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
|
||||
workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + formatNumber(cost, 2));
|
||||
}
|
||||
return newServ.hostname;
|
||||
},
|
||||
deleteServer : function(hostname) {
|
||||
@ -1572,7 +1699,9 @@ function NetscriptFunctions(workerScript) {
|
||||
for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
|
||||
if (ip == homeComputer.serversOnNetwork[i]) {
|
||||
homeComputer.serversOnNetwork.splice(i, 1);
|
||||
workerScript.scriptRef.log("Deleted server " + hostnameStr);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {
|
||||
workerScript.scriptRef.log("Deleted server " + hostnameStr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1604,10 +1733,6 @@ function NetscriptFunctions(workerScript) {
|
||||
});
|
||||
return res;
|
||||
},
|
||||
round : function(n) {
|
||||
if (isNaN(n)) {return 0;}
|
||||
return Math.round(n);
|
||||
},
|
||||
write : function(port, data="", mode="a") {
|
||||
if (workerScript.checkingRam) {
|
||||
if (workerScript.loadedFns.write) {
|
||||
@ -1673,7 +1798,7 @@ function NetscriptFunctions(workerScript) {
|
||||
if (port == null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
|
||||
}
|
||||
if (port.length == 0) {
|
||||
if (port.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
return port.shift();
|
||||
@ -1694,6 +1819,30 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for read(): " + port);
|
||||
}
|
||||
},
|
||||
peek : function(port) {
|
||||
if (workerScript.checkingRam) {
|
||||
if (workerScript.loadedFns.peek) {
|
||||
return 0;
|
||||
} else {
|
||||
workerScript.loadedFns.peek = true;
|
||||
return CONSTANTS.ScriptReadWriteRamCost;
|
||||
}
|
||||
}
|
||||
if (isNaN(port) || port < 1 || port > 10) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and 10");
|
||||
}
|
||||
var portName = "Port" + String(port);
|
||||
var port = NetscriptPorts[portName];
|
||||
if (port == null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
|
||||
}
|
||||
if (port.length === 0) {
|
||||
return "NULL PORT DATA";
|
||||
} else {
|
||||
var foo = port.slice();
|
||||
return foo[0];
|
||||
}
|
||||
},
|
||||
clear : function(port) {
|
||||
if (workerScript.checkingRam) {
|
||||
if (workerScript.loadedFns.clear) {
|
||||
@ -2020,7 +2169,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
|
||||
var costMult, expMult;
|
||||
@ -2082,7 +2233,9 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
Player.startClass(costMult, expMult, task);
|
||||
workerScript.scriptRef.log("Started " + task + " at " + universityName);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
|
||||
workerScript.scriptRef.log("Started " + task + " at " + universityName);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -2109,7 +2262,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
var costMult, expMult;
|
||||
switch(gymName.toLowerCase()) {
|
||||
@ -2184,7 +2339,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed");
|
||||
return false;
|
||||
}
|
||||
workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
|
||||
workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -2216,7 +2373,9 @@ function NetscriptFunctions(workerScript) {
|
||||
Player.loseMoney(200000);
|
||||
Player.city = cityname;
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.scriptRef.log("Traveled to " + cityname);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {
|
||||
workerScript.scriptRef.log("Traveled to " + cityname);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity().");
|
||||
@ -2262,7 +2421,9 @@ function NetscriptFunctions(workerScript) {
|
||||
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
||||
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.scriptRef.log("You have purchased a Tor router!");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
|
||||
workerScript.scriptRef.log("You have purchased a Tor router!");
|
||||
}
|
||||
return true;
|
||||
},
|
||||
purchaseProgram(programName) {
|
||||
@ -2294,8 +2455,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);
|
||||
workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2306,8 +2468,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);
|
||||
workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2318,8 +2481,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);
|
||||
workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2330,8 +2494,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);
|
||||
workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2342,8 +2507,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);
|
||||
workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2354,8 +2520,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV1);
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2366,8 +2533,9 @@ function NetscriptFunctions(workerScript) {
|
||||
if (price > 0 && Player.money.gt(price)) {
|
||||
Player.loseMoney(price);
|
||||
Player.getHomeComputer().programs.push(Programs.DeepscanV2);
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program " +
|
||||
"can be found on your home computer.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
|
||||
workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + programName);
|
||||
return false;
|
||||
@ -2439,7 +2607,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -2483,7 +2653,9 @@ function NetscriptFunctions(workerScript) {
|
||||
Player.loseMoney(cost);
|
||||
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {
|
||||
workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
|
||||
}
|
||||
return true;
|
||||
},
|
||||
getUpgradeHomeRamCost() {
|
||||
@ -2544,7 +2716,9 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
|
||||
if (Player.companyPosition.isPartTimeJob()) {
|
||||
@ -2552,7 +2726,9 @@ function NetscriptFunctions(workerScript) {
|
||||
} else {
|
||||
Player.startWork();
|
||||
}
|
||||
workerScript.scriptRef.log("Began working at " + Player.companyName + " as a " + Player.companyPosition.positionName);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
|
||||
workerScript.scriptRef.log("Began working at " + Player.companyName + " as a " + Player.companyPosition.positionName);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
applyToCompany(companyName, field) {
|
||||
@ -2630,9 +2806,13 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
if (res) {
|
||||
workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + Player.companyPosition.positionName);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
|
||||
workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + Player.companyPosition.positionName);
|
||||
}
|
||||
} else {
|
||||
workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
|
||||
workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
@ -2719,7 +2899,9 @@ function NetscriptFunctions(workerScript) {
|
||||
var fac = Factions[name];
|
||||
joinFaction(fac);
|
||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||
workerScript.scriptRef.log("Joined the " + name + " faction.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
|
||||
workerScript.scriptRef.log("Joined the " + name + " faction.");
|
||||
}
|
||||
return true;
|
||||
},
|
||||
workForFaction(name, type) {
|
||||
@ -2757,7 +2939,9 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
|
||||
var fac = Factions[name];
|
||||
@ -2866,7 +3050,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
|
||||
switch(name.toLowerCase()) {
|
||||
@ -2966,7 +3152,9 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (Player.isWorking) {
|
||||
var txt = Player.singularityStopWork();
|
||||
workerScript.scriptRef.log(txt);
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
|
||||
workerScript.scriptRef.log(txt);
|
||||
}
|
||||
}
|
||||
|
||||
//Set Location to slums
|
||||
|
@ -19,16 +19,17 @@ function WorkerScript(runningScriptObj) {
|
||||
this.serverIp = null;
|
||||
this.code = runningScriptObj.scriptRef.code;
|
||||
this.env = new Environment(this);
|
||||
this.env.set("args", runningScriptObj.args);
|
||||
this.env.set("args", runningScriptObj.args.slice());
|
||||
this.output = "";
|
||||
this.ramUsage = 0;
|
||||
this.scriptRef = runningScriptObj;
|
||||
this.errorMessage = "";
|
||||
this.args = runningScriptObj.args;
|
||||
this.args = runningScriptObj.args.slice();
|
||||
this.delay = null;
|
||||
this.fnWorker = null; //Workerscript for a function call
|
||||
this.checkingRam = false;
|
||||
this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM
|
||||
this.disableLogs = {}; //Stores names of fns that should have logs disabled
|
||||
}
|
||||
|
||||
//Returns the server on which the workerScript is running
|
||||
|
@ -1069,8 +1069,9 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
|
||||
}
|
||||
|
||||
var txt = document.getElementById("work-in-progress-text");
|
||||
txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name + "." +
|
||||
" You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
||||
txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name +
|
||||
" (Current Faction Reputation: " + formatNumber(faction.playerReputation, 0) + "). " +
|
||||
"You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
||||
"You have earned: <br><br>" +
|
||||
"$" + formatNumber(this.workMoneyGained, 2) + " (" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
|
||||
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this faction <br><br>" +
|
||||
@ -1949,21 +1950,17 @@ PlayerObject.prototype.reapplyAllAugmentations = function(resetMultipliers=true)
|
||||
|
||||
for (let i = 0; i < this.augmentations.length; ++i) {
|
||||
//Compatibility with new version
|
||||
if (typeof this.augmentations[i] === 'string' || this.augmentations[i] instanceof String) {
|
||||
var newOwnedAug = new PlayerOwnedAugmentation(this.augmentations[i]);
|
||||
if (this.augmentations[i] == AugmentationNames.NeuroFluxGovernor) {
|
||||
newOwnedAug.level = Augmentations[AugmentationNames.NeuroFluxGovernor].level;
|
||||
}
|
||||
this.augmentations[i] = newOwnedAug;
|
||||
if (this.augmentations[i].name === "HacknetNode NIC Architecture Neural-Upload") {
|
||||
this.augmentations[i].name = "Hacknet Node NIC Architecture Neural-Upload";
|
||||
}
|
||||
|
||||
var augName = this.augmentations[i].name;
|
||||
var aug = Augmentations[augName];
|
||||
aug.owned = true;
|
||||
if (aug == null) {
|
||||
console.log("WARNING: Invalid augmentation name");
|
||||
continue;
|
||||
}
|
||||
aug.owned = true;
|
||||
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
||||
for (let j = 0; j < aug.level; ++j) {
|
||||
applyAugmentation(this.augmentations[i], true);
|
||||
|
@ -25,6 +25,7 @@ import {initStockMarket, initSymbolToStockMap,
|
||||
setStockMarketContentCreated} from "./StockMarket.js";
|
||||
import {Terminal, postNetburnerText} from "./Terminal.js";
|
||||
import Decimal from '../utils/decimal.js';
|
||||
import {dialogBoxCreate} from "../utils/DialogBox.js";
|
||||
|
||||
//Prestige by purchasing augmentation
|
||||
function prestigeAugmentation() {
|
||||
@ -148,11 +149,8 @@ function prestigeAugmentation() {
|
||||
function prestigeSourceFile() {
|
||||
initBitNodeMultipliers();
|
||||
|
||||
//Crime statistics
|
||||
Player.prestigeSourceFile();
|
||||
|
||||
//Delete all Worker Scripts objects
|
||||
prestigeWorkerScripts();
|
||||
prestigeWorkerScripts(); //Delete all Worker Scripts objects
|
||||
|
||||
var homeComp = Player.getHomeComputer();
|
||||
|
||||
@ -234,7 +232,7 @@ function prestigeSourceFile() {
|
||||
//Reinitialize Bit Node flags
|
||||
initSingularitySFFlags();
|
||||
|
||||
//Reset Stock market
|
||||
//Reset Stock market, gang, and corporation
|
||||
if (Player.hasWseAccount) {
|
||||
initStockMarket();
|
||||
initSymbolToStockMap();
|
||||
@ -245,11 +243,17 @@ function prestigeSourceFile() {
|
||||
stockMarketList.removeChild(stockMarketList.firstChild);
|
||||
}
|
||||
|
||||
Player.gang = null;
|
||||
Player.corporation = null;
|
||||
|
||||
|
||||
//BitNode 3, get Handbook .lit file
|
||||
homeComp.messages.push("corporation-management-handbook.lit");
|
||||
dialogBoxCreate("You received a copy of the Corporation Management Handbook on your home computer. " +
|
||||
"Read it if you need help getting started with Corporations!");
|
||||
|
||||
//Gain int exp
|
||||
Player.gainIntelligenceExp(5);
|
||||
|
||||
//Reset gang
|
||||
Player.gang = null;
|
||||
}
|
||||
|
||||
export {prestigeAugmentation, prestigeSourceFile};
|
||||
|
@ -76,7 +76,7 @@ function scriptEditorInit() {
|
||||
|
||||
var documentationButton = createElement("a", {
|
||||
display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation",
|
||||
href:"https://bitburner.wikia.com/wiki/Netscript",
|
||||
href:"https://bitburner.readthedocs.io/en/latest/index.html",
|
||||
target:"_blank"
|
||||
});
|
||||
|
||||
|
@ -689,7 +689,7 @@ function processSingleServerGrowth(server, numCycles) {
|
||||
}
|
||||
|
||||
function prestigeHomeComputer(homeComp) {
|
||||
homeComp.programs.length = 0;
|
||||
homeComp.programs.length = 0; //Remove programs
|
||||
homeComp.runningScripts = [];
|
||||
homeComp.serversOnNetwork = [];
|
||||
homeComp.isConnectedTo = true;
|
||||
@ -701,7 +701,7 @@ function prestigeHomeComputer(homeComp) {
|
||||
script.updateRamUsage();
|
||||
});
|
||||
|
||||
homeComp.messages.length = 0;
|
||||
homeComp.messages.length = 0; //Remove .lit and .msg files
|
||||
homeComp.messages.push("hackers-starting-handbook.lit");
|
||||
}
|
||||
|
||||
|
@ -506,9 +506,11 @@ function shortStock(stock, shares, workerScript=null) {
|
||||
stock.playerAvgShortPx = newTotal / stock.playerShortShares;
|
||||
updateStockPlayerPosition(stock);
|
||||
if (tixApi) {
|
||||
workerScript.scriptRef.log("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at " +
|
||||
numeral(stock.price).format('($0.000a)') + " per share. Paid " +
|
||||
numeral(CONSTANTS.StockMarketCommission).format('($0.000a)') + " in commission fees.");
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
|
||||
workerScript.scriptRef.log("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at " +
|
||||
numeral(stock.price).format('($0.000a)') + " per share. Paid " +
|
||||
numeral(CONSTANTS.StockMarketCommission).format('($0.000a)') + " in commission fees.");
|
||||
}
|
||||
} else {
|
||||
dialogBoxCreate("Bought a short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share. You also paid $" +
|
||||
@ -548,9 +550,11 @@ function sellShort(stock, shares, workerScript=null) {
|
||||
}
|
||||
updateStockPlayerPosition(stock);
|
||||
if (tixApi) {
|
||||
workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
|
||||
numeral(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
|
||||
"a total of " + numeral(origCost + profit).format('($0.000a)'));
|
||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
|
||||
workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
|
||||
numeral(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
|
||||
"a total of " + numeral(origCost + profit).format('($0.000a)'));
|
||||
}
|
||||
} else {
|
||||
dialogBoxCreate("Sold your short position of " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share. After commissions, you gained " +
|
||||
|
@ -328,6 +328,9 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
allPos.push(currServ.messages[i]);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < currServ.textFiles.length; ++i) {
|
||||
allPos.push(currServ.textFiles[i].fn);
|
||||
}
|
||||
}
|
||||
|
||||
if (input.startsWith("connect ") || input.startsWith("telnet ")) {
|
||||
@ -1131,16 +1134,17 @@ let Terminal = {
|
||||
return;
|
||||
}
|
||||
var scriptname = args[0];
|
||||
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")){
|
||||
post("Error: scp only works for .script and .lit files");
|
||||
if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
|
||||
!scriptname.endsWith(".txt")){
|
||||
post("Error: scp only works for .script, .txt, and .lit files");
|
||||
return;
|
||||
}
|
||||
var server = getServer(args[1]);
|
||||
if (server == null) {
|
||||
var destServer = getServer(args[1]);
|
||||
if (destServer == null) {
|
||||
post("Invalid destination. " + args[1] + " not found");
|
||||
return;
|
||||
}
|
||||
var ip = server.ip;
|
||||
var ip = destServer.ip;
|
||||
var currServ = Player.getCurrentServer();
|
||||
|
||||
//Scp for lit files
|
||||
@ -1149,26 +1153,49 @@ let Terminal = {
|
||||
for (var i = 0; i < currServ.messages.length; ++i) {
|
||||
if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
post("Error: no such file exists!");
|
||||
return;
|
||||
}
|
||||
if (!found) {return post("Error: no such file exists!");}
|
||||
|
||||
for (var i = 0; i < server.messages.length; ++i) {
|
||||
if (server.messages[i] === scriptname) {
|
||||
post(scriptname + " copied over to " + server.hostname);
|
||||
for (var i = 0; i < destServer.messages.length; ++i) {
|
||||
if (destServer.messages[i] === scriptname) {
|
||||
post(scriptname + " copied over to " + destServer.hostname);
|
||||
return; //Already exists
|
||||
}
|
||||
}
|
||||
server.messages.push(scriptname);
|
||||
post(scriptname + " copied over to " + server.hostname);
|
||||
destServer.messages.push(scriptname);
|
||||
post(scriptname + " copied over to " + destServer.hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
//Scp for txt files
|
||||
if (scriptname.endsWith(".txt")) {
|
||||
var found = false, txtFile;
|
||||
for (var i = 0; i < currServ.textFiles.length; ++i) {
|
||||
if (currServ.textFiles[i].fn === scriptname) {
|
||||
found = true;
|
||||
txtFile = currServ.textFiles[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {return post("Error: no such file exists!");}
|
||||
|
||||
for (var i = 0; i < destServer.textFiles.length; ++i) {
|
||||
if (destServer.textFiles[i].fn === scriptname) {
|
||||
//Overwrite
|
||||
destServer.textFiles[i].text = txtFile.text;
|
||||
post("WARNING: " + scriptname + " already exists on " + destServer.hostname +
|
||||
"and will be overwriten");
|
||||
return post(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
}
|
||||
var newFile = new TextFile(txtFile.fn, txtFile.text);
|
||||
destServer.textFiles.push(newFile);
|
||||
return post(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
|
||||
//Get the current script
|
||||
var sourceScript = null;
|
||||
@ -1184,13 +1211,13 @@ let Terminal = {
|
||||
}
|
||||
|
||||
//Overwrite script if it exists
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
if (scriptname == server.scripts[i].filename) {
|
||||
post("WARNING: " + scriptname + " already exists on " + server.hostname + " and will be overwritten");
|
||||
var oldScript = server.scripts[i];
|
||||
for (var i = 0; i < destServer.scripts.length; ++i) {
|
||||
if (scriptname == destServer.scripts[i].filename) {
|
||||
post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten");
|
||||
var oldScript = destServer.scripts[i];
|
||||
oldScript.code = sourceScript.code;
|
||||
oldScript.ramUsage = sourceScript.ramUsage;
|
||||
post(scriptname + " overwriten on " + server.hostname);
|
||||
post(scriptname + " overwriten on " + destServer.hostname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1199,9 +1226,9 @@ let Terminal = {
|
||||
newScript.filename = scriptname;
|
||||
newScript.code = sourceScript.code;
|
||||
newScript.ramUsage = sourceScript.ramUsage;
|
||||
newScript.server = ip;
|
||||
server.scripts.push(newScript);
|
||||
post(scriptname + " copied over to " + server.hostname);
|
||||
newScript.destServer = ip;
|
||||
destServer.scripts.push(newScript);
|
||||
post(scriptname + " copied over to " + destServer.hostname);
|
||||
break;
|
||||
case "sudov":
|
||||
if (commandArray.length != 1) {
|
||||
|
@ -21,7 +21,7 @@ TextFile.prototype.read = function() {
|
||||
}
|
||||
|
||||
TextFile.prototype.show = function() {
|
||||
dialogBoxCreate(this.fn + "<br><br>" + this.text);
|
||||
dialogBoxCreate(this.fn + "<br><br>" + this.text, true);
|
||||
}
|
||||
|
||||
TextFile.prototype.download = function() {
|
||||
|
@ -100,6 +100,12 @@ function createElement(type, params) {
|
||||
class:"tooltiptext",
|
||||
innerHTML:params.tooltip
|
||||
}));
|
||||
} else if (params.tooltipleft) {
|
||||
el.className += " tooltip";
|
||||
el.appendChild(createElement("span", {
|
||||
class:"tooltiptextleft",
|
||||
innerHTML:params.tooltipleft
|
||||
}));
|
||||
}
|
||||
if (params.href) {el.href = params.href;}
|
||||
if (params.target) {el.target = params.target;}
|
||||
|
@ -139,6 +139,17 @@ function isHTML(str) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Generates a random alphanumeric string with N characters
|
||||
function generateRandomString(n) {
|
||||
var str = "",
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
for (var i = 0; i < n; i++)
|
||||
str += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
export {getIndicesOf, convertTimeMsToTimeElapsedString, longestCommonStart,
|
||||
isString, isPositiveNumber, containsAllStrings, formatNumber,
|
||||
numOccurrences, numNetscriptOperators, isHTML};
|
||||
numOccurrences, numNetscriptOperators, isHTML, generateRandomString};
|
||||
|
26
webpack.config.js
Normal file
26
webpack.config.js
Normal file
@ -0,0 +1,26 @@
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
|
||||
new webpack.ProvidePlugin({
|
||||
// Automtically detect jQuery and $ as free var in modules
|
||||
// and inject the jquery library
|
||||
// This is required by many jquery plugins
|
||||
jquery: "jquery",
|
||||
jQuery: "jquery",
|
||||
$: "jquery"
|
||||
}),
|
||||
],
|
||||
|
||||
entry: "./src/engine.js",
|
||||
output: {
|
||||
path: __dirname + "/dist/",
|
||||
filename: "bundle.js"
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.css$/, loader: "style!css" },
|
||||
]
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user