basic sleeve api

This commit is contained in:
Olivier Gagnon 2019-03-12 03:40:48 -04:00 committed by danielyxie
parent b4057fcb26
commit 8df7f8de4b
2 changed files with 107 additions and 1 deletions

@ -90,6 +90,7 @@ export let CONSTANTS: IMap<any> = {
ScriptGetHackTimeRamCost: 0.05, ScriptGetHackTimeRamCost: 0.05,
ScriptGetFavorToDonate: 0.10, ScriptGetFavorToDonate: 0.10,
ScriptCodingContractBaseRamCost:10, ScriptCodingContractBaseRamCost:10,
ScriptSleeveBaseRamCost: 0, // TODO: let big boss figure out balance.
ScriptSingularityFn1RamCost: 1, ScriptSingularityFn1RamCost: 1,
ScriptSingularityFn2RamCost: 2, ScriptSingularityFn2RamCost: 2,

@ -4807,7 +4807,112 @@ function NetscriptFunctions(workerScript) {
} }
return contract.getMaxNumTries() - contract.tries; return contract.getMaxNumTries() - contract.tries;
}, },
}, // End coding contracts
sleeve : {
getNumSleeves: function() {
if (workerScript.checkingRam) {
return updateStaticRam("getNumSleeves", CONSTANTS.ScriptSleeveBaseRamCost);
} }
updateDynamicRam("getNumSleeves", CONSTANTS.ScriptSleeveBaseRamCost);
return Player.sleeves.length;
},
shockRecovery : function(sleeveNumber=0) {
if (workerScript.checkingRam) {
return updateStaticRam("shockRecovery", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("shockRecovery", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.shockRecovery(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].shockRecovery(Player);
},
synchronize : function(sleeveNumber=0) {
if (workerScript.checkingRam) {
return updateStaticRam("synchronize", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("synchronize", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.synchronize(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].synchronize(Player);
},
commitCrime : function(sleeveNumber=0, crimeName="") {
if (workerScript.checkingRam) {
return updateStaticRam("commitCrime", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("commitCrime", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.commitCrime(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].commitCrime(Player, crimeName);
},
takeUniversityCourse : function(sleeveNumber=0, universityName="", className="") {
if (workerScript.checkingRam) {
return updateStaticRam("takeUniversityCourse", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("takeUniversityCourse", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.takeUniversityCourse(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].takeUniversityCourse(Player, universityName, className);
},
travel : function(sleeveNumber=0, cityName="") {
if (workerScript.checkingRam) {
return updateStaticRam("travel", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("travel", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.travel(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].travel(Player, cityName);
},
workForCompany : function(sleeveNumber=0, companyName="") {
if (workerScript.checkingRam) {
return updateStaticRam("workForCompany", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("workForCompany", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.workForCompany(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].workForCompany(Player, companyName);
},
workForFaction : function(sleeveNumber=0, factionName="", workType="") {
if (workerScript.checkingRam) {
return updateStaticRam("workForFaction", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("workForFaction", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.workForFaction(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].workForFaction(Player, factionName, workType);
},
workoutAtGym : function(sleeveNumber=0, gymName="", stat="") {
if (workerScript.checkingRam) {
return updateStaticRam("workoutAtGym", CONSTANTS.ScriptSleeveBaseRamCost);
}
updateDynamicRam("workoutAtGym", CONSTANTS.ScriptSleeveBaseRamCost);
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
workerScript.log(`ERROR: sleeve.workoutAtGym(${sleeveNumber}) failed because it is an invalid sleeve number.`);
return false;
}
return Player.sleeves[sleeveNumber].workoutAtGym(Player, gymName, stat);
},
} // End sleeve
} //End return } //End return
} //End NetscriptFunction() } //End NetscriptFunction()