2016-10-14 23:02:06 +02:00
|
|
|
//Netburner Player class
|
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
var Player = {
|
2016-10-14 23:02:06 +02:00
|
|
|
//Skills and stats
|
|
|
|
hacking_skill: 1,
|
2016-11-02 22:45:10 +01:00
|
|
|
|
|
|
|
//Fighting
|
|
|
|
strength: 1, //Damage dealt
|
|
|
|
defense: 1, //Damage received
|
|
|
|
dexterity: 1, //Accuracy
|
|
|
|
agility: 1, //Dodge %
|
|
|
|
|
|
|
|
//Labor stats
|
|
|
|
charisma: 1,
|
|
|
|
|
|
|
|
//Hacking multipliers
|
2016-10-24 23:16:51 +02:00
|
|
|
hacking_chance_multiplier: 2, //Increase through ascensions/augmentations
|
2016-10-27 05:34:18 +02:00
|
|
|
//hacking_speed_multiplier: 5, //Decrease through ascensions/augmentations
|
|
|
|
hacking_speed_multiplier: 1, //Make it faster for debugging
|
2016-10-27 20:26:00 +02:00
|
|
|
hacking_money_multiplier: .01, //Increase through ascensions/augmentations. Can't go above 1
|
2016-10-14 23:02:06 +02:00
|
|
|
|
|
|
|
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
|
|
|
|
//Accumulative stats and skills
|
|
|
|
total_hacking: 1,
|
|
|
|
total_strength: 1,
|
|
|
|
total_defense: 1,
|
|
|
|
total_dexterity: 1,
|
|
|
|
total_agility: 1,
|
2016-11-02 22:45:10 +01:00
|
|
|
total_charisma: 1,
|
2016-10-14 23:02:06 +02:00
|
|
|
lifetime_hacking: 1,
|
|
|
|
lifetime_strength: 1,
|
|
|
|
lifetime_defense: 1,
|
|
|
|
lifetime_dexterity: 1,
|
|
|
|
lifetime_agility: 1,
|
2016-11-02 22:45:10 +01:00
|
|
|
lifetime_charisma: 1,
|
2016-10-14 23:02:06 +02:00
|
|
|
|
|
|
|
//Experience and multipliers
|
|
|
|
hacking_exp: 0,
|
|
|
|
strength_exp: 0,
|
|
|
|
defense_exp: 0,
|
|
|
|
dexterity_exp: 0,
|
|
|
|
agility_exp: 0,
|
2016-11-02 22:45:10 +01:00
|
|
|
charisma_exp: 0,
|
2016-10-14 23:02:06 +02:00
|
|
|
|
|
|
|
hacking_exp_mult: 1,
|
|
|
|
strength_exp_mult: 1,
|
|
|
|
defense_exp_mult: 1,
|
|
|
|
dexterity_exp_mult: 1,
|
|
|
|
agility_exp_mult: 1,
|
2016-11-02 22:45:10 +01:00
|
|
|
charisma_exp_mult: 1,
|
|
|
|
|
|
|
|
company_rep_mult: 1, //Multiplier for how fast the player gains reputation at a company
|
2016-10-14 23:02:06 +02:00
|
|
|
|
|
|
|
//Money
|
|
|
|
money: 0,
|
|
|
|
total_money: 0,
|
|
|
|
lifetime_money: 0,
|
|
|
|
|
2016-10-17 23:23:23 +02:00
|
|
|
//Starting (home) computer
|
2016-10-20 20:26:38 +02:00
|
|
|
homeComputer: new Server(),
|
2016-10-17 23:23:23 +02:00
|
|
|
|
2016-10-14 23:02:06 +02:00
|
|
|
//Servers
|
2016-10-20 20:26:38 +02:00
|
|
|
currentServer: null, //Server currently being accessed through terminal
|
|
|
|
discoveredServers: [],
|
|
|
|
purchasedServers: [],
|
2016-10-14 23:02:06 +02:00
|
|
|
|
|
|
|
//Achievements and achievement progress
|
|
|
|
|
|
|
|
|
2016-10-24 23:16:51 +02:00
|
|
|
//Flag to let the engine know the player is starting a hack
|
2016-11-01 06:30:59 +01:00
|
|
|
startAction: false,
|
|
|
|
actionTime: 0,
|
2016-10-24 23:16:51 +02:00
|
|
|
|
|
|
|
|
2016-10-20 20:26:38 +02:00
|
|
|
init: function() {
|
2016-10-24 23:16:51 +02:00
|
|
|
/* Initialize properties of Player's home computer */
|
2016-10-20 23:11:01 +02:00
|
|
|
Player.homeComputer.init("19.42.93.219", "home", "Home PC", true, true, true, true, 1);
|
|
|
|
Player.currentServer = Player.homeComputer;
|
2016-10-27 20:26:00 +02:00
|
|
|
|
|
|
|
Player.homeComputer.programs.push("PortHack.exe");
|
2016-10-24 08:34:04 +02:00
|
|
|
|
|
|
|
var NetworkGroup1 = [ForeignServers.IronGym, ForeignServers.FoodNStuff, ForeignServers.SigmaCosmetics, ForeignServers.JoesGuns, ForeignServers.HongFangTeaHouse, ForeignServers.HaraKiriSushiBar];
|
|
|
|
for (var i = 0; i < NetworkGroup1.length; i++) {
|
|
|
|
Player.homeComputer.serversOnNetwork.push(NetworkGroup1[i]);
|
2016-10-24 23:16:51 +02:00
|
|
|
NetworkGroup1[i].serversOnNetwork.push(Player.homeComputer);
|
2016-10-24 08:34:04 +02:00
|
|
|
}
|
|
|
|
},
|
2016-10-21 23:15:45 +02:00
|
|
|
|
2016-11-01 22:19:57 +01:00
|
|
|
//Calculates skill level based on experience. The same formula will be used for every skill
|
2016-10-21 23:15:45 +02:00
|
|
|
// At the maximum possible exp (MAX_INT = 9007199254740991), the hacking skill will by 1796
|
|
|
|
// Gets to level 1000 hacking skill at ~1,100,000,000 exp
|
2016-11-01 22:19:57 +01:00
|
|
|
calculateSkill: function(exp) {
|
2016-10-21 23:15:45 +02:00
|
|
|
return Math.max(Math.floor(50 * log(9007199254740991+ 2.270) - 40), 1);
|
2016-10-24 23:16:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
//Calculates the chance of hacking a server
|
|
|
|
//The formula is:
|
|
|
|
// (hacking_chance_multiplier * hacking_skill - requiredLevel) 100 - difficulty
|
|
|
|
// ----------------------------------------------------------- * -----------------
|
2016-10-27 20:26:00 +02:00
|
|
|
// (hacking_chance_multiplier * hacking_skill) 100
|
2016-10-24 23:16:51 +02:00
|
|
|
calculateHackingChance: function() {
|
|
|
|
var difficultyMult = (100 - Player.currentServer.hackDifficulty) / 100;
|
|
|
|
var skillMult = (Player.hacking_chance_multiplier * Player.hacking_skill);
|
|
|
|
var skillChance = (skillMult - Player.currentServer.requiredHackingSkill) / skillMult;
|
|
|
|
return (skillChance * difficultyMult);
|
|
|
|
},
|
|
|
|
|
|
|
|
//Calculate the time it takes to hack a server in seconds. Returns the time
|
|
|
|
//The formula is:
|
|
|
|
// (requiredLevel * difficulty)
|
|
|
|
// ------------------------------- * hacking_speed_multiplier
|
|
|
|
// hacking_skill
|
|
|
|
calculateHackingTime: function() {
|
2016-10-27 05:34:18 +02:00
|
|
|
var difficultyMult = Player.currentServer.requiredHackingSkill * Player.currentServer.hackDifficulty;
|
2016-10-24 23:16:51 +02:00
|
|
|
var skillFactor = difficultyMult / Player.hacking_skill;
|
|
|
|
return skillFactor * Player.hacking_speed_multiplier;
|
|
|
|
},
|
|
|
|
|
2016-10-27 20:26:00 +02: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
|
|
|
|
calculatePercentMoneyHacked: function() {
|
|
|
|
var difficultyMult = (100 - Player.currentServer.hackDifficulty) / 100;
|
|
|
|
var skillMult = (Player.hacking_skill - (Player.currentServer.requiredHackingSkill - 1)) / Player.hacking_skill;
|
|
|
|
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_multiplier;
|
|
|
|
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
|
|
|
return percentMoneyHacked;
|
|
|
|
},
|
|
|
|
|
|
|
|
//Returns how much EXP the player gains on a successful hack
|
|
|
|
//The formula is:
|
|
|
|
// difficulty * requiredLevel * hacking_multiplier
|
|
|
|
//
|
|
|
|
// Note: Keep it at an integer for now,
|
|
|
|
calculateExpGain: function() {
|
|
|
|
return Math.round(Player.currentServer.hackDifficulty * Player.currentServer.requiredHackingSkill * Player.hacking_exp_mult);
|
|
|
|
},
|
|
|
|
|
2016-11-01 06:30:59 +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
|
2016-10-27 20:26:00 +02:00
|
|
|
//This assumes that the server being hacked is not purchased by the player, that the player's hacking skill is greater than the
|
2016-10-24 23:16:51 +02:00
|
|
|
//required hacking skill and that the player has admin rights.
|
2016-10-27 20:26:00 +02:00
|
|
|
hack: function() {
|
2016-11-01 06:30:59 +01:00
|
|
|
Player.actionTime = Player.calculateHackingTime();
|
|
|
|
console.log("Hacking time: " + Player.actionTime);
|
2016-10-24 23:16:51 +02:00
|
|
|
//Set the startHack flag so the engine starts the hacking process
|
2016-11-01 06:30:59 +01:00
|
|
|
Player.startAction = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
analyze: function() {
|
|
|
|
//TODO Analyze only takes 5 seconds for now..maybe change this in the future?
|
|
|
|
Player.actionTime = 5;
|
|
|
|
Player.startAction = true;
|
|
|
|
}
|
2016-10-14 23:02:06 +02:00
|
|
|
};
|