mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-08 03:24:48 +01:00
@ -1,6 +1,6 @@
|
||||
/* CSS for different main menu pages, such as character info, script editor, etc (but excluding
|
||||
terminal which has its own page) */
|
||||
|
||||
|
||||
.generic-menupage-container {
|
||||
height: 100%;
|
||||
padding-left: 10px;
|
||||
@ -21,7 +21,7 @@
|
||||
visibility: hidden;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
|
||||
#script-editor-container {
|
||||
position: fixed;
|
||||
padding-top: 10px;
|
||||
@ -64,7 +64,7 @@
|
||||
margin-right: 0px;
|
||||
padding-left: 6px;
|
||||
width: 100%;
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
}
|
||||
|
||||
#script-editor-filename-tag {
|
||||
@ -76,26 +76,26 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
#script-editor-filename {
|
||||
#script-editor-filename {
|
||||
background-color: #555;
|
||||
display: inline-block;
|
||||
float: center;
|
||||
resize: none;
|
||||
color: white;
|
||||
margin: 4px;
|
||||
|
||||
|
||||
padding: 2px;
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
#script-editor-status {
|
||||
@ -108,21 +108,21 @@
|
||||
height: 80%;
|
||||
width: 100%;
|
||||
margin-left: 6px;
|
||||
|
||||
|
||||
padding-left: 6px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
/* Active scripts */
|
||||
@ -301,16 +301,16 @@
|
||||
margin: 6px;
|
||||
padding: 6px;
|
||||
width: 85%;
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
border: 2px solid var(--my-highlight-color);
|
||||
-webkit-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
-moz-box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
box-shadow:
|
||||
inset 0 0 8px rgba(0,0,0,0.1),
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
0 0 16px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.hacknet-node-button-div a {
|
||||
@ -380,7 +380,7 @@
|
||||
#faction-donate-div-wrapper {
|
||||
float: left;
|
||||
border: 2px solid #333;
|
||||
padding: 14px 6px 4px 6px;
|
||||
padding: 14px 6px 4px 6px;
|
||||
margin: 6px;
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
#faction-donate-amount-txt,
|
||||
#faction-donate-amount-txt,
|
||||
#faction-donate-input {
|
||||
padding: 6px;
|
||||
margin: 6px;
|
||||
@ -477,6 +477,10 @@ div.faction-clear {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#tutorial-container a {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
/* Location */
|
||||
#location-container {
|
||||
position: fixed;
|
||||
@ -512,12 +516,12 @@ div.faction-clear {
|
||||
position: fixed;
|
||||
padding: 6px;
|
||||
}
|
||||
#infiltration-left-panel,
|
||||
#infiltration-left-panel,
|
||||
#infiltration-right-panel {
|
||||
display:inline-block;
|
||||
border: 1px solid white;
|
||||
width: 35%;
|
||||
height: 75%;
|
||||
height: 75%;
|
||||
top: 10px;
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
@ -544,7 +548,7 @@ div.faction-clear {
|
||||
}
|
||||
|
||||
#stock-market-container p {
|
||||
padding: 10px;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
width: 70%;
|
||||
}
|
||||
@ -574,4 +578,4 @@ div.faction-clear {
|
||||
color: var(--my-font-color);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@
|
||||
}
|
||||
|
||||
/* Infiltration-box */
|
||||
#infiltration-box-sell,
|
||||
#infiltration-box-sell,
|
||||
#infiltration-box-faction {
|
||||
display: block;
|
||||
padding: 8px;
|
||||
@ -141,17 +141,23 @@
|
||||
|
||||
#game-options-content {
|
||||
background-color: var(--my-background-color);
|
||||
margin: 15% auto; /* 15% from the top and centered */
|
||||
margin: 15% auto;
|
||||
padding: 10px;
|
||||
border: 5px solid var(--my-highlight-color);
|
||||
width: 50%; /* Could be more or less, depending on screen size */
|
||||
width: 60%;
|
||||
color: var(--my-font-color);
|
||||
}
|
||||
|
||||
#game-options-left-panel,
|
||||
#game-options-right-panel {
|
||||
display: inline-block;
|
||||
width: 49%;
|
||||
}
|
||||
|
||||
#game-options-close-button {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
margin: 4px;
|
||||
margin: 4px;
|
||||
padding: 4px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
@ -170,7 +176,11 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#game-options-left-panel fieldset {
|
||||
padding:2px;
|
||||
margin:2px;
|
||||
}
|
||||
|
||||
#import-game-file-selector {
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
305
index.html
305
index.html
@ -10,10 +10,10 @@
|
||||
<link rel="stylesheet" type="text/css" href="css/popupboxes.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/interactivetutorial.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/loader.css" />
|
||||
|
||||
|
||||
<!--jQuery library-->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
|
||||
|
||||
<!-- Utils -->
|
||||
<script src="utils/IPAddress.js"></script>
|
||||
<script src="utils/JSONReviver.js"></script>
|
||||
@ -28,14 +28,14 @@
|
||||
<script src="utils/GameOptions.js"></script>
|
||||
<script src="utils/LogBox.js"></script>
|
||||
<script src="utils/InfiltrationBox.js"></script>
|
||||
|
||||
|
||||
<!-- Netscript -->
|
||||
<script src="src/NetscriptWorker.js"></script>
|
||||
<script src="src/NetscriptEvaluator.js"></script>
|
||||
<script src="src/NetscriptEnvironment.js"></script>
|
||||
<script src="src/NetscriptFunctions.js"></script>
|
||||
<script src="utils/acorn.js"></script>
|
||||
|
||||
|
||||
<!-- Main game files -->
|
||||
<script src="src/Constants.js"></script>
|
||||
<script src="src/HelpText.js"></script>
|
||||
@ -66,9 +66,10 @@
|
||||
<script src="src/StockMarket.js"></script>
|
||||
<script src="src/RedPill.js"></script>
|
||||
<script src="src/BitNode.js"></script>
|
||||
|
||||
<script src="src/Settings.js"></script>
|
||||
|
||||
<script src="src/engine.js"></script>
|
||||
|
||||
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
@ -103,7 +104,7 @@
|
||||
<a id="create-program-menu-link"> Create Program </a>
|
||||
<span id="create-program-notification" class="notification-off"> </span>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Character dropdown -->
|
||||
<li id="character-menu-header-li">
|
||||
<a id="character-menu-header" class="mainmenu-accordion-header"> Character </a>
|
||||
@ -120,7 +121,7 @@
|
||||
<li id="hacknet-nodes-tab" class="mainmenu-accordion-panel">
|
||||
<a id="hacknet-nodes-menu-link"> Hacknet Nodes </a>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- World dropdown -->
|
||||
<li id="world-menu-header-li">
|
||||
<a id="world-menu-header" class="mainmenu-accordion-header">World</a>
|
||||
@ -134,7 +135,7 @@
|
||||
<li id="job-tab" class="mainmenu-accordion-panel">
|
||||
<a id="job-menu-link">Job</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="help-menu-header-li">
|
||||
<a id="help-menu-header" class="mainmenu-accordion-header">Help</a>
|
||||
</li>
|
||||
@ -146,26 +147,26 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Terminal page -->
|
||||
<div id="terminal-container">
|
||||
<table id="terminal">
|
||||
<tr id="terminal-input">
|
||||
<td id="terminal-input-td" tabindex="2">$
|
||||
<td id="terminal-input-td" tabindex="2">$
|
||||
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"
|
||||
onfocus="this.value = this.value;"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Character Info page -->
|
||||
<div id="character-container" class="generic-menupage-container">
|
||||
<div id="character-content">
|
||||
<p id="character-info"> </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Script editor -->
|
||||
<div id="script-editor-container" class="generic-menupage-container">
|
||||
<div id="script-editor-wrapper">
|
||||
@ -182,7 +183,7 @@
|
||||
</div>
|
||||
<p> <br><br> </p>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Active scripts info page -->
|
||||
<div id="active-scripts-container" class="generic-menupage-container">
|
||||
<p id="active-scripts-text"> This page displays a list of all of your scripts that are currently running across every machine. It also
|
||||
@ -192,21 +193,21 @@
|
||||
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Hacknet Nodes -->
|
||||
<div id="hacknet-nodes-container" class="generic-menupage-container">
|
||||
<h1 id="hacknet-nodes-title"> Hacknet Nodes </h1>
|
||||
<p id="hacknet-nodes-text">
|
||||
<p id="hacknet-nodes-text">
|
||||
The Hacknet is a global, decentralized network of machines. It is used by hackers all around
|
||||
the world to anonymously share computing power and perform distributed cyberattacks without the
|
||||
fear of being traced.
|
||||
fear of being traced.
|
||||
<br><br>
|
||||
Here, you can purchase a Hacknet Node, a specialized machine that can connect and contribute its
|
||||
resources to the Hacknet network. This allows you to take a small percentage of profits
|
||||
from hacks performed on the network. Essentially, you are renting out your Node's computing power.
|
||||
from hacks performed on the network. Essentially, you are renting out your Node's computing power.
|
||||
<br><br>
|
||||
Each Hacknet Node you purchase will passively earn you money. Each Hacknet Node can be upgraded
|
||||
in order to increase its computing power and thereby increase the profit you earn from it.
|
||||
Each Hacknet Node you purchase will passively earn you money. Each Hacknet Node can be upgraded
|
||||
in order to increase its computing power and thereby increase the profit you earn from it.
|
||||
</p>
|
||||
<a id="hacknet-nodes-purchase-button" class="a-link-button"> Purchase Hacknet Node </a>
|
||||
<br>
|
||||
@ -277,7 +278,7 @@
|
||||
<a id="aevum-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="chongqing-locations-list">
|
||||
<li id="chongqing-travelagency-li">
|
||||
<a id="chongqing-travelagency" class="a-link-button"> Travel Agency </a>
|
||||
@ -295,7 +296,7 @@
|
||||
<a id="chongqing-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="sector12-locations-list">
|
||||
<li id="sector12-travelagency-li">
|
||||
<a id="sector12-travelagency" class="a-link-button">Travel Agency </a>
|
||||
@ -352,7 +353,7 @@
|
||||
<a id="sector12-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="newtokyo-locations-list">
|
||||
<li id="newtokyo-travelagency-li">
|
||||
<a id="newtokyo-travelagency" class="a-link-button"> Travel Agency</a>
|
||||
@ -376,7 +377,7 @@
|
||||
<a id="newtokyo-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="ishima-locations-list">
|
||||
<li id="ishima-travelagency-li">
|
||||
<a id="ishima-travelagency" class="a-link-button">Travel Agency </a>
|
||||
@ -397,7 +398,7 @@
|
||||
<a id="ishima-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="volhaven-locations-list">
|
||||
<li id="volhaven-travelagency-li">
|
||||
<a id="volhaven-travelagency" class="a-link-button">Travel Agency </a>
|
||||
@ -436,23 +437,23 @@
|
||||
<a id="volhaven-slums" class="a-link-button">The Slums</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<ul id="generic-locations-list">
|
||||
<li id="generic-location-wse-li">
|
||||
<a id="generic-location-wse" class="a-link-button">World Stock Exchange </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Create a program(executable) -->
|
||||
<div id="create-program-container" class="generic-menupage-container">
|
||||
<p id="create-program-page-text">
|
||||
<p id="create-program-page-text">
|
||||
This page displays any programs that you are able to create. Writing the code for a program takes time, which
|
||||
can vary based on how complex the program is. If you are working on creating on a program you can cancel
|
||||
at any time. Your progress will be saved and you can continue later.
|
||||
at any time. Your progress will be saved and you can continue later.
|
||||
</p>
|
||||
|
||||
<ul id="create-program-list">
|
||||
|
||||
<ul id="create-program-list">
|
||||
<a class="a-link-button tooltip" id="create-program-nuke">
|
||||
NUKE.exe
|
||||
<span class="tooltiptext"> This virus is used to gain root access to a machine if enough ports are opened. </span>
|
||||
@ -472,7 +473,7 @@
|
||||
<a class="a-link-button tooltip" id="create-program-httpworm">
|
||||
HTTPWorm.exe
|
||||
<span class="tooltiptext"> This virus opens up HTTP ports </span>
|
||||
</a>
|
||||
</a>
|
||||
<a class="a-link-button tooltip" id="create-program-sqlinject">
|
||||
SQLInject.exe
|
||||
<span class="tooltiptext"> This virus opens SQL ports</span>
|
||||
@ -495,14 +496,14 @@
|
||||
</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Factions -->
|
||||
<div id="factions-container" class="generic-menupage-container">
|
||||
<h1> Factions </h1>
|
||||
<p> Lists all factions you have joined </p>
|
||||
<ul class="factions-list" id="factions-list"></ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Single Faction info (when you select a faction from the Factions menu) -->
|
||||
<div id="faction-container" class="generic-menupage-container">
|
||||
<h1 id="faction-name"></h1>
|
||||
@ -512,13 +513,13 @@
|
||||
<p> --------------- </p>
|
||||
<p id="faction-favor" class="tooltip"></p>
|
||||
<p> --------------- </p>
|
||||
<p id="faction-work-description-text">
|
||||
<p id="faction-work-description-text">
|
||||
Perform work/carry out assignments for your faction to help further its cause! By doing so
|
||||
you will gain reputation for your faction. You will also gain reputation passively over time,
|
||||
you will gain reputation for your faction. You will also gain reputation passively over time,
|
||||
although at a very slow rate. Note that you cannot
|
||||
use your terminal or create scripts when you are performing a task! <br><br><br><br>
|
||||
</p>
|
||||
|
||||
|
||||
<div id="faction-hack-div">
|
||||
<div id="faction-hack-div-wrapper">
|
||||
<a id="faction-hack-button" class="a-link-button">Hacking Contracts</a>
|
||||
@ -530,7 +531,7 @@
|
||||
</div>
|
||||
<div class="faction-clear"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="faction-fieldwork-div">
|
||||
<div id="faction-fieldwork-div-wrapper">
|
||||
<a id="faction-fieldwork-button" class="a-link-button">Field Work</a>
|
||||
@ -542,7 +543,7 @@
|
||||
</div>
|
||||
<div class="faction-clear"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="faction-securitywork-div">
|
||||
<div id="faction-securitywork-div-wrapper">
|
||||
<a id="faction-securitywork-button" class="a-link-button">Security Work</a>
|
||||
@ -554,7 +555,7 @@
|
||||
</div>
|
||||
<div class="faction-clear"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="faction-donate-div">
|
||||
<div id="faction-donate-div-wrapper">
|
||||
<a id="faction-donate-button" class="a-link-button">Donate Money</a>
|
||||
@ -566,14 +567,14 @@
|
||||
<input id="faction-donate-input" type="number"> </input>
|
||||
</div>
|
||||
<p id="faction-donate-rep-gain"> This donation will result in 0 reputation gain</p>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="faction-clear"></div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<br>
|
||||
As your reputation with this faction rises, you will unlock Augmentations, which you
|
||||
As your reputation with this faction rises, you will unlock Augmentations, which you
|
||||
can purchase to enhance your abilities.
|
||||
<br><br>
|
||||
</p>
|
||||
@ -585,16 +586,16 @@
|
||||
<a id="faction-augmentations-back-button" class="a-link-button"> Back </a>
|
||||
<h1> Faction Augmentations </h1>
|
||||
<p id="faction-augmentations-page-desc"> Lists all augmentations that are available to purchase from </p>
|
||||
|
||||
|
||||
<ul class="faction-augmentations-list" id="faction-augmentations-list">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Augmentations -->
|
||||
<div id="augmentations-container" class="generic-menupage-container">
|
||||
<h1> Purchased Augmentations </h1>
|
||||
<p style="width:70%;">
|
||||
Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.
|
||||
<p style="width:70%;">
|
||||
Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.
|
||||
<br>WARNING: Purchasing an Augmentation resets most of your progress, including: <br><br>
|
||||
Stats/Skill levels and Experience <br>
|
||||
Money <br>
|
||||
@ -605,7 +606,7 @@
|
||||
Stocks<br><br>
|
||||
Purchasing an Augmentation lets you start over with the perks and benefits granted by all
|
||||
of the Augmentations you have ever purchased. Also, you will keep any scripts and RAM upgrades
|
||||
on your home computer (but you will lose all programs besides NUKE.exe).
|
||||
on your home computer (but you will lose all programs besides NUKE.exe).
|
||||
</p>
|
||||
<br><br>
|
||||
<ul id="queued-augmentations-list"></ul>
|
||||
@ -617,7 +618,7 @@
|
||||
<ul id="augmentations-list">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Tutorial content -->
|
||||
<div id="tutorial-container" class="generic-menupage-container">
|
||||
<a id="tutorial-getting-started-link" class="a-link-button"> Getting Started </a>
|
||||
@ -629,24 +630,26 @@
|
||||
<a id="tutorial-jobs-link" class="a-link-button"> Companies and Infiltration </a>
|
||||
<a id="tutorial-factions-link" class="a-link-button"> Factions </a>
|
||||
<a id="tutorial-augmentations-link" class="a-link-button"> Augmentations </a>
|
||||
|
||||
<a id="tutorial-shortcuts-link" class="a-link-button"
|
||||
href="https://bitburner.wikia.com/wiki/Shortcuts" target="_blank"> Keyboard Shortcuts </a>
|
||||
|
||||
<a id="tutorial-back-button" class="a-link-button"> Back </a>
|
||||
<p id="tutorial-text"> </p>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Location (visiting a location in World) -->
|
||||
<div id="location-container" class="generic-menupage-container">
|
||||
<a id="location-return-to-world-button" class="a-link-button"> Return to World </a>
|
||||
<h1 id="location-name"></h1>
|
||||
<p id="location-info"> </p>
|
||||
|
||||
|
||||
<p id="location-job-title"> </p>
|
||||
<p id="location-text-divider-1"> --------------- </p>
|
||||
<p id="location-job-reputation" class="tooltip"> </p>
|
||||
<p id="location-text-divider-2"> --------------- </p>
|
||||
<p id="location-company-favor" class="tooltip"> </p>
|
||||
<p id="location-text-divider-3"> --------------- </p>
|
||||
|
||||
|
||||
<!-- Jobs/Work at a company -->
|
||||
<a id="location-software-job" class="a-link-button"> Apply for Software Job</a>
|
||||
<a id="location-software-consultant-job" class="a-link-button"> Apply for Software Consultant Job</a>
|
||||
@ -661,15 +664,15 @@
|
||||
<a id="location-parttime-employee-job" class="a-link-button"> Apply to be a Part-time Employee </a>
|
||||
<a id="location-waiter-job" class="a-link-button"> Apply to be a Waiter</a>
|
||||
<a id="location-parttime-waiter-job" class="a-link-button"> Apply to be a Part-time Waiter</a>
|
||||
|
||||
|
||||
<a id="location-work" class="a-link-button"> Work </a>
|
||||
|
||||
|
||||
<!-- Gym -->
|
||||
<a id="location-gym-train-str" class="a-link-button">Train Strength</a>
|
||||
<a id="location-gym-train-def" class="a-link-button">Train Defense </a>
|
||||
<a id="location-gym-train-dex" class="a-link-button">Train Dexterity</a>
|
||||
<a id="location-gym-train-agi" class="a-link-button">Train Agility</a>
|
||||
|
||||
|
||||
<!-- Study/Take classes at a university -->
|
||||
<a id="location-study-computer-science" class="a-link-button">Study Computer Science (free)</a>
|
||||
<a id="location-data-structures-class" class="a-link-button">Take Data Structures course</a>
|
||||
@ -677,7 +680,7 @@
|
||||
<a id="location-algorithms-class" class="a-link-button">Take Algorithms course</a>
|
||||
<a id="location-management-class" class="a-link-button">Take Management course</a>
|
||||
<a id="location-leadership-class" class="a-link-button">Take Leadership course</a>
|
||||
|
||||
|
||||
<!-- Purchase servers -->
|
||||
<a id="location-purchase-2gb" class="a-link-button"> Purchase 2GB Server - $150,000</a>
|
||||
<a id="location-purchase-4gb" class="a-link-button"> Purchase 4GB Server - $300,000</a>
|
||||
@ -691,21 +694,21 @@
|
||||
<a id="location-purchase-1tb" class="a-link-button"> Purchase 1TB Server - $75,000,000</a>
|
||||
<a id="location-purchase-tor" class="a-link-button"> Purchase TOR Router - $100,000</a>
|
||||
<a id="location-purchase-home-ram" class="a-link-button"> Purchase additional RAM for Home computer </a>
|
||||
|
||||
|
||||
<!-- Infiltrate -->
|
||||
<a id="location-infiltrate" class="a-link-button tooltip"> Infiltrate Company
|
||||
<a id="location-infiltrate" class="a-link-button tooltip"> Infiltrate Company
|
||||
<span class="tooltiptext">
|
||||
Infiltrate this company's facility to try and steal their classified secrets!
|
||||
Infiltrate this company's facility to try and steal their classified secrets!
|
||||
Warning: You may end up hospitalized if you are unsuccessful!
|
||||
</span>
|
||||
</a>
|
||||
|
||||
|
||||
<!-- Hospital -->
|
||||
<a id="location-hospital-treatment" class="a-link-button"> Get Treatment for Wounds </a>
|
||||
|
||||
|
||||
<!-- Travel agency -->
|
||||
<p id="location-travel-agency-text">
|
||||
From here, you can travel to any other city! A ticket costs $200,000.
|
||||
<p id="location-travel-agency-text">
|
||||
From here, you can travel to any other city! A ticket costs $200,000.
|
||||
</p>
|
||||
<a id="location-travel-to-aevum" class="a-link-button"> Travel to Aevum </a>
|
||||
<a id="location-travel-to-chongqing" class="a-link-button"> Travel to Chongqing</a>
|
||||
@ -713,14 +716,14 @@
|
||||
<a id="location-travel-to-newtokyo" class="a-link-button"> Travel to New Tokyo</a>
|
||||
<a id="location-travel-to-ishima" class="a-link-button"> Travel to Ishima</a>
|
||||
<a id="location-travel-to-volhaven" class="a-link-button"> Travel to Volhaven</a>
|
||||
|
||||
|
||||
<!-- Slums -->
|
||||
<p id="location-slums-description">
|
||||
<p id="location-slums-description">
|
||||
You have entered the Slums, a poverty-ridden district filled with gangs, criminals, and
|
||||
other shadowy entities. The city's government and police have neglected this area for years... <br><br><br>
|
||||
|
||||
In the Slums you can commit crimes to earn money and experience. Crime attempts are not always
|
||||
successful. Your chance at successfully committing a crime is determined by your stats.
|
||||
|
||||
In the Slums you can commit crimes to earn money and experience. Crime attempts are not always
|
||||
successful. Your chance at successfully committing a crime is determined by your stats.
|
||||
</p>
|
||||
<a class="a-link-button tooltip" id="location-slums-shoplift"> Shoplift </a>
|
||||
<a id="location-slums-mug" class="a-link-button tooltip"> Mug someone </a>
|
||||
@ -732,7 +735,7 @@
|
||||
<a id="location-slums-assassinate" class="a-link-button tooltip"> Assassinate </a>
|
||||
<a id="location-slums-heist" class="a-link-button tooltip"> Heist </a>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="infiltration-container" class="generic-menupage-container">
|
||||
<div id="infiltration-left-panel">
|
||||
<p id="infiltration-level-text"> </p>
|
||||
@ -753,34 +756,34 @@
|
||||
<p id="infiltration-status-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="stock-market-container" class="generic-menupage-container">
|
||||
<p>
|
||||
Welcome to the World Stock Exchange (WSE)! <br><br>
|
||||
|
||||
|
||||
To begin trading, you must first purchase an account. WSE accounts will persist
|
||||
after you 'reset' by installing Augmentations.
|
||||
after you 'reset' by installing Augmentations.
|
||||
</p>
|
||||
<a id="stock-market-buy-account" class="a-link-button-inactive"> Buy WSE Account </a>
|
||||
<p>
|
||||
You can also purchase access to the World Stock Exchange's TIX API! TIX, short for
|
||||
Trade Information eXchange, is the communications protocol supported by the WSE.
|
||||
Trade Information eXchange, is the communications protocol supported by the WSE.
|
||||
<br><br>
|
||||
Gaining access to the TIX API lets you write code to build automated trading
|
||||
systems. In other words, you can create your own algorithmic trading strategies!
|
||||
<br><br>
|
||||
If you purchase access to the TIX API, you will retain that access even after
|
||||
you 'reset' by installing Augmentations.
|
||||
If you purchase access to the TIX API, you will retain that access even after
|
||||
you 'reset' by installing Augmentations.
|
||||
</p>
|
||||
<a id="stock-market-buy-tix-api" class="a-link-button-inactive">
|
||||
<a id="stock-market-buy-tix-api" class="a-link-button-inactive">
|
||||
Buy Trade Information eXchange (TIX) API Access - COMING SOON
|
||||
</a>
|
||||
<p id="stock-market-commission"> </p>
|
||||
|
||||
|
||||
<ul id="stock-market-list" style="list-style:none;">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Log Box -->
|
||||
<div id="log-box-container">
|
||||
<div id="log-box-content">
|
||||
@ -788,7 +791,7 @@
|
||||
<p id="log-box-text"> </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Purchase Server Pop-up Box -->
|
||||
<div id="purchase-server-box-container" class="popup-box-container">
|
||||
<div id="purchase-server-box-content" class="popup-box-content">
|
||||
@ -799,7 +802,7 @@
|
||||
<span id="purchase-server-box-cancel" class="popup-box-button"> Cancel </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Purchase RAM for Home Computer Pop-up Box -->
|
||||
<div id="purchase-ram-for-home-box-container" class="popup-box-container">
|
||||
<div id="purchase-ram-for-home-box-content" class="popup-box-content">
|
||||
@ -808,7 +811,7 @@
|
||||
<span id="purchase-ram-for-home-box-cancel" class="popup-box-button"> Cancel </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Travel Pop-up Box -->
|
||||
<div id="travel-box-container" class="popup-box-container">
|
||||
<div id="travel-box-content" class="popup-box-content">
|
||||
@ -828,44 +831,44 @@
|
||||
<span id="purchase-augmentation-box-cancel" class="popup-box-button"> Cancel </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Faction Invitation Pop-up Box -->
|
||||
<div id="faction-invitation-box-container" class="popup-box-container">
|
||||
<div id="faction-invitation-box-content" class="popup-box-content">
|
||||
<p id="faction-invitation-box-text"> </p>
|
||||
<p id="faction-invitation-box-message"> </p>
|
||||
<p id="faction-invitation-box-warning">
|
||||
<p id="faction-invitation-box-warning">
|
||||
Would you like to join? <br> <br>
|
||||
Warning: Joining this faction may prevent you from joining other factions during this run!
|
||||
Warning: Joining this faction may prevent you from joining other factions during this run!
|
||||
</p>
|
||||
<span id="faction-invitation-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="faction-invitation-box-no" class="popup-box-button"> No </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- End of Infiltration pop up box -->
|
||||
<div id="infiltration-box-container" class="popup-box-container">
|
||||
<div id="infiltration-box-content" class="popup-box-content">
|
||||
<p id="infiltration-box-text"> </p>
|
||||
|
||||
|
||||
<span id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </span> <br><br>
|
||||
<select id="infiltration-faction-select"> </select> <br>
|
||||
<span id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Work in progress screen -->
|
||||
<div id="work-in-progress-container" class="generic-fullscreen-container">
|
||||
<p id="work-in-progress-text"> </p>
|
||||
|
||||
|
||||
<span id="work-in-progress-cancel-button"> Cancel Work </span>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Red Pill Container -->
|
||||
<div id="red-pill-container" class="generic-fullscreen-container">
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Interactive Tutorial Text Screen -->
|
||||
<div id="interactive-tutorial-wrapper">
|
||||
<div id="interactive-tutorial-container">
|
||||
@ -875,7 +878,7 @@
|
||||
<span id="interactive-tutorial-back"> Back </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Character Overview Screen -->
|
||||
<div id="character-overview-wrapper">
|
||||
<div id="character-overview-container">
|
||||
@ -884,47 +887,113 @@
|
||||
<span id="character-overview-options-button"> Options </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status text -->
|
||||
|
||||
<!-- Status text -->
|
||||
<div id="status-text-container">
|
||||
<p id="status-text"> </p>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Game Options -->
|
||||
<div id="game-options-container" class="popup-box-container">
|
||||
<div id="game-options-content" class="game-options-box">
|
||||
<span id="game-options-close-button">×</span>
|
||||
<h1> Game Options </h1>
|
||||
<br>
|
||||
<a class="a-link-button" style="display:block;" href="https://bitburner.wikia.com/wiki/Changelog" target="_blank"> Changelog </a>
|
||||
<a class="a-link-button" style="display:block;" href="https://bitburner.wikia.com" target="_blank">Wiki</a>
|
||||
<a id="save-game-link" class="a-link-button" style="display:block;"> Save Game </a>
|
||||
<a id="export-game-link" class="a-link-button" style="display:block;"> (BETA) Export Game </a>
|
||||
<input type="file" id="import-game-file-selector" name="file"/>
|
||||
<a id="import-game-link" class="a-link-button" style="display:block;" onclick="saveObject.importGame();"> (BETA) Import Game </a>
|
||||
<a id="delete-game-link" class="a-link-button" style="display:block;"> Delete Game </a>
|
||||
<a class="a-link-button" style="display:block;" href="https://bitburner.wikia.com/wiki/Shortcuts" target="_blank"> Keyboard Shortcuts </a>
|
||||
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;">
|
||||
(DEBUG) Delete Active Scripts
|
||||
<span class="tooltiptext">
|
||||
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
|
||||
using this, save the game and then reload the page.
|
||||
</span>
|
||||
</a>
|
||||
<a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;">
|
||||
(DEBUG) Soft Reset
|
||||
<span class="tooltiptext">
|
||||
Perform a soft reset. Resets everything as if you had just purchased an Augmentation
|
||||
</span>
|
||||
</a>
|
||||
<div id="game-options-left-panel">
|
||||
<!-- Netscript execution time -->
|
||||
<fieldset>
|
||||
<label for="settingsNSExecTimeRangeVal" class="tooltip">Netscript exec time:
|
||||
<span class="tooltiptext">
|
||||
The minimum number of milliseconds it takes to execute an operation in Netscript.
|
||||
Setting this too low can result in poor performance if you have many scripts running.
|
||||
The default value is 100ms.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="200" min="25"
|
||||
oninput="document.getElementById('settingsNSExecTimeRangeValLabel').innerHTML = this.value + 'ms';
|
||||
Settings.CodeInstructionRunTime=this.value;"
|
||||
step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="100">
|
||||
</input>
|
||||
<em id="settingsNSExecTimeRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
<!-- Log capacity -->
|
||||
<fieldset>
|
||||
<label for="settingsNSLogRangeVal" class="tooltip">Netscript log size:
|
||||
<span class="tooltiptext">
|
||||
The maximum number of lines a script's logs can hold. Setting this too high
|
||||
can cause the game to use a lot of memory if you have many scripts running.
|
||||
The default value is 50.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="100" min="20"
|
||||
oninput="document.getElementById('settingsNSLogRangeValLabel').innerHTML = this.value;
|
||||
Settings.MaxLogCapacity=this.value;"
|
||||
step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50">
|
||||
</input>
|
||||
<em id="settingsNSLogRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
<!-- Port capacity -->
|
||||
<fieldset>
|
||||
<label for="settingsNSPortRangeVal" class="tooltip">Netscript port size:
|
||||
<span class="tooltiptext">
|
||||
The maximum number of entries that can be written to a port using Netscript's
|
||||
write() function. Setting this too high can cause the game to use a lot of memory.
|
||||
The default value is 50.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type ="range" max="100" min="20"
|
||||
oninput="document.getElementById('settingsNSPortRangeValLabel').innerHTML = this.value;
|
||||
Settings.MaxPortCapacity=this.value;"
|
||||
step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50">
|
||||
</input>
|
||||
<em id="settingsNSPortRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
<!-- Donate button -->
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYA2Y2VGE75oWct89z//G2YEJKmzx0uDTXNrpje9ThxmUnBLFZCY+I11Pors7lGRvFqo5okwnu41CfYMPHDxpAgyYyQndMX9pWUX0gLfBMm2BaHwsNBCwt34WmpQqj7TGsQ+aw9NbmkxiJltGnOa+6/gy10mPZAA3HxiieLeCKkGgDELMAkGBSsOAwIaBQAwgcQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI72F1YSzHUd2AgaDMekHU3AKT93Ey9wkB3486bV+ngFSD6VOHrPweH9QATsp+PMe9QM9vmq+s2bGtTbZaYrFqM3M97SnQ0l7IQ5yuOzdZhRdfysu5uJ8dnuHUzq4gLSzqMnZ6/3c+PoHB8AS1nYHUVL4U0+ogZsO1s97IAQyfck9SaoFlxVtqQhkb8752MkQJJvGu3ZQSQGcVC4hFDPk8prXqyq4BU/k/EliwoIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTcwNzI1MDExODE2WjAjBgkqhkiG9w0BCQQxFgQUNo8efiZ7sk7nwKM/6B6Z7sU8hIIwDQYJKoZIhvcNAQEBBQAEgYB+JB4vZ/r48815/1HF/xK3+rOx7bPz3kAXmbhW/mkoF4OUbzqMeljvDIA9q/BDdlCLtxFOw9XlftTzv0eZCW/uCIiwu5wTzPIfPY1SI8WHe4cJbP2f2EYxIVs8D7OSirbW4yVa0+gACaLLj0rzIzNN8P/5PxgB03D+jwkcJABqng==-----END PKCS7-----
|
||||
">
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
</div>
|
||||
<div id="game-options-right-panel">
|
||||
<a class="a-link-button" style="display:block;" href="https://bitburner.wikia.com/wiki/Changelog" target="_blank"> Changelog </a>
|
||||
<a class="a-link-button" style="display:block;" href="https://bitburner.wikia.com" target="_blank">Wiki</a>
|
||||
<a class="a-link-button" style="display:block;", href="https://www.reddit.com/r/bitburner" target="_blank">Subreddit</a>
|
||||
<a id="save-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Save Game </a>
|
||||
<a id="delete-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Delete Game </a>
|
||||
<a id="export-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Export Game </a>
|
||||
<input type="file" id="import-game-file-selector" name="file"/>
|
||||
<a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;" onclick="saveObject.importGame();"> Import Game </a>
|
||||
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;">
|
||||
(DEBUG) Delete Active Scripts
|
||||
<span class="tooltiptext">
|
||||
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
|
||||
using this, save the game and then reload the page.
|
||||
</span>
|
||||
</a>
|
||||
<a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;width:46%;">
|
||||
(DEBUG) Soft Reset
|
||||
<span class="tooltiptext">
|
||||
Perform a soft reset. Resets everything as if you had just purchased an Augmentation
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Loader (Loading screen) -->
|
||||
<div id="loader" class="loaderoverlay">
|
||||
<div class="loaderspinner"></div>
|
||||
<div class="loaderlabel">Loading Bitburner...</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
975
src/Constants.js
975
src/Constants.js
File diff suppressed because it is too large
Load Diff
270
src/Faction.js
270
src/Faction.js
@ -5,10 +5,10 @@ function factionInit() {
|
||||
var val = document.getElementById("faction-donate-input").value;
|
||||
if (isPositiveNumber(val)) {
|
||||
var numMoneyDonate = Number(val);
|
||||
document.getElementById("faction-donate-rep-gain").innerHTML =
|
||||
document.getElementById("faction-donate-rep-gain").innerHTML =
|
||||
"This donation will result in " + formatNumber(numMoneyDonate/1000000 * Player.faction_rep_mult, 3) + " reputation gain";
|
||||
} else {
|
||||
document.getElementById("faction-donate-rep-gain").innerHTML =
|
||||
document.getElementById("faction-donate-rep-gain").innerHTML =
|
||||
"This donation will result in 0 reputation gain";
|
||||
}
|
||||
}
|
||||
@ -17,20 +17,20 @@ function factionInit() {
|
||||
document.addEventListener("DOMContentLoaded", factionInit, false);
|
||||
|
||||
function Faction(name) {
|
||||
this.name = name;
|
||||
this.name = name;
|
||||
this.augmentations = []; //Name of augmentation only
|
||||
this.info = ""; //Introductory/informational text about the faction
|
||||
|
||||
this.info = ""; //Introductory/informational text about the faction
|
||||
|
||||
//Player-related properties for faction
|
||||
this.isMember = false; //Whether player is member
|
||||
this.isMember = false; //Whether player is member
|
||||
this.isBanned = false; //Whether or not player is banned from joining this faction
|
||||
this.playerReputation = 0; //"Reputation" within faction
|
||||
this.alreadyInvited = false;
|
||||
|
||||
|
||||
//Multipliers for unlocking and purchasing augmentations
|
||||
this.augmentationPriceMult = 1;
|
||||
this.augmentationRepRequirementMult = 1;
|
||||
|
||||
|
||||
//Faction favor
|
||||
this.favor = 0;
|
||||
};
|
||||
@ -83,7 +83,7 @@ initFactions = function() {
|
||||
delete Factions["Illuminati"];
|
||||
}
|
||||
AddToFactions(Illuminati);
|
||||
|
||||
|
||||
var Daedalus = new Faction("Daedalus");
|
||||
Daedalus.setInfo(FactionInfo.DaedalusInfo);
|
||||
if (factionExists("Daedalus")) {
|
||||
@ -91,7 +91,7 @@ initFactions = function() {
|
||||
delete Factions["Daedalus"];
|
||||
}
|
||||
AddToFactions(Daedalus);
|
||||
|
||||
|
||||
var Covenant = new Faction("The Covenant");
|
||||
Covenant.setInfo(FactionInfo.CovenantInfo);
|
||||
if (factionExists("The Covenant")) {
|
||||
@ -99,7 +99,7 @@ initFactions = function() {
|
||||
delete Factions["The Covenant"];
|
||||
}
|
||||
AddToFactions(Covenant);
|
||||
|
||||
|
||||
//Megacorporations, each forms its own faction
|
||||
var ECorp = new Faction("ECorp");
|
||||
ECorp.setInfo(FactionInfo.ECorpInfo);
|
||||
@ -108,7 +108,7 @@ initFactions = function() {
|
||||
delete Factions["ECorp"];
|
||||
}
|
||||
AddToFactions(ECorp);
|
||||
|
||||
|
||||
var MegaCorp = new Faction("MegaCorp");
|
||||
MegaCorp.setInfo(FactionInfo.MegaCorpInfo);
|
||||
if (factionExists("MegaCorp")) {
|
||||
@ -116,7 +116,7 @@ initFactions = function() {
|
||||
delete Factions["MegaCorp"];
|
||||
}
|
||||
AddToFactions(MegaCorp);
|
||||
|
||||
|
||||
var BachmanAndAssociates = new Faction("Bachman & Associates");
|
||||
BachmanAndAssociates.setInfo(FactionInfo.BachmanAndAssociatesInfo);
|
||||
if (factionExists("Bachman & Associates")) {
|
||||
@ -124,7 +124,7 @@ initFactions = function() {
|
||||
delete Factions["Bachman & Associates"];
|
||||
}
|
||||
AddToFactions(BachmanAndAssociates);
|
||||
|
||||
|
||||
var BladeIndustries = new Faction("Blade Industries");
|
||||
BladeIndustries.setInfo(FactionInfo.BladeIndustriesInfo);
|
||||
if (factionExists("Blade Industries")) {
|
||||
@ -132,7 +132,7 @@ initFactions = function() {
|
||||
delete Factions["Blade Industries"];
|
||||
}
|
||||
AddToFactions(BladeIndustries);
|
||||
|
||||
|
||||
var NWO = new Faction("NWO");
|
||||
NWO.setInfo(FactionInfo.NWOInfo);
|
||||
if (factionExists("NWO")) {
|
||||
@ -140,7 +140,7 @@ initFactions = function() {
|
||||
delete Factions["NWO"];
|
||||
}
|
||||
AddToFactions(NWO);
|
||||
|
||||
|
||||
var ClarkeIncorporated = new Faction("Clarke Incorporated");
|
||||
ClarkeIncorporated.setInfo(FactionInfo.ClarkeIncorporatedInfo);
|
||||
if (factionExists("Clarke Incorporated")) {
|
||||
@ -148,7 +148,7 @@ initFactions = function() {
|
||||
delete Factions["Clarke Incorporated"];
|
||||
}
|
||||
AddToFactions(ClarkeIncorporated);
|
||||
|
||||
|
||||
var OmniTekIncorporated = new Faction("OmniTek Incorporated");
|
||||
OmniTekIncorporated.setInfo(FactionInfo.OmniTekIncorporatedInfo);
|
||||
if (factionExists("OmniTek Incorporated")) {
|
||||
@ -156,7 +156,7 @@ initFactions = function() {
|
||||
delete Factions["OmniTek Incorporated"];
|
||||
}
|
||||
AddToFactions(OmniTekIncorporated);
|
||||
|
||||
|
||||
var FourSigma = new Faction("Four Sigma");
|
||||
FourSigma.setInfo(FactionInfo.FourSigmaInfo);
|
||||
if (factionExists("Four Sigma")) {
|
||||
@ -164,7 +164,7 @@ initFactions = function() {
|
||||
delete Factions["Four Sigma"];
|
||||
}
|
||||
AddToFactions(FourSigma);
|
||||
|
||||
|
||||
var KuaiGongInternational = new Faction("KuaiGong International");
|
||||
KuaiGongInternational.setInfo(FactionInfo.KuaiGongInternationalInfo);
|
||||
if (factionExists("KuaiGong International")) {
|
||||
@ -172,7 +172,7 @@ initFactions = function() {
|
||||
delete Factions["KuaiGong International"];
|
||||
}
|
||||
AddToFactions(KuaiGongInternational);
|
||||
|
||||
|
||||
//Other corporations
|
||||
var FulcrumTechnologies = new Faction("Fulcrum Secret Technologies");
|
||||
FulcrumTechnologies.setInfo(FactionInfo.FulcrumSecretTechnologiesInfo);
|
||||
@ -181,7 +181,7 @@ initFactions = function() {
|
||||
delete Factions["Fulcrum Secret Technologies"];
|
||||
}
|
||||
AddToFactions(FulcrumTechnologies);
|
||||
|
||||
|
||||
//Hacker groups
|
||||
var BitRunners = new Faction("BitRunners");
|
||||
BitRunners.setInfo(FactionInfo.BitRunnersInfo);
|
||||
@ -190,7 +190,7 @@ initFactions = function() {
|
||||
delete Factions["BitRunners"];
|
||||
}
|
||||
AddToFactions(BitRunners);
|
||||
|
||||
|
||||
var BlackHand = new Faction("The Black Hand");
|
||||
BlackHand.setInfo(FactionInfo.BlackHandInfo);
|
||||
if (factionExists("The Black Hand")) {
|
||||
@ -198,7 +198,7 @@ initFactions = function() {
|
||||
delete Factions["The Black Hand"];
|
||||
}
|
||||
AddToFactions(BlackHand);
|
||||
|
||||
|
||||
var NiteSec = new Faction("NiteSec");
|
||||
NiteSec.setInfo(FactionInfo.NiteSecInfo);
|
||||
if (factionExists("NiteSec")) {
|
||||
@ -206,7 +206,7 @@ initFactions = function() {
|
||||
delete Factions["NiteSec"];
|
||||
}
|
||||
AddToFactions(NiteSec);
|
||||
|
||||
|
||||
//City factions, essentially governments
|
||||
var Chongqing = new Faction("Chongqing");
|
||||
Chongqing.setInfo(FactionInfo.ChongqingInfo);
|
||||
@ -215,7 +215,7 @@ initFactions = function() {
|
||||
delete Factions["Chongqing"];
|
||||
}
|
||||
AddToFactions(Chongqing);
|
||||
|
||||
|
||||
var Sector12 = new Faction("Sector-12");
|
||||
Sector12.setInfo(FactionInfo.Sector12Info);
|
||||
if (factionExists("Sector-12")) {
|
||||
@ -223,7 +223,7 @@ initFactions = function() {
|
||||
delete Factions["Sector-12"];
|
||||
}
|
||||
AddToFactions(Sector12);
|
||||
|
||||
|
||||
var NewTokyo = new Faction("New Tokyo");
|
||||
NewTokyo.setInfo(FactionInfo.NewTokyoInfo);
|
||||
if (factionExists("New Tokyo")) {
|
||||
@ -231,7 +231,7 @@ initFactions = function() {
|
||||
delete Factions["New Tokyo"];
|
||||
}
|
||||
AddToFactions(NewTokyo);
|
||||
|
||||
|
||||
var Aevum = new Faction("Aevum");
|
||||
Aevum.setInfo(FactionInfo.AevumInfo);
|
||||
if (factionExists("Aevum")) {
|
||||
@ -239,7 +239,7 @@ initFactions = function() {
|
||||
delete Factions["Aevum"];
|
||||
}
|
||||
AddToFactions(Aevum);
|
||||
|
||||
|
||||
var Ishima = new Faction("Ishima");
|
||||
Ishima.setInfo
|
||||
var Volhaven = new Faction("Volhaven");
|
||||
@ -254,17 +254,17 @@ initFactions = function() {
|
||||
delete Factions["Ishima"];
|
||||
}
|
||||
AddToFactions(Ishima);
|
||||
|
||||
|
||||
|
||||
|
||||
//Criminal Organizations/Gangs
|
||||
var SpeakersForTheDead = new Faction("Speakers for the Dead");
|
||||
var SpeakersForTheDead = new Faction("Speakers for the Dead");
|
||||
SpeakersForTheDead.setInfo(FactionInfo.SpeakersForTheDeadInfo);
|
||||
if (factionExists("Speakers for the Dead")) {
|
||||
SpeakersForTheDead.favor = Factions["Speakers for the Dead"].favor;
|
||||
delete Factions["Speakers for the Dead"];
|
||||
}
|
||||
AddToFactions(SpeakersForTheDead);
|
||||
|
||||
|
||||
var DarkArmy = new Faction("The Dark Army");
|
||||
DarkArmy.setInfo(FactionInfo.DarkArmyInfo);
|
||||
if (factionExists("The Dark Army")) {
|
||||
@ -272,7 +272,7 @@ initFactions = function() {
|
||||
delete Factions["The Dark Army"];
|
||||
}
|
||||
AddToFactions(DarkArmy);
|
||||
|
||||
|
||||
var TheSyndicate = new Faction("The Syndicate");
|
||||
TheSyndicate.setInfo(FactionInfo.TheSyndicateInfo);
|
||||
if (factionExists("The Syndicate")) {
|
||||
@ -280,7 +280,7 @@ initFactions = function() {
|
||||
delete Factions["The Syndicate"];
|
||||
}
|
||||
AddToFactions(TheSyndicate);
|
||||
|
||||
|
||||
var Silhouette = new Faction("Silhouette");
|
||||
Silhouette.setInfo(FactionInfo.SilhouetteInfo);
|
||||
if (factionExists("Silhouette")) {
|
||||
@ -288,7 +288,7 @@ initFactions = function() {
|
||||
delete Factions["Silhouette"];
|
||||
}
|
||||
AddToFactions(Silhouette);
|
||||
|
||||
|
||||
var Tetrads = new Faction("Tetrads"); //Low-medium level asian crime gang
|
||||
Tetrads.setInfo(FactionInfo.TetradsInfo);
|
||||
if (factionExists("Tetrads")) {
|
||||
@ -296,7 +296,7 @@ initFactions = function() {
|
||||
delete Factions["Tetrads"];
|
||||
}
|
||||
AddToFactions(Tetrads);
|
||||
|
||||
|
||||
var SlumSnakes = new Faction("Slum Snakes"); //Low level crime gang
|
||||
SlumSnakes.setInfo(FactionInfo.SlumSnakesInfo);
|
||||
if (factionExists("Slum Snakes")) {
|
||||
@ -304,7 +304,7 @@ initFactions = function() {
|
||||
delete Factions["Slum Snakes"];
|
||||
}
|
||||
AddToFactions(SlumSnakes);
|
||||
|
||||
|
||||
//Earlygame factions - factions the player will prestige with early on that don't
|
||||
//belong in other categories
|
||||
var Netburners = new Faction("Netburners");
|
||||
@ -314,7 +314,7 @@ initFactions = function() {
|
||||
delete Factions["Netburners"];
|
||||
}
|
||||
AddToFactions(Netburners);
|
||||
|
||||
|
||||
var TianDiHui = new Faction("Tian Di Hui"); //Society of the Heaven and Earth
|
||||
TianDiHui.setInfo(FactionInfo.TianDiHuiInfo);
|
||||
if (factionExists("Tian Di Hui")) {
|
||||
@ -322,7 +322,7 @@ initFactions = function() {
|
||||
delete Factions["Tian Di Hui"];
|
||||
}
|
||||
AddToFactions(TianDiHui);
|
||||
|
||||
|
||||
var CyberSec = new Faction("CyberSec");
|
||||
CyberSec.setInfo(FactionInfo.CyberSecInfo);
|
||||
if (factionExists("CyberSec")) {
|
||||
@ -337,37 +337,37 @@ initFactions = function() {
|
||||
//receive an invitation to
|
||||
PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
invitedFactions = []; //Array which will hold all Factions th eplayer should be invited to
|
||||
|
||||
|
||||
var numAugmentations = this.augmentations.length;
|
||||
|
||||
|
||||
var company = Companies[this.companyName];
|
||||
var companyRep = 0;
|
||||
if (company != null) {
|
||||
companyRep = company.playerReputation;
|
||||
}
|
||||
|
||||
|
||||
//Illuminati
|
||||
var illuminatiFac = Factions["Illuminati"];
|
||||
if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited &&
|
||||
numAugmentations >= 30 &&
|
||||
if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited &&
|
||||
numAugmentations >= 30 &&
|
||||
this.money >= 150000000000 &&
|
||||
this.hacking_skill >= 1500 &&
|
||||
this.strength >= 1200 && this.defense >= 1200 &&
|
||||
this.strength >= 1200 && this.defense >= 1200 &&
|
||||
this.dexterity >= 1200 && this.agility >= 1200) {
|
||||
invitedFactions.push(illuminatiFac);
|
||||
}
|
||||
|
||||
|
||||
//Daedalus
|
||||
var daedalusFac = Factions["Daedalus"];
|
||||
if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited &&
|
||||
numAugmentations >= 30 &&
|
||||
if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited &&
|
||||
numAugmentations >= 30 &&
|
||||
this.money >= 100000000000 &&
|
||||
(this.hacking_skill >= 2500 ||
|
||||
(this.strength >= 1500 && this.defense >= 1500 &&
|
||||
(this.strength >= 1500 && this.defense >= 1500 &&
|
||||
this.dexterity >= 1500 && this.agility >= 1500))) {
|
||||
invitedFactions.push(daedalusFac);
|
||||
}
|
||||
|
||||
|
||||
//The Covenant
|
||||
var covenantFac = Factions["The Covenant"];
|
||||
if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited &&
|
||||
@ -380,72 +380,72 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
this.agility >= 850) {
|
||||
invitedFactions.push(covenantFac);
|
||||
}
|
||||
|
||||
|
||||
//ECorp
|
||||
var ecorpFac = Factions["ECorp"];
|
||||
if (!ecorpFac.isBanned && !ecorpFac.isMember && !ecorpFac.alreadyInvited &&
|
||||
if (!ecorpFac.isBanned && !ecorpFac.isMember && !ecorpFac.alreadyInvited &&
|
||||
this.companyName == Locations.AevumECorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(ecorpFac);
|
||||
}
|
||||
|
||||
|
||||
//MegaCorp
|
||||
var megacorpFac = Factions["MegaCorp"];
|
||||
if (!megacorpFac.isBanned && !megacorpFac.isMember && !megacorpFac.alreadyInvited &&
|
||||
this.companyName == Locations.Sector12MegaCorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(megacorpFac);
|
||||
}
|
||||
|
||||
|
||||
//Bachman & Associates
|
||||
var bachmanandassociatesFac = Factions["Bachman & Associates"];
|
||||
if (!bachmanandassociatesFac.isBanned && !bachmanandassociatesFac.isMember &&
|
||||
!bachmanandassociatesFac.alreadyInvited &&
|
||||
!bachmanandassociatesFac.alreadyInvited &&
|
||||
this.companyName == Locations.AevumBachmanAndAssociates && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(bachmanandassociatesFac);
|
||||
}
|
||||
|
||||
|
||||
//Blade Industries
|
||||
var bladeindustriesFac = Factions["Blade Industries"];
|
||||
if (!bladeindustriesFac.isBanned && !bladeindustriesFac.isMember && !bladeindustriesFac.alreadyInvited &&
|
||||
if (!bladeindustriesFac.isBanned && !bladeindustriesFac.isMember && !bladeindustriesFac.alreadyInvited &&
|
||||
this.companyName == Locations.Sector12BladeIndustries && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(bladeindustriesFac);
|
||||
}
|
||||
|
||||
|
||||
//NWO
|
||||
var nwoFac = Factions["NWO"];
|
||||
if (!nwoFac.isBanned && !nwoFac.isMember && !nwoFac.alreadyInvited &&
|
||||
if (!nwoFac.isBanned && !nwoFac.isMember && !nwoFac.alreadyInvited &&
|
||||
this.companyName == Locations.VolhavenNWO && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(nwoFac);
|
||||
}
|
||||
|
||||
|
||||
//Clarke Incorporated
|
||||
var clarkeincorporatedFac = Factions["Clarke Incorporated"];
|
||||
if (!clarkeincorporatedFac.isBanned && !clarkeincorporatedFac.isMember && !clarkeincorporatedFac.alreadyInvited &&
|
||||
if (!clarkeincorporatedFac.isBanned && !clarkeincorporatedFac.isMember && !clarkeincorporatedFac.alreadyInvited &&
|
||||
this.companyName == Locations.AevumClarkeIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(clarkeincorporatedFac);
|
||||
}
|
||||
|
||||
|
||||
//OmniTek Incorporated
|
||||
var omnitekincorporatedFac = Factions["OmniTek Incorporated"];
|
||||
if (!omnitekincorporatedFac.isBanned && !omnitekincorporatedFac.isMember && !omnitekincorporatedFac.alreadyInvited &&
|
||||
if (!omnitekincorporatedFac.isBanned && !omnitekincorporatedFac.isMember && !omnitekincorporatedFac.alreadyInvited &&
|
||||
this.companyName == Locations.VolhavenOmniTekIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(omnitekincorporatedFac);
|
||||
}
|
||||
|
||||
|
||||
//Four Sigma
|
||||
var foursigmaFac = Factions["Four Sigma"];
|
||||
if (!foursigmaFac.isBanned && !foursigmaFac.isMember && !foursigmaFac.alreadyInvited &&
|
||||
if (!foursigmaFac.isBanned && !foursigmaFac.isMember && !foursigmaFac.alreadyInvited &&
|
||||
this.companyName == Locations.Sector12FourSigma && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(foursigmaFac);
|
||||
}
|
||||
|
||||
|
||||
//KuaiGong International
|
||||
var kuaigonginternationalFac = Factions["KuaiGong International"];
|
||||
if (!kuaigonginternationalFac.isBanned && !kuaigonginternationalFac.isMember &&
|
||||
!kuaigonginternationalFac.alreadyInvited &&
|
||||
!kuaigonginternationalFac.alreadyInvited &&
|
||||
this.companyName == Locations.ChongqingKuaiGongInternational && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
|
||||
invitedFactions.push(kuaigonginternationalFac);
|
||||
}
|
||||
|
||||
|
||||
//Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
|
||||
var fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
|
||||
var fulcrumSecretServer = AllServers[SpecialServerIps[SpecialServerNames.FulcrumSecretTechnologies]];
|
||||
@ -453,13 +453,13 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
console.log("ERROR: Could not find Fulcrum Secret Technologies Server");
|
||||
} else {
|
||||
if (!fulcrumsecrettechonologiesFac.isBanned && !fulcrumsecrettechonologiesFac.isMember &&
|
||||
!fulcrumsecrettechonologiesFac.alreadyInvited &&
|
||||
fulcrumSecretServer.manuallyHacked &&
|
||||
!fulcrumsecrettechonologiesFac.alreadyInvited &&
|
||||
fulcrumSecretServer.manuallyHacked &&
|
||||
this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) {
|
||||
invitedFactions.push(fulcrumsecrettechonologiesFac);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//BitRunners
|
||||
var bitrunnersFac = Factions["BitRunners"];
|
||||
var homeComp = this.getHomeComputer();
|
||||
@ -470,7 +470,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
!bitrunnersFac.alreadyInvited && this.hacking_skill >= 500 && homeComp.maxRam >= 128) {
|
||||
invitedFactions.push(bitrunnersFac);
|
||||
}
|
||||
|
||||
|
||||
//The Black Hand
|
||||
var theblackhandFac = Factions["The Black Hand"];
|
||||
var blackhandServer = AllServers[SpecialServerIps[SpecialServerNames.TheBlackHandServer]];
|
||||
@ -480,7 +480,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
!theblackhandFac.alreadyInvited && this.hacking_skill >= 350 && homeComp.maxRam >= 64) {
|
||||
invitedFactions.push(theblackhandFac);
|
||||
}
|
||||
|
||||
|
||||
//NiteSec
|
||||
var nitesecFac = Factions["NiteSec"];
|
||||
var nitesecServer = AllServers[SpecialServerIps[SpecialServerNames.NiteSecServer]];
|
||||
@ -490,99 +490,99 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
!nitesecFac.alreadyInvited && this.hacking_skill >= 200 && homeComp.maxRam >= 32) {
|
||||
invitedFactions.push(nitesecFac);
|
||||
}
|
||||
|
||||
|
||||
//Chongqing
|
||||
var chongqingFac = Factions["Chongqing"];
|
||||
if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited &&
|
||||
this.money >= 20000000 && this.city == Locations.Chongqing) {
|
||||
invitedFactions.push(chongqingFac);
|
||||
}
|
||||
|
||||
|
||||
//Sector-12
|
||||
var sector12Fac = Factions["Sector-12"];
|
||||
if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
|
||||
if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
|
||||
this.money >= 15000000 && this.city == Locations.Sector12) {
|
||||
invitedFactions.push(sector12Fac);
|
||||
}
|
||||
|
||||
|
||||
//New Tokyo
|
||||
var newtokyoFac = Factions["New Tokyo"];
|
||||
if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited &&
|
||||
this.money >= 20000000 && this.city == Locations.NewTokyo) {
|
||||
invitedFactions.push(newtokyoFac);
|
||||
}
|
||||
|
||||
|
||||
//Aevum
|
||||
var aevumFac = Factions["Aevum"];
|
||||
if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited &&
|
||||
this.money >= 40000000 && this.city == Locations.Aevum) {
|
||||
invitedFactions.push(aevumFac);
|
||||
}
|
||||
|
||||
|
||||
//Ishima
|
||||
var ishimaFac = Factions["Ishima"];
|
||||
if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited &&
|
||||
this.money >= 30000000 && this.city == Locations.Ishima) {
|
||||
invitedFactions.push(ishimaFac);
|
||||
}
|
||||
|
||||
|
||||
//Volhaven
|
||||
var volhavenFac = Factions["Volhaven"];
|
||||
if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited &&
|
||||
this.money >= 50000000 && this.city == Locations.Volhaven) {
|
||||
invitedFactions.push(volhavenFac);
|
||||
}
|
||||
|
||||
|
||||
//Speakers for the Dead
|
||||
var speakersforthedeadFac = Factions["Speakers for the Dead"];
|
||||
if (!speakersforthedeadFac.isBanned && !speakersforthedeadFac.isMember && !speakersforthedeadFac.alreadyInvited &&
|
||||
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
|
||||
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
|
||||
this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 &&
|
||||
this.numPeopleKilledTotal >= 100 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
|
||||
this.companyName != Locations.Sector12NSA) {
|
||||
invitedFactions.push(speakersforthedeadFac);
|
||||
}
|
||||
|
||||
|
||||
//The Dark Army
|
||||
var thedarkarmyFac = Factions["The Dark Army"];
|
||||
if (!thedarkarmyFac.isBanned && !thedarkarmyFac.isMember && !thedarkarmyFac.alreadyInvited &&
|
||||
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
|
||||
this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing &&
|
||||
this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
|
||||
if (!thedarkarmyFac.isBanned && !thedarkarmyFac.isMember && !thedarkarmyFac.alreadyInvited &&
|
||||
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
|
||||
this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing &&
|
||||
this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
|
||||
this.companyName != Locations.Sector12NSA) {
|
||||
invitedFactions.push(thedarkarmyFac);
|
||||
}
|
||||
|
||||
|
||||
//The Syndicate
|
||||
var thesyndicateFac = Factions["The Syndicate"];
|
||||
if (!thesyndicateFac.isBanned && !thesyndicateFac.isMember && !thesyndicateFac.alreadyInvited &&
|
||||
if (!thesyndicateFac.isBanned && !thesyndicateFac.isMember && !thesyndicateFac.alreadyInvited &&
|
||||
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
|
||||
this.dexterity >= 200 && this.agility >= 200 &&
|
||||
this.dexterity >= 200 && this.agility >= 200 &&
|
||||
(this.city == Locations.Aevum || this.city == Locations.Sector12) &&
|
||||
this.money >= 10000000 && this.karma <= -90 &&
|
||||
this.money >= 10000000 && this.karma <= -90 &&
|
||||
this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) {
|
||||
invitedFactions.push(thesyndicateFac);
|
||||
}
|
||||
|
||||
|
||||
//Silhouette
|
||||
var silhouetteFac = Factions["Silhouette"];
|
||||
if (!silhouetteFac.isBanned && !silhouetteFac.isMember && !silhouetteFac.alreadyInvited &&
|
||||
(this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
|
||||
this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
|
||||
(this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
|
||||
this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
|
||||
this.companyPosition.positionName == CompanyPositions.CEO.positionName) &&
|
||||
this.money >= 15000000 && this.karma <= -22) {
|
||||
invitedFactions.push(silhouetteFac);
|
||||
}
|
||||
|
||||
|
||||
//Tetrads
|
||||
var tetradsFac = Factions["Tetrads"];
|
||||
if (!tetradsFac.isBanned && !tetradsFac.isMember && !tetradsFac.alreadyInvited &&
|
||||
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
|
||||
if (!tetradsFac.isBanned && !tetradsFac.isMember && !tetradsFac.alreadyInvited &&
|
||||
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
|
||||
this.city == Locations.Ishima) && this.strength >= 75 && this.defense >= 75 &&
|
||||
this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) {
|
||||
invitedFactions.push(tetradsFac);
|
||||
}
|
||||
|
||||
|
||||
//SlumSnakes
|
||||
var slumsnakesFac = Factions["Slum Snakes"];
|
||||
if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited &&
|
||||
@ -590,7 +590,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
this.agility >= 30 && this.karma <= -9 && this.money >= 1000000) {
|
||||
invitedFactions.push(slumsnakesFac);
|
||||
}
|
||||
|
||||
|
||||
//Netburners
|
||||
var netburnersFac = Factions["Netburners"];
|
||||
var totalHacknetRam = 0;
|
||||
@ -602,20 +602,20 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
totalHacknetCores += Player.hacknetNodes[i].numCores;
|
||||
}
|
||||
if (!netburnersFac.isBanned && !netburnersFac.isMember && !netburnersFac.alreadyInvited &&
|
||||
this.hacking_skill >= 80 && totalHacknetRam >= 8 &&
|
||||
this.hacking_skill >= 80 && totalHacknetRam >= 8 &&
|
||||
totalHacknetCores >= 4 && totalHacknetLevels >= 100) {
|
||||
invitedFactions.push(netburnersFac);
|
||||
}
|
||||
|
||||
|
||||
//Tian Di Hui
|
||||
var tiandihuiFac = Factions["Tian Di Hui"];
|
||||
if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited &&
|
||||
this.money >= 1000000 && this.hacking_skill >= 50 &&
|
||||
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
|
||||
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
|
||||
this.city == Locations.Ishima)) {
|
||||
invitedFactions.push(tiandihuiFac);
|
||||
}
|
||||
|
||||
|
||||
//CyberSec
|
||||
var cybersecFac = Factions["CyberSec"];
|
||||
var cybersecServer = AllServers[SpecialServerIps[SpecialServerNames.CyberSecServer]];
|
||||
@ -625,7 +625,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
|
||||
!cybersecFac.alreadyInvited && this.hacking_skill >= 50) {
|
||||
invitedFactions.push(cybersecFac);
|
||||
}
|
||||
|
||||
|
||||
return invitedFactions;
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ inviteToFaction = function(faction) {
|
||||
joinFaction = function(faction) {
|
||||
faction.isMember = true;
|
||||
Player.factions.push(faction.name);
|
||||
|
||||
|
||||
//Determine what factions you are banned from now that you have joined this faction
|
||||
if (faction.name == "Chongqing") {
|
||||
Factions["Sector-12"].isBanned = true;
|
||||
@ -675,7 +675,7 @@ leaveFaction = function(faction) {
|
||||
if (i > -1) {
|
||||
Player.factions.splice(i, 1);
|
||||
}
|
||||
|
||||
|
||||
//Unban from faction
|
||||
if (faction.name == "Chongqing") {
|
||||
Factions["Sector-12"].isBanned = false;
|
||||
@ -713,43 +713,43 @@ displayFactionContent = function(factionName) {
|
||||
var faction = Factions[factionName];
|
||||
document.getElementById("faction-name").innerHTML = factionName;
|
||||
document.getElementById("faction-info").innerHTML = "<i>" + faction.info + "</i>";
|
||||
document.getElementById("faction-reputation").innerHTML = "Reputation: " + formatNumber(faction.playerReputation, 4) +
|
||||
"<span class='tooltiptext'>You will earn " +
|
||||
document.getElementById("faction-reputation").innerHTML = "Reputation: " + formatNumber(faction.playerReputation, 4) +
|
||||
"<span class='tooltiptext'>You will earn " +
|
||||
formatNumber(faction.playerReputation / CONSTANTS.FactionReputationToFavor, 4) +
|
||||
" faction favor upon resetting after installing an Augmentation</span>";
|
||||
document.getElementById("faction-favor").innerHTML = "Faction Favor: " + formatNumber(faction.favor, 4) +
|
||||
"<span class='tooltiptext'>Faction favor increases the rate at which " +
|
||||
"you earn reputation for this faction by 1% per favor. Faction favor " +
|
||||
"<span class='tooltiptext'>Faction favor increases the rate at which " +
|
||||
"you earn reputation for this faction by 1% per favor. Faction favor " +
|
||||
"is gained whenever you reset after installing an Augmentation. The amount of " +
|
||||
"favor you gain depends on how much reputation you have with the faction</span>";
|
||||
|
||||
|
||||
var hackDiv = document.getElementById("faction-hack-div");
|
||||
var fieldWorkDiv = document.getElementById("faction-fieldwork-div");
|
||||
var securityWorkDiv = document.getElementById("faction-securitywork-div");
|
||||
var donateDiv = document.getElementById("faction-donate-div");
|
||||
|
||||
|
||||
//Set new event listener for all of the work buttons
|
||||
//The old buttons need to be replaced to clear the old event listeners
|
||||
var newHackButton = clearEventListeners("faction-hack-button");
|
||||
var newFieldWorkButton = clearEventListeners("faction-fieldwork-button");
|
||||
var newSecurityWorkButton = clearEventListeners("faction-securitywork-button");
|
||||
var newDonateWorkButton = clearEventListeners("faction-donate-button");
|
||||
|
||||
|
||||
newHackButton.addEventListener("click", function() {
|
||||
Player.startFactionHackWork(faction);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
newFieldWorkButton.addEventListener("click", function() {
|
||||
Player.startFactionFieldWork(faction);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
newSecurityWorkButton.addEventListener("click", function() {
|
||||
Player.startFactionSecurityWork(faction);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
newDonateWorkButton.addEventListener("click", function() {
|
||||
var donateAmountVal = document.getElementById("faction-donate-input").value;
|
||||
if (isPositiveNumber(donateAmountVal)) {
|
||||
@ -761,40 +761,40 @@ displayFactionContent = function(factionName) {
|
||||
Player.loseMoney(numMoneyDonate);
|
||||
var repGain = numMoneyDonate / 1000000 * Player.faction_rep_mult;
|
||||
faction.playerReputation += repGain;
|
||||
dialogBoxCreate("You just donated $" + formatNumber(numMoneyDonate, 2) + " to " +
|
||||
faction.name + " to gain " + formatNumber(repGain, 3) + " reputation");
|
||||
dialogBoxCreate("You just donated $" + formatNumber(numMoneyDonate, 2) + " to " +
|
||||
faction.name + " to gain " + formatNumber(repGain, 3) + " reputation");
|
||||
displayFactionContent(factionName);
|
||||
} else {
|
||||
dialogBoxCreate("Invalid amount entered!");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//Set new event listener for the purchase augmentation buttons
|
||||
//The old button needs to be replaced to clear the old event listeners
|
||||
var newPurchaseAugmentationsButton = clearEventListeners("faction-purchase-augmentations");
|
||||
|
||||
|
||||
newPurchaseAugmentationsButton.addEventListener("click", function() {
|
||||
Engine.hideAllContent();
|
||||
Engine.Display.factionAugmentationsContent.style.visibility = "visible";
|
||||
|
||||
|
||||
var newBackButton = clearEventListeners("faction-augmentations-back-button");
|
||||
newBackButton.addEventListener("click", function() {
|
||||
Engine.loadFactionContent();
|
||||
displayFactionContent(factionName);
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
displayFactionAugmentations(factionName);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
if (faction.isMember) {
|
||||
if (faction.favor >= 150) {
|
||||
donateDiv.style.display = "inline";
|
||||
} else {
|
||||
donateDiv.style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
switch(faction.name) {
|
||||
case "Illuminati":
|
||||
hackDiv.style.display = "inline";
|
||||
@ -963,12 +963,12 @@ displayFactionContent = function(factionName) {
|
||||
displayFactionAugmentations = function(factionName) {
|
||||
document.getElementById("faction-augmentations-page-desc").innerHTML = "Lists all augmentations that are available to purchase from " + factionName;
|
||||
var faction = Factions[factionName];
|
||||
|
||||
|
||||
var augmentationsList = document.getElementById("faction-augmentations-list");
|
||||
while (augmentationsList.firstChild) {
|
||||
augmentationsList.removeChild(augmentationsList.firstChild);
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < faction.augmentations.length; ++i) {
|
||||
(function () {
|
||||
var aug = Augmentations[faction.augmentations[i]];
|
||||
@ -987,7 +987,7 @@ displayFactionAugmentations = function(factionName) {
|
||||
owned = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var item = document.createElement("li");
|
||||
var span = document.createElement("span");
|
||||
var aDiv = document.createElement("div");
|
||||
@ -1013,21 +1013,21 @@ displayFactionAugmentations = function(factionName) {
|
||||
aElem.innerHTML += " - Level " + (getNextNeurofluxLevel());
|
||||
}
|
||||
span.style.display = "inline-block"
|
||||
|
||||
//The div will have the tooltip.
|
||||
|
||||
//The div will have the tooltip.
|
||||
aDiv.setAttribute("class", "tooltip");
|
||||
aDiv.innerHTML = '<span class="tooltiptext">' + aug.info + " </span>";
|
||||
aDiv.appendChild(aElem);
|
||||
|
||||
|
||||
aElem.addEventListener("click", function() {
|
||||
purchaseAugmentationBoxCreate(aug, faction);
|
||||
});
|
||||
|
||||
|
||||
span.appendChild(aDiv);
|
||||
span.appendChild(pElem);
|
||||
|
||||
|
||||
item.appendChild(span);
|
||||
|
||||
|
||||
augmentationsList.appendChild(item);
|
||||
}()); //Immediate invocation closure
|
||||
}
|
||||
@ -1038,11 +1038,11 @@ function processPassiveFactionRepGain(numCycles) {
|
||||
for (var name in Factions) {
|
||||
if (Factions.hasOwnProperty(name)) {
|
||||
var faction = Factions[name];
|
||||
|
||||
|
||||
//TODO Get hard value of 1 rep per "rep gain cycle"" for now..
|
||||
//maybe later make this based on
|
||||
//a player's 'status' like how powerful they are and how much money they have
|
||||
if (faction.isMember) {faction.playerReputation += numTimesGain;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ function hacknetNodesInit() {
|
||||
hacknetNodePurchaseMultiplier = 10;
|
||||
updateHacknetNodesMultiplierButtons();
|
||||
updateHacknetNodesContent();
|
||||
return false;
|
||||
return false;
|
||||
});
|
||||
var multMax = document.getElementById("hacknet-nodes-max-multiplier");
|
||||
multMax.addEventListener("click", function() {
|
||||
@ -34,43 +34,48 @@ document.addEventListener("DOMContentLoaded", hacknetNodesInit, false);
|
||||
function HacknetNode(name) {
|
||||
this.level = 1;
|
||||
this.ram = 1; //GB
|
||||
this.cores = 1;
|
||||
|
||||
this.cores = 1;
|
||||
|
||||
this.name = name;
|
||||
|
||||
|
||||
this.totalMoneyGenerated = 0;
|
||||
this.onlineTimeSeconds = 0;
|
||||
|
||||
|
||||
this.moneyGainRatePerSecond = 0;
|
||||
}
|
||||
|
||||
HacknetNode.prototype.updateMoneyGainRate = function() {
|
||||
//How much extra $/s is gained per level
|
||||
var gainPerLevel = CONSTANTS.HacknetNodeMoneyGainPerLevel;
|
||||
|
||||
this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
|
||||
Math.pow(1.035, this.ram-1) *
|
||||
|
||||
this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
|
||||
Math.pow(1.035, this.ram-1) *
|
||||
((this.cores + 5) / 6) * Player.hacknet_node_money_mult;
|
||||
if (isNaN(this.moneyGainRatePerSecond)) {
|
||||
this.moneyGainRatePerSecond = 0;
|
||||
dialogBoxCreate("Error in calculating Hacknet Node production. Please report to game developer");
|
||||
}
|
||||
|
||||
|
||||
updateTotalHacknetProduction();
|
||||
}
|
||||
|
||||
HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) {
|
||||
if (levels < 1) {return 0;}
|
||||
var mult = CONSTANTS.HacknetNodeUpgradeLevelMult;
|
||||
var totalMultiplier = 0; //Summed
|
||||
var totalMultiplier = 0; //Summed
|
||||
var currLevel = this.level;
|
||||
for (var i = 0; i < levels; ++i) {
|
||||
totalMultiplier += Math.pow(mult, currLevel);
|
||||
totalMultiplier += Math.pow(mult, currLevel);
|
||||
++currLevel;
|
||||
}
|
||||
return CONSTANTS.BaseCostForHacknetNode / 2 * totalMultiplier * Player.hacknet_node_level_cost_mult;
|
||||
}
|
||||
|
||||
//Wrapper function for Netscript
|
||||
HacknetNode.prototype.getLevelUpgradeCost = function(levels=1) {
|
||||
return this.calculateLevelUpgradeCost(levels);
|
||||
}
|
||||
|
||||
HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
|
||||
var cost = this.calculateLevelUpgradeCost(levels);
|
||||
if (isNaN(cost)) {return false;}
|
||||
@ -92,7 +97,7 @@ HacknetNode.prototype.upgradeLevel = function(levels=1) {
|
||||
|
||||
HacknetNode.prototype.calculateRamUpgradeCost = function() {
|
||||
var numUpgrades = Math.log2(this.ram);
|
||||
|
||||
|
||||
//Calculate cost
|
||||
//Base cost of RAM is 50k per 1GB, increased by some multiplier for each time RAM is upgraded
|
||||
var baseCost = this.ram * CONSTANTS.BaseCostFor1GBOfRamHacknetNode;
|
||||
@ -100,6 +105,11 @@ HacknetNode.prototype.calculateRamUpgradeCost = function() {
|
||||
return baseCost * mult * Player.hacknet_node_ram_cost_mult;
|
||||
}
|
||||
|
||||
//Wrapper function for Netscript
|
||||
HacknetNode.prototype.getRamUpgradeCost = function() {
|
||||
return this.calculateRamUpgradeCost();
|
||||
}
|
||||
|
||||
HacknetNode.prototype.purchaseRamUpgrade = function() {
|
||||
var cost = this.calculateRamUpgradeCost();
|
||||
if (isNaN(cost)) {return false;}
|
||||
@ -122,6 +132,11 @@ HacknetNode.prototype.calculateCoreUpgradeCost = function() {
|
||||
return coreBaseCost * Math.pow(mult, this.cores-1) * Player.hacknet_node_core_cost_mult;
|
||||
}
|
||||
|
||||
//Wrapper function for Netscript
|
||||
HacknetNode.prototype.getCoreUpgradeCost = function() {
|
||||
return this.calculateCoreUpgradeCost();
|
||||
}
|
||||
|
||||
HacknetNode.prototype.purchaseCoreUpgrade = function() {
|
||||
var cost = this.calculateCoreUpgradeCost();
|
||||
if (isNaN(cost)) {return false;}
|
||||
@ -159,31 +174,31 @@ purchaseHacknet = function() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* END INTERACTIVE TUTORIAL */
|
||||
|
||||
|
||||
var cost = getCostOfNextHacknetNode();
|
||||
if (isNaN(cost)) {throw new Error("Cost is NaN"); return;}
|
||||
if (cost > Player.money) {
|
||||
//dialogBoxCreate("You cannot afford to purchase a Hacknet Node!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Auto generate a name for the node for now...TODO
|
||||
var numOwned = Player.hacknetNodes.length;
|
||||
var name = "hacknet-node-" + numOwned;
|
||||
var node = new HacknetNode(name);
|
||||
node.updateMoneyGainRate();
|
||||
|
||||
|
||||
Player.loseMoney(cost);
|
||||
Player.hacknetNodes.push(node);
|
||||
|
||||
|
||||
displayHacknetNodesContent();
|
||||
updateTotalHacknetProduction();
|
||||
return numOwned;
|
||||
}
|
||||
|
||||
//Calculates the total production from all HacknetNodes
|
||||
//Calculates the total production from all HacknetNodes
|
||||
updateTotalHacknetProduction = function() {
|
||||
var total = 0;
|
||||
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
|
||||
@ -235,10 +250,10 @@ getMaxNumberLevelUpgrades = function(nodeObj) {
|
||||
if (nodeObj.calculateLevelUpgradeCost(levelsToMax) < Player.money) {
|
||||
return levelsToMax;
|
||||
}
|
||||
|
||||
|
||||
while (min <= max) {
|
||||
var curr = (min + max) / 2 | 0;
|
||||
if (curr != CONSTANTS.HacknetNodeMaxLevel &&
|
||||
if (curr != CONSTANTS.HacknetNodeMaxLevel &&
|
||||
nodeObj.calculateLevelUpgradeCost(curr) < Player.money &&
|
||||
nodeObj.calculateLevelUpgradeCost(curr+1) > Player.money) {
|
||||
return Math.min(levelsToMax, curr);
|
||||
@ -256,21 +271,21 @@ getMaxNumberLevelUpgrades = function(nodeObj) {
|
||||
displayHacknetNodesContent = function() {
|
||||
//Update Hacknet Nodes button
|
||||
var newPurchaseButton = clearEventListeners("hacknet-nodes-purchase-button");
|
||||
|
||||
|
||||
newPurchaseButton.addEventListener("click", function() {
|
||||
purchaseHacknet();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//Handle Purchase multiplier buttons
|
||||
updateHacknetNodesMultiplierButtons();
|
||||
|
||||
|
||||
//Remove all old hacknet Node DOM elements
|
||||
var hacknetNodesList = document.getElementById("hacknet-nodes-list");
|
||||
while (hacknetNodesList.firstChild) {
|
||||
hacknetNodesList.removeChild(hacknetNodesList.firstChild);
|
||||
}
|
||||
|
||||
|
||||
//Then re-create them
|
||||
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
|
||||
createHacknetNodeDomElement(Player.hacknetNodes[i]);
|
||||
@ -289,12 +304,12 @@ updateHacknetNodesContent = function() {
|
||||
} else {
|
||||
purchaseButton.setAttribute("class", "a-link-button");
|
||||
}
|
||||
|
||||
|
||||
//Update player's money
|
||||
var moneyElem = document.getElementById("hacknet-nodes-money");
|
||||
moneyElem.innerHTML = "Money: $" + formatNumber(Player.money, 2) + "<br>" +
|
||||
moneyElem.innerHTML = "Money: $" + formatNumber(Player.money, 2) + "<br>" +
|
||||
"Total production from all Hacknet Nodes: $" + formatNumber(Player.totalHacknetNodeProduction, 2) + " / second";
|
||||
|
||||
|
||||
//Update information in each owned hacknet node
|
||||
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
|
||||
updateHacknetNodeDomElement(Player.hacknetNodes[i]);
|
||||
@ -304,26 +319,26 @@ updateHacknetNodesContent = function() {
|
||||
//Creates a single Hacknet Node DOM element
|
||||
createHacknetNodeDomElement = function(nodeObj) {
|
||||
var nodeName = nodeObj.name;
|
||||
|
||||
|
||||
var listItem = document.createElement("li");
|
||||
listItem.setAttribute("class", "hacknet-node");
|
||||
|
||||
|
||||
var span = document.createElement("span");
|
||||
span.style.display = "inline";
|
||||
|
||||
|
||||
var buttonDiv = document.createElement("div");
|
||||
buttonDiv.setAttribute("class", "hacknet-node-button-div");
|
||||
|
||||
|
||||
//Text
|
||||
var txt = document.createElement("p");
|
||||
//txt.setAttribute("id", "hacknet-node-text-" + nodeName);
|
||||
txt.id = "hacknet-node-text-" + nodeName;
|
||||
|
||||
|
||||
//Upgrade buttons
|
||||
var upgradeLevelButton = document.createElement("a");
|
||||
var upgradeRamButton = document.createElement("a");
|
||||
var upgradeCoreButton = document.createElement("a");
|
||||
|
||||
|
||||
//upgradeLevelButton.setAttribute("id", "hacknet-node-upgrade-level-" + nodeName);
|
||||
upgradeLevelButton.id = "hacknet-node-upgrade-level-" + nodeName;
|
||||
upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
|
||||
@ -352,7 +367,7 @@ createHacknetNodeDomElement = function(nodeObj) {
|
||||
updateHacknetNodesContent();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//Put all the components together in the li element
|
||||
span.appendChild(txt);
|
||||
buttonDiv.appendChild(upgradeLevelButton);
|
||||
@ -360,9 +375,9 @@ createHacknetNodeDomElement = function(nodeObj) {
|
||||
buttonDiv.appendChild(upgradeCoreButton);
|
||||
span.appendChild(buttonDiv);
|
||||
listItem.appendChild(span);
|
||||
|
||||
|
||||
document.getElementById("hacknet-nodes-list").appendChild(listItem);
|
||||
|
||||
|
||||
//Set the text and stuff inside the DOM element
|
||||
updateHacknetNodeDomElement(nodeObj);
|
||||
}
|
||||
@ -373,12 +388,12 @@ updateHacknetNodeDomElement = function(nodeObj) {
|
||||
var txt = document.getElementById("hacknet-node-text-" + nodeName);
|
||||
if (txt == null) {throw new Error("Cannot find text element");}
|
||||
txt.innerHTML = "Node name: " + nodeName + "<br>" +
|
||||
"Production: $" + formatNumber(nodeObj.totalMoneyGenerated, 2) +
|
||||
" ($" + formatNumber(nodeObj.moneyGainRatePerSecond, 2) + " / second) <br>" +
|
||||
"Level: " + nodeObj.level + "<br>" +
|
||||
"RAM: " + nodeObj.ram + "GB<br>" +
|
||||
"Production: $" + formatNumber(nodeObj.totalMoneyGenerated, 2) +
|
||||
" ($" + formatNumber(nodeObj.moneyGainRatePerSecond, 2) + " / second) <br>" +
|
||||
"Level: " + nodeObj.level + "<br>" +
|
||||
"RAM: " + nodeObj.ram + "GB<br>" +
|
||||
"Cores: " + nodeObj.cores;
|
||||
|
||||
|
||||
//Upgrade level
|
||||
var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName);
|
||||
if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");}
|
||||
@ -394,7 +409,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
|
||||
var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level;
|
||||
multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier);
|
||||
}
|
||||
|
||||
|
||||
var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier);
|
||||
upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier +
|
||||
" - $" + formatNumber(upgradeLevelCost, 2);
|
||||
@ -404,7 +419,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
|
||||
upgradeLevelButton.setAttribute("class", "a-link-button");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Upgrade RAM
|
||||
var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName);
|
||||
if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");}
|
||||
@ -420,7 +435,7 @@ updateHacknetNodeDomElement = function(nodeObj) {
|
||||
upgradeRamButton.setAttribute("class", "a-link-button");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Upgrade Cores
|
||||
var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName);
|
||||
if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");}
|
||||
@ -464,4 +479,4 @@ getHacknetNode = function(name) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -205,8 +205,8 @@ function evaluate(exp, workerScript) {
|
||||
reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". This is a bug please report to game developer"));
|
||||
break;
|
||||
} //End switch
|
||||
}, CONSTANTS.CodeInstructionRunTime); //End setTimeout, the Netscript operation run time
|
||||
|
||||
}, Settings.CodeInstructionRunTime); //End setTimeout, the Netscript operation run time
|
||||
|
||||
}); // End Promise
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ function evalAssignment(exp, workerScript) {
|
||||
if (exp.operator !== "=" && !(exp.left.name in env.vars)){
|
||||
return reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.left.name + " not definied"));
|
||||
}
|
||||
|
||||
|
||||
var expRightPromise = evaluate(exp.right, workerScript);
|
||||
expRightPromise.then(function(expRight) {
|
||||
if (exp.left.type == "MemberExpression") {
|
||||
@ -452,7 +452,7 @@ function evaluateFor(exp, workerScript) {
|
||||
var env = workerScript.env;
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (env.stopFlag) {reject(workerScript); return;}
|
||||
|
||||
|
||||
var pCond = evaluate(exp.test, workerScript);
|
||||
pCond.then(function(resCond) {
|
||||
if (resCond) {
|
||||
@ -485,21 +485,21 @@ function evaluateFor(exp, workerScript) {
|
||||
|
||||
function evaluateWhile(exp, workerScript) {
|
||||
var env = workerScript.env;
|
||||
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (env.stopFlag) {reject(workerScript); return;}
|
||||
|
||||
|
||||
var pCond = new Promise(function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
var evaluatePromise = evaluate(exp.test, workerScript);
|
||||
evaluatePromise.then(function(resCond) {
|
||||
resolve(resCond);
|
||||
}, function(e) {
|
||||
reject(e);
|
||||
reject(e);
|
||||
});
|
||||
}, CONSTANTS.CodeInstructionRunTime);
|
||||
});
|
||||
|
||||
|
||||
pCond.then(function(resCond) {
|
||||
if (resCond) {
|
||||
//Run the while loop code
|
||||
@ -513,7 +513,7 @@ function evaluateWhile(exp, workerScript) {
|
||||
});
|
||||
}, CONSTANTS.CodeInstructionRunTime);
|
||||
});
|
||||
|
||||
|
||||
//After the code executes make a recursive call
|
||||
pCode.then(function(resCode) {
|
||||
var recursiveCall = evaluateWhile(exp, workerScript);
|
||||
@ -545,13 +545,13 @@ function evaluateHacknetNode(exp, workerScript) {
|
||||
(exp.op.type == "var" && exp.op.value == "length")) {
|
||||
resolve(Player.hacknetNodes.length);
|
||||
workerScript.scriptRef.log("hacknetnodes.length returned " + Player.hacknetNodes.length);
|
||||
return;
|
||||
return;
|
||||
} else {
|
||||
workerScript.scriptRef.log("Invalid/null index for hacknetnodes");
|
||||
reject(makeRuntimeRejectMsg(workerScript, "Invalid/null index. hacknetnodes array must be accessed with an index"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
var indexPromise = evaluate(exp.index.value, workerScript);
|
||||
indexPromise.then(function(index) {
|
||||
@ -576,11 +576,11 @@ function evaluateHacknetNode(exp, workerScript) {
|
||||
case "cores":
|
||||
resolve(nodeObj.numCores);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
reject(makeRuntimeRejectMsg(workerScript, "Unrecognized property for Hacknet Node. Valid properties: ram, cores, level"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} else if (exp.op.type == "call") {
|
||||
switch(exp.op.func.value) {
|
||||
case "upgradeLevel":
|
||||
@ -633,7 +633,7 @@ function evaluateHacknetNode(exp, workerScript) {
|
||||
}, function(e) {
|
||||
reject(e);
|
||||
});
|
||||
|
||||
|
||||
}, CONSTANTS.CodeInstructionRunTime);
|
||||
}, function(e) {
|
||||
reject(e);
|
||||
@ -643,10 +643,10 @@ function evaluateHacknetNode(exp, workerScript) {
|
||||
|
||||
function evaluateProg(exp, workerScript, index) {
|
||||
var env = workerScript.env;
|
||||
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (env.stopFlag) {reject(workerScript); return;}
|
||||
|
||||
|
||||
if (index >= exp.body.length) {
|
||||
resolve("progFinished");
|
||||
} else {
|
||||
@ -661,7 +661,7 @@ function evaluateProg(exp, workerScript, index) {
|
||||
});
|
||||
}, CONSTANTS.CodeInstructionRunTime);
|
||||
});
|
||||
|
||||
|
||||
//After the code finishes evaluating, evaluate the next line recursively
|
||||
code.then(function(codeRes) {
|
||||
var nextLine = evaluateProg(exp, workerScript, index + 1);
|
||||
@ -678,7 +678,7 @@ function evaluateProg(exp, workerScript, index) {
|
||||
}
|
||||
|
||||
function netscriptDelay(time) {
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function(resolve) {
|
||||
setTimeout(resolve, time);
|
||||
});
|
||||
}
|
||||
@ -786,7 +786,7 @@ function scriptCalculateHackingTime(server) {
|
||||
return hackingTime;
|
||||
}
|
||||
|
||||
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
||||
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
||||
function scriptCalculateExpGain(server) {
|
||||
if (server.baseDifficulty == null) {
|
||||
server.baseDifficulty = server.hackDifficulty;
|
||||
@ -818,4 +818,4 @@ function scriptCalculateWeakenTime(server) {
|
||||
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50);
|
||||
var weakenTime = 20 * skillFactor / Player.hacking_speed_mult; //This is in seconds
|
||||
return weakenTime * 1000;
|
||||
}
|
||||
}
|
||||
|
@ -28,21 +28,21 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
|
||||
throw makeRuntimeRejectMsg(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
|
||||
}
|
||||
|
||||
//Calculate the hacking time
|
||||
|
||||
//Calculate the hacking time
|
||||
var hackingTime = scriptCalculateHackingTime(server); //This is in seconds
|
||||
|
||||
|
||||
//No root access or skill level too low
|
||||
if (server.hasAdminRights == false) {
|
||||
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access");
|
||||
}
|
||||
|
||||
|
||||
if (server.requiredHackingSkill > Player.hacking_skill) {
|
||||
workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
|
||||
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 + ")");
|
||||
return netscriptDelay(hackingTime* 1000).then(function() {
|
||||
@ -54,7 +54,7 @@ function NetscriptFunctions(workerScript) {
|
||||
if (rand < hackChance) { //Success!
|
||||
var moneyGained = scriptCalculatePercentMoneyHacked(server);
|
||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
|
||||
|
||||
|
||||
//Over-the-top safety checks
|
||||
if (moneyGained <= 0) {
|
||||
moneyGained = 0;
|
||||
@ -63,7 +63,7 @@ function NetscriptFunctions(workerScript) {
|
||||
if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
|
||||
server.moneyAvailable -= moneyGained;
|
||||
if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
|
||||
|
||||
|
||||
Player.gainMoney(moneyGained);
|
||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||
workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
|
||||
@ -73,7 +73,7 @@ function NetscriptFunctions(workerScript) {
|
||||
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);
|
||||
} else {
|
||||
} else {
|
||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||
Player.gainHackingExp(expGainedOnFailure);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
|
||||
@ -105,13 +105,13 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
|
||||
|
||||
//No root access or skill level too low
|
||||
if (server.hasAdminRights == false) {
|
||||
workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access");
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
|
||||
}
|
||||
|
||||
|
||||
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 + ")");
|
||||
@ -124,13 +124,13 @@ 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 +")");
|
||||
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);
|
||||
Player.gainHackingExp(expGain);
|
||||
return Promise.resolve(growthPercentage);
|
||||
});
|
||||
});
|
||||
},
|
||||
weaken : function(ip){
|
||||
var threads = workerScript.scriptRef.threads;
|
||||
@ -143,28 +143,28 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
|
||||
|
||||
//No root access or skill level too low
|
||||
if (server.hasAdminRights == false) {
|
||||
workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access");
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
|
||||
}
|
||||
|
||||
|
||||
var weakenTime = scriptCalculateWeakenTime(server);
|
||||
//console.log("Executing weaken() on server " + server.hostname + " in " + formatNumber(weakenTime/1000, 3) + " seconds")
|
||||
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
||||
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
||||
formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
|
||||
return netscriptDelay(weakenTime).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 +
|
||||
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);
|
||||
Player.gainHackingExp(expGain);
|
||||
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);
|
||||
});
|
||||
});
|
||||
},
|
||||
print : function(args){
|
||||
if (args === undefined) {
|
||||
@ -212,7 +212,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (!server.sshPortOpen) {
|
||||
workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
|
||||
server.sshPortOpen = true;
|
||||
server.sshPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
|
||||
@ -233,7 +233,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (!server.ftpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
|
||||
server.ftpPortOpen = true;
|
||||
server.ftpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
|
||||
@ -254,7 +254,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (!server.smtpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
|
||||
server.smtpPortOpen = true;
|
||||
server.smtpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
|
||||
@ -275,7 +275,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (!server.httpPortOpen) {
|
||||
workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
|
||||
server.httpPortOpen = true;
|
||||
server.httpPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
|
||||
@ -296,7 +296,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
if (!server.sqlPortOpen) {
|
||||
workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
|
||||
server.sqlPortOpen = true;
|
||||
server.sqlPortOpen = true;
|
||||
++server.openPortCount;
|
||||
} else {
|
||||
workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
|
||||
@ -318,7 +318,7 @@ function NetscriptFunctions(workerScript) {
|
||||
if (scriptServer == null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
|
||||
}
|
||||
|
||||
|
||||
return runScriptFromScript(scriptServer, scriptname, argsForNewScript, workerScript, threads);
|
||||
},
|
||||
exec : function(scriptname,ip,threads = 1){
|
||||
@ -340,7 +340,7 @@ function NetscriptFunctions(workerScript) {
|
||||
},
|
||||
kill : function(filename,ip){
|
||||
if (filename === undefined || ip === undefined) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
|
||||
throw makeRuntimeRejectMsg(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
|
||||
}
|
||||
var server = getServer(ip);
|
||||
if (server == null) {
|
||||
@ -388,12 +388,12 @@ function NetscriptFunctions(workerScript) {
|
||||
if (destServer == null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid hostname/ip passed into scp() command: " + ip);
|
||||
}
|
||||
|
||||
|
||||
var currServ = getServer(workerScript.serverIp);
|
||||
if (currServ == null) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
|
||||
}
|
||||
|
||||
|
||||
var sourceScript = null;
|
||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||
if (scriptname == currServ.scripts[i].filename) {
|
||||
@ -405,7 +405,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Overwrite script if it already exists
|
||||
for (var i = 0; i < destServer.scripts.length; ++i) {
|
||||
if (scriptname == destServer.scripts[i].filename) {
|
||||
@ -417,7 +417,7 @@ function NetscriptFunctions(workerScript) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Create new script if it does not already exist
|
||||
var newScript = new Script();
|
||||
newScript.filename = scriptname;
|
||||
@ -510,9 +510,18 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getServerNumPortsRequired() returned " + formatNumber(server.numOpenPortsRequired, 0) + " for " + server.hostname);
|
||||
return server.numOpenPortsRequired;
|
||||
},
|
||||
getServerRam : function(ip) {
|
||||
var server = getServer(ip);
|
||||
if (server == null) {
|
||||
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]");
|
||||
return [server.maxRam, server.ramUsed];
|
||||
},
|
||||
fileExists : function(filename,ip=workerScript.serverIp){
|
||||
if (filename === undefined) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
|
||||
throw makeRuntimeRejectMsg(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
|
||||
}
|
||||
var server = getServer(ip);
|
||||
if (server == null) {
|
||||
@ -533,7 +542,7 @@ function NetscriptFunctions(workerScript) {
|
||||
},
|
||||
isRunning : function(filename,ip){
|
||||
if (filename === undefined || ip === undefined) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||
throw makeRuntimeRejectMsg(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||
}
|
||||
var server = getServer(ip);
|
||||
if (server == null) {
|
||||
@ -581,24 +590,24 @@ function NetscriptFunctions(workerScript) {
|
||||
return false;
|
||||
}
|
||||
shares = Math.round(shares);
|
||||
|
||||
|
||||
var totalPrice = stock.price * shares;
|
||||
if (Player.money < totalPrice + CONSTANTS.StockMarketCommission) {
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + formatNumber(shares, 0) + " shares of " +
|
||||
symbol + ". Need $" +
|
||||
workerScript.scriptRef.log("Not enough money to purchase " + formatNumber(shares, 0) + " shares of " +
|
||||
symbol + ". Need $" +
|
||||
formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var origTotal = stock.playerShares * stock.playerAvgPx;
|
||||
Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission);
|
||||
var newTotal = origTotal + totalPrice;
|
||||
stock.playerShares += shares;
|
||||
stock.playerShares += shares;
|
||||
stock.playerAvgPx = newTotal / stock.playerShares;
|
||||
if (Engine.currentPage == Engine.Page.StockMarket) {
|
||||
updateStockPlayerPosition(stock);
|
||||
}
|
||||
workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
workerScript.scriptRef.log("Bought " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share");
|
||||
return true;
|
||||
},
|
||||
@ -619,12 +628,12 @@ function NetscriptFunctions(workerScript) {
|
||||
if (shares == 0) {return false;}
|
||||
var gains = stock.price * shares - CONSTANTS.StockMarketCommission;
|
||||
Player.gainMoney(gains);
|
||||
|
||||
|
||||
//Calculate net profit and add to script stats
|
||||
var netProfit = ((stock.price - stock.playerAvgPx) * shares) - CONSTANTS.StockMarketCommission;
|
||||
if (isNaN(netProfit)) {netProfit = 0;}
|
||||
workerScript.scriptRef.onlineMoneyMade += netProfit;
|
||||
|
||||
|
||||
stock.playerShares -= shares;
|
||||
if (stock.playerShares == 0) {
|
||||
stock.playerAvgPx = 0;
|
||||
@ -632,8 +641,8 @@ 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 " +
|
||||
workerScript.scriptRef.log("Sold " + formatNumber(shares, 0) + " shares of " + stock.symbol + " at $" +
|
||||
formatNumber(stock.price, 2) + " per share. Gained " +
|
||||
"$" + formatNumber(gains, 2));
|
||||
return true;
|
||||
},
|
||||
@ -644,13 +653,13 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
ram = Math.round(ram);
|
||||
if (isNaN(ram) || !powerOfTwo(ram)) {
|
||||
workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
var cost = 2 * ram * CONSTANTS.BaseCostFor1GBOfRamServer;
|
||||
if (cost > Player.money) {
|
||||
workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + formatNumber(cost, 2));
|
||||
@ -659,7 +668,7 @@ function NetscriptFunctions(workerScript) {
|
||||
var newServ = new Server();
|
||||
newServ.init(createRandomIp(), hostnameStr, "", true, false, true, true, ram);
|
||||
AddToAllServers(newServ);
|
||||
|
||||
|
||||
Player.purchasedServers.push(newServ.ip);
|
||||
var homeComputer = Player.getHomeComputer();
|
||||
homeComputer.serversOnNetwork.push(newServ.ip);
|
||||
@ -684,7 +693,7 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
|
||||
}
|
||||
port.push(data);
|
||||
if (port.length > CONSTANTS.MaxPortCapacity) {
|
||||
if (port.length > Settings.MaxPortCapacity) {
|
||||
port.shift();
|
||||
return true;
|
||||
}
|
||||
@ -713,7 +722,6 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* SaveObject.js
|
||||
* Defines the object used to save/load games
|
||||
/* SaveObject.js
|
||||
* Defines the object used to save/load games
|
||||
*/
|
||||
var saveObject = new BitburnerSaveObject();
|
||||
|
||||
@ -13,13 +13,14 @@ function BitburnerSaveObject() {
|
||||
this.GlobalAliasesSave = "";
|
||||
this.MessagesSave = "";
|
||||
this.StockMarketSave = "";
|
||||
this.SettingsSave = "";
|
||||
this.VersionSave = "";
|
||||
}
|
||||
|
||||
BitburnerSaveObject.prototype.saveGame = function() {
|
||||
this.PlayerSave = JSON.stringify(Player);
|
||||
|
||||
//Delete all logs from all running scripts
|
||||
|
||||
//Delete all logs from all running scripts
|
||||
var TempAllServers = JSON.parse(JSON.stringify(AllServers), Reviver);
|
||||
//var TempAllServers = jQuery.extend(true, {}, AllServers); //Deep copy
|
||||
for (var ip in TempAllServers) {
|
||||
@ -31,7 +32,7 @@ BitburnerSaveObject.prototype.saveGame = function() {
|
||||
runningScriptObj.logs = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.AllServersSave = JSON.stringify(TempAllServers);
|
||||
this.CompaniesSave = JSON.stringify(Companies);
|
||||
this.FactionsSave = JSON.stringify(Factions);
|
||||
@ -40,10 +41,11 @@ BitburnerSaveObject.prototype.saveGame = function() {
|
||||
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
|
||||
this.MessagesSave = JSON.stringify(Messages);
|
||||
this.StockMarketSave = JSON.stringify(StockMarket);
|
||||
this.SettingsSave = JSON.stringify(Settings);
|
||||
this.VersionSave = JSON.stringify(CONSTANTS.Version);
|
||||
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
|
||||
window.localStorage.setItem("bitburnerSave", saveString);
|
||||
|
||||
|
||||
console.log("Game saved!");
|
||||
Engine.createStatusText("Game saved!");
|
||||
}
|
||||
@ -55,13 +57,13 @@ loadGame = function(saveObj) {
|
||||
}
|
||||
var saveString = decodeURIComponent(escape(atob(window.localStorage.getItem("bitburnerSave"))));
|
||||
saveObj = JSON.parse(saveString, Reviver);
|
||||
|
||||
|
||||
Player = JSON.parse(saveObj.PlayerSave, Reviver);
|
||||
AllServers = JSON.parse(saveObj.AllServersSave, Reviver);
|
||||
Companies = JSON.parse(saveObj.CompaniesSave, Reviver);
|
||||
Factions = JSON.parse(saveObj.FactionsSave, Reviver);
|
||||
SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver);
|
||||
|
||||
|
||||
if (saveObj.hasOwnProperty("AliasesSave")) {
|
||||
try {
|
||||
Aliases = JSON.parse(saveObj.AliasesSave, Reviver);
|
||||
@ -98,6 +100,15 @@ loadGame = function(saveObj) {
|
||||
} else {
|
||||
StockMarket = {};
|
||||
}
|
||||
if (saveObj.hasOwnProperty("SettingsSave")) {
|
||||
try {
|
||||
Settings = JSON.parse(saveObj.SettingsSave, Reviver);
|
||||
} catch(e) {
|
||||
initSettings();
|
||||
}
|
||||
} else {
|
||||
initSettings();
|
||||
}
|
||||
if (saveObj.hasOwnProperty("VersionSave")) {
|
||||
try {
|
||||
var ver = JSON.parse(saveObj.VersionSave, Reviver);
|
||||
@ -105,8 +116,8 @@ loadGame = function(saveObj) {
|
||||
if (CONSTANTS.Version == "0.21.0" || CONSTANTS.Version == "0.22.0" ||
|
||||
CONSTANTS.Version == "0.22.1") {
|
||||
dialogBoxCreate("All scripts automatically killed for the sake of compatibility " +
|
||||
"with new version. If the game is still broken, try the following: " +
|
||||
"Options -> Soft Reset -> Save Game -> Reload page. If that STILL " +
|
||||
"with new version. If the game is still broken, try the following: " +
|
||||
"Options -> Soft Reset -> Save Game -> Reload page. If that STILL " +
|
||||
"doesn't work contact the dev");
|
||||
//This is the big update that might break games. Kill all running scripts
|
||||
for (var ip in AllServers) {
|
||||
@ -127,7 +138,7 @@ loadGame = function(saveObj) {
|
||||
} else {
|
||||
createNewUpdateText();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -147,7 +158,7 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
saveString = decodeURIComponent(escape(atob(saveString)));
|
||||
tempSaveObj = new BitburnerSaveObject();
|
||||
tempSaveObj = JSON.parse(saveString, Reviver);
|
||||
|
||||
|
||||
tempPlayer = JSON.parse(tempSaveObj.PlayerSave, Reviver);
|
||||
tempAllServers = JSON.parse(tempSaveObj.AllServersSave, Reviver);
|
||||
tempCompanies = JSON.parse(tempSaveObj.CompaniesSave, Reviver);
|
||||
@ -196,14 +207,14 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
if (ver != CONSTANTS.Version) {
|
||||
createNewUpdateText();
|
||||
}
|
||||
|
||||
|
||||
if (ver != CONSTANTS.Version) {
|
||||
if (CONSTANTS.Version == "0.21.0" || CONSTANTS.Version == "0.22.0" ||
|
||||
CONSTANTS.Version == "0.22.1") {
|
||||
console.log("here");
|
||||
//This is the big update that might break games. Kill all running scripts
|
||||
for (var ip in tempAllServers) {
|
||||
if (tempAllServers.hasOwnProperty(ip)) {
|
||||
if (tempAllServers.hasOwnProperty(ip)) {
|
||||
tempAllServers[ip].runningScripts = [];
|
||||
tempAllServers[ip].runningScripts.length = 0;
|
||||
}
|
||||
@ -224,7 +235,7 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
dialogBoxCreate("Error importing game");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
saveObj = tempSaveObj;
|
||||
Player = tempPlayer;
|
||||
AllServers = tempAllServers;
|
||||
@ -235,22 +246,22 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
if (tempAliases) {
|
||||
Aliases = tempAliases;
|
||||
}
|
||||
|
||||
|
||||
if (tempGlobalAliases) {
|
||||
GlobalAliases = tempGlobalAliases;
|
||||
}
|
||||
|
||||
|
||||
if (tempMessages) {
|
||||
Messages = tempMessages;
|
||||
}
|
||||
|
||||
|
||||
if (tempStockMarket) {
|
||||
StockMarket = tempStockMarket;
|
||||
}
|
||||
|
||||
|
||||
dialogBoxCreate("Imported game");
|
||||
gameOptionsBoxClose();
|
||||
|
||||
|
||||
//Re-start game
|
||||
console.log("Importing game");
|
||||
Engine.setDisplayElements(); //Sets variables for important DOM elements
|
||||
@ -261,7 +272,7 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
Engine._lastUpdate = new Date().getTime();
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
|
||||
|
||||
|
||||
/* Process offline progress */
|
||||
var offlineProductionFromScripts = loadAllRunningScripts(); //This also takes care of offline production for those scripts
|
||||
if (Player.isWorking) {
|
||||
@ -280,30 +291,30 @@ loadImportedGame = function(saveObj, saveString) {
|
||||
Player.work(numCyclesOffline);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Hacknet Nodes offline progress
|
||||
var offlineProductionFromHacknetNodes = processAllHacknetNodeEarnings(numCyclesOffline);
|
||||
|
||||
|
||||
//Passive faction rep gain offline
|
||||
processPassiveFactionRepGain(numCyclesOffline);
|
||||
|
||||
|
||||
//Update total playtime
|
||||
var time = numCyclesOffline * Engine._idleSpeed;
|
||||
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
|
||||
if (Player.playtimeSinceLastAug == null) {Player.playtimeSinceLastAug = 0;}
|
||||
Player.totalPlaytime += time;
|
||||
Player.playtimeSinceLastAug += time;
|
||||
|
||||
|
||||
//Re-apply augmentations
|
||||
Player.reapplyAllAugmentations();
|
||||
|
||||
|
||||
//Clear terminal
|
||||
$("#terminal tr:not(:last)").remove();
|
||||
|
||||
|
||||
Player.lastUpdate = Engine._lastUpdate;
|
||||
Engine.start(); //Run main game loop and Scripts loop
|
||||
dialogBoxCreate("While you were offline, your scripts generated $" +
|
||||
formatNumber(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
|
||||
dialogBoxCreate("While you were offline, your scripts generated $" +
|
||||
formatNumber(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
|
||||
formatNumber(offlineProductionFromHacknetNodes, 2));
|
||||
return true;
|
||||
}
|
||||
@ -319,12 +330,12 @@ BitburnerSaveObject.prototype.exportGame = function() {
|
||||
this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
|
||||
this.MessagesSave = JSON.stringify(Messages);
|
||||
this.VersionSave = JSON.stringify(CONSTANTS.Version);
|
||||
|
||||
|
||||
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
|
||||
|
||||
|
||||
var file = new Blob([saveString], {type: 'text/plain'});
|
||||
if (window.navigator.msSaveOrOpenBlob) {// IE10+
|
||||
window.navigator.msSaveOrOpenBlob(file, filename);
|
||||
window.navigator.msSaveOrOpenBlob(file, filename);
|
||||
} else { // Others
|
||||
var a = document.createElement("a"),
|
||||
url = URL.createObjectURL(file);
|
||||
@ -334,8 +345,8 @@ BitburnerSaveObject.prototype.exportGame = function() {
|
||||
a.click();
|
||||
setTimeout(function() {
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}, 0);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,7 +358,7 @@ BitburnerSaveObject.prototype.importGame = function() {
|
||||
} else {
|
||||
dialogBoxCreate("ERR: Your browser does not support HTML5 File API. Cannot import.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
BitburnerSaveObject.prototype.deleteGame = function() {
|
||||
@ -358,9 +369,9 @@ BitburnerSaveObject.prototype.deleteGame = function() {
|
||||
}
|
||||
|
||||
createNewUpdateText = function() {
|
||||
dialogBoxCreate("New update!<br>" +
|
||||
"Please report any bugs/issues through the github repository " +
|
||||
"or the Bitburner subreddit (reddit.com/r/bitburner).<br><br>" +
|
||||
dialogBoxCreate("New update!<br>" +
|
||||
"Please report any bugs/issues through the github repository " +
|
||||
"or the Bitburner subreddit (reddit.com/r/bitburner).<br><br>" +
|
||||
CONSTANTS.LatestUpdate);
|
||||
}
|
||||
|
||||
@ -375,7 +386,7 @@ BitburnerSaveObject.fromJSON = function(value) {
|
||||
|
||||
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;
|
||||
|
||||
//Import game
|
||||
//Import game
|
||||
|
||||
function openImportFileHandler(evt) {
|
||||
var file = evt.target.files[0];
|
||||
@ -383,11 +394,11 @@ function openImportFileHandler(evt) {
|
||||
dialogBoxCreate("Invalid file selected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
var contents = e.target.result;
|
||||
loadImportedGame(saveObject, contents);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
|
144
src/Script.js
144
src/Script.js
@ -5,12 +5,12 @@
|
||||
function scriptEditorInit() {
|
||||
//Initialize save and close button
|
||||
var closeButton = document.getElementById("script-editor-save-and-close-button");
|
||||
|
||||
|
||||
closeButton.addEventListener("click", function() {
|
||||
saveAndCloseScriptEditor();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//Allow tabs (four spaces) in all textareas
|
||||
var textareas = document.getElementsByTagName('textarea');
|
||||
var count = textareas.length;
|
||||
@ -37,11 +37,11 @@ document.addEventListener("DOMContentLoaded", scriptEditorInit, false);
|
||||
function upgradeScriptEditorContent() {
|
||||
var txt = $("#script-editor-text")[0];
|
||||
var lineNum = txt.value.substr(0, txt.selectionStart).split("\n").length;
|
||||
|
||||
|
||||
var code = document.getElementById("script-editor-text").value;
|
||||
var codeCopy = code.repeat(1);
|
||||
var ramUsage = calculateRamUsage(codeCopy);
|
||||
document.getElementById("script-editor-status-text").innerText =
|
||||
document.getElementById("script-editor-status-text").innerText =
|
||||
"Line Number: " + lineNum + ", RAM: " + formatNumber(ramUsage, 2).toString() + "GB";
|
||||
}
|
||||
|
||||
@ -69,21 +69,21 @@ function saveAndCloseScriptEditor() {
|
||||
dialogBoxCreate("Please copy and paste the code from the tutorial!");
|
||||
return;
|
||||
}
|
||||
iTutorialNextStep();
|
||||
iTutorialNextStep();
|
||||
}
|
||||
|
||||
|
||||
if (filename == "") {
|
||||
dialogBoxCreate("You must specify a filename!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (checkValidFilename(filename) == false) {
|
||||
dialogBoxCreate("Script filename can contain only alphanumerics, hyphens, and underscores");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
filename += ".script";
|
||||
|
||||
|
||||
//If the current script already exists on the server, overwrite it
|
||||
for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) {
|
||||
if (filename == Player.getCurrentServer().scripts[i].filename) {
|
||||
@ -92,7 +92,7 @@ function saveAndCloseScriptEditor() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//If the current script does NOT exist, create a new one
|
||||
var script = new Script();
|
||||
script.saveScript();
|
||||
@ -104,14 +104,14 @@ function saveAndCloseScriptEditor() {
|
||||
// underscores and hyphens
|
||||
function checkValidFilename(filename) {
|
||||
var regex = /^[a-zA-Z0-9_-]+$/;
|
||||
|
||||
|
||||
if (filename.match(regex)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function Script() {
|
||||
function Script() {
|
||||
this.filename = "";
|
||||
this.code = "";
|
||||
this.ramUsage = 0;
|
||||
@ -124,14 +124,14 @@ Script.prototype.saveScript = function() {
|
||||
//Update code and filename
|
||||
var code = document.getElementById("script-editor-text").value;
|
||||
this.code = code.replace(/^\s+|\s+$/g, '');
|
||||
|
||||
|
||||
var filename = document.getElementById("script-editor-filename").value + ".script";
|
||||
this.filename = filename;
|
||||
|
||||
|
||||
//Server
|
||||
this.server = Player.currentServer;
|
||||
|
||||
//Calculate/update ram usage, execution time, etc.
|
||||
|
||||
//Calculate/update ram usage, execution time, etc.
|
||||
this.updateRamUsage();
|
||||
}
|
||||
}
|
||||
@ -181,53 +181,53 @@ function calculateRamUsage(codeCopy) {
|
||||
var hnUpgLevelCount = numOccurrences(codeCopy, ".upgradeLevel(");
|
||||
var hnUpgRamCount = numOccurrences(codeCopy, ".upgradeRam()");
|
||||
var hnUpgCoreCount = numOccurrences(codeCopy, ".upgradeCore()");
|
||||
var scriptGetStockCount = numOccurrences(codeCopy, "getStockPrice(") +
|
||||
var scriptGetStockCount = numOccurrences(codeCopy, "getStockPrice(") +
|
||||
numOccurrences(codeCopy, "getStockPosition(");
|
||||
var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") +
|
||||
var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") +
|
||||
numOccurrences(codeCopy, "sellStock(");
|
||||
var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer(");
|
||||
var scriptRoundCount = numOccurrences(codeCopy, "round(");
|
||||
var scriptWriteCount = numOccurrences(codeCopy, "write(");
|
||||
var scriptReadCount = numOccurrences(codeCopy, "read(");
|
||||
|
||||
return baseRam +
|
||||
((whileCount * CONSTANTS.ScriptWhileRamCost) +
|
||||
(forCount * CONSTANTS.ScriptForRamCost) +
|
||||
(ifCount * CONSTANTS.ScriptIfRamCost) +
|
||||
(hackCount * CONSTANTS.ScriptHackRamCost) +
|
||||
(growCount * CONSTANTS.ScriptGrowRamCost) +
|
||||
(weakenCount * CONSTANTS.ScriptWeakenRamCost) +
|
||||
(scanCount * CONSTANTS.ScriptScanRamCost) +
|
||||
(nukeCount * CONSTANTS.ScriptNukeRamCost) +
|
||||
(brutesshCount * CONSTANTS.ScriptBrutesshRamCost) +
|
||||
(ftpcrackCount * CONSTANTS.ScriptFtpcrackRamCost) +
|
||||
(relaysmtpCount * CONSTANTS.ScriptRelaysmtpRamCost) +
|
||||
(httpwormCount * CONSTANTS.ScriptHttpwormRamCost) +
|
||||
(sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) +
|
||||
(runCount * CONSTANTS.ScriptRunRamCost) +
|
||||
(execCount * CONSTANTS.ScriptExecRamCost) +
|
||||
(scpCount * CONSTANTS.ScriptScpRamCost) +
|
||||
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
|
||||
|
||||
return baseRam +
|
||||
((whileCount * CONSTANTS.ScriptWhileRamCost) +
|
||||
(forCount * CONSTANTS.ScriptForRamCost) +
|
||||
(ifCount * CONSTANTS.ScriptIfRamCost) +
|
||||
(hackCount * CONSTANTS.ScriptHackRamCost) +
|
||||
(growCount * CONSTANTS.ScriptGrowRamCost) +
|
||||
(weakenCount * CONSTANTS.ScriptWeakenRamCost) +
|
||||
(scanCount * CONSTANTS.ScriptScanRamCost) +
|
||||
(nukeCount * CONSTANTS.ScriptNukeRamCost) +
|
||||
(brutesshCount * CONSTANTS.ScriptBrutesshRamCost) +
|
||||
(ftpcrackCount * CONSTANTS.ScriptFtpcrackRamCost) +
|
||||
(relaysmtpCount * CONSTANTS.ScriptRelaysmtpRamCost) +
|
||||
(httpwormCount * CONSTANTS.ScriptHttpwormRamCost) +
|
||||
(sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) +
|
||||
(runCount * CONSTANTS.ScriptRunRamCost) +
|
||||
(execCount * CONSTANTS.ScriptExecRamCost) +
|
||||
(scpCount * CONSTANTS.ScriptScpRamCost) +
|
||||
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
|
||||
(getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) +
|
||||
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
|
||||
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getServerMaxMoneyCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
|
||||
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getServerMaxMoneyCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
|
||||
(getServerSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) +
|
||||
(getServerBaseSecurityCount * CONSTANTS.ScriptGetServerSecurityRamCost) +
|
||||
(getServerReqdHackingCount * CONSTANTS.ScriptGetServerReqdHackRamCost) +
|
||||
(fileExistsCount * CONSTANTS.ScriptFileExistsRamCost) +
|
||||
(getServerReqdHackingCount * CONSTANTS.ScriptGetServerReqdHackRamCost) +
|
||||
(fileExistsCount * CONSTANTS.ScriptFileExistsRamCost) +
|
||||
(isRunningCount * CONSTANTS.ScriptIsRunningRamCost) +
|
||||
(numOperators * CONSTANTS.ScriptOperatorRamCost) +
|
||||
(purchaseHacknetCount * CONSTANTS.ScriptPurchaseHacknetRamCost) +
|
||||
(purchaseHacknetCount * CONSTANTS.ScriptPurchaseHacknetRamCost) +
|
||||
(hacknetnodesArrayCount * CONSTANTS.ScriptHacknetNodesRamCost) +
|
||||
(hnUpgLevelCount * CONSTANTS.ScriptHNUpgLevelRamCost) +
|
||||
(hnUpgLevelCount * CONSTANTS.ScriptHNUpgLevelRamCost) +
|
||||
(hnUpgRamCount * CONSTANTS.ScriptHNUpgRamRamCost) +
|
||||
(hnUpgCoreCount * CONSTANTS.ScriptHNUpgCoreRamCost) +
|
||||
(scriptGetStockCount * CONSTANTS.ScriptGetStockRamCost) +
|
||||
(scriptBuySellStockCount * CONSTANTS.ScriptBuySellStockRamCost) +
|
||||
(scriptPurchaseServerCount * CONSTANTS.ScriptPurchaseServerRamCost) +
|
||||
(scriptRoundCount * CONSTANTS.ScriptRoundRamCost) +
|
||||
(scriptWriteCount * CONSTANTS.ScriptReadWriteRamCost) +
|
||||
(hnUpgCoreCount * CONSTANTS.ScriptHNUpgCoreRamCost) +
|
||||
(scriptGetStockCount * CONSTANTS.ScriptGetStockRamCost) +
|
||||
(scriptBuySellStockCount * CONSTANTS.ScriptBuySellStockRamCost) +
|
||||
(scriptPurchaseServerCount * CONSTANTS.ScriptPurchaseServerRamCost) +
|
||||
(scriptRoundCount * CONSTANTS.ScriptRoundRamCost) +
|
||||
(scriptWriteCount * CONSTANTS.ScriptReadWriteRamCost) +
|
||||
(scriptReadCount * CONSTANTS.ScriptReadWriteRamCost));
|
||||
}
|
||||
|
||||
@ -250,14 +250,14 @@ loadAllRunningScripts = function() {
|
||||
for (var property in AllServers) {
|
||||
if (AllServers.hasOwnProperty(property)) {
|
||||
var server = AllServers[property];
|
||||
|
||||
|
||||
//Reset each server's RAM usage to 0
|
||||
server.ramUsed = 0;
|
||||
|
||||
|
||||
for (var j = 0; j < server.runningScripts.length; ++j) {
|
||||
count++;
|
||||
addWorkerScript(server.runningScripts[j], server);
|
||||
|
||||
|
||||
//Offline production
|
||||
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
|
||||
}
|
||||
@ -273,15 +273,15 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds
|
||||
console.log("Offline for " + timePassed + " seconds");
|
||||
|
||||
|
||||
//Calculate the "confidence" rating of the script's true production. This is based
|
||||
//entirely off of time. We will arbitrarily say that if a script has been running for
|
||||
//4 hours (14400 sec) then we are completely confident in its ability
|
||||
var confidence = (runningScriptObj.onlineRunningTime) / 14400;
|
||||
if (confidence >= 1) {confidence = 1;}
|
||||
|
||||
|
||||
//Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
||||
|
||||
|
||||
//Grow
|
||||
for (var ip in runningScriptObj.dataMap) {
|
||||
if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
|
||||
@ -295,7 +295,7 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
runningScriptObj.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var totalOfflineProduction = 0;
|
||||
for (var ip in runningScriptObj.dataMap) {
|
||||
if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
|
||||
@ -308,7 +308,7 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
production = serv.moneyAvailable;
|
||||
}
|
||||
totalOfflineProduction += production;
|
||||
Player.gainMoney(production);
|
||||
Player.gainMoney(production);
|
||||
console.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname);
|
||||
runningScriptObj.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname);
|
||||
serv.moneyAvailable -= production;
|
||||
@ -318,17 +318,17 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
}
|
||||
|
||||
//Offline EXP gain
|
||||
//A script's offline production will always be at most half of its online production.
|
||||
//A script's offline production will always be at most half of its online production.
|
||||
var expGain = 0.5 * (runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime) * timePassed;
|
||||
expGain *= confidence;
|
||||
|
||||
|
||||
Player.gainHackingExp(expGain);
|
||||
|
||||
|
||||
//Update script stats
|
||||
runningScriptObj.offlineMoneyMade += totalOfflineProduction;
|
||||
runningScriptObj.offlineRunningTime += timePassed;
|
||||
runningScriptObj.offlineExpGained += expGain;
|
||||
|
||||
|
||||
//Fortify a server's security based on how many times it was hacked
|
||||
for (var ip in runningScriptObj.dataMap) {
|
||||
if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
|
||||
@ -341,7 +341,7 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
serv.fortify(CONSTANTS.ServerFortifyAmount * timesHacked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Weaken
|
||||
for (var ip in runningScriptObj.dataMap) {
|
||||
if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
|
||||
@ -354,7 +354,7 @@ scriptCalculateOfflineProduction = function(runningScriptObj) {
|
||||
serv.weaken(CONSTANTS.ServerWeakenAmount * timesWeakened);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return totalOfflineProduction;
|
||||
}
|
||||
|
||||
@ -376,9 +376,9 @@ function RunningScript(script, args) {
|
||||
this.args = args;
|
||||
this.scriptRef = script;
|
||||
this.server = script.server; //IP Address only
|
||||
|
||||
|
||||
this.logs = []; //Script logging. Array of strings, with each element being a log entry
|
||||
|
||||
|
||||
//Stats to display on the Scripts menu, and used to determine offline progress
|
||||
this.offlineRunningTime = 0.01; //Seconds
|
||||
this.offlineMoneyMade = 0;
|
||||
@ -386,16 +386,16 @@ function RunningScript(script, args) {
|
||||
this.onlineRunningTime = 0.01; //Seconds
|
||||
this.onlineMoneyMade = 0;
|
||||
this.onlineExpGained = 0;
|
||||
|
||||
|
||||
this.threads = 1;
|
||||
|
||||
|
||||
//[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
|
||||
this.dataMap = new AllServersMap([0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
RunningScript.prototype.reset = function() {
|
||||
this.scriptRef.updateRamUsage();
|
||||
|
||||
|
||||
this.offlineRunningTime = 0.01; //Seconds
|
||||
this.offlineMoneyMade = 0;
|
||||
this.offlineExpGained = 0;
|
||||
@ -406,7 +406,7 @@ RunningScript.prototype.reset = function() {
|
||||
}
|
||||
|
||||
RunningScript.prototype.log = function(txt) {
|
||||
if (this.logs.length > CONSTANTS.MaxLogCapacity) {
|
||||
if (this.logs.length > Settings.MaxLogCapacity) {
|
||||
//Delete first element and add new log entry to the end.
|
||||
//TODO Eventually it might be better to replace this with circular array
|
||||
//to improve performance
|
||||
@ -424,7 +424,7 @@ RunningScript.prototype.displayLog = function() {
|
||||
RunningScript.prototype.clearLog = function() {
|
||||
this.logs.length = 0;
|
||||
}
|
||||
|
||||
|
||||
//Update the moneyStolen and numTimesHack maps when hacking
|
||||
RunningScript.prototype.recordHack = function(serverIp, moneyGained, n=1) {
|
||||
if (this.dataMap == null) {
|
||||
@ -505,4 +505,4 @@ AllServersMap.fromJSON = function(value) {
|
||||
return Generic_fromJSON(AllServersMap, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.AllServersMap = AllServersMap;
|
||||
Reviver.constructors.AllServersMap = AllServersMap;
|
||||
|
@ -4,4 +4,20 @@ Settings = {
|
||||
suppressMessages: false,
|
||||
MaxLogCapacity: 50,
|
||||
MaxPortCapacity: 50,
|
||||
}
|
||||
}
|
||||
|
||||
function initSettings() {
|
||||
Settings.CodeInstructionRunTime = 100;
|
||||
Settings.suppressMessages = false;
|
||||
Settings.MaxLogCapacity = 50;
|
||||
Settings.MaxPortCapacity = 50;
|
||||
}
|
||||
|
||||
function setSettingsLabels() {
|
||||
document.getElementById("settingsNSExecTimeRangeValLabel").innerHTML
|
||||
= Settings.CodeInstructionRunTime + "ms";
|
||||
document.getElementById("settingsNSLogRangeValLabel").innerHTML
|
||||
= Settings.MaxLogCapacity;
|
||||
document.getElementById("settingsNSPortRangeValLabel").innerHTML
|
||||
= Settings.MaxPortCapacity;
|
||||
}
|
||||
|
276
src/Terminal.js
276
src/Terminal.js
@ -7,7 +7,7 @@ var post = function(input, replace=true) {
|
||||
} else {
|
||||
$("#terminal-input").before('<tr class="posted"><td class="terminal-line" style="color: var(--my-font-color); background-color: var(--my-background-color);">' + input + '</td></tr>');
|
||||
}
|
||||
|
||||
|
||||
updateTerminalScroll();
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ var hackProgressBarPost = function(input) {
|
||||
|
||||
var hackProgressPost = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td id="hack-progress" style="color: var(--my-font-color); background-color: var(--my-background-color);">' + input + '</td></tr>');
|
||||
updateTerminalScroll();
|
||||
updateTerminalScroll();
|
||||
}
|
||||
|
||||
//Scroll to the bottom of the terminal's 'text area'
|
||||
@ -38,37 +38,37 @@ $(document).keydown(function(event) {
|
||||
if (Engine.currentPage == Engine.Page.Terminal) {
|
||||
var terminalInput = document.getElementById("terminal-input-text-box");
|
||||
if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();}
|
||||
|
||||
|
||||
//Enter
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault(); //Prevent newline from being entered in Script Editor
|
||||
var command = $('input[class=terminal-input]').val();
|
||||
if (command.length > 0) {
|
||||
post("> " + command);
|
||||
|
||||
|
||||
Terminal.executeCommand(command);
|
||||
$('input[class=terminal-input]').val("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Ctrl + c when an "Action" is in progress
|
||||
if (event.keyCode == 67 && event.ctrlKey && Engine._actionInProgress) {
|
||||
post("Cancelling...");
|
||||
Engine._actionInProgress = false;
|
||||
Terminal.finishAction(true);
|
||||
}
|
||||
|
||||
|
||||
//Up key to cycle through past commands
|
||||
if (event.keyCode == 38) {
|
||||
if (terminalInput == null) {return;}
|
||||
var i = Terminal.commandHistoryIndex;
|
||||
var len = Terminal.commandHistory.length;
|
||||
|
||||
|
||||
if (len == 0) {return;}
|
||||
if (i < 0 || i > len) {
|
||||
Terminal.commandHistoryIndex = len;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (i != 0) {
|
||||
--Terminal.commandHistoryIndex;
|
||||
}
|
||||
@ -76,18 +76,18 @@ $(document).keydown(function(event) {
|
||||
terminalInput.value = prevCommand;
|
||||
setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0);
|
||||
}
|
||||
|
||||
|
||||
//Down key
|
||||
if (event.keyCode == 40) {
|
||||
if (terminalInput == null) {return;}
|
||||
var i = Terminal.commandHistoryIndex;
|
||||
var len = Terminal.commandHistory.length;
|
||||
|
||||
|
||||
if (len == 0) {return;}
|
||||
if (i < 0 || i > len) {
|
||||
Terminal.commandHistoryIndex = len;
|
||||
}
|
||||
|
||||
|
||||
//Latest command, put nothing
|
||||
if (i == len || i == len-1) {
|
||||
Terminal.commandHistoryIndex = len;
|
||||
@ -98,7 +98,7 @@ $(document).keydown(function(event) {
|
||||
terminalInput.value = prevCommand;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Tab (autocomplete)
|
||||
if (event.keyCode == 9) {
|
||||
if (terminalInput == null) {return;}
|
||||
@ -106,16 +106,17 @@ $(document).keydown(function(event) {
|
||||
if (input == "") {return;}
|
||||
input = input.trim();
|
||||
input = input.replace(/\s\s+/g, ' ');
|
||||
|
||||
|
||||
var commandArray = input.split(" ");
|
||||
var index = commandArray.length - 2;
|
||||
if (index < -1) {index = 0;}
|
||||
var allPos = determineAllPossibilitiesForTabCompletion(input, index);
|
||||
if (allPos.length == 0) {return;}
|
||||
|
||||
|
||||
var arg = "";
|
||||
var command = "";
|
||||
if (commandArray.length == 0) {return;}
|
||||
if (commandArray.length == 1) {command = commandArray[0];}
|
||||
else if (commandArray.length == 2) {
|
||||
command = commandArray[0];
|
||||
arg = commandArray[1];
|
||||
@ -123,9 +124,10 @@ $(document).keydown(function(event) {
|
||||
command = commandArray[0] + " " + commandArray[1];
|
||||
arg = commandArray[2];
|
||||
} else {
|
||||
command = commandArray[0];
|
||||
arg = commandArray.pop();
|
||||
command = commandArray.join(" ");
|
||||
}
|
||||
|
||||
|
||||
tabCompletion(command, arg, allPos);
|
||||
}
|
||||
}
|
||||
@ -149,7 +151,7 @@ $(document).keydown(function(e) {
|
||||
if (inputTextBox != null) {
|
||||
inputTextBox.focus();
|
||||
}
|
||||
|
||||
|
||||
terminalCtrlPressed = false;
|
||||
}
|
||||
}
|
||||
@ -172,9 +174,9 @@ $(document).keyup(function(e) {
|
||||
function tabCompletion(command, arg, allPossibilities, index=0) {
|
||||
if (!(allPossibilities.constructor === Array)) {return;}
|
||||
if (!containsAllStrings(allPossibilities)) {return;}
|
||||
|
||||
|
||||
command = command.toLowerCase();
|
||||
|
||||
|
||||
//Remove all options in allPossibilities that do not match the current string
|
||||
//that we are attempting to autocomplete
|
||||
if (arg == "") {
|
||||
@ -190,11 +192,11 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var val = "";
|
||||
if (allPossibilities.length == 0) {
|
||||
return;
|
||||
} else if (allPossibilities.length == 1) {
|
||||
} else if (allPossibilities.length == 1) {
|
||||
if (arg == "") {
|
||||
//Autocomplete command
|
||||
val = allPossibilities[0] + " ";
|
||||
@ -231,29 +233,30 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
|
||||
document.getElementById("terminal-input-text-box").focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
var allPos = [];
|
||||
allPos = allPos.concat(Object.keys(GlobalAliases));
|
||||
var currServ = Player.getCurrentServer();
|
||||
input = input.toLowerCase();
|
||||
|
||||
|
||||
//Autocomplete the command
|
||||
if (index == -1) {
|
||||
return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free",
|
||||
return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free",
|
||||
"hack", "help", "home", "hostname", "ifconfig", "kill", "killall",
|
||||
"ls", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze",
|
||||
"ls", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze",
|
||||
"scp", "sudov", "tail", "theme", "top"].concat(Object.keys(Aliases)).concat(Object.keys(GlobalAliases));
|
||||
}
|
||||
|
||||
|
||||
if (input.startsWith ("buy ")) {
|
||||
return [Programs.BruteSSHProgram, Programs.FTPCrackProgram, Programs.RelaySMTPProgram,
|
||||
Programs.HTTPWormProgram, Programs.SQLInjectProgram, Programs.DeepscanV1,
|
||||
Programs.DeepscanV2];
|
||||
Programs.DeepscanV2].concat(Object.keys(GlobalAliases));
|
||||
}
|
||||
|
||||
|
||||
if (input.startsWith("scp ") && index == 1) {
|
||||
for (var iphostname in AllServers) {
|
||||
if (AllServers.hasOwnProperty(iphostname)) {
|
||||
@ -262,7 +265,7 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (input.startsWith("connect ") || input.startsWith("telnet ")) {
|
||||
//All network connections
|
||||
for (var i = 0; i < currServ.serversOnNetwork.length; ++i) {
|
||||
@ -272,8 +275,8 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
allPos.push(serv.hostname); //Hostname
|
||||
}
|
||||
return allPos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (input.startsWith("kill ") || input.startsWith("nano ") ||
|
||||
input.startsWith("tail ") || input.startsWith("rm ") ||
|
||||
input.startsWith("mem ") || input.startsWith("check ") ||
|
||||
@ -284,13 +287,13 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
}
|
||||
return allPos;
|
||||
}
|
||||
|
||||
|
||||
if (input.startsWith("run ")) {
|
||||
//All programs and scripts
|
||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||
allPos.push(currServ.scripts[i].filename);
|
||||
}
|
||||
|
||||
|
||||
//Programs are on home computer
|
||||
var homeComputer = Player.getHomeComputer();
|
||||
for(var i = 0; i < homeComputer.programs.length; ++i) {
|
||||
@ -298,7 +301,7 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
}
|
||||
return allPos;
|
||||
}
|
||||
|
||||
|
||||
if (input.startsWith("cat ")) {
|
||||
for (var i = 0; i < currServ.messages.length; ++i) {
|
||||
allPos.push(currServ.messages[i].filename);
|
||||
@ -310,12 +313,12 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
|
||||
var Terminal = {
|
||||
//Flags to determine whether the player is currently running a hack or an analyze
|
||||
hackFlag: false,
|
||||
analyzeFlag: false,
|
||||
|
||||
hackFlag: false,
|
||||
analyzeFlag: false,
|
||||
|
||||
commandHistory: [],
|
||||
commandHistoryIndex: 0,
|
||||
|
||||
|
||||
finishAction: function(cancelled = false) {
|
||||
if (Terminal.hackFlag) {
|
||||
Terminal.finishHack(cancelled);
|
||||
@ -323,12 +326,12 @@ var Terminal = {
|
||||
Terminal.finishAnalyze(cancelled);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//Complete the hack/analyze command
|
||||
finishHack: function(cancelled = false) {
|
||||
if (cancelled == false) {
|
||||
var server = Player.getCurrentServer();
|
||||
|
||||
|
||||
//Calculate whether hack was successful
|
||||
var hackChance = Player.calculateHackingChance();
|
||||
var rand = Math.random();
|
||||
@ -344,17 +347,17 @@ var Terminal = {
|
||||
server.manuallyHacked = true;
|
||||
var moneyGained = Player.calculatePercentMoneyHacked();
|
||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
|
||||
|
||||
|
||||
//Safety check
|
||||
if (moneyGained <= 0) {moneyGained = 0;}
|
||||
|
||||
|
||||
server.moneyAvailable -= moneyGained;
|
||||
Player.gainMoney(moneyGained);
|
||||
|
||||
|
||||
Player.gainHackingExp(expGainedOnSuccess)
|
||||
|
||||
|
||||
server.fortify(CONSTANTS.ServerFortifyAmount);
|
||||
|
||||
|
||||
post("Hack successful! Gained $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " hacking EXP");
|
||||
} else { //Failure
|
||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||
@ -362,16 +365,16 @@ var Terminal = {
|
||||
post("Failed to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " hacking EXP");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
||||
$("#hack-progress-bar").attr('id', "old-hack-progress-bar");
|
||||
$("#hack-progress").attr('id', "old-hack-progress");
|
||||
document.getElementById("terminal-input-td").innerHTML = '$ <input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', false);
|
||||
$('input[class=terminal-input]').prop('disabled', false);
|
||||
|
||||
Terminal.hackFlag = false;
|
||||
},
|
||||
|
||||
|
||||
finishAnalyze: function(cancelled = false) {
|
||||
if (cancelled == false) {
|
||||
post(Player.getCurrentServer().hostname + ": ");
|
||||
@ -391,25 +394,25 @@ var Terminal = {
|
||||
} else {
|
||||
post("SSH port: Closed")
|
||||
}
|
||||
|
||||
|
||||
if (Player.getCurrentServer().ftpPortOpen) {
|
||||
post("FTP port: Open")
|
||||
} else {
|
||||
post("FTP port: Closed")
|
||||
}
|
||||
|
||||
|
||||
if (Player.getCurrentServer().smtpPortOpen) {
|
||||
post("SMTP port: Open")
|
||||
} else {
|
||||
post("SMTP port: Closed")
|
||||
}
|
||||
|
||||
|
||||
if (Player.getCurrentServer().httpPortOpen) {
|
||||
post("HTTP port: Open")
|
||||
} else {
|
||||
post("HTTP port: Closed")
|
||||
}
|
||||
|
||||
|
||||
if (Player.getCurrentServer().sqlPortOpen) {
|
||||
post("SQL port: Open")
|
||||
} else {
|
||||
@ -417,19 +420,19 @@ var Terminal = {
|
||||
}
|
||||
}
|
||||
Terminal.analyzeFlag = false;
|
||||
|
||||
|
||||
//Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
|
||||
$("#hack-progress-bar").attr('id', "old-hack-progress-bar");
|
||||
$("#hack-progress").attr('id', "old-hack-progress");
|
||||
document.getElementById("terminal-input-td").innerHTML = '$ <input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', false);
|
||||
},
|
||||
|
||||
$('input[class=terminal-input]').prop('disabled', false);
|
||||
},
|
||||
|
||||
executeCommand: function(command) {
|
||||
command = command.trim();
|
||||
//Replace all extra whitespace in command with a single space
|
||||
command = command.replace(/\s\s+/g, ' ');
|
||||
|
||||
|
||||
//Terminal history
|
||||
if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) {
|
||||
Terminal.commandHistory.push(command);
|
||||
@ -438,28 +441,28 @@ var Terminal = {
|
||||
}
|
||||
}
|
||||
Terminal.commandHistoryIndex = Terminal.commandHistory.length;
|
||||
|
||||
|
||||
//Process any aliases
|
||||
command = substituteAliases(command);
|
||||
|
||||
|
||||
//Allow usage of ./
|
||||
if (command.startsWith("./")) {
|
||||
command = command.slice(0, 2) + " " + command.slice(2);
|
||||
}
|
||||
|
||||
|
||||
//Only split the first space
|
||||
var commandArray = command.split(" ");
|
||||
if (commandArray.length > 1) {
|
||||
commandArray = [commandArray.shift(), commandArray.join(" ")];
|
||||
}
|
||||
|
||||
|
||||
if (commandArray.length == 0) {return;}
|
||||
|
||||
|
||||
/****************** Interactive Tutorial Terminal Commands ******************/
|
||||
if (iTutorialIsRunning) {
|
||||
var foodnstuffServ = GetServerByHostname("foodnstuff");
|
||||
if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;}
|
||||
|
||||
|
||||
switch(currITutorialStep) {
|
||||
case iTutorialSteps.TerminalHelp:
|
||||
if (commandArray[0] == "help") {
|
||||
@ -506,7 +509,7 @@ var Terminal = {
|
||||
} else {post("Bad command. Please follow the tutorial");}
|
||||
break;
|
||||
case iTutorialSteps.TerminalAnalyze:
|
||||
if (commandArray[0] == "analyze") {
|
||||
if (commandArray[0] == "analyze") {
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect usage of analyze command. Usage: analyze"); return;
|
||||
}
|
||||
@ -516,7 +519,7 @@ var Terminal = {
|
||||
hackProgressPost("Time left:");
|
||||
hackProgressBarPost("[");
|
||||
Player.analyze();
|
||||
|
||||
|
||||
//Disable terminal
|
||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', true);
|
||||
@ -526,7 +529,7 @@ var Terminal = {
|
||||
}
|
||||
break;
|
||||
case iTutorialSteps.TerminalNuke:
|
||||
if (commandArray.length == 2 &&
|
||||
if (commandArray.length == 2 &&
|
||||
commandArray[0] == "run" && commandArray[1] == "NUKE.exe") {
|
||||
foodnstuffServ.hasAdminRights = true;
|
||||
post("NUKE successful! Gained root access to foodnstuff");
|
||||
@ -539,7 +542,7 @@ var Terminal = {
|
||||
hackProgressPost("Time left:");
|
||||
hackProgressBarPost("[");
|
||||
Player.hack();
|
||||
|
||||
|
||||
//Disable terminal
|
||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', true);
|
||||
@ -547,7 +550,7 @@ var Terminal = {
|
||||
} else {post("Bad command. Please follow the tutorial");}
|
||||
break;
|
||||
case iTutorialSteps.TerminalCreateScript:
|
||||
if (commandArray.length == 2 &&
|
||||
if (commandArray.length == 2 &&
|
||||
commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") {
|
||||
Engine.loadScriptEditorContent("foodnstuff", "");
|
||||
iTutorialNextStep();
|
||||
@ -559,7 +562,7 @@ var Terminal = {
|
||||
}
|
||||
break;
|
||||
case iTutorialSteps.TerminalRunScript:
|
||||
if (commandArray.length == 2 &&
|
||||
if (commandArray.length == 2 &&
|
||||
commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") {
|
||||
Terminal.runScript("foodnstuff.script");
|
||||
iTutorialNextStep();
|
||||
@ -578,15 +581,15 @@ var Terminal = {
|
||||
iTutorialNextStep();
|
||||
} else {post("Bad command. Please follow the tutorial");}
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/****************** END INTERACTIVE TUTORIAL ******************/
|
||||
|
||||
|
||||
/* Command parser */
|
||||
var s = Player.getCurrentServer();
|
||||
switch (commandArray[0].toLowerCase()) {
|
||||
@ -607,7 +610,7 @@ var Terminal = {
|
||||
}
|
||||
}
|
||||
}
|
||||
post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
|
||||
post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
|
||||
break;
|
||||
case "analyze":
|
||||
if (commandArray.length != 1) {
|
||||
@ -619,7 +622,7 @@ var Terminal = {
|
||||
hackProgressPost("Time left:");
|
||||
hackProgressBarPost("[");
|
||||
Player.analyze();
|
||||
|
||||
|
||||
//Disable terminal
|
||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', true);
|
||||
@ -658,12 +661,12 @@ var Terminal = {
|
||||
for (var i = 1; i < results.length; ++i) {
|
||||
args.push(results[i]);
|
||||
}
|
||||
|
||||
|
||||
//Can only tail script files
|
||||
if (scriptName.endsWith(".script") == false) {
|
||||
post("Error: tail can only be called on .script files (filename must end with .script)"); return;
|
||||
}
|
||||
|
||||
|
||||
//Check that the script exists on this machine
|
||||
var runningScript = findRunningScript(scriptName, args, s);
|
||||
if (runningScript == null) {
|
||||
@ -680,24 +683,24 @@ var Terminal = {
|
||||
}
|
||||
$("#terminal tr:not(:last)").remove();
|
||||
postNetburnerText();
|
||||
break;
|
||||
break;
|
||||
case "connect":
|
||||
//Disconnect from current server in terminal and connect to new one
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect usage of connect command. Usage: connect [ip/hostname]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var ip = commandArray[1];
|
||||
|
||||
|
||||
for (var i = 0; i < Player.getCurrentServer().serversOnNetwork.length; i++) {
|
||||
if (Player.getCurrentServer().getServerOnNetwork(i).ip == ip || Player.getCurrentServer().getServerOnNetwork(i).hostname == ip) {
|
||||
Terminal.connectToServer(ip);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
post("Host not found");
|
||||
|
||||
post("Host not found");
|
||||
break;
|
||||
case "free":
|
||||
Terminal.executeFreeCommand(commandArray);
|
||||
@ -719,7 +722,7 @@ var Terminal = {
|
||||
hackProgressPost("Time left:");
|
||||
hackProgressBarPost("[");
|
||||
Player.hack();
|
||||
|
||||
|
||||
//Disable terminal
|
||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
||||
$('input[class=terminal-input]').prop('disabled', true);
|
||||
@ -810,13 +813,13 @@ var Terminal = {
|
||||
}
|
||||
scriptName = results[0];
|
||||
}
|
||||
|
||||
|
||||
var currServ = Player.getCurrentServer();
|
||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||
if (scriptName == currServ.scripts[i].filename) {
|
||||
var scriptBaseRamUsage = currServ.scripts[i].ramUsage;
|
||||
var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(CONSTANTS.MultithreadingRAMCost, numThreads-1);
|
||||
|
||||
|
||||
post("This script requires " + formatNumber(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)");
|
||||
return;
|
||||
}
|
||||
@ -827,17 +830,17 @@ var Terminal = {
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect usage of nano command. Usage: nano [scriptname]"); return;
|
||||
}
|
||||
|
||||
|
||||
var filename = commandArray[1];
|
||||
|
||||
|
||||
//Can only edit script files
|
||||
if (filename.endsWith(".script") == false) {
|
||||
post("Error: Only .script files are editable with nano (filename must end with .script)"); return;
|
||||
}
|
||||
|
||||
|
||||
//Script name is the filename without the .script at the end
|
||||
var scriptname = filename.substr(0, filename.indexOf(".script"));
|
||||
|
||||
|
||||
//Check if the script already exists
|
||||
for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) {
|
||||
if (filename == Player.getCurrentServer().scripts[i].filename) {
|
||||
@ -864,7 +867,7 @@ var Terminal = {
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect number of arguments. Usage: rm [program/script]"); return;
|
||||
}
|
||||
|
||||
|
||||
//Check programs
|
||||
var delTarget = commandArray[1];
|
||||
for (var i = 0; i < s.programs.length; ++i) {
|
||||
@ -873,7 +876,7 @@ var Terminal = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Check scripts
|
||||
for (var i = 0; i < s.scripts.length; ++i) {
|
||||
if (s.scripts[i].filename == delTarget) {
|
||||
@ -888,7 +891,7 @@ var Terminal = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
post("No such file exists");
|
||||
break;
|
||||
case "run":
|
||||
@ -898,7 +901,7 @@ var Terminal = {
|
||||
post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");
|
||||
} else {
|
||||
var executableName = commandArray[1];
|
||||
//Check if its a script or just a program/executable
|
||||
//Check if its a script or just a program/executable
|
||||
if (executableName.indexOf(".script") == -1) {
|
||||
//Not a script
|
||||
Terminal.runProgram(executableName);
|
||||
@ -920,7 +923,7 @@ var Terminal = {
|
||||
post("Incorrect usage of scan-analyze command. depth argument must be positive numeric");
|
||||
return;
|
||||
}
|
||||
if (depth > 3 && !Player.hasProgram(Programs.DeepscanV1) &&
|
||||
if (depth > 3 && !Player.hasProgram(Programs.DeepscanV1) &&
|
||||
!Player.hasProgram(Programs.DeepscanV2)) {
|
||||
post("You cannot scan-analyze with that high of a depth. Maximum depth is 3");
|
||||
return;
|
||||
@ -934,7 +937,7 @@ var Terminal = {
|
||||
Terminal.executeScanAnalyzeCommand(depth);
|
||||
} else {
|
||||
post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "scp":
|
||||
if (commandArray.length != 2) {
|
||||
@ -953,9 +956,9 @@ var Terminal = {
|
||||
return;
|
||||
}
|
||||
var ip = server.ip;
|
||||
|
||||
|
||||
var currServ = Player.getCurrentServer();
|
||||
|
||||
|
||||
//Get the current script
|
||||
var sourceScript = null;
|
||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||
@ -968,7 +971,7 @@ var Terminal = {
|
||||
post("ERROR: scp() failed. No such script exists");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Overwrite script if it exists
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
if (scriptname == server.scripts[i].filename) {
|
||||
@ -980,20 +983,20 @@ var Terminal = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var newScript = new Script();
|
||||
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);
|
||||
post(scriptname + " copied over to " + server.hostname);
|
||||
break;
|
||||
case "sudov":
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect number of arguments. Usage: sudov"); return;
|
||||
}
|
||||
|
||||
|
||||
if (Player.getCurrentServer().hasAdminRights) {
|
||||
post("You have ROOT access to this machine");
|
||||
} else {
|
||||
@ -1010,12 +1013,12 @@ var Terminal = {
|
||||
for (var i = 1; i < results.length; ++i) {
|
||||
args.push(results[i]);
|
||||
}
|
||||
|
||||
|
||||
//Can only tail script files
|
||||
if (scriptName.endsWith(".script") == false) {
|
||||
post("Error: tail can only be called on .script files (filename must end with .script)"); return;
|
||||
}
|
||||
|
||||
|
||||
//Check that the script exists on this machine
|
||||
var runningScript = findRunningScript(scriptName, args, s);
|
||||
if (runningScript == null) {
|
||||
@ -1026,7 +1029,7 @@ var Terminal = {
|
||||
}
|
||||
break;
|
||||
case "theme":
|
||||
//todo support theme saving
|
||||
//todo support theme saving
|
||||
var args = commandArray[1] ? commandArray[1].split(" ") : [];
|
||||
if(args.length != 1 && args.length != 3) {
|
||||
post("Incorrect number of arguments.");
|
||||
@ -1047,7 +1050,7 @@ var Terminal = {
|
||||
document.body.style.setProperty('--my-background-color',"#002b36");
|
||||
}else{
|
||||
post("Theme not found");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
inputBackgroundHex = args[0];
|
||||
inputTextHex = args[1];
|
||||
@ -1060,7 +1063,7 @@ var Terminal = {
|
||||
document.body.style.setProperty('--my-background-color',inputBackgroundHex);
|
||||
}else{
|
||||
post("Invalid Hex Input for theme");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "top":
|
||||
@ -1110,7 +1113,7 @@ var Terminal = {
|
||||
post("Command not found");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
connectToServer: function(ip) {
|
||||
console.log("Connect to server called");
|
||||
var serv = getServer(ip);
|
||||
@ -1126,19 +1129,19 @@ var Terminal = {
|
||||
checkIfConnectedToDarkweb(); //Posts a 'help' message if connecting to dark web
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
executeListCommand: function(commandArray) {
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect usage of ls command. Usage: ls"); return;
|
||||
}
|
||||
|
||||
|
||||
//Display all programs and scripts
|
||||
var allFiles = [];
|
||||
|
||||
var allFiles = [];
|
||||
|
||||
//Get all of the programs and scripts on the machine into one temporary array
|
||||
var s = Player.getCurrentServer();
|
||||
for (var i = 0; i < s.programs.length; i++) {
|
||||
allFiles.push(s.programs[i]);
|
||||
allFiles.push(s.programs[i]);
|
||||
}
|
||||
for (var i = 0; i < s.scripts.length; i++) {
|
||||
allFiles.push(s.scripts[i].filename);
|
||||
@ -1146,15 +1149,15 @@ var Terminal = {
|
||||
for (var i = 0; i < s.messages.length; i++) {
|
||||
allFiles.push(s.messages[i].filename);
|
||||
}
|
||||
|
||||
|
||||
//Sort the files alphabetically then print each
|
||||
allFiles.sort();
|
||||
|
||||
|
||||
for (var i = 0; i < allFiles.length; i++) {
|
||||
post(allFiles[i]);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
executeScanCommand: function(commandArray) {
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return;
|
||||
@ -1166,13 +1169,13 @@ var Terminal = {
|
||||
var entry = Player.getCurrentServer().getServerOnNetwork(i);
|
||||
if (entry == null) {continue;}
|
||||
entry = entry.hostname;
|
||||
|
||||
|
||||
//Calculate padding and add IP
|
||||
var numSpaces = 21 - entry.length;
|
||||
var spaces = Array(numSpaces+1).join(" ");
|
||||
entry += spaces;
|
||||
entry += Player.getCurrentServer().getServerOnNetwork(i).ip;
|
||||
|
||||
|
||||
//Calculate padding and add root access info
|
||||
var hasRoot;
|
||||
if (Player.getCurrentServer().getServerOnNetwork(i).hasAdminRights) {
|
||||
@ -1187,7 +1190,7 @@ var Terminal = {
|
||||
post(entry);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
executeScanAnalyzeCommand: function(depth=1) {
|
||||
//We'll use the AllServersMap as a visited() array
|
||||
//TODO Using array as stack for now, can make more efficient
|
||||
@ -1227,7 +1230,7 @@ var Terminal = {
|
||||
post(dashes + "RAM: " + s.maxRam);
|
||||
post(" ");
|
||||
}
|
||||
|
||||
|
||||
var links = document.getElementsByClassName("scan-analyze-link");
|
||||
for (var i = 0; i < links.length; ++i) {
|
||||
(function() {
|
||||
@ -1237,9 +1240,9 @@ var Terminal = {
|
||||
}
|
||||
}());//Immediate invocation
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
executeFreeCommand: function(commandArray) {
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect usage of free command. Usage: free"); return;
|
||||
@ -1248,7 +1251,7 @@ var Terminal = {
|
||||
post("Used: " + formatNumber(Player.getCurrentServer().ramUsed, 2) + " GB");
|
||||
post("Available: " + formatNumber(Player.getCurrentServer().maxRam - Player.getCurrentServer().ramUsed, 2) + " GB");
|
||||
},
|
||||
|
||||
|
||||
//First called when the "run [program]" command is called. Checks to see if you
|
||||
//have the executable and, if you do, calls the executeProgram() function
|
||||
runProgram: function(programName) {
|
||||
@ -1267,7 +1270,7 @@ var Terminal = {
|
||||
}
|
||||
post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)");
|
||||
},
|
||||
|
||||
|
||||
//Contains the implementations of all possible programs
|
||||
executeProgram: function(programName) {
|
||||
var s = Player.getCurrentServer();
|
||||
@ -1382,10 +1385,10 @@ var Terminal = {
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
runScript: function(scriptName) {
|
||||
var server = Player.getCurrentServer();
|
||||
|
||||
|
||||
var numThreads = 1;
|
||||
var args = [];
|
||||
var results = scriptName.split(" ");
|
||||
@ -1402,7 +1405,7 @@ var Terminal = {
|
||||
}
|
||||
for (var i = 3; i < results.length; ++i) {
|
||||
var arg = results[i];
|
||||
|
||||
|
||||
//Forced string
|
||||
if ((arg.startsWith("'") && arg.endsWith("'")) ||
|
||||
(arg.startsWith('"') && arg.endsWith('"'))) {
|
||||
@ -1421,7 +1424,7 @@ var Terminal = {
|
||||
} else {
|
||||
for (var i = 1; i < results.length; ++i) {
|
||||
var arg = results[i];
|
||||
|
||||
|
||||
//Forced string
|
||||
if ((arg.startsWith("'") && arg.endsWith("'")) ||
|
||||
(arg.startsWith('"') && arg.endsWith('"'))) {
|
||||
@ -1438,15 +1441,15 @@ var Terminal = {
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Check if this script is already running
|
||||
if (findRunningScript(scriptName, args, server) != null) {
|
||||
post("ERROR: This script is already running. Cannot run multiple instances");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//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) {
|
||||
@ -1454,7 +1457,7 @@ var Terminal = {
|
||||
var script = server.scripts[i];
|
||||
var ramUsage = script.ramUsage * numThreads * Math.pow(CONSTANTS.MultithreadingRAMCost, numThreads-1);
|
||||
var ramAvailable = server.maxRam - server.ramUsed;
|
||||
|
||||
|
||||
if (server.hasAdminRights == false) {
|
||||
post("Need root access to run script");
|
||||
return;
|
||||
@ -1469,17 +1472,14 @@ var Terminal = {
|
||||
var runningScriptObj = new RunningScript(script, args);
|
||||
runningScriptObj.threads = numThreads;
|
||||
server.runningScripts.push(runningScriptObj);
|
||||
|
||||
|
||||
addWorkerScript(runningScriptObj, server);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
post("ERROR: No such script");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
525
src/engine.js
525
src/engine.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user