Skip to content

Commit

Permalink
Adding more copy functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
benbernard committed Oct 19, 2019
1 parent 1e293e9 commit 0fddb37
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ module.exports = {
"rest-spread-spacing": ["error", "never"],
semi: "off",
"semi-spacing": "error",
"sort-imports": "error",
"sort-imports": "off",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": [
Expand Down
3 changes: 1 addition & 2 deletions netrun/bernard/analyze-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class ThisScript extends TK.Script {
} else if (servers.length === 1) {
let server = servers[0];
this.tlog(server.info(true, {asConnect: true}));
let connectString = server.path({asConnect: true});
copy(connectString);
server.copyConnectionPath();
} else {
this.tlog(`No matching servers for ${term}`);
}
Expand Down
7 changes: 6 additions & 1 deletion netrun/bernard/contracts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {trading1, trading2, trading3, trading4} from "./trading2.js";
import {NSObject} from "./baseScript.js";
import validMath from "./validMath.js";
import {json} from "./utils.js";

export default class Contract extends NSObject {
constructor(ns, file, serverName) {
Expand Down Expand Up @@ -124,7 +125,11 @@ function largestFactor(target) {
}
}

return factors[factors.length - 1];
if (factors.length === 0) {
return target;
} else {
return factors[factors.length - 1];
}
}

// Cheated, didn't actually implement this
Expand Down
6 changes: 6 additions & 0 deletions netrun/bernard/find-cct.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ class ThisScript extends TK.Script {
purchasedSet(this.ns)
);

let lastServer;
for (let server of servers) {
let files = server.ls().filter(name => name.endsWith(".cct"));
if (files.length) {
lastServer = server;
this.tlog(
`Found Contracts on ${server.name}: ${files.join(
" "
)} Path: ${server.path()}`
);
}
}

if (lastServer) {
lastServer.copyConnectionPath();
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion netrun/bernard/tk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BaseScript, NSObject} from "./baseScript.js";
import {_} from "./utils.js";
import {_, copy} from "./utils.js";
import traverse from "./traverse.js";

const DYING_FILE = "dying.txt";
Expand Down Expand Up @@ -270,6 +270,11 @@ export class Server extends NSObject {
return parts.join(" ");
}

copyConnectionPath() {
let connectString = this.path({asConnect: true});
copy(connectString);
}

path(options = {}) {
let parentPath = "";
if (this.parent) parentPath = this.parent.path(options) + "; ";
Expand Down

0 comments on commit 0fddb37

Please sign in to comment.