2016-10-14 23:02:06 +02:00
|
|
|
//Netburner Player class
|
2016-12-01 23:18:18 +01:00
|
|
|
function PlayerObject() {
|
|
|
|
//Skills and stats
|
|
|
|
this.hacking_skill = 1;
|
|
|
|
|
|
|
|
//Fighting
|
2017-06-26 01:39:17 +02:00
|
|
|
this.hp = 10;
|
|
|
|
this.max_hp = 10;
|
2016-12-01 23:18:18 +01:00
|
|
|
this.strength = 1; //Damage dealt
|
|
|
|
this.defense = 1; //Damage received
|
|
|
|
this.dexterity = 1; //Accuracy
|
|
|
|
this.agility = 1; //Dodge %
|
|
|
|
|
|
|
|
//Labor stats
|
|
|
|
this.charisma = 1;
|
2017-01-11 21:00:51 +01:00
|
|
|
//Intelligence, perhaps?
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
//Hacking multipliers
|
2017-05-05 03:08:44 +02:00
|
|
|
this.hacking_chance_mult = 1; //Increase through ascensions/augmentations
|
|
|
|
this.hacking_speed_mult = 1; //Decrease through ascensions/augmentations
|
|
|
|
this.hacking_money_mult = 1; //Increase through ascensions/augmentations. Can't go above 1
|
2017-05-18 22:00:37 +02:00
|
|
|
this.hacking_grow_mult = 1;
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
|
|
|
|
//Accumulative stats and skills
|
|
|
|
this.total_hacking = 1;
|
|
|
|
this.total_strength = 1;
|
|
|
|
this.total_defense = 1;
|
|
|
|
this.total_dexterity = 1;
|
|
|
|
this.total_agility = 1;
|
|
|
|
this.total_charisma = 1;
|
|
|
|
this.lifetime_hacking = 1;
|
|
|
|
this.lifetime_strength = 1;
|
|
|
|
this.lifetime_defense = 1;
|
|
|
|
this.lifetime_dexterity = 1;
|
|
|
|
this.lifetime_agility = 1;
|
|
|
|
this.lifetime_charisma = 1;
|
|
|
|
|
|
|
|
//Experience and multipliers
|
|
|
|
this.hacking_exp = 0;
|
|
|
|
this.strength_exp = 0;
|
|
|
|
this.defense_exp = 0;
|
|
|
|
this.dexterity_exp = 0;
|
|
|
|
this.agility_exp = 0;
|
|
|
|
this.charisma_exp = 0;
|
|
|
|
|
2017-02-20 23:06:16 +01:00
|
|
|
this.hacking_mult = 1;
|
|
|
|
this.strength_mult = 1;
|
|
|
|
this.defense_mult = 1;
|
|
|
|
this.dexterity_mult = 1;
|
|
|
|
this.agility_mult = 1;
|
|
|
|
this.charisma_mult = 1;
|
|
|
|
|
2016-12-01 23:18:18 +01:00
|
|
|
this.hacking_exp_mult = 1;
|
|
|
|
this.strength_exp_mult = 1;
|
|
|
|
this.defense_exp_mult = 1;
|
|
|
|
this.dexterity_exp_mult = 1;
|
|
|
|
this.agility_exp_mult = 1;
|
|
|
|
this.charisma_exp_mult = 1;
|
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
this.company_rep_mult = 1;
|
|
|
|
this.faction_rep_mult = 1;
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
//Money
|
2017-05-01 19:04:30 +02:00
|
|
|
this.money = 1000;
|
2017-05-03 19:52:54 +02:00
|
|
|
this.total_money = 0; //Total money ever earned in this "simulation"
|
2017-04-13 19:33:34 +02:00
|
|
|
this.lifetime_money = 0; //Total money ever earned
|
2016-12-01 23:18:18 +01:00
|
|
|
|
2016-12-15 18:51:23 +01:00
|
|
|
//IP Address of Starting (home) computer
|
2017-01-11 21:00:51 +01:00
|
|
|
this.homeComputer = "";
|
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Location information
|
2017-02-03 23:05:59 +01:00
|
|
|
this.city = Locations.Sector12;
|
2017-01-11 21:00:51 +01:00
|
|
|
this.location = "";
|
2016-12-01 23:18:18 +01:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Company Information
|
2017-02-06 06:01:01 +01:00
|
|
|
this.companyName = ""; //Name of Company, equivalent to an object from Locations
|
|
|
|
this.companyPosition = ""; //CompanyPosition object
|
2017-01-31 04:41:42 +01:00
|
|
|
|
2016-12-01 23:18:18 +01:00
|
|
|
//Servers
|
2017-05-10 19:42:46 +02:00
|
|
|
this.currentServer = ""; //IP address of Server currently being accessed through terminal
|
|
|
|
this.discoveredServers = []; //IP addresses of secret servers not in the network that you have discovered
|
|
|
|
this.purchasedServers = [];
|
|
|
|
this.hacknetNodes = [];
|
|
|
|
this.totalHacknetNodeProduction = 0;
|
2016-12-01 23:18:18 +01:00
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
//Factions
|
|
|
|
this.factions = []; //Names of all factions player has joined
|
|
|
|
|
2017-02-09 23:40:55 +01:00
|
|
|
//Augmentations
|
2017-06-26 01:39:17 +02:00
|
|
|
this.queuedAugmentations = []; //Purchased but not installed, names only
|
2017-02-17 23:19:25 +01:00
|
|
|
this.augmentations = []; //Names of all installed augmentations
|
2017-02-09 23:40:55 +01:00
|
|
|
|
2017-05-03 19:52:54 +02:00
|
|
|
//Crime statistics (Total refers to this 'simulation'. Lifetime is forever)
|
|
|
|
this.karma = 0;
|
|
|
|
this.numTimesShoplifted = 0;
|
|
|
|
this.numTimesShopliftedTotal = 0;
|
|
|
|
this.numTimesShopliftedLifetime = 0;
|
|
|
|
this.numPeopleMugged = 0;
|
|
|
|
this.numPeopleMuggedTotal = 0;
|
|
|
|
this.numPeopleMuggedLifetime = 0;
|
|
|
|
this.numTimesDealtDrugs = 0;
|
|
|
|
this.numTimesDealtDrugsTotal = 0;
|
|
|
|
this.numTimesDealtDrugsLifetime = 0;
|
|
|
|
this.numTimesTraffickArms = 0;
|
|
|
|
this.numTimesTraffickArmsTotal = 0;
|
2017-05-05 03:08:44 +02:00
|
|
|
this.numTimesTraffickArmsLifetime = 0;
|
2017-05-03 19:52:54 +02:00
|
|
|
this.numPeopleKilled = 0;
|
|
|
|
this.numPeopleKilledTotal = 0;
|
|
|
|
this.numPeopleKilledLifetime = 0;
|
2017-05-08 18:00:34 +02:00
|
|
|
this.numTimesGrandTheftAuto = 0;
|
|
|
|
this.numTimesGrandTheftAutoTotal = 0;
|
|
|
|
this.numTimesGrandTheftAutoLifetime = 0;
|
2017-05-03 19:52:54 +02:00
|
|
|
this.numTimesKidnapped = 0;
|
|
|
|
this.numTimesKidnappedTotal = 0;
|
|
|
|
this.numTimesKidnappedLifetime = 0;
|
2017-05-08 18:00:34 +02:00
|
|
|
this.numTimesHeist = 0;
|
|
|
|
this.numTimesHeistTotal = 0;
|
|
|
|
this.numTimesHeistLifetime = 0;
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-05-12 20:12:32 +02:00
|
|
|
this.crime_money_mult = 1;
|
2017-05-18 22:00:37 +02:00
|
|
|
this.crime_success_mult = 1;
|
2016-12-01 23:18:18 +01:00
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
//Flag to let the engine know the player is starting an action
|
|
|
|
// Current actions: hack, analyze
|
2016-12-01 23:18:18 +01:00
|
|
|
this.startAction = false;
|
|
|
|
this.actionTime = 0;
|
2017-02-06 06:01:01 +01:00
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
//Flags/variables for working (Company, Faction, Creating Program, Taking Class)
|
2017-02-06 06:01:01 +01:00
|
|
|
this.isWorking = false;
|
2017-04-24 21:10:35 +02:00
|
|
|
this.workType = "";
|
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
this.currentWorkFactionName = "";
|
|
|
|
this.currentWorkFactionDescription = "";
|
2017-02-08 01:27:11 +01:00
|
|
|
|
|
|
|
this.workHackExpGainRate = 0;
|
|
|
|
this.workStrExpGainRate = 0;
|
|
|
|
this.workDefExpGainRate = 0;
|
|
|
|
this.workDexExpGainRate = 0;
|
|
|
|
this.workAgiExpGainRate = 0;
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workChaExpGainRate = 0;
|
2017-02-08 01:27:11 +01:00
|
|
|
this.workRepGainRate = 0;
|
|
|
|
this.workMoneyGainRate = 0;
|
2017-04-24 21:10:35 +02:00
|
|
|
this.workMoneyLossRate = 0;
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
this.workHackExpGained = 0;
|
|
|
|
this.workStrExpGained = 0;
|
|
|
|
this.workDefExpGained = 0;
|
|
|
|
this.workDexExpGained = 0;
|
|
|
|
this.workAgiExpGained = 0;
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workChaExpGained = 0;
|
2017-02-06 06:01:01 +01:00
|
|
|
this.workRepGained = 0;
|
|
|
|
this.workMoneyGained = 0;
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
this.createProgramName = "";
|
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
this.className = "";
|
|
|
|
|
2017-05-03 19:52:54 +02:00
|
|
|
this.crimeType = "";
|
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
this.timeWorked = 0; //in ms
|
2017-04-19 23:39:25 +02:00
|
|
|
this.timeNeededToCompleteWork = 0;
|
2017-02-08 01:27:11 +01:00
|
|
|
|
|
|
|
this.work_money_mult = 1;
|
2017-05-02 21:24:24 +02:00
|
|
|
|
|
|
|
//Hacknet Node multipliers
|
|
|
|
this.hacknet_node_money_mult = 1;
|
|
|
|
this.hacknet_node_purchase_cost_mult = 1;
|
|
|
|
this.hacknet_node_ram_cost_mult = 1;
|
|
|
|
this.hacknet_node_core_cost_mult = 1;
|
|
|
|
this.hacknet_node_level_cost_mult = 1;
|
2017-07-03 21:42:11 +02:00
|
|
|
|
|
|
|
//Stock Market
|
|
|
|
this.hasWseAccount = false;
|
|
|
|
this.hasTixApiAccess = false;
|
2016-12-19 21:59:13 +01:00
|
|
|
|
|
|
|
//Used to store the last update time.
|
2017-05-15 21:11:40 +02:00
|
|
|
this.lastUpdate = 0;
|
2017-05-15 16:15:59 +02:00
|
|
|
this.totalPlaytime = 0;
|
2017-06-17 19:47:04 +02:00
|
|
|
this.playtimeSinceLastAug = 0;
|
2016-12-01 23:18:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
PlayerObject.prototype.init = function() {
|
|
|
|
/* Initialize Player's home computer */
|
|
|
|
var t_homeComp = new Server();
|
2017-05-24 07:05:31 +02:00
|
|
|
t_homeComp.init(createRandomIp(), "home", "Home PC", true, true, true, true, 8);
|
2016-12-01 23:18:18 +01:00
|
|
|
this.homeComputer = t_homeComp.ip;
|
|
|
|
this.currentServer = t_homeComp.ip;
|
|
|
|
AddToAllServers(t_homeComp);
|
|
|
|
|
2017-04-13 19:33:34 +02:00
|
|
|
this.getHomeComputer().programs.push(Programs.NukeProgram);
|
2017-05-08 16:33:26 +02:00
|
|
|
}
|
2016-10-14 23:02:06 +02:00
|
|
|
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.getCurrentServer = function() {
|
|
|
|
return AllServers[this.currentServer];
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.getHomeComputer = function() {
|
|
|
|
return AllServers[this.homeComputer];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Calculates skill level based on experience. The same formula will be used for every skill
|
2016-12-19 19:20:19 +01:00
|
|
|
// At the maximum possible exp (MAX_INT = 9007199254740991), the hacking skill will be 1796 TODO REcalculate this
|
|
|
|
// Gets to level 1000 hacking skill at (TODO Determine this)
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.calculateSkill = function(exp) {
|
2017-02-16 19:52:11 +01:00
|
|
|
return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1);
|
2016-12-15 23:22:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.updateSkillLevels = function() {
|
2017-02-20 23:06:16 +01:00
|
|
|
this.hacking_skill = Math.floor(this.calculateSkill(this.hacking_exp) * this.hacking_mult);
|
|
|
|
this.strength = Math.floor(this.calculateSkill(this.strength_exp) * this.strength_mult);
|
|
|
|
this.defense = Math.floor(this.calculateSkill(this.defense_exp) * this.defense_mult);
|
|
|
|
this.dexterity = Math.floor(this.calculateSkill(this.dexterity_exp) * this.dexterity_mult);
|
|
|
|
this.agility = Math.floor(this.calculateSkill(this.agility_exp) * this.agility_mult);
|
|
|
|
this.charisma = Math.floor(this.calculateSkill(this.charisma_exp) * this.charisma_mult);
|
2017-07-03 21:42:11 +02:00
|
|
|
|
|
|
|
var ratio = this.hp / this.max_hp;
|
|
|
|
this.max_hp = Math.floor(10 + this.defense / 10);
|
|
|
|
Player.hp = Math.round(this.max_hp * ratio);
|
2016-12-15 23:22:42 +01:00
|
|
|
}
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
//Calculates the chance of hacking a server
|
|
|
|
//The formula is:
|
2017-05-17 15:55:59 +02:00
|
|
|
// (2 * hacking_chance_multiplier * hacking_skill - requiredLevel) 100 - difficulty
|
2016-12-01 23:18:18 +01:00
|
|
|
// ----------------------------------------------------------- * -----------------
|
2017-06-13 07:34:45 +02:00
|
|
|
// (2 * hacking_chance_multiplier * hacking_skill) 100
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.calculateHackingChance = function() {
|
|
|
|
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
2017-05-05 03:08:44 +02:00
|
|
|
var skillMult = (2 * this.hacking_chance_mult * this.hacking_skill);
|
2016-12-01 23:18:18 +01:00
|
|
|
var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult;
|
2017-04-17 14:26:54 +02:00
|
|
|
var chance = skillChance * difficultyMult;
|
2017-05-17 15:55:59 +02:00
|
|
|
if (chance > 1) {return 1;}
|
2017-04-17 14:26:54 +02:00
|
|
|
if (chance < 0) {return 0;}
|
2017-05-20 09:33:33 +02:00
|
|
|
return chance;
|
2016-12-15 23:22:42 +01:00
|
|
|
}
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
//Calculate the time it takes to hack a server in seconds. Returns the time
|
|
|
|
//The formula is:
|
2017-05-03 06:38:58 +02:00
|
|
|
// (2.5 * requiredLevel * difficulty + 200)
|
2017-05-02 18:28:54 +02:00
|
|
|
// ----------------------------------- * hacking_speed_multiplier
|
|
|
|
// hacking_skill + 100
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.calculateHackingTime = function() {
|
|
|
|
var difficultyMult = this.getCurrentServer().requiredHackingSkill * this.getCurrentServer().hackDifficulty;
|
2017-05-03 06:38:58 +02:00
|
|
|
var skillFactor = (2.5 * difficultyMult + 200) / (this.hacking_skill + 100);
|
2017-06-18 06:36:16 +02:00
|
|
|
return 5 * skillFactor / this.hacking_speed_mult;
|
2016-12-01 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Calculates the PERCENTAGE of a server's money that the player will hack from the server if successful
|
|
|
|
//The formula is:
|
|
|
|
// (hacking_skill - (requiredLevel-1)) 100 - difficulty
|
|
|
|
// --------------------------------------* ----------------------- * hacking_money_multiplier
|
|
|
|
// hacking_skill 100
|
|
|
|
PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
|
|
|
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
|
|
|
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
|
2017-07-03 21:42:11 +02:00
|
|
|
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 225;
|
2016-12-01 23:18:18 +01:00
|
|
|
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
2017-04-18 06:32:17 +02:00
|
|
|
if (percentMoneyHacked < 0) {return 0;}
|
|
|
|
if (percentMoneyHacked > 1) {return 1;}
|
2016-12-01 23:18:18 +01:00
|
|
|
return percentMoneyHacked;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Returns how much EXP the player gains on a successful hack
|
|
|
|
//The formula is:
|
|
|
|
// difficulty * requiredLevel * hacking_multiplier
|
|
|
|
PlayerObject.prototype.calculateExpGain = function() {
|
2017-06-15 03:19:52 +02:00
|
|
|
var s = this.getCurrentServer();
|
|
|
|
if (s.baseDifficulty == null) {
|
|
|
|
s.baseDifficulty = s.hackDifficulty;
|
|
|
|
}
|
2017-07-03 21:42:11 +02:00
|
|
|
return (s.baseDifficulty * this.hacking_exp_mult * 0.4 + 2);
|
2016-12-01 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//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
|
|
|
|
//This assumes that the server being hacked is not purchased by the player, that the player's hacking skill is greater than the
|
|
|
|
//required hacking skill and that the player has admin rights.
|
|
|
|
PlayerObject.prototype.hack = function() {
|
|
|
|
this.actionTime = this.calculateHackingTime();
|
|
|
|
console.log("Hacking time: " + this.actionTime);
|
2017-05-11 06:20:17 +02:00
|
|
|
this.startAction = true; //Set the startAction flag so the engine starts the hacking process
|
2016-12-01 23:18:18 +01:00
|
|
|
}
|
2016-12-15 23:22:42 +01:00
|
|
|
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.analyze = function() {
|
2017-04-24 03:43:41 +02:00
|
|
|
this.actionTime = 1;
|
2016-12-01 23:18:18 +01:00
|
|
|
this.startAction = true;
|
2017-05-11 06:20:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.hasProgram = function(programName) {
|
|
|
|
var home = Player.getHomeComputer();
|
|
|
|
for (var i = 0; i < home.programs.length; ++i) {
|
2017-06-05 17:31:46 +02:00
|
|
|
if (programName.toLowerCase() == home.programs[i].toLowerCase()) {return true;}
|
2017-05-11 06:20:17 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-01 23:18:18 +01:00
|
|
|
|
2016-12-19 21:59:13 +01:00
|
|
|
PlayerObject.prototype.gainMoney = function(money) {
|
2017-04-18 06:32:17 +02:00
|
|
|
if (isNaN(money)) {
|
|
|
|
console.log("ERR: NaN passed into Player.gainMoney()"); return;
|
|
|
|
}
|
2016-12-19 21:59:13 +01:00
|
|
|
this.money += money;
|
|
|
|
this.total_money += money;
|
|
|
|
this.lifetime_money += money;
|
|
|
|
}
|
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
PlayerObject.prototype.loseMoney = function(money) {
|
|
|
|
if (isNaN(money)) {
|
|
|
|
console.log("ERR: NaN passed into Player.loseMoney()"); return;
|
|
|
|
}
|
|
|
|
this.money -= money;
|
|
|
|
}
|
|
|
|
|
2017-04-18 06:32:17 +02:00
|
|
|
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;
|
2017-05-03 19:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******* Working functions *******/
|
|
|
|
PlayerObject.prototype.resetWorkStatus = function() {
|
|
|
|
this.workHackExpGainRate = 0;
|
|
|
|
this.workStrExpGainRate = 0;
|
|
|
|
this.workDefExpGainRate = 0;
|
|
|
|
this.workDexExpGainRate = 0;
|
|
|
|
this.workAgiExpGainRate = 0;
|
|
|
|
this.workChaExpGainRate = 0;
|
|
|
|
this.workRepGainRate = 0;
|
|
|
|
this.workMoneyGainRate = 0;
|
|
|
|
|
|
|
|
this.workHackExpGained = 0;
|
|
|
|
this.workStrExpGained = 0;
|
|
|
|
this.workDefExpGained = 0;
|
|
|
|
this.workDexExpGained = 0;
|
|
|
|
this.workAgiExpGained = 0;
|
|
|
|
this.workChaExpGained = 0;
|
|
|
|
this.workRepGained = 0;
|
|
|
|
this.workMoneyGained = 0;
|
|
|
|
|
|
|
|
this.timeWorked = 0;
|
|
|
|
|
|
|
|
this.currentWorkFactionName = "";
|
|
|
|
this.currentWorkFactionDescription = "";
|
|
|
|
this.createProgramName = "";
|
|
|
|
this.className = "";
|
2017-05-21 23:04:57 +02:00
|
|
|
|
|
|
|
document.getElementById("work-in-progress-text").innerHTML = "";
|
2017-05-03 19:52:54 +02:00
|
|
|
}
|
|
|
|
|
2017-05-31 17:58:09 +02:00
|
|
|
PlayerObject.prototype.gainWorkExp = function() {
|
|
|
|
this.gainHackingExp(this.workHackExpGained);
|
|
|
|
this.gainStrengthExp(this.workStrExpGained);
|
|
|
|
this.gainDefenseExp(this.workDefExpGained);
|
|
|
|
this.gainDexterityExp(this.workDexExpGained);
|
|
|
|
this.gainAgilityExp(this.workAgiExpGained);
|
|
|
|
this.gainCharismaExp(this.workChaExpGained);
|
2017-04-18 06:32:17 +02:00
|
|
|
}
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
/* Working for Company */
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.finishWork = function(cancelled) {
|
|
|
|
//Since the work was cancelled early, player only gains half of what they've earned so far
|
2017-05-31 17:58:09 +02:00
|
|
|
if (cancelled) {
|
|
|
|
this.workRepGained /= 2;
|
2017-02-16 19:52:11 +01:00
|
|
|
}
|
2017-05-03 19:52:54 +02:00
|
|
|
|
2017-05-31 17:58:09 +02:00
|
|
|
this.gainWorkExp();
|
2017-02-08 01:27:11 +01:00
|
|
|
|
|
|
|
var company = Companies[this.companyName];
|
2017-05-31 17:58:09 +02:00
|
|
|
company.playerReputation += (this.workRepGained);
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-05-31 17:58:09 +02:00
|
|
|
this.gainMoney(this.workMoneyGained);
|
2017-02-08 01:27:11 +01:00
|
|
|
|
|
|
|
this.updateSkillLevels();
|
|
|
|
|
2017-05-10 19:42:46 +02:00
|
|
|
var txt = "You earned a total of: <br>" +
|
2017-05-31 17:58:09 +02:00
|
|
|
"$" + 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>";
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-05-10 19:42:46 +02:00
|
|
|
if (cancelled) {
|
|
|
|
txt = "You worked a short shift of " + convertTimeMsToTimeElapsedString(this.timeWorked) + " <br><br> " +
|
2017-05-31 17:58:09 +02:00
|
|
|
"Since you cancelled your work early, you only gained half of the reputation you earned. <br><br>" + txt;
|
2017-02-08 01:27:11 +01:00
|
|
|
} else {
|
2017-02-16 19:52:11 +01:00
|
|
|
txt = "You worked a full shift of 8 hours! <br><br> " +
|
2017-05-10 19:42:46 +02:00
|
|
|
"You earned a total of: <br>" + txt;
|
2017-02-08 01:27:11 +01:00
|
|
|
}
|
|
|
|
dialogBoxCreate(txt);
|
2017-02-08 05:48:50 +01:00
|
|
|
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
2017-03-31 14:32:04 +02:00
|
|
|
this.isWorking = false;
|
2017-02-08 05:48:50 +01:00
|
|
|
Engine.loadTerminalContent();
|
2017-02-08 01:27:11 +01:00
|
|
|
}
|
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
PlayerObject.prototype.startWork = function() {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
2017-02-06 06:01:01 +01:00
|
|
|
this.isWorking = true;
|
2017-04-24 21:10:35 +02:00
|
|
|
this.workType = CONSTANTS.WorkTypeCompany;
|
2017-02-08 01:27:11 +01:00
|
|
|
|
|
|
|
this.workHackExpGainRate = this.getWorkHackExpGain();
|
|
|
|
this.workStrExpGainRate = this.getWorkStrExpGain();
|
|
|
|
this.workDefExpGainRate = this.getWorkDefExpGain();
|
|
|
|
this.workDexExpGainRate = this.getWorkDexExpGain();
|
|
|
|
this.workAgiExpGainRate = this.getWorkAgiExpGain();
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workChaExpGainRate = this.getWorkChaExpGain();
|
2017-02-08 01:27:11 +01:00
|
|
|
this.workRepGainRate = this.getWorkRepGain();
|
|
|
|
this.workMoneyGainRate = this.getWorkMoneyGain();
|
|
|
|
|
2017-04-19 23:39:25 +02:00
|
|
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
//Remove all old event listeners from Cancel button
|
2017-05-10 19:42:46 +02:00
|
|
|
var newCancelButton = clearEventListeners("work-in-progress-cancel-button");
|
2017-05-16 05:06:25 +02:00
|
|
|
newCancelButton.innerHTML = "Cancel Work";
|
2017-02-16 19:52:11 +01:00
|
|
|
newCancelButton.addEventListener("click", function() {
|
2017-02-08 05:48:50 +01:00
|
|
|
Player.finishWork(true);
|
2017-02-16 19:52:11 +01:00
|
|
|
return false;
|
2017-02-08 01:27:11 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.work = function(numCycles) {
|
2017-04-20 10:29:07 +02:00
|
|
|
this.workRepGainRate = this.getWorkRepGain();
|
|
|
|
|
2017-02-08 01:27:11 +01:00
|
|
|
this.workHackExpGained += this.workHackExpGainRate * numCycles;
|
|
|
|
this.workStrExpGained += this.workStrExpGainRate * numCycles;
|
|
|
|
this.workDefExpGained += this.workDefExpGainRate * numCycles;
|
|
|
|
this.workDexExpGained += this.workDexExpGainRate * numCycles;
|
|
|
|
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workChaExpGained += this.workChaExpGainRate * numCycles;
|
2017-02-08 01:27:11 +01:00
|
|
|
this.workRepGained += this.workRepGainRate * numCycles;
|
|
|
|
this.workMoneyGained += this.workMoneyGainRate * numCycles;
|
|
|
|
|
|
|
|
var cyclesPerSec = 1000 / Engine._idleSpeed;
|
|
|
|
|
|
|
|
this.timeWorked += Engine._idleSpeed * numCycles;
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
|
2017-04-18 06:32:17 +02:00
|
|
|
if (this.timeWorked >= CONSTANTS.MillisecondsPer8Hours) {
|
2017-04-19 23:39:25 +02:00
|
|
|
var maxCycles = CONSTANTS.GameCyclesPer8Hours;
|
2017-04-19 07:02:40 +02:00
|
|
|
this.workHackExpGained = this.workHackExpGainRate * maxCycles;
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
|
|
|
|
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
|
|
|
|
this.workDexExpGained = this.workDexExpGainRate * maxCycles;
|
|
|
|
this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
|
|
|
|
this.workChaExpGained = this.workChaExpGainRate * maxCycles;
|
|
|
|
this.workRepGained = this.workRepGainRate * maxCycles;
|
|
|
|
this.workMoneyGained = this.workMoneyGainRate * maxCycles;
|
2017-02-08 01:27:11 +01:00
|
|
|
this.finishWork(false);
|
2017-05-10 19:42:46 +02:00
|
|
|
return;
|
2017-02-08 01:27:11 +01:00
|
|
|
}
|
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
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>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
|
|
|
|
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this company <br><br>" +
|
|
|
|
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br><br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br><br> " +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br><br>" +
|
2017-05-31 17:58:09 +02:00
|
|
|
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, " +
|
|
|
|
"but you will only gain half of the reputation you've earned so far."
|
2017-02-08 01:27:11 +01:00
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
2017-05-10 19:42:46 +02:00
|
|
|
PlayerObject.prototype.startWorkPartTime = function() {
|
|
|
|
this.resetWorkStatus();
|
|
|
|
this.isWorking = true;
|
|
|
|
this.workType = CONSTANTS.WorkTypeCompanyPartTime;
|
|
|
|
|
|
|
|
this.workHackExpGainRate = this.getWorkHackExpGain();
|
|
|
|
this.workStrExpGainRate = this.getWorkStrExpGain();
|
|
|
|
this.workDefExpGainRate = this.getWorkDefExpGain();
|
|
|
|
this.workDexExpGainRate = this.getWorkDexExpGain();
|
|
|
|
this.workAgiExpGainRate = this.getWorkAgiExpGain();
|
|
|
|
this.workChaExpGainRate = this.getWorkChaExpGain();
|
|
|
|
this.workRepGainRate = this.getWorkRepGain();
|
|
|
|
this.workMoneyGainRate = this.getWorkMoneyGain();
|
|
|
|
|
|
|
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer8Hours;
|
|
|
|
|
|
|
|
var newCancelButton = clearEventListeners("work-in-progress-cancel-button");
|
2017-05-16 05:06:25 +02:00
|
|
|
newCancelButton.innerHTML = "Stop Working";
|
2017-05-10 19:42:46 +02:00
|
|
|
newCancelButton.addEventListener("click", function() {
|
|
|
|
Player.finishWorkPartTime();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.workPartTime = function(numCycles) {
|
|
|
|
this.workRepGainRate = this.getWorkRepGain();
|
|
|
|
|
|
|
|
this.workHackExpGained += this.workHackExpGainRate * numCycles;
|
|
|
|
this.workStrExpGained += this.workStrExpGainRate * numCycles;
|
|
|
|
this.workDefExpGained += this.workDefExpGainRate * numCycles;
|
|
|
|
this.workDexExpGained += this.workDexExpGainRate * numCycles;
|
|
|
|
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
|
|
|
|
this.workChaExpGained += this.workChaExpGainRate * numCycles;
|
|
|
|
this.workRepGained += this.workRepGainRate * numCycles;
|
|
|
|
this.workMoneyGained += this.workMoneyGainRate * numCycles;
|
|
|
|
|
|
|
|
var cyclesPerSec = 1000 / Engine._idleSpeed;
|
|
|
|
|
|
|
|
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 >= CONSTANTS.MillisecondsPer8Hours) {
|
|
|
|
var maxCycles = CONSTANTS.GameCyclesPer8Hours;
|
|
|
|
this.workHackExpGained = this.workHackExpGainRate * maxCycles;
|
|
|
|
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
|
|
|
|
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
|
|
|
|
this.workDexExpGained = this.workDexExpGainRate * maxCycles;
|
|
|
|
this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
|
|
|
|
this.workChaExpGained = this.workChaExpGainRate * maxCycles;
|
|
|
|
this.workRepGained = this.workRepGainRate * maxCycles;
|
|
|
|
this.workMoneyGained = this.workMoneyGainRate * maxCycles;
|
|
|
|
this.finishWorkPartTime();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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>" +
|
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
|
|
|
|
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this company <br><br>" +
|
|
|
|
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br><br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br><br> " +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br><br>" +
|
|
|
|
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, <br>" +
|
|
|
|
"and there will be no penalty because this is a part-time job.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.finishWorkPartTime = function() {
|
2017-05-10 22:21:15 +02:00
|
|
|
this.gainWorkExp();
|
2017-05-10 19:42:46 +02:00
|
|
|
|
|
|
|
var company = Companies[this.companyName];
|
2017-05-10 22:21:15 +02:00
|
|
|
company.playerReputation += (this.workRepGained);
|
2017-05-10 19:42:46 +02:00
|
|
|
|
2017-05-10 22:21:15 +02:00
|
|
|
this.gainMoney(this.workMoneyGained);
|
2017-05-10 19:42:46 +02:00
|
|
|
|
|
|
|
this.updateSkillLevels();
|
|
|
|
|
|
|
|
var txt = "You earned a total of: <br>" +
|
2017-05-10 22:21:15 +02:00
|
|
|
"$" + 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>";
|
2017-05-15 19:49:49 +02:00
|
|
|
txt = "You worked for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br> " + txt;
|
2017-05-10 19:42:46 +02:00
|
|
|
dialogBoxCreate(txt);
|
|
|
|
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
|
|
|
this.isWorking = false;
|
|
|
|
Engine.loadTerminalContent();
|
|
|
|
}
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
/* Working for Faction */
|
2017-02-17 23:19:25 +01:00
|
|
|
PlayerObject.prototype.finishFactionWork = function(cancelled, faction) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.gainWorkExp();
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
var faction = Factions[this.currentWorkFactionName];
|
|
|
|
faction.playerReputation += (this.workRepGained);
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-02-20 23:06:16 +01:00
|
|
|
this.gainMoney(this.workMoneyGained);
|
2017-02-16 19:52:11 +01:00
|
|
|
|
|
|
|
this.updateSkillLevels();
|
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
var txt = "You worked for your faction " + faction.name + " for a total of " + convertTimeMsToTimeElapsedString(this.timeWorked) + " <br><br> " +
|
2017-02-16 19:52:11 +01:00
|
|
|
"You earned a total of: <br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + "<br>" +
|
|
|
|
formatNumber(this.workRepGained, 4) + " reputation for the faction <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>";
|
2017-02-16 19:52:11 +01:00
|
|
|
dialogBoxCreate(txt);
|
|
|
|
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
|
|
|
|
2017-04-22 00:22:25 +02:00
|
|
|
this.isWorking = false;
|
2017-02-16 19:52:11 +01:00
|
|
|
|
|
|
|
Engine.loadTerminalContent();
|
|
|
|
}
|
|
|
|
|
2017-02-27 23:14:11 +01:00
|
|
|
PlayerObject.prototype.startFactionWork = function(faction) {
|
2017-06-20 18:11:33 +02:00
|
|
|
//Update reputation gain rate to account for faction favor
|
|
|
|
var favorMult = 1 + (faction.favor / 100);
|
|
|
|
if (isNaN(favorMult)) {favorMult = 1;}
|
|
|
|
this.workRepGainRate *= favorMult;
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
this.isWorking = true;
|
2017-04-24 21:10:35 +02:00
|
|
|
this.workType = CONSTANTS.WorkTypeFaction;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.currentWorkFactionName = faction.name;
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-04-19 23:39:25 +02:00
|
|
|
this.timeNeededToCompleteWork = CONSTANTS.MillisecondsPer20Hours;
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-05-16 05:06:25 +02:00
|
|
|
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
|
|
|
|
cancelButton.innerHTML = "Stop Faction Work";
|
|
|
|
cancelButton.addEventListener("click", function() {
|
2017-02-17 23:19:25 +01:00
|
|
|
Player.finishFactionWork(true, faction);
|
2017-02-16 19:52:11 +01:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
2017-02-17 23:19:25 +01:00
|
|
|
|
|
|
|
PlayerObject.prototype.startFactionHackWork = function(faction) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
|
|
|
|
2017-06-20 18:11:33 +02:00
|
|
|
this.workHackExpGainRate = .15 * this.hacking_exp_mult;
|
|
|
|
this.workRepGainRate = 0.9 * this.hacking_skill / CONSTANTS.MaxSkillLevel * this.faction_rep_mult;
|
2017-02-17 23:19:25 +01:00
|
|
|
|
2017-04-20 10:29:07 +02:00
|
|
|
this.factionWorkType = CONSTANTS.FactionWorkHacking;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.currentWorkFactionDescription = "carrying out hacking contracts";
|
|
|
|
|
|
|
|
this.startFactionWork(faction);
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.startFactionFieldWork = function(faction) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
|
|
|
|
2017-05-11 06:20:17 +02:00
|
|
|
this.workHackExpGainRate = .1 * this.hacking_exp_mult;
|
|
|
|
this.workStrExpGainRate = .1 * this.strength_exp_mult;
|
|
|
|
this.workDefExpGainRate = .1 * this.defense_exp_mult;
|
|
|
|
this.workDexExpGainRate = .1 * this.dexterity_exp_mult;
|
|
|
|
this.workAgiExpGainRate = .1 * this.agility_exp_mult;
|
|
|
|
this.workChaExpGainRate = .1 * this.charisma_exp_mult;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.workRepGainRate = this.getFactionFieldWorkRepGain();
|
|
|
|
|
2017-06-23 16:23:35 +02:00
|
|
|
this.factionWorkType = CONSTANTS.FactionWorkField;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.currentWorkFactionDescription = "carrying out field missions"
|
|
|
|
|
|
|
|
this.startFactionWork(faction);
|
|
|
|
}
|
|
|
|
|
2017-02-27 23:14:11 +01:00
|
|
|
PlayerObject.prototype.startFactionSecurityWork = function(faction) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
|
|
|
|
2017-05-11 06:20:17 +02:00
|
|
|
this.workHackExpGainRate = 0.05 * this.hacking_exp_mult;
|
|
|
|
this.workStrExpGainRate = 0.15 * this.strength_exp_mult;
|
|
|
|
this.workDefExpGainRate = 0.15 * this.defense_exp_mult;
|
|
|
|
this.workDexExpGainRate = 0.15 * this.dexterity_exp_mult;
|
|
|
|
this.workAgiExpGainRate = 0.15 * this.agility_exp_mult;
|
|
|
|
this.workChaExpGainRate = 0.00 * this.charisma_exp_mult;
|
2017-04-20 10:29:07 +02:00
|
|
|
this.workRepGainRate = this.getFactionSecurityWorkRepGain();
|
2017-02-17 23:19:25 +01:00
|
|
|
|
2017-04-20 10:29:07 +02:00
|
|
|
this.factionWorkType = CONSTANTS.FactionWorkSecurity;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.currentWorkFactionDescription = "performing security detail"
|
|
|
|
|
|
|
|
this.startFactionWork(faction);
|
|
|
|
}
|
2017-02-16 19:52:11 +01:00
|
|
|
|
|
|
|
PlayerObject.prototype.workForFaction = function(numCycles) {
|
2017-02-17 23:19:25 +01:00
|
|
|
var faction = Factions[this.currentWorkFactionName];
|
|
|
|
|
2017-04-20 10:29:07 +02:00
|
|
|
//Constantly update the rep gain rate
|
|
|
|
switch (this.factionWorkType) {
|
|
|
|
case CONSTANTS.FactionWorkHacking:
|
|
|
|
this.workRepGainRate = this.hacking_skill / CONSTANTS.MaxSkillLevel * this.faction_rep_mult;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.FactionWorkField:
|
|
|
|
this.workRepGainRate = this.getFactionFieldWorkRepGain();
|
|
|
|
break;
|
|
|
|
case CONSTANTS.FactionWorkSecurity:
|
|
|
|
this.workRepGainRate = this.getFactionSecurityWorkRepGain();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-06-20 18:11:33 +02:00
|
|
|
//Update reputation gain rate to account for faction favor
|
|
|
|
var favorMult = 1 + (faction.favor / 100);
|
|
|
|
if (isNaN(favorMult)) {favorMult = 1;}
|
|
|
|
this.workRepGainRate *= favorMult;
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workHackExpGained += this.workHackExpGainRate * numCycles;
|
|
|
|
this.workStrExpGained += this.workStrExpGainRate * numCycles;
|
|
|
|
this.workDefExpGained += this.workDefExpGainRate * numCycles;
|
|
|
|
this.workDexExpGained += this.workDexExpGainRate * numCycles;
|
|
|
|
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
|
|
|
|
this.workChaExpGained += this.workChaExpGainRate * numCycles;
|
|
|
|
this.workRepGained += this.workRepGainRate * numCycles;
|
|
|
|
this.workMoneyGained += this.workMoneyGainRate * numCycles;
|
|
|
|
|
|
|
|
var cyclesPerSec = 1000 / Engine._idleSpeed;
|
|
|
|
|
|
|
|
this.timeWorked += Engine._idleSpeed * numCycles;
|
|
|
|
|
2017-02-17 23:19:25 +01:00
|
|
|
//If timeWorked == 20 hours, then finish. You can only work for the faction for 20 hours
|
2017-04-18 06:32:17 +02:00
|
|
|
if (this.timeWorked >= CONSTANTS.MillisecondsPer20Hours) {
|
2017-04-19 23:39:25 +02:00
|
|
|
var maxCycles = CONSTANTS.GameCyclesPer20Hours;
|
2017-04-19 07:02:40 +02:00
|
|
|
this.workHackExpGained = this.workHackExpGainRate * maxCycles;
|
2017-02-16 19:52:11 +01:00
|
|
|
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
|
|
|
|
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
|
|
|
|
this.workDexExpGained = this.workDexExpGainRate * maxCycles;
|
|
|
|
this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
|
|
|
|
this.workChaExpGained = this.workChaExpGainRate * maxCycles;
|
|
|
|
this.workRepGained = this.workRepGainRate * maxCycles;
|
|
|
|
this.workMoneyGained = this.workMoneyGainRate * maxCycles;
|
2017-02-17 23:19:25 +01:00
|
|
|
this.finishFactionWork(false, faction);
|
2017-02-16 19:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var txt = document.getElementById("work-in-progress-text");
|
2017-02-17 23:19:25 +01:00
|
|
|
txt.innerHTML = "You are currently " + this.currentWorkFactionDescription + " for your faction " + faction.name + "." +
|
2017-05-07 00:19:18 +02:00
|
|
|
" You have been doing this for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
2017-02-16 19:52:11 +01:00
|
|
|
"You have earned: <br><br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + " (" + formatNumber(this.workMoneyGainRate * cyclesPerSec, 2) + " / sec) <br><br>" +
|
|
|
|
formatNumber(this.workRepGained, 4) + " (" + formatNumber(this.workRepGainRate * cyclesPerSec, 4) + " / sec) reputation for this faction <br><br>" +
|
|
|
|
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br><br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br><br> " +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br><br>" +
|
2017-02-16 19:52:11 +01:00
|
|
|
|
2017-04-19 23:39:25 +02:00
|
|
|
"You will automatically finish after working for 20 hours. You can cancel earlier if you wish.<br>" +
|
|
|
|
"There is no penalty for cancelling earlier.";
|
2017-02-16 19:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
//Money gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkMoneyGain = function() {
|
2017-02-06 06:01:01 +01:00
|
|
|
var company = Companies[this.companyName];
|
2017-02-08 01:27:11 +01:00
|
|
|
return this.companyPosition.baseSalary * company.salaryMultiplier * this.work_money_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Hack exp gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkHackExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
|
|
|
return this.companyPosition.hackingExpGain * company.expMultiplier * this.hacking_exp_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Str exp gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkStrExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
2017-02-08 05:48:50 +01:00
|
|
|
return this.companyPosition.strengthExpGain * company.expMultiplier * this.strength_exp_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Def exp gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkDefExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
2017-02-08 05:48:50 +01:00
|
|
|
return this.companyPosition.defenseExpGain * company.expMultiplier * this.defense_exp_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Dex exp gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkDexExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
2017-02-08 05:48:50 +01:00
|
|
|
return this.companyPosition.dexterityExpGain * company.expMultiplier * this.dexterity_exp_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Agi exp gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkAgiExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
2017-02-08 05:48:50 +01:00
|
|
|
return this.companyPosition.agilityExpGain * company.expMultiplier * this.agility_exp_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
//Charisma exp gained per game cycle
|
|
|
|
PlayerObject.prototype.getWorkChaExpGain = function() {
|
|
|
|
var company = Companies[this.companyName];
|
|
|
|
return this.companyPosition.charismaExpGain * company.expMultiplier * this.charisma_exp_mult;
|
|
|
|
}
|
|
|
|
|
2017-02-06 06:01:01 +01:00
|
|
|
//Reputation gained per game cycle
|
2017-02-08 01:27:11 +01:00
|
|
|
PlayerObject.prototype.getWorkRepGain = function() {
|
2017-06-20 18:11:33 +02:00
|
|
|
var company = Companies[this.companyName];
|
2017-02-17 23:19:25 +01:00
|
|
|
var jobPerformance = this.companyPosition.calculateJobPerformance(this.hacking_skill, this.strength,
|
|
|
|
this.defense, this.dexterity,
|
2017-06-20 18:11:33 +02:00
|
|
|
this.agility, this.charisma);
|
|
|
|
//Update reputation gain rate to account for company favor
|
|
|
|
var favorMult = 1 + (company.favor / 100);
|
|
|
|
if (isNaN(favorMult)) {favorMult = 1;}
|
|
|
|
return jobPerformance * this.company_rep_mult * favorMult;
|
2017-02-17 23:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.getFactionSecurityWorkRepGain = function() {
|
2017-06-20 18:11:33 +02:00
|
|
|
var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.strength / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.defense / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.dexterity / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.agility / CONSTANTS.MaxSkillLevel) / 5;
|
2017-02-17 23:19:25 +01:00
|
|
|
return t * this.faction_rep_mult;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.getFactionFieldWorkRepGain = function() {
|
2017-06-20 18:11:33 +02:00
|
|
|
var t = 0.9 * (this.hacking_skill / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.strength / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.defense / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.dexterity / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.agility / CONSTANTS.MaxSkillLevel +
|
|
|
|
this.charisma / CONSTANTS.MaxSkillLevel) / 6;
|
2017-02-17 23:19:25 +01:00
|
|
|
return t * this.faction_rep_mult;
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
|
|
|
|
2017-03-31 14:32:04 +02:00
|
|
|
/* Creating a Program */
|
2017-05-17 16:23:47 +02:00
|
|
|
PlayerObject.prototype.startCreateProgramWork = function(programName, time, reqLevel) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
2017-03-31 14:32:04 +02:00
|
|
|
this.isWorking = true;
|
2017-04-24 21:10:35 +02:00
|
|
|
this.workType = CONSTANTS.WorkTypeCreateProgram;
|
2017-03-31 14:32:04 +02:00
|
|
|
|
2017-05-17 16:23:47 +02:00
|
|
|
//Time needed to complete work affected by hacking skill (linearly based on
|
|
|
|
//ratio of (your skill - required level) to MAX skill)
|
|
|
|
var timeMultiplier = (CONSTANTS.MaxSkillLevel - (this.hacking_skill - reqLevel)) / CONSTANTS.MaxSkillLevel;
|
|
|
|
if (timeMultiplier > 1) {timeMultiplier = 1;}
|
|
|
|
if (timeMultiplier < 0.01) {timeMultiplier = 0.01;}
|
2017-06-23 16:23:35 +02:00
|
|
|
|
2017-05-21 07:39:18 +02:00
|
|
|
this.timeNeededToCompleteWork = timeMultiplier * time;
|
2017-06-23 16:23:35 +02:00
|
|
|
//Check for incomplete program
|
|
|
|
for (var i = 0; i < Player.getHomeComputer().programs.length; ++i) {
|
|
|
|
var programFile = Player.getHomeComputer().programs[i];
|
|
|
|
if (programFile.startsWith(programName) && programFile.endsWith("%-INC")) {
|
|
|
|
var res = programFile.split("-");
|
|
|
|
if (res.length != 3) {break;}
|
|
|
|
var percComplete = Number(res[1].slice(0, -1));
|
2017-06-24 23:33:44 +02:00
|
|
|
if (isNaN(percComplete) || percComplete < 0 || percComplete >= 100) {break;}
|
2017-06-23 16:23:35 +02:00
|
|
|
this.timeWorked = percComplete / 100 * this.timeNeededToCompleteWork;
|
|
|
|
Player.getHomeComputer().programs.splice(i, 1);
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 14:32:04 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
this.createProgramName = programName;
|
|
|
|
|
2017-05-16 05:06:25 +02:00
|
|
|
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
|
|
|
|
cancelButton.innerHTML = "Cancel work on creating program";
|
|
|
|
cancelButton.addEventListener("click", function() {
|
2017-03-31 23:47:06 +02:00
|
|
|
Player.finishCreateProgramWork(true, programName);
|
2017-03-31 14:32:04 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
PlayerObject.prototype.createProgramWork = function(numCycles) {
|
|
|
|
this.timeWorked += Engine._idleSpeed * numCycles;
|
|
|
|
var programName = this.createProgramName;
|
|
|
|
|
2017-04-19 23:39:25 +02:00
|
|
|
if (this.timeWorked >= this.timeNeededToCompleteWork) {
|
2017-03-31 23:47:06 +02:00
|
|
|
this.finishCreateProgramWork(false, programName);
|
|
|
|
}
|
2017-03-31 14:32:04 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
var txt = document.getElementById("work-in-progress-text");
|
|
|
|
txt.innerHTML = "You are currently working on coding " + programName + ".<br><br> " +
|
|
|
|
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
2017-04-19 23:39:25 +02:00
|
|
|
"The program is " + (this.timeWorked / this.timeNeededToCompleteWork * 100).toFixed(2) + "% complete. <br>" +
|
2017-06-23 16:23:35 +02:00
|
|
|
"If you cancel, your work will be saved and you can come back to complete the program later.";
|
2017-03-31 14:32:04 +02:00
|
|
|
}
|
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
PlayerObject.prototype.finishCreateProgramWork = function(cancelled, programName) {
|
|
|
|
if (cancelled == false) {
|
|
|
|
dialogBoxCreate("You've finished creating " + programName + "!<br>" +
|
|
|
|
"The new program can be found on your home computer.");
|
|
|
|
|
|
|
|
Player.getHomeComputer().programs.push(programName);
|
2017-06-23 16:23:35 +02:00
|
|
|
} else {
|
|
|
|
var perc = Math.floor(this.timeWorked / this.timeNeededToCompleteWork * 100).toString();
|
|
|
|
var incompleteName = programName + "-" + perc + "%-INC";
|
|
|
|
Player.getHomeComputer().programs.push(incompleteName);
|
2017-03-31 23:47:06 +02:00
|
|
|
}
|
2017-03-31 14:32:04 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
|
|
|
|
|
|
|
Player.isWorking = false;
|
|
|
|
|
|
|
|
Engine.loadTerminalContent();
|
2017-03-31 14:32:04 +02:00
|
|
|
}
|
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
/* Studying/Taking Classes */
|
|
|
|
PlayerObject.prototype.startClass = function(costMult, expMult, className) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.resetWorkStatus();
|
2017-04-24 21:10:35 +02:00
|
|
|
this.isWorking = true;
|
|
|
|
this.workType = CONSTANTS.WorkTypeStudyClass;
|
|
|
|
|
|
|
|
this.className = className;
|
|
|
|
|
|
|
|
var gameCPS = 1000 / Engine._idleSpeed;
|
2017-05-08 16:33:26 +02:00
|
|
|
|
2017-05-10 23:21:45 +02:00
|
|
|
//Base exp gains per second
|
2017-07-04 21:34:17 +02:00
|
|
|
var baseStudyComputerScienceExp = 0.3;
|
|
|
|
var baseDataStructuresExp = 0.6;
|
|
|
|
var baseNetworksExp = 1.2;
|
|
|
|
var baseAlgorithmsExp = 2.4;
|
2017-05-08 16:33:26 +02:00
|
|
|
var baseManagementExp = 1.0;
|
|
|
|
var baseLeadershipExp = 2.0;
|
2017-05-10 19:42:46 +02:00
|
|
|
var baseGymExp = 1.0;
|
2017-04-24 21:10:35 +02:00
|
|
|
|
|
|
|
//Find cost and exp gain per game cycle
|
2017-05-10 19:42:46 +02:00
|
|
|
var cost = 0;
|
|
|
|
var hackExp = 0, strExp = 0, defExp = 0, dexExp = 0, agiExp = 0, chaExp = 0;
|
2017-04-24 21:10:35 +02:00
|
|
|
switch (className) {
|
|
|
|
case CONSTANTS.ClassStudyComputerScience:
|
|
|
|
hackExp = baseStudyComputerScienceExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassDataStructures:
|
2017-05-08 16:33:26 +02:00
|
|
|
cost = CONSTANTS.ClassDataStructuresBaseCost * costMult / gameCPS;
|
2017-04-24 21:10:35 +02:00
|
|
|
hackExp = baseDataStructuresExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassNetworks:
|
2017-05-08 16:33:26 +02:00
|
|
|
cost = CONSTANTS.ClassNetworksBaseCost * costMult / gameCPS;
|
2017-04-24 21:10:35 +02:00
|
|
|
hackExp = baseNetworksExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassAlgorithms:
|
2017-05-08 16:33:26 +02:00
|
|
|
cost = CONSTANTS.ClassAlgorithmsBaseCost * costMult / gameCPS;
|
2017-04-24 21:10:35 +02:00
|
|
|
hackExp = baseAlgorithmsExp * expMult / gameCPS;
|
|
|
|
break;
|
2017-04-25 21:14:01 +02:00
|
|
|
case CONSTANTS.ClassManagement:
|
2017-05-08 16:33:26 +02:00
|
|
|
cost = CONSTANTS.ClassManagementBaseCost * costMult / gameCPS;
|
2017-04-25 21:14:01 +02:00
|
|
|
chaExp = baseManagementExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassLeadership:
|
2017-05-08 16:33:26 +02:00
|
|
|
cost = CONSTANTS.ClassLeadershipBaseCost * costMult / gameCPS;
|
2017-04-25 21:14:01 +02:00
|
|
|
chaExp = baseLeadershipExp * expMult / gameCPS;
|
|
|
|
break;
|
2017-05-10 19:42:46 +02:00
|
|
|
case CONSTANTS.ClassGymStrength:
|
|
|
|
cost = CONSTANTS.ClassGymBaseCost * costMult / gameCPS;
|
|
|
|
strExp = baseGymExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassGymDefense:
|
|
|
|
cost = CONSTANTS.ClassGymBaseCost * costMult / gameCPS;
|
|
|
|
defExp = baseGymExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassGymDexterity:
|
|
|
|
cost = CONSTANTS.ClassGymBaseCost * costMult / gameCPS;
|
|
|
|
dexExp = baseGymExp * expMult / gameCPS;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.ClassGymAgility:
|
|
|
|
cost = CONSTANTS.ClassGymBaseCost * costMult / gameCPS;
|
|
|
|
agiExp = baseGymExp * expMult / gameCPS;
|
|
|
|
break;
|
2017-04-24 21:10:35 +02:00
|
|
|
default:
|
|
|
|
throw new Error("ERR: Invalid/unregocnized class name");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-25 21:14:01 +02:00
|
|
|
this.workMoneyLossRate = cost;
|
2017-04-27 22:59:57 +02:00
|
|
|
this.workHackExpGainRate = hackExp * this.hacking_exp_mult;
|
2017-05-10 19:42:46 +02:00
|
|
|
this.workStrExpGainRate = strExp * this.strength_exp_mult;
|
|
|
|
this.workDefExpGainRate = defExp * this.defense_exp_mult;
|
|
|
|
this.workDexExpGainRate = dexExp * this.dexterity_exp_mult;
|
|
|
|
this.workAgiExpGainRate = agiExp * this.agility_exp_mult;
|
2017-04-27 22:59:57 +02:00
|
|
|
this.workChaExpGainRate = chaExp * this.charisma_exp_mult;
|
2017-04-24 21:10:35 +02:00
|
|
|
|
2017-05-16 05:06:25 +02:00
|
|
|
var cancelButton = clearEventListeners("work-in-progress-cancel-button");
|
|
|
|
if (className == CONSTANTS.ClassGymStrength ||
|
|
|
|
className == CONSTANTS.ClassGymDefense ||
|
|
|
|
className == CONSTANTS.ClassGymDexterity ||
|
|
|
|
className == CONSTANTS.ClassGymAgility) {
|
|
|
|
cancelButton.innerHTML = "Stop training at gym";
|
|
|
|
} else {
|
|
|
|
cancelButton.innerHTML = "Stop taking course";
|
|
|
|
}
|
|
|
|
cancelButton.addEventListener("click", function() {
|
2017-04-24 21:10:35 +02:00
|
|
|
Player.finishClass();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.takeClass = function(numCycles) {
|
|
|
|
this.timeWorked += Engine._idleSpeed * numCycles;
|
|
|
|
var className = this.className;
|
|
|
|
|
|
|
|
this.workHackExpGained += this.workHackExpGainRate * numCycles;
|
|
|
|
this.workStrExpGained += this.workStrExpGainRate * numCycles;
|
|
|
|
this.workDefExpGained += this.workDefExpGainRate * numCycles;
|
|
|
|
this.workDexExpGained += this.workDexExpGainRate * numCycles;
|
|
|
|
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
|
|
|
|
this.workChaExpGained += this.workChaExpGainRate * numCycles;
|
|
|
|
this.workRepGained += this.workRepGainRate * numCycles;
|
|
|
|
this.workMoneyGained += this.workMoneyGainRate * numCycles;
|
|
|
|
this.workMoneyGained -= this.workMoneyLossRate * numCycles;
|
|
|
|
|
|
|
|
var cyclesPerSec = 1000 / Engine._idleSpeed;
|
2017-05-03 19:52:54 +02:00
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
var txt = document.getElementById("work-in-progress-text");
|
2017-05-15 21:11:40 +02:00
|
|
|
txt.innerHTML = "You have been " + className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
2017-04-24 21:10:35 +02:00
|
|
|
"This has cost you: <br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + " ($" + formatNumber(this.workMoneyLossRate * cyclesPerSec, 2) + " / sec) <br><br>" +
|
2017-04-24 21:10:35 +02:00
|
|
|
"You have gained: <br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
formatNumber(this.workHackExpGained, 4) + " (" + formatNumber(this.workHackExpGainRate * cyclesPerSec, 4) + " / sec) hacking exp <br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " (" + formatNumber(this.workDefExpGainRate * cyclesPerSec, 4) + " / sec) defense exp <br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " (" + formatNumber(this.workStrExpGainRate * cyclesPerSec, 4) + " / sec) strength exp <br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " (" + formatNumber(this.workDexExpGainRate * cyclesPerSec, 4) + " / sec) dexterity exp <br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " (" + formatNumber(this.workAgiExpGainRate * cyclesPerSec, 4) + " / sec) agility exp <br>" +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " (" + formatNumber(this.workChaExpGainRate * cyclesPerSec, 4) + " / sec) charisma exp <br>" +
|
2017-05-03 19:52:54 +02:00
|
|
|
"You may cancel at any time";
|
2017-04-24 21:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.finishClass = function() {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.gainWorkExp();
|
2017-04-24 21:10:35 +02:00
|
|
|
|
|
|
|
if (this.workMoneyGained > 0) {
|
|
|
|
throw new Error("ERR: Somehow gained money while taking class");
|
|
|
|
}
|
|
|
|
this.loseMoney(this.workMoneyGained * -1);
|
|
|
|
|
|
|
|
this.updateSkillLevels();
|
|
|
|
var txt = "After " + this.className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ", <br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
"you spent a total of $" + formatNumber(this.workMoneyGained * -1, 2) + ". <br><br>" +
|
2017-04-24 21:10:35 +02:00
|
|
|
"You earned a total of: <br>" +
|
2017-05-04 22:50:17 +02:00
|
|
|
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>";
|
2017-04-24 21:10:35 +02:00
|
|
|
|
|
|
|
dialogBoxCreate(txt);
|
|
|
|
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
|
|
|
|
|
|
|
this.isWorking = false;
|
|
|
|
|
2017-05-04 07:05:48 +02:00
|
|
|
Engine.loadLocationContent();
|
2017-04-24 21:10:35 +02:00
|
|
|
}
|
|
|
|
|
2017-05-03 19:52:54 +02:00
|
|
|
//The EXP and $ gains are hardcoded. Time is in ms
|
|
|
|
PlayerObject.prototype.startCrime = function(hackExp, strExp, defExp, dexExp, agiExp, chaExp, money, time) {
|
|
|
|
this.resetWorkStatus();
|
|
|
|
this.isWorking = true;
|
|
|
|
this.workType = CONSTANTS.WorkTypeCrime;
|
|
|
|
|
2017-05-04 07:05:48 +02:00
|
|
|
this.workHackExpGained = hackExp * this.hacking_exp_mult;
|
|
|
|
this.workStrExpGained = strExp * this.strength_exp_mult;
|
|
|
|
this.workDefExpGained = defExp * this.defense_exp_mult;
|
2017-05-04 07:27:22 +02:00
|
|
|
this.workDexExpGained = dexExp * this.dexterity_exp_mult;
|
2017-05-04 07:05:48 +02:00
|
|
|
this.workAgiExpGained = agiExp * this.agility_exp_mult;
|
|
|
|
this.workChaExpGained = chaExp * this.charisma_exp_mult;
|
2017-05-12 20:12:32 +02:00
|
|
|
this.workMoneyGained = money * this.crime_money_mult;
|
2017-05-03 19:52:54 +02:00
|
|
|
|
|
|
|
this.timeNeededToCompleteWork = time;
|
|
|
|
|
|
|
|
//Remove all old event listeners from Cancel button
|
2017-05-10 19:42:46 +02:00
|
|
|
var newCancelButton = clearEventListeners("work-in-progress-cancel-button")
|
2017-05-16 05:06:25 +02:00
|
|
|
newCancelButton.innerHTML = "Cancel crime"
|
2017-05-03 19:52:54 +02:00
|
|
|
newCancelButton.addEventListener("click", function() {
|
|
|
|
Player.finishCrime(true);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//Display Work In Progress Screen
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
|
|
|
|
2017-05-04 07:27:22 +02:00
|
|
|
PlayerObject.prototype.commitCrime = function (numCycles) {
|
2017-05-03 19:52:54 +02:00
|
|
|
this.timeWorked += Engine._idleSpeed * numCycles;
|
|
|
|
|
2017-05-08 16:33:26 +02:00
|
|
|
if (this.timeWorked >= this.timeNeededToCompleteWork) {Player.finishCrime(false); return;}
|
|
|
|
|
|
|
|
var percent = Math.round(Player.timeWorked / Player.timeNeededToCompleteWork * 100);
|
|
|
|
var numBars = Math.round(percent / 5);
|
2017-05-10 19:42:46 +02:00
|
|
|
if (numBars < 0) {numBars = 0;}
|
|
|
|
if (numBars > 20) {numBars = 20;}
|
2017-05-08 16:33:26 +02:00
|
|
|
var progressBar = "[" + Array(numBars+1).join("|") + Array(20 - numBars + 1).join(" ") + "]";
|
2017-05-04 07:27:22 +02:00
|
|
|
|
2017-05-03 19:52:54 +02:00
|
|
|
var txt = document.getElementById("work-in-progress-text");
|
|
|
|
txt.innerHTML = "You are attempting to " + Player.crimeType + ".<br>" +
|
2017-05-08 16:33:26 +02:00
|
|
|
"Time remaining: " + convertTimeMsToTimeElapsedString(this.timeNeededToCompleteWork - this.timeWorked) + "<br>" +
|
|
|
|
progressBar.replace( / /g, " " );
|
2017-05-03 19:52:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.finishCrime = function(cancelled) {
|
2017-05-04 07:05:48 +02:00
|
|
|
//Determine crime success/failure
|
2017-05-04 07:27:22 +02:00
|
|
|
if (!cancelled) {
|
2017-05-08 18:00:34 +02:00
|
|
|
var statusText = ""; //TODO, unique message for each crime when you succeed
|
2017-05-04 07:27:22 +02:00
|
|
|
if (determineCrimeSuccess(this.crimeType, this.workMoneyGained)) {
|
2017-05-04 09:05:43 +02:00
|
|
|
//Handle Karma and crime statistics
|
|
|
|
switch(this.crimeType) {
|
|
|
|
case CONSTANTS.CrimeShoplift:
|
|
|
|
this.karma -= 0.1;
|
|
|
|
++this.numTimesShoplifted;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeMug:
|
2017-05-30 16:55:58 +02:00
|
|
|
this.karma -= 0.25;
|
2017-05-04 09:05:43 +02:00
|
|
|
++this.numPeopleMugged;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeDrugs:
|
|
|
|
++this.numTimesDealtDrugs;
|
|
|
|
this.karma -= 0.5;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeTraffickArms:
|
|
|
|
++this.numTimesTraffickArms;
|
|
|
|
this.karma -= 1;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeHomicide:
|
|
|
|
++this.numPeopleKilled;
|
|
|
|
this.karma -= 3;
|
|
|
|
break;
|
2017-05-08 18:00:34 +02:00
|
|
|
case CONSTANTS.CrimeGrandTheftAuto:
|
|
|
|
++this.numTimesGrandTheftAuto;
|
|
|
|
this.karma -= 5;
|
|
|
|
break;
|
2017-05-04 09:05:43 +02:00
|
|
|
case CONSTANTS.CrimeKidnap:
|
|
|
|
++this.numTimesKidnapped;
|
2017-05-08 18:00:34 +02:00
|
|
|
this.karma -= 6;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeAssassination:
|
|
|
|
++this.numPeopleKilled;
|
|
|
|
this.karma -= 10;
|
|
|
|
break;
|
|
|
|
case CONSTANTS.CrimeHeist:
|
|
|
|
++this.numTimesHeist;
|
|
|
|
this.karma -= 15;
|
2017-05-04 09:05:43 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dialogBoxCreate("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-04 07:27:22 +02:00
|
|
|
//On a crime success, gain 2x exp
|
|
|
|
this.workHackExpGained *= 2;
|
|
|
|
this.workStrExpGained *= 2;
|
|
|
|
this.workDefExpGained *= 2;
|
|
|
|
this.workDexExpGained *= 2;
|
|
|
|
this.workAgiExpGained *= 2;
|
|
|
|
this.workChaExpGained *= 2;
|
|
|
|
|
|
|
|
dialogBoxCreate("Crime successful! <br><br>" +
|
|
|
|
"You gained:<br>"+
|
2017-05-05 06:54:40 +02:00
|
|
|
"$" + formatNumber(this.workMoneyGained, 2) + "<br>" +
|
|
|
|
formatNumber(this.workHackExpGained, 4) + " hacking experience <br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " strength experience<br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " defense experience<br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " dexterity experience<br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " agility experience<br>" +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " charisma experience");
|
2017-05-04 07:27:22 +02:00
|
|
|
} else {
|
|
|
|
dialogBoxCreate("Crime failed! <br><br>" +
|
|
|
|
"You gained:<br>"+
|
2017-05-05 06:54:40 +02:00
|
|
|
formatNumber(this.workHackExpGained, 4) + " hacking experience <br>" +
|
|
|
|
formatNumber(this.workStrExpGained, 4) + " strength experience<br>" +
|
|
|
|
formatNumber(this.workDefExpGained, 4) + " defense experience<br>" +
|
|
|
|
formatNumber(this.workDexExpGained, 4) + " dexterity experience<br>" +
|
|
|
|
formatNumber(this.workAgiExpGained, 4) + " agility experience<br>" +
|
|
|
|
formatNumber(this.workChaExpGained, 4) + " charisma experience");
|
2017-05-04 07:27:22 +02:00
|
|
|
}
|
2017-05-08 18:00:34 +02:00
|
|
|
|
|
|
|
this.gainWorkExp();
|
2017-05-04 07:05:48 +02:00
|
|
|
}
|
|
|
|
|
2017-05-08 18:00:34 +02:00
|
|
|
|
2017-05-04 07:27:22 +02:00
|
|
|
|
2017-05-03 19:52:54 +02:00
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "visible";
|
|
|
|
this.isWorking = false;
|
2017-05-04 07:05:48 +02:00
|
|
|
Engine.loadLocationContent();
|
2017-05-03 19:52:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
|
|
|
|
//Returns true if hospitalized, false otherwise
|
|
|
|
PlayerObject.prototype.takeDamage = function(amt) {
|
|
|
|
this.hp -= amt;
|
|
|
|
if (this.hp <= 0) {
|
|
|
|
this.hospitalize();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-28 22:53:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PlayerObject.prototype.hospitalize = function() {
|
2017-07-03 21:42:11 +02:00
|
|
|
dialogBoxCreate("You were in critical condition! You were taken to the hospital where " +
|
|
|
|
"luckily they were able to save your life. You were charged $" +
|
|
|
|
formatNumber(this.max_hp * CONSTANTS.HospitalCostPerHp, 2));
|
|
|
|
Player.loseMoney(this.max_hp * CONSTANTS.HospitalCostPerHp);
|
|
|
|
this.hp = this.max_hp;
|
2017-06-28 22:53:12 +02:00
|
|
|
}
|
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
/* Functions for saving and loading the Player data */
|
2016-12-01 23:18:18 +01:00
|
|
|
PlayerObject.prototype.toJSON = function() {
|
|
|
|
return Generic_toJSON("PlayerObject", this);
|
2017-02-08 01:27:11 +01:00
|
|
|
}
|
2016-12-01 23:18:18 +01:00
|
|
|
|
|
|
|
PlayerObject.fromJSON = function(value) {
|
|
|
|
return Generic_fromJSON(PlayerObject, value.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
Reviver.constructors.PlayerObject = PlayerObject;
|
|
|
|
|
|
|
|
Player = new PlayerObject();
|
|
|
|
|
|
|
|
|
2016-11-01 06:30:59 +01:00
|
|
|
|