mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 20:55:44 +01:00
Playtesting - Fixed some bugs, refactoring
This commit is contained in:
parent
ffda024431
commit
77f386d14a
@ -64,6 +64,10 @@
|
||||
}
|
||||
|
||||
/* Active scripts */
|
||||
.active-scripts-list {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#active-scripts-container {
|
||||
position: fixed;
|
||||
padding-top: 10px;
|
||||
|
@ -21,6 +21,14 @@ h2 {
|
||||
color: #66ff33;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
/* Main menu */
|
||||
.mainmenu {
|
||||
list-style-type: none;
|
||||
|
@ -131,7 +131,7 @@
|
||||
|
||||
<!-- Active scripts info page -->
|
||||
<div id="active-scripts-container">
|
||||
<ul class="active-scripts-list" id="active-scripts-list">
|
||||
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -504,7 +504,7 @@
|
||||
|
||||
<!-- Travel Pop-up Box -->
|
||||
<div id="travel-box-container">
|
||||
<div id="travel-box-content".
|
||||
<div id="travel-box-content">
|
||||
<p id="travel-box-text"> </p>
|
||||
<span id="travel-box-confirm"> Yes </span>
|
||||
<span id="travel-box-cancel"> No </span>
|
||||
|
@ -62,6 +62,10 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
|
||||
if (currCompany != "") {
|
||||
if (currCompany.companyName != company.companyName) {
|
||||
company.playerReputation -= 1000;
|
||||
if (company.playerReputation < 0) {company.playerReputation = 0;}
|
||||
if (Engine.debug) {
|
||||
console.log("Lost reputation for " + company.companyName + ". It is now " + company.playerReputation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,15 @@ CONSTANTS = {
|
||||
//How much a TOR router costs
|
||||
TorRouterCost: 2000000,
|
||||
|
||||
MillisecondsPer20Hours: 72000000,
|
||||
GameCyclesPer20Hours: 72000000 / 200,
|
||||
|
||||
MillisecondsPer8Hours: 28800000,
|
||||
GameCyclesPer8Hours: 28800000 / 200,
|
||||
|
||||
MillisecondsPerHour: 3600000,
|
||||
GameCyclesPerHour: 3600000 / 200,
|
||||
|
||||
//Text that is displayed when the 'help' command is ran in Terminal
|
||||
HelpText: "analyze Get statistics and information about current machine <br>" +
|
||||
"clear Clear all text on the terminal <br>" +
|
||||
|
@ -244,14 +244,14 @@ function evaluate(exp, workerScript) {
|
||||
Player.gainMoney(moneyGained);
|
||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||
|
||||
Player.hacking_exp += expGainedOnSuccess;
|
||||
Player.gainHackingExp(expGainedOnSuccess);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
|
||||
console.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
|
||||
workerScript.scriptRef.log("Script successfully hacked " + server.hostname + " for $" + moneyGained + " and " + expGainedOnSuccess + " exp");
|
||||
resolve("Hack success");
|
||||
} else {
|
||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||
Player.hacking_exp += expGainedOnFailure;
|
||||
Player.gainHackingExp(expGainedOnFailure);
|
||||
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
|
||||
|
||||
console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + expGainedOnFailure + " exp");
|
||||
@ -544,7 +544,7 @@ function scriptCalculateHackingTime(server) {
|
||||
|
||||
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
||||
function scriptCalculateExpGain(server) {
|
||||
return Math.round(server.hackDifficulty * server.requiredHackingSkill * Player.hacking_exp_mult);
|
||||
return Math.round(server.hackDifficulty * Player.hacking_exp_mult);
|
||||
}
|
||||
|
||||
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
|
||||
@ -553,5 +553,7 @@ function scriptCalculatePercentMoneyHacked(server) {
|
||||
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
|
||||
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult;
|
||||
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
||||
if (percentMoneyHacked < 0) {return 0;}
|
||||
if (percentMoneyHacked > 1) {return 1;}
|
||||
return percentMoneyHacked;
|
||||
}
|
@ -203,6 +203,8 @@ PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
||||
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
|
||||
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult;
|
||||
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
||||
if (percentMoneyHacked < 0) {return 0;}
|
||||
if (percentMoneyHacked > 1) {return 1;}
|
||||
return percentMoneyHacked;
|
||||
}
|
||||
|
||||
@ -212,7 +214,7 @@ PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
||||
//
|
||||
// Note: Keep it at an integer for now,
|
||||
PlayerObject.prototype.calculateExpGain = function() {
|
||||
return Math.round(this.getCurrentServer().hackDifficulty * this.getCurrentServer().requiredHackingSkill * this.hacking_exp_mult);
|
||||
return Math.round(this.getCurrentServer().hackDifficulty * this.hacking_exp_mult);
|
||||
}
|
||||
|
||||
//Hack/Analyze a server. Return the amount of time the hack will take. This lets the Terminal object know how long to disable itself for
|
||||
@ -232,27 +234,71 @@ PlayerObject.prototype.analyze = function() {
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainMoney = function(money) {
|
||||
if (isNaN(money)) {
|
||||
console.log("ERR: NaN passed into Player.gainMoney()"); return;
|
||||
}
|
||||
this.money += money;
|
||||
this.total_money += money;
|
||||
this.lifetime_money += money;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainHackingExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into Player.gainHackingExp()"); return;
|
||||
}
|
||||
this.hacking_exp += exp;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainStrengthExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into Player.gainStrengthExp()"); return;
|
||||
}
|
||||
this.strength_exp += exp;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainDefenseExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into player.gainDefenseExp()"); return;
|
||||
}
|
||||
this.defense_exp += exp;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainDexterityExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into Player.gainDexterityExp()"); return;
|
||||
}
|
||||
this.dexterity_exp += exp;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainAgilityExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into Player.gainAgilityExp()"); return;
|
||||
}
|
||||
this.agility_exp += exp;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.gainCharismaExp = function(exp) {
|
||||
if (isNaN(exp)) {
|
||||
console.log("ERR: NaN passed into Player.gainCharismaExp()"); return;
|
||||
}
|
||||
this.charisma_exp += exp;
|
||||
}
|
||||
|
||||
/* Working for Company */
|
||||
PlayerObject.prototype.finishWork = function(cancelled) {
|
||||
//Since the work was cancelled early, player only gains half of what they've earned so far
|
||||
var cancMult = 1;
|
||||
if (cancelled) {
|
||||
cancMult = 2;
|
||||
}
|
||||
if (cancelled) {cancMult = 2;}
|
||||
|
||||
if (Engine.Debug) {
|
||||
console.log("Player finishWork() called with " + this.workMoneyGained / cancMult + " $ gained");
|
||||
}
|
||||
this.hacking_exp += (this.workHackExpGained / cancMult);
|
||||
this.strength_exp += (this.workStrExpGained / cancMult);
|
||||
this.defense_exp += (this.workDefExpGained / cancMult);
|
||||
this.dexterity_exp += (this.workDexExpGained / cancMult);
|
||||
this.agility_exp += (this.workAgiExpGained / cancMult);
|
||||
this.charisma_exp += (this.workChaExpGained / cancMult);
|
||||
this.gainHackingExp(this.workHackExpGained / cancMult);
|
||||
this.gainStrengthExp(this.workStrExpGained / cancMult);
|
||||
this.gainDefenseExp(this.workDefExpGained / cancMult);
|
||||
this.gainDexterityExp(this.workDexExpGained / cancMult);
|
||||
this.gainAgilityExp(this.workAgiExpGained / cancMult);
|
||||
this.gainCharismaExp(this.workChaExpGained / cancMult);
|
||||
|
||||
var company = Companies[this.companyName];
|
||||
company.playerReputation += (this.workRepGained / cancMult);
|
||||
@ -279,13 +325,13 @@ PlayerObject.prototype.finishWork = function(cancelled) {
|
||||
txt = "You worked a full shift of 8 hours! <br><br> " +
|
||||
"You earned a total of: <br>" +
|
||||
"$" + (this.workMoneyGained / cancMult) + "<br>" +
|
||||
(this.workRepGained / cancMult) + " reputation for the company <br>" +
|
||||
(this.workHackExpGained / cancMult) + " hacking exp <br>" +
|
||||
(this.workStrExpGained / cancMult) + " strength exp <br>" +
|
||||
(this.workDefExpGained / cancMult) + " defense exp <br>" +
|
||||
(this.workDexExpGained / cancMult) + " dexterity exp <br>" +
|
||||
(this.workAgiExpGained / cancMult) + " agility exp <br>" +
|
||||
(this.workChaExpGained / cancMult) + " charisma exp <br>";
|
||||
(this.workRepGained / cancMult).toFixed(3) + " reputation for the company <br>" +
|
||||
(this.workHackExpGained / cancMult).toFixed(3) + " hacking exp <br>" +
|
||||
(this.workStrExpGained / cancMult).toFixed(3) + " strength exp <br>" +
|
||||
(this.workDefExpGained / cancMult).toFixed(3) + " defense exp <br>" +
|
||||
(this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp <br>" +
|
||||
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>" +
|
||||
(this.workChaExpGained / cancMult).toFixed(3) + " charisma exp <br>";
|
||||
}
|
||||
dialogBoxCreate(txt);
|
||||
|
||||
@ -353,8 +399,8 @@ PlayerObject.prototype.work = function(numCycles) {
|
||||
this.timeWorked += Engine._idleSpeed * numCycles;
|
||||
|
||||
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
|
||||
if (this.timeWorked >= 28800000) {
|
||||
var maxCycles = 144000; //Number of cycles in 8 hours
|
||||
if (this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
|
||||
var maxCycles = CONSTANTS.GameCyclesPer8Hours; //Number of cycles in 8 hours
|
||||
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
|
||||
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
|
||||
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
|
||||
@ -515,8 +561,8 @@ PlayerObject.prototype.workForFaction = function(numCycles) {
|
||||
this.timeWorked += Engine._idleSpeed * numCycles;
|
||||
|
||||
//If timeWorked == 20 hours, then finish. You can only work for the faction for 20 hours
|
||||
if (this.timeWorked >= 72000000) {
|
||||
var maxCycles = 360000; //Number of cycles in 20 hours
|
||||
if (this.timeWorked >= CONSTANTS.MillisecondsPer20Hours) {
|
||||
var maxCycles = CONSTANTS.GameCyclesPer20Hours; //Number of cycles in 20 hours
|
||||
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
|
||||
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
|
||||
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
|
||||
|
@ -396,7 +396,7 @@ initForeignServers = function() {
|
||||
//"Low level" targets
|
||||
var FoodNStuffServer = new Server();
|
||||
FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 2);
|
||||
FoodNStuffServer.setHackingParameters(1, 1000000, 10, 20);
|
||||
FoodNStuffServer.setHackingParameters(1, 500000, 10, 20);
|
||||
FoodNStuffServer.setPortProperties(0);
|
||||
AddToAllServers(FoodNStuffServer);
|
||||
|
||||
@ -644,7 +644,7 @@ processServerGrowth = function(numCycles) {
|
||||
|
||||
//Apply serverGrowth for the calculated number of growth cycles
|
||||
var serverGrowth = Math.pow(1.0001, numServerGrowthCyclesAdjusted);
|
||||
console.log("serverGrowth ratio: " + serverGrowth);
|
||||
//console.log("serverGrowth ratio: " + serverGrowth);
|
||||
server.moneyAvailable *= serverGrowth;
|
||||
}
|
||||
}
|
||||
|
@ -112,12 +112,12 @@ var Terminal = {
|
||||
Player.getCurrentServer().moneyAvailable -= moneyGained;
|
||||
Player.gainMoney(moneyGained);
|
||||
|
||||
Player.hacking_exp += expGainedOnSuccess;
|
||||
Player.gainHackingExp(expGainedOnSuccess)
|
||||
|
||||
post("Hack successful! Gained $" + moneyGained + " and " + expGainedOnSuccess + " hacking EXP");
|
||||
} else { //Failure
|
||||
//Player only gains 25% exp for failure? TODO Can change this later to balance
|
||||
Player.hacking_exp += expGainedOnFailure;
|
||||
Player.gainHackingExp(expGainedOnFailure)
|
||||
post("Failed to hack " + Player.getCurrentServer().hostname + ". Gained " + expGainedOnFailure + " hacking EXP");
|
||||
}
|
||||
}
|
||||
|
@ -645,6 +645,7 @@ var Engine = {
|
||||
updateHackProgress: function(numCycles = 1) {
|
||||
var timeElapsedMilli = numCycles * Engine._idleSpeed;
|
||||
Engine._actionTimeLeft -= (timeElapsedMilli/ 1000); //Substract idle speed (ms)
|
||||
Engine._actionTimeLeft = Math.max(Engine._actionTimeLeft, 0);
|
||||
|
||||
//Calculate percent filled
|
||||
var percent = Math.round((1 - Engine._actionTimeLeft / Engine._totalActionTime) * 100);
|
||||
|
Loading…
Reference in New Issue
Block a user