bitburner-src/src/NetscriptGang.js
danielyxie 61150f5823 Revert "Revert "Gang rework""
This reverts commit be0a08d70caacd9bc3a43faab2825cd5f3c68e1f.
2018-10-29 11:09:33 -05:00

16 lines
584 B
JavaScript

import {Player} from "./Player";
import {Gang} from "./Gang";
import {makeRuntimeRejectMsg} from "./NetscriptEvaluator";
export function unknownGangApiExceptionMessage(functionName, err) {
return `gang.${functionName}() failed with exception: ` + err;
}
export function checkGangApiAccess(workerScript, functionName) {
const accessDenied = `gang.${functionName}() failed because you do not currently have a Gang`;
const hasAccess = Player.gang instanceof Gang;
if (!hasAccess) {
throw makeRuntimeRejectMsg(workerScript, accessDenied);
}
}