Added autocompletion for aliases. Added autocompletion for any number of arguments. Added getServerRam() function

This commit is contained in:
danielyxie 2017-07-24 20:06:40 -05:00
parent e653b7b315
commit d5be649bbd
6 changed files with 739 additions and 727 deletions

@ -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;
}
}

@ -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,9 @@
<script src="src/StockMarket.js"></script>
<script src="src/RedPill.js"></script>
<script src="src/BitNode.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 +103,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 +120,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 +134,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 +146,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 +182,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 +192,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 +277,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 +295,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 +352,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 +376,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 +397,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 +436,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 +472,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 +495,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 +512,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 +530,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 +542,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 +554,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 +566,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 +585,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 +605,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 +617,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 +629,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 +663,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 +679,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 +693,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 +715,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 +734,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 +755,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 +790,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 +801,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 +810,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 +830,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 +877,7 @@
<span id="interactive-tutorial-back"> Back </span>
</div>
</div>
<!-- Character Overview Screen -->
<div id="character-overview-wrapper">
<div id="character-overview-container">
@ -884,12 +886,12 @@
<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">
@ -898,17 +900,17 @@
<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">
<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;">
(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.
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;">
@ -920,11 +922,11 @@
</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>

@ -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;}
}
}
}
}

@ -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);
@ -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");
}
}
}
}

@ -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");
}
};

File diff suppressed because it is too large Load Diff