In the Gang Mechanic, added ability to see your chance to win clash with other gangs. rm() now takes an optional parameter for server

This commit is contained in:
danielyxie 2018-11-13 22:05:51 -08:00
parent 8778e835e0
commit 93f241029a
6 changed files with 60 additions and 36 deletions

@ -951,9 +951,10 @@ getPortHandle
rm rm
^^ ^^
.. js:function:: rm(fn) .. js:function:: rm(fn[, hostname/ip=current server])
:param string fn: Filename of file to remove. Must include the extension :param string fn: Filename of file to remove. Must include the extension
:param string hostname/ip: Hostname or IP Address of the server on which to delete the file. Optional. Defaults to current server
:returns: True if it successfully deletes the file, and false otherwise :returns: True if it successfully deletes the file, and false otherwise
:RAM cost: 1 GB :RAM cost: 1 GB
@ -1011,7 +1012,7 @@ getScriptRam
.. js:function:: getScriptRam(scriptname[, hostname/ip]) .. js:function:: getScriptRam(scriptname[, hostname/ip])
:param string scriptname: Filename of script. This is case-sensitive. :param string scriptname: Filename of script. This is case-sensitive.
:param string hostname/ip: Hostname or IP of target server the script is located on. This is optional, If it is not specified then the function will se the current server as the target server. :param string hostname/ip: Hostname or IP of target server the script is located on. This is optional, If it is not specified then the function will set the current server as the target server.
:RAM cost: 0.1 GB :RAM cost: 0.1 GB
Returns the amount of RAM required to run the specified script on the target server. Returns Returns the amount of RAM required to run the specified script on the target server. Returns

@ -234,6 +234,17 @@ setTerritoryWarfare
Set whether or not the gang should engage in territory warfare Set whether or not the gang should engage in territory warfare
getChanceToWinClash
-------------------
.. js:function:: getChanceToWinClash(gangName)
:param string gangName: Target gang
Returns the chance you have to win a clash with the specified gang. The chance
is returned in decimal form, not percentage
getBonusTime getBonusTime
------------ ------------

@ -107,7 +107,7 @@ let NetscriptFunctions =
"getMemberNames|getGangInformation|getMemberInformation|canRecruitMember|" + "getMemberNames|getGangInformation|getMemberInformation|canRecruitMember|" +
"recruitMember|getTaskNames|setMemberTask|getEquipmentNames|" + "recruitMember|getTaskNames|setMemberTask|getEquipmentNames|" +
"getEquipmentCost|purchaseEquipment|ascendMember|setTerritoryWarfare|" + "getEquipmentCost|purchaseEquipment|ascendMember|setTerritoryWarfare|" +
"getBonusTime|" + "getChanceToWinClash|getBonusTime|" +
// Bladeburner API // Bladeburner API
"bladeburner|getContractNames|getOperationNames|getBlackOpNames|" + "bladeburner|getContractNames|getOperationNames|getBlackOpNames|" +

@ -502,31 +502,13 @@ let CONSTANTS = {
LatestUpdate: LatestUpdate:
` `
v0.41.1 v0.41.2
* IMPORTANT - Netscript Changes: * IMPORTANT - Netscript Changes:
** purchaseTor() now returns true if you already have a TOR router (it used to return false) ** rm() now takes an optional parameter that lets you specify on which server to delete the file
** getPurchasedServerCost() now returns Infinity if the specified RAM is an invalid amount or is greater than the max amount of RAM (2 ^ 20 GB)
** Added purchase4SMarketData() and purchase4SMarketDataTixApi() functions
** getScriptLogs() now takes in optional arguments that let you get the logs of another script
* Stock Market changes: * Gang Changes:
** Stocks now have "maximum prices". These are hidden from the player ** UI now displays your chance to win a clash with other gangs
** If a stock reaches its "maximum price", it will most likely drop in value (although it might still rise) ** Added getChanceToWinClash() function to the Gang API
** Each stock has its own, unique maximum price
** Maximum price for each stock are randomly generated and change during each 'reset'
** Stock Market cycles are now accumulated/stored, much like it is for Gangs and Bladeburners
** Accumulated/stored cycles cause stock prices to update up to 50% faster (from every 6 seconds to 4 seconds)
*** This means that after coming back from being offline, stock prices will update faster to make up for offline time
* Decreased the Hacking Level multiplier for BitNodes 6 and 7 to 0.4 (from 0.5)
* Bladeburner console history is now saved and persists when switching screens or closing/reopening the game
* In Bladeburner, if your stamina reaches 0 your current action will be cancelled
* b1t_flum3.exe is no longer removed from your home computer upon reset
* Added main menu link for the Stock Market (once you've purchased an account)
* Job main menu link only appears if you actually have a job
* Bug Fix: Netscript Gang API functions purchaseEquipment() and ascendMember() should now work properly
* Bug Fix: After installing Augs, the "Portfolio Mode" button on the Stock Market page should be properly reset
* Bug Fix: bladeburner.getActionCountRemaining()'s return value is now rounded down (by Kline-)
` `
} }

@ -1521,9 +1521,10 @@ Gang.prototype.updateGangContent = function() {
// Update territory information // Update territory information
UIElems.gangTerritoryInfoText.innerHTML = ""; UIElems.gangTerritoryInfoText.innerHTML = "";
for (var gangname in AllGangs) { const playerPower = AllGangs[this.facName].power;
for (const gangname in AllGangs) {
if (AllGangs.hasOwnProperty(gangname)) { if (AllGangs.hasOwnProperty(gangname)) {
var gangTerritoryInfo = AllGangs[gangname]; const gangTerritoryInfo = AllGangs[gangname];
let territory = gangTerritoryInfo.territory * 100; let territory = gangTerritoryInfo.territory * 100;
//Fix some rounding issues graphically //Fix some rounding issues graphically
@ -1536,12 +1537,16 @@ Gang.prototype.updateGangContent = function() {
displayNumber = formatNumber(territory, 2); displayNumber = formatNumber(territory, 2);
} }
if (gangname == this.facName) { if (gangname === this.facName) {
UIElems.gangTerritoryInfoText.innerHTML += ("<b>" + gangname + "</b><br>(Power: " + formatNumber(gangTerritoryInfo.power, 6) + "): " + let newHTML = `<b><u>${gangname}</u></b><br>Power: ${formatNumber(gangTerritoryInfo.power, 6)}<br>`;
displayNumber + "%<br><br>"); newHTML += `Territory: ${displayNumber}%<br><br>`;
UIElems.gangTerritoryInfoText.innerHTML += newHTML;
} else { } else {
UIElems.gangTerritoryInfoText.innerHTML += (gangname + "<br>(Power: " + formatNumber(gangTerritoryInfo.power, 6) + "): " + const clashVictoryChance = playerPower / (gangTerritoryInfo.power + playerPower);
displayNumber + "%<br><br>"); let newHTML = `<u>${gangname}</u><br>Power: ${formatNumber(gangTerritoryInfo.power, 6)}<br>`;
newHTML += `Territory: ${displayNumber}%<br>`;
newHTML += `Chance to win clash with this gang: ${numeralWrapper.format(clashVictoryChance, "0.000%")}<br><br>`;
UIElems.gangTerritoryInfoText.innerHTML += newHTML;
} }
} }
} }

@ -2138,14 +2138,18 @@ function NetscriptFunctions(workerScript) {
} }
return port; return port;
}, },
rm : function(fn) { rm : function(fn, ip) {
if (workerScript.checkingRam) { if (workerScript.checkingRam) {
return updateStaticRam("rm", CONSTANTS.ScriptReadWriteRamCost); return updateStaticRam("rm", CONSTANTS.ScriptReadWriteRamCost);
} }
updateDynamicRam("rm", CONSTANTS.ScriptReadWriteRamCost); updateDynamicRam("rm", CONSTANTS.ScriptReadWriteRamCost);
var s = getServer(workerScript.serverIp);
if (ip == null || ip === "") {
ip = workerScript.serverIp;
}
var s = getServer(ip);
if (s == null) { if (s == null) {
throw makeRuntimeRejectMsg(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev"); throw makeRuntimeRejectMsg(workerScript, `Invalid server specified for rm(): ${ip}`);
} }
if (fn.includes(".exe")) { if (fn.includes(".exe")) {
@ -3932,6 +3936,27 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("setTerritoryWarfare", e)); throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("setTerritoryWarfare", e));
} }
}, },
getChanceToWinClash : function(otherGang) {
if (workerScript.checkingRam) {
return updateStaticRam("getChanceToWinClash", CONSTANTS.ScriptGangApiBaseRamCost);
}
updateDynamicRam("getChanceToWinClash", CONSTANTS.ScriptGangApiBaseRamCost);
nsGang.checkGangApiAccess(workerScript, "getChanceToWinClash");
try {
if (AllGangs[otherGang] == null) {
workerScript.log(`Invalid gang specified in gang.getChanceToWinClash() : ${otherGang}`);
return 0;
}
const playerPower = AllGangs[Player.gang.facName].power;
const otherPower = AllGangs[otherGang].power;
return playerPower / (otherPower + playerPower);
} catch(e) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getChanceToWinClash", e));
}
},
getBonusTime : function() { getBonusTime : function() {
if (workerScript.checkingRam) { return 0; } if (workerScript.checkingRam) { return 0; }
nsGang.checkGangApiAccess(workerScript, "getBonusTime"); nsGang.checkGangApiAccess(workerScript, "getBonusTime");