mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
Started working on Work functionality
This commit is contained in:
parent
d20da28c51
commit
f5b0796948
27
css/workinprogress.css
Normal file
27
css/workinprogress.css
Normal file
@ -0,0 +1,27 @@
|
||||
#work-in-progress-container {
|
||||
|
||||
}
|
||||
|
||||
#work-in-progress-text {
|
||||
color: #66ff33;
|
||||
}
|
||||
|
||||
#work-in-progress-cancel-button {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
-webkit-border-radius: 12px;
|
||||
-moz-border-radius: 12px;
|
||||
border-radius: 12px;
|
||||
-moz-box-shadow: 1px 1px 3px #000;
|
||||
-webkit-box-shadow: 1px 1px 3px #000;
|
||||
box-shadow: 1px 1px 3px #000;
|
||||
}
|
||||
|
||||
#work-in-progress-cancel-button:hover,
|
||||
#work-in-progress-cancel-button:focus {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
@ -355,6 +355,8 @@
|
||||
<p id="location-info"> </p>
|
||||
|
||||
<p id="location-job-title"> </p>
|
||||
<p id="location-job-reputation"> </p>
|
||||
|
||||
<!-- Jobs/Work at a company -->
|
||||
<a href="#" id="location-software-job" class="a-link-button"> Apply for Software Job</a>
|
||||
<a href="#" id="location-it-job" class="a-link-button"> Apply for IT Job </a>
|
||||
@ -418,5 +420,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Work in progress screen -->
|
||||
<div id="work-in-progress-container">
|
||||
<p id="work-in-progress-text"> </p>
|
||||
|
||||
<span id="work-in-progress-cancel-button"> Cancel Work </span>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -141,7 +141,7 @@ displayLocationContent = function() {
|
||||
employeeJob.style.display = "none";
|
||||
waiterJob.style.display = "none";
|
||||
|
||||
work.style.display = "none"; //TODO DIsplay this
|
||||
work.style.display = "block";
|
||||
|
||||
gymTrainStr.style.display = "none";
|
||||
gymTrainDef.style.display = "none";
|
||||
@ -167,6 +167,24 @@ displayLocationContent = function() {
|
||||
travelToIshima.style.display = "none";
|
||||
travelToVolhaven.style.display = "none";
|
||||
|
||||
//Check if the player is employed at this Location. If he is, display the "Work" button,
|
||||
//update the job title, etc.
|
||||
if (pos == Player.companyName) {
|
||||
var company = Companies[pos];
|
||||
|
||||
jobTitle = document.getElementById("location-job-title");
|
||||
jobTitle.innerHTML = "Job Title: " + Player.companyPosition.positionName;
|
||||
jobReputation = document.getElementById("location-job-reputation");
|
||||
jobReputation.innerHTML = "Company reputation: " + company.playerReputation;
|
||||
work.style.display = "block";
|
||||
|
||||
work.addEventListener("click", function() {
|
||||
Player.startWork();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
switch (loc) {
|
||||
case Locations.AevumTravelAgency:
|
||||
travelToChongqing.style.display = "block";
|
||||
|
@ -64,8 +64,8 @@ function PlayerObject() {
|
||||
this.location = "";
|
||||
|
||||
//Company Information
|
||||
this.companyName = "";
|
||||
this.companyPosition = "";
|
||||
this.companyName = ""; //Name of Company, equivalent to an object from Locations
|
||||
this.companyPosition = ""; //CompanyPosition object
|
||||
|
||||
//Servers
|
||||
this.currentServer = ""; //IP address of Server currently being accessed through terminal
|
||||
@ -74,9 +74,21 @@ function PlayerObject() {
|
||||
|
||||
//Achievements and achievement progress
|
||||
|
||||
//Flag to let the engine know the player is starting a hack
|
||||
//Flag to let the engine know the player is starting an action
|
||||
// Current actions: hack, analyze
|
||||
this.startAction = false;
|
||||
this.actionTime = 0;
|
||||
|
||||
//Flags for working
|
||||
this.isWorking = false;
|
||||
this.workHackExpGained = 0;
|
||||
this.workStrExpGained = 0;
|
||||
this.workDefExpGained = 0;
|
||||
this.workDexExpGained = 0;
|
||||
this.workAgiExpGained = 0;
|
||||
this.workRepGained = 0;
|
||||
this.workMoneyGained = 0;
|
||||
this.timeWorked = 0; //in ms
|
||||
|
||||
//Used to store the last update time.
|
||||
this.lastUpdate = new Date().getTime();
|
||||
@ -184,6 +196,68 @@ PlayerObject.prototype.gainMoney = function(money) {
|
||||
this.lifetime_money += money;
|
||||
}
|
||||
|
||||
/* Working */
|
||||
PlayerObject.prototype.startWork = function() {
|
||||
this.isWorking = true;
|
||||
this.workHackExpGained = 0;
|
||||
this.workStrExpGained = 0;
|
||||
this.workDefExpGained = 0;
|
||||
this.workDexExpGained = 0;
|
||||
this.workAgiExpGained = 0;
|
||||
this.workRepGained = 0;
|
||||
this.workMoneyGained = 0;
|
||||
this.timeWorked = 0;
|
||||
}
|
||||
|
||||
PlayerObject.prototype.work = function(numCycles) {
|
||||
var txt = document.getElementById("work-in-progress-text");
|
||||
txt.innerHTML = "You are currently working as a " + this.companyPosition.positionName +
|
||||
" at " + Player.companyName + "<br><br>" +
|
||||
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
||||
"You have earned: <br><br>" +
|
||||
"$" + this.workMoneyGained + " ("
|
||||
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, <br><br>" +
|
||||
"but you will only gain half of the experience, money, and reputation you've earned so far."
|
||||
}
|
||||
|
||||
//Money gained per game cycle
|
||||
PlayerObject.prototype.getWorkMoneyGain() {
|
||||
var company = Companies[this.companyName];
|
||||
|
||||
var salary = this.companyPosition.baseSalary;
|
||||
return salary * company.salaryMultiplier;
|
||||
}
|
||||
|
||||
//Hack exp gained per game cycle
|
||||
PlayerObject.prototype.getWorkHackExpGain() {
|
||||
|
||||
}
|
||||
|
||||
//Str exp gained per game cycle
|
||||
PlayerObject.prototype.getWorkStrExpGain() {
|
||||
|
||||
}
|
||||
|
||||
//Def exp gained per game cycle
|
||||
PlayerObject.prototype.getWorkDefExpGain() {
|
||||
|
||||
}
|
||||
|
||||
//Dex exp gained per game cycle
|
||||
PlayerObject.prototype.getWorkDexExpGain() {
|
||||
|
||||
}
|
||||
|
||||
//Agi exp gained per game cycle
|
||||
PlayerObject.prototype.getWorkAgiExpGain() {
|
||||
|
||||
}
|
||||
|
||||
//Reputation gained per game cycle
|
||||
PlayerObject.prototype.getWorkRepGain() {
|
||||
|
||||
}
|
||||
|
||||
//Functions for saving and loading the Player data
|
||||
PlayerObject.prototype.toJSON = function() {
|
||||
return Generic_toJSON("PlayerObject", this);
|
||||
|
@ -425,6 +425,10 @@ var Engine = {
|
||||
Player.startAction = false;
|
||||
}
|
||||
|
||||
if (Player.isWorking) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
//Counters
|
||||
Engine.decrementAllCounters(numCycles);
|
||||
Engine.checkCounters();
|
||||
|
@ -22,4 +22,23 @@ function getIndicesOf(searchStr, str, caseSensitive) {
|
||||
//Replaces the character at an index with a new character
|
||||
String.prototype.replaceAt=function(index, character) {
|
||||
return this.substr(0, index) + character + this.substr(index+character.length);
|
||||
}
|
||||
|
||||
//Converts a date representing time in milliseconds to a string with the format
|
||||
// H hours M minutes and S seconds
|
||||
// e.g. 10000 -> "0 hours 0 minutes and 10 seconds"
|
||||
// 120000 -> "0 0 hours 2 minutes and 0 seconds"
|
||||
function convertTimeMsToTimeElapsedString(time) {
|
||||
//Convert ms to seconds, since we only have second-level precision
|
||||
time = Math.floor(time / 1000);
|
||||
|
||||
var hours = Math.floor(time / 3600);
|
||||
time %= 3600;
|
||||
|
||||
var minutes = Math.floor(time / 60);
|
||||
time %= 60;
|
||||
|
||||
var seconds = time;
|
||||
|
||||
return hours + " hours " + minutes + " minutes " + seconds + " seconds";
|
||||
}
|
Loading…
Reference in New Issue
Block a user