Minor UI improvements and bug fixes

This commit is contained in:
Daniel Xie 2017-05-10 15:21:15 -05:00
parent f2287b5696
commit 3808fe5a3f
13 changed files with 72 additions and 60 deletions

@ -26,7 +26,9 @@ TESTING TODO:
Should add something where if you click it in the "Active Scripts" GUI you can see the logs too
Seems to work fine
Gyms - Later..don't need for MVP
Tasks TODO:
Adding augmentations for Silhouette fac
@ -42,11 +44,7 @@ Tasks TODO:
Create new menu page for purchased servers
Gyms - Later..don't need for MVP
Update CONSTANTS.HelpText
Account for Max possible int when gaining exp (it will overflow)
Text in script editor that says ("ctrl + x" to save and quit)
OPTIMIZATION
https://gamealchemist.wordpress.com/2013/05/01/lets-get-those-javascript-arrays-to-work-fast/

@ -149,7 +149,7 @@ tr:focus {
.tooltip .tooltiptext {
visibility: hidden;
width: 200px;
width: 300px;
background-color: black;
border: 2px solid white;
color: white;

@ -31,9 +31,6 @@ CONSTANTS = {
/* Script related things */
//Time (ms) it takes to run one operation in Netscript.
CodeInstructionRunTime: 1500,
//Time (seconds) it takes to run one operation in Netscript OFFLINE
CodeOfflineExecutionTime: 10,
//Server growth rate
ServerGrowthRate: 1.00075,

@ -92,7 +92,7 @@ function determineCrimeChanceShoplift() {
var chance = ((Player.strength / CONSTANTS.MaxSkillLevel +
Player.defense / CONSTANTS.MaxSkillLevel +
Player.dexterity / CONSTANTS.MaxSkillLevel +
Player.agility / CONSTANTS.MaxSkillLevel)) * 8;
Player.agility / CONSTANTS.MaxSkillLevel)) * 10;
return Math.min(chance, 1);
}
@ -101,12 +101,12 @@ function determineCrimeChanceMug() {
var chance = ((Player.strength / CONSTANTS.MaxSkillLevel +
Player.defense / CONSTANTS.MaxSkillLevel +
Player.dexterity / CONSTANTS.MaxSkillLevel +
Player.agility / CONSTANTS.MaxSkillLevel)) * 4;
Player.agility / CONSTANTS.MaxSkillLevel)) * 5;
return Math.min(chance, 1);
}
function determineCrimeChanceDealDrugs() {
var chance = ((1.5*Player.charisma / CONSTANTS.MaxSkillLevel +
var chance = ((2*Player.charisma / CONSTANTS.MaxSkillLevel +
Player.strength / CONSTANTS.MaxSkillLevel +
Player.defense / CONSTANTS.MaxSkillLevel +
Player.dexterity / CONSTANTS.MaxSkillLevel +

@ -747,13 +747,13 @@ displayFactionAugmentations = function(factionName) {
aElem.setAttribute("href", "#");
var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult;
if (aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) {
aElem.setAttribute("class", "a-link-button-inactive");
aElem.setAttribute("class", "a-link-button-inactive tooltip");
pElem.innerHTML = "ALREADY OWNED";
} else if (faction.playerReputation >= req) {
aElem.setAttribute("class", "a-link-button tooltip");
pElem.innerHTML = "UNLOCKED - $" + formatNumber(aug.baseCost * faction.augmentationPriceMult, 2);
} else {
aElem.setAttribute("class", "a-link-button-inactive");
aElem.setAttribute("class", "a-link-button-inactive tooltip");
pElem.innerHTML = "LOCKED (Requires " + formatNumber(req, 4) + " faction reputation)";
pElem.style.color = "red";
}
@ -764,7 +764,7 @@ displayFactionAugmentations = function(factionName) {
aElem.innerHTML += " - Level " + (aug.level + 1);
}
aElem.innerHTML += "<span class='tooltiptext'>" + aug.info + " </span>";
aElem.innerHTML += '<span class="tooltiptext">' + aug.info + " </span>";
aElem.addEventListener("click", function() {
purchaseAugmentationBoxCreate(aug, faction);

@ -27,7 +27,8 @@ FactionInfo = {
"transporation on an unprecendented scale, in ways that no other company can.\n\n" +
"In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.",
BachmanAndAssociatesInfo: "TODO",
BachmanAndAssociatesInfo: "Where Law and Business meet - thats where we are. <br><br>" +
"Legal Insight - Business Instinct - Experience Innovation",
BladeIndustriesInfo: "TODO",
@ -39,7 +40,7 @@ FactionInfo = {
FourSigmaInfo: "TODO",
KuaiGongInternationalInfo: "TODO",
KuaiGongInternationalInfo: "Dream big. Work hard. Make history.",
//Other Corporations
FulcrumSecretTechnologiesInfo: "TODO",
@ -116,6 +117,7 @@ FactionInfo = {
//Earlygame factions - factions the player will prestige with early on that don't
//belong in other categories
NetburnersInfo: "~~//*><H4CK|\|3T 8URN3R5**>?>\\~~",
TianDiHuiInfo: "Obey Heaven and Work Righteousness",
CyberSecInfo: "The Internet is the first thing that humanity has built that humanity doesnt understand,\n" +

@ -900,7 +900,7 @@ displayLocationContent = function() {
employeeJob.style.display = "none";
} else if (currPos.positionName == CompanyPositions.Waiter.positionName) {
waiterJob.style.display = "none";
} else if (currPos.positionName == CompanyPositions.PartTimeEmploye.positionName) {
} else if (currPos.positionName == CompanyPositions.PartTimeEmployee.positionName) {
employeePartTimeJob.style.display = "none";
} else if (currPos.positionName == CompanyPositions.PartTimeWaiter.positionName) {
waiterPartTimeJob.style.display = "none";

@ -562,24 +562,24 @@ PlayerObject.prototype.workPartTime = function(numCycles) {
}
PlayerObject.prototype.finishWorkPartTime = function() {
this.gainWorkExp(cancMult);
this.gainWorkExp();
var company = Companies[this.companyName];
company.playerReputation += (this.workRepGained / cancMult);
company.playerReputation += (this.workRepGained);
this.gainMoney(this.workMoneyGained / cancMult);
this.gainMoney(this.workMoneyGained);
this.updateSkillLevels();
var txt = "You earned a total of: <br>" +
"$" + formatNumber(this.workMoneyGained / cancMult, 2) + "<br>" +
formatNumber(this.workRepGained / cancMult, 4) + " reputation for the company <br>" +
formatNumber(this.workHackExpGained / cancMult, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained / cancMult, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained / cancMult, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained / cancMult, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained / cancMult, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained / cancMult, 4) + " charisma exp<br>";
"$" + formatNumber(this.workMoneyGained, 2) + "<br>" +
formatNumber(this.workRepGained, 4) + " reputation for the company <br>" +
formatNumber(this.workHackExpGained, 4) + " hacking exp <br>" +
formatNumber(this.workStrExpGained, 4) + " strength exp <br>" +
formatNumber(this.workDefExpGained, 4) + " defense exp <br>" +
formatNumber(this.workDexExpGained, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained, 4) + " charisma exp<br>";
txt = "You worked for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ".<br><br> " + txt;
dialogBoxCreate(txt);

@ -128,12 +128,7 @@ function prestigeAugmentation() {
//Reset statistics of all scripts on home computer
for (var i = 0; i < homeComp.scripts.length; ++i) {
var s = homeComp.scripts[i];
s.offlineRunningTime = 0.01; //Seconds
s.offlineMoneyMade = 0;
s.offlineExpGained = 0;
s.onlineRunningTime = 0.01; //Seconds
s.onlineMoneyMade = 0;
s.onlineExpGained = 0;
s.reset();
}
//Delete all running scripts objects
@ -159,13 +154,17 @@ function prestigeAugmentation() {
//Delete Companies
for (var member in Companies) {
delete Companies[member];
if (Companies.hasOwnProperty(member)) {
delete Companies[member];
}
}
Companies = {};
//Reset Factions
for (var member in Factions) {
Factions[member].reset();
if (Factions.hasOwnProperty(member)) {
Factions[member].reset();
}
}
//Re-initialize Augmentations - This will update any changes

@ -139,6 +139,17 @@ Script.prototype.saveScript = function() {
}
}
Script.prototype.reset = function() {
this.offlineRunningTime = 0.01; //Seconds
this.offlineMoneyMade = 0;
this.offlineExpGained = 0;
this.onlineRunningTime = 0.01; //Seconds
this.onlineMoneyMade = 0;
this.onlineExpGained = 0;
this.moneyStolenMap = new AllServersToMoneyMap();
}
//Calculates the number of instructions, which is just determined by number of semicolons
Script.prototype.updateNumInstructions = function() {
var numSemicolons = this.code.split(";").length - 1;
@ -146,9 +157,6 @@ Script.prototype.updateNumInstructions = function() {
}
//Updates how much RAM the script uses when it is running.
//Right now, it is determined solely by the number of instructions
//Ideally, I would want it to be based on type of instructions as well
// (e.g. hack() costs a lot but others dont)
Script.prototype.updateRamUsage = function() {
this.ramUsage = this.numInstructions * 0.5;
}
@ -225,8 +233,9 @@ scriptCalculateOfflineProduction = function(script) {
var totalOfflineProduction = 0;
for (var ip in script.moneyStolenMap) {
if (script.moneyStolenMap.hasOwnProperty(ip)) {
if (script.moneyStolenMap[ip] == 0) {continue;}
if (script.moneyStolenMap[ip] == 0 || script.moneyStolenMap[ip] == null) {continue;}
var serv = AllServers[ip];
if (serv == null) {continue;}
var production = 0.5 * script.moneyStolenMap[ip] / script.onlineRunningTime * timePassed;
production *= confidence;
if (production > serv.moneyAvailable) {

@ -415,92 +415,92 @@ initForeignServers = function() {
var JoesGunsServer = new Server();
JoesGunsServer.init(createRandomIp(), "joesguns", "Joe's Guns", true, false, false, false, 2);
JoesGunsServer.setHackingParameters(10, 600000, 20, 20);
JoesGunsServer.setHackingParameters(10, 1000000, 20, 20);
JoesGunsServer.setPortProperties(0);
AddToAllServers(JoesGunsServer);
var Zer0NightclubServer = new Server();
Zer0NightclubServer.init(createRandomIp(), "zer0", "ZER0 Nightclub", true, false, false, false, 2);
Zer0NightclubServer.setHackingParameters(75, 750000, 25, 40);
Zer0NightclubServer.setHackingParameters(75, 5000000, 25, 40);
Zer0NightclubServer.setPortProperties(1);
AddToAllServers(Zer0NightclubServer);
var NectarNightclubServer = new Server();
NectarNightclubServer.init(createRandomIp(), "nectar-net", "Nectar Nightclub Network", true, false, false, false, 2);
NectarNightclubServer.setHackingParameters(20, 650000, 20, 25);
NectarNightclubServer.setHackingParameters(20, 1200000, 20, 25);
NectarNightclubServer.setPortProperties(0);
AddToAllServers(NectarNightclubServer);
var NeoNightclubServer = new Server();
NeoNightclubServer.init(createRandomIp(), "neo-net", "Neo Nightclub Network", true, false, false, false, 2);
NeoNightclubServer.setHackingParameters(50, 900000, 25, 25);
NeoNightclubServer.setHackingParameters(50, 2500000, 25, 25);
NeoNightclubServer.setPortProperties(1);
AddToAllServers(NeoNightclubServer);
var SilverHelixServer = new Server();
SilverHelixServer.init(createRandomIp(), "silver-helix", "Silver Helix", true, false, false, false, 2);
SilverHelixServer.setHackingParameters(150, 5000000, 30, 30);
SilverHelixServer.setHackingParameters(150, 50000000, 30, 30);
SilverHelixServer.setPortProperties(2);
AddToAllServers(SilverHelixServer);
var HongFangTeaHouseServer = new Server();
HongFangTeaHouseServer.init(createRandomIp(), "hong-fang-tea", "HongFang Teahouse", true, false, false, false, 0);
HongFangTeaHouseServer.setHackingParameters(30, 800000, 15, 15);
HongFangTeaHouseServer.setHackingParameters(30, 1500000, 15, 15);
HongFangTeaHouseServer.setPortProperties(0);
AddToAllServers(HongFangTeaHouseServer);
var HaraKiriSushiBarServer = new Server();
HaraKiriSushiBarServer.setHackingParameters(40, 800000, 15, 40);
HaraKiriSushiBarServer.setHackingParameters(40, 2000000, 15, 40);
HaraKiriSushiBarServer.init(createRandomIp(), "harakiri-sushi", "HaraKiri Sushi Bar Network", true, false, false, false, 0);
HaraKiriSushiBarServer.setPortProperties(1);
AddToAllServers(HaraKiriSushiBarServer);
var PhantasyServer = new Server();
PhantasyServer.init(createRandomIp(), "phantasy", "Phantasy Club", true, false, false, false, 4);
PhantasyServer.setHackingParameters(100, 1500000, 20, 35);
PhantasyServer.setHackingParameters(100, 25000000, 20, 35);
PhantasyServer.setPortProperties(2);
AddToAllServers(PhantasyServer);
var MaxHardwareServer = new Server();
MaxHardwareServer.init(createRandomIp(), "max-hardware", "Max Hardware Store", true, false, false, false, 0);
MaxHardwareServer.setHackingParameters(80, 800000, 15, 25);
MaxHardwareServer.setHackingParameters(80, 10000000, 15, 25);
MaxHardwareServer.setPortProperties(1);
AddToAllServers(MaxHardwareServer);
var OmegaSoftwareServer = new Server();
OmegaSoftwareServer.init(createRandomIp(), "omega-net", "Omega Software", true, false, false, false, 8);
OmegaSoftwareServer.setHackingParameters(200, 10000000, 30, 35);
OmegaSoftwareServer.setHackingParameters(200, 80000000, 30, 35);
OmegaSoftwareServer.setPortProperties(2);
AddToAllServers(OmegaSoftwareServer);
//Gyms
var CrushFitnessGymServer = new Server();
CrushFitnessGymServer.init(createRandomIp(), "crush-fitness", "Crush Fitness", true, false, false, false, 0);
CrushFitnessGymServer.setHackingParameters(250, 5000000, 40, 25);
CrushFitnessGymServer.setHackingParameters(250, 10000000, 40, 25);
CrushFitnessGymServer.setPortProperties(2);
AddToAllServers(CrushFitnessGymServer);
var IronGymServer = new Server();
IronGymServer.init(createRandomIp(), "iron-gym", "Iron Gym Network", true, false, false, false, 0);
IronGymServer.setHackingParameters(100, 2500000, 30, 15);
IronGymServer.setHackingParameters(100, 5000000, 30, 15);
IronGymServer.setPortProperties(1);
AddToAllServers(IronGymServer);
var MilleniumFitnessGymServer = new Server();
MilleniumFitnessGymServer.init(createRandomIp(), "millenium-fitness", "Millenium Fitness Network", true, false, false, false, 0);
MilleniumFitnessGymServer.setHackingParameters(500, 7500000, 50, 30);
MilleniumFitnessGymServer.setHackingParameters(500, 2500000, 50, 30);
MilleniumFitnessGymServer.setPortProperties(3);
AddToAllServers(MilleniumFitnessGymServer);
var PowerhouseGymServer = new Server();
PowerhouseGymServer.init(createRandomIp(), "powerhouse-fitness", "Powerhouse Fitness", true, false, false, false, 0);
PowerhouseGymServer.setHackingParameters(1000, 20000000, 60, 50);
PowerhouseGymServer.setHackingParameters(1000, 100000000, 60, 50);
PowerhouseGymServer.setPortProperties(5);
AddToAllServers(PowerhouseGymServer);
var SnapFitnessGymServer = new Server();
SnapFitnessGymServer.init(createRandomIp(), "snap-fitness", "Snap Fitness", true, false, false, false, 0);
SnapFitnessGymServer.setHackingParameters(750, 750000, 50, 45);
SnapFitnessGymServer.setHackingParameters(750, 75000000, 50, 45);
SnapFitnessGymServer.setPortProperties(4);
AddToAllServers(SnapFitnessGymServer);

@ -543,6 +543,8 @@ var Engine = {
Player.takeClass(numCycles);
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
Player.commitCrime(numCycles);
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
Player.workPartTime(numCycles);
} else {
Player.work(numCycles);
}
@ -703,6 +705,10 @@ var Engine = {
Player.createProgramWork(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
Player.takeClass(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
Player.commitCrime(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
Player.workPartTime(numCycles);
} else {
Player.work(numCyclesOffline);
}
@ -960,7 +966,7 @@ var Engine = {
//Message at the top of terminal
postNetburnerText();
//Player was working
//Player was working cancel button
if (Player.isWorking) {
var cancelButton = document.getElementById("work-in-progress-cancel-button");
cancelButton.addEventListener("click", function() {
@ -971,6 +977,10 @@ var Engine = {
Player.finishCreateProgramWork(true, Player.createProgramName);
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
Player.finishClass();
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
Player.finishCrime(true);
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
Player.finishWorkPartTime();
} else {
Player.finishWork(true);
}

@ -13,9 +13,6 @@ function dialogBoxInit() {
document.addEventListener("DOMContentLoaded", dialogBoxInit, false);
dialogBoxClose = function() {
if (Engine.Debug) {
console.log("Dialog Box Close called");
}
var dialogBox = document.getElementById("dialog-box-container");
dialogBox.style.display = "none";
}