Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd92cd1
commit be19754
Showing
8 changed files
with
165 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as TK from "./tk.js"; | ||
import {Sleeve} from "./sleeves.js"; | ||
import {_, json} from "./utils.js"; | ||
import {canonicalStat} from "./gameConstants.js"; | ||
|
||
class ThisScript extends TK.Script { | ||
async perform() { | ||
let sleeves = Sleeve.getSleeves(this.ns); | ||
this.sleeves = sleeves; | ||
let mode = this.pullFirstArg() || "train"; | ||
|
||
if (mode === "train") { | ||
let target = this.pullFirstArg() || 50; | ||
let stats = ["str", "def", "dex", "agi"].map(canonicalStat); | ||
await this.train(stats, target); | ||
} else if (mode === "murder") { | ||
this.crime("Homicide"); | ||
} else if (mode === "hack") { | ||
this.hack(); | ||
} | ||
} | ||
|
||
hack() { | ||
for (let sleeve of this.sleeves) { | ||
sleeve.train("hacking"); | ||
} | ||
} | ||
|
||
crime(crime) { | ||
for (let sleeve of this.sleeves) { | ||
sleeve.commitCrime(crime); | ||
} | ||
} | ||
|
||
async train(stats, target = 20) { | ||
for (let stat of stats) { | ||
for (let sleeve of this.sleeves) { | ||
sleeve.train(stat); | ||
} | ||
|
||
while (true) { | ||
if (this.sleeves.every(s => s.hasStatAt(stat, target))) { | ||
break; | ||
} | ||
|
||
await this.sleep(5000); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export let main = ThisScript.runner(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {NSObject} from "./baseScript.js"; | ||
import {_, json} from "./utils.js"; | ||
import {canonicalStat} from "./gameConstants.js"; | ||
|
||
const GYM_NAME = "Powerhouse Gym"; | ||
|
||
export class Sleeve extends NSObject { | ||
constructor(ns, num) { | ||
super(ns); | ||
this.num = num; | ||
} | ||
|
||
get s() { | ||
return this.ns.sleeve; | ||
} | ||
|
||
sync() { | ||
return this.s.synchronize(this.num); | ||
} | ||
|
||
shock() { | ||
return this.s.setToShockRecovery(this.num); | ||
} | ||
|
||
buyableAugs() { | ||
return this.s.getSleevePurchasableAugs(this.num); | ||
} | ||
|
||
static getSleeves(ns) { | ||
let sleeves = []; | ||
for (let i = 0; i < ns.sleeve.getNumSleeves(); i++) { | ||
sleeves.push(new Sleeve(ns, i)); | ||
} | ||
return sleeves; | ||
} | ||
|
||
train(inputStat) { | ||
let stat = canonicalStat(inputStat); | ||
if (stat === "hacking") { | ||
this.s.setToUniversityCourse( | ||
this.num, | ||
"Rothman University", | ||
"Algorithms" | ||
); | ||
} else { | ||
this.s.setToGymWorkout(this.num, GYM_NAME, stat); | ||
} | ||
} | ||
|
||
hasStatAt(stat, target) { | ||
return this.s.getSleeveStats(this.num)[stat] >= target; | ||
} | ||
|
||
commitCrime(crime) { | ||
return this.s.setToCommitCrime(this.num, crime); | ||
} | ||
} |