Last active
February 10, 2019 16:17
-
-
Save stenno/05b136d679de8c27b2ea1195be21353f to your computer and use it in GitHub Desktop.
Nethack API Frontend WIP
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
const NethackAPI = require("./nethackapi"); | |
const nethackAPI = new NethackAPI(); | |
// lazy top-level await | |
(async () => { | |
// connect to HDF | |
await nethackAPI.loginSSH("stenno", "not my password", "nethack@eu.hardfought.org"); | |
if (!nethackAPI.connected) { | |
throw "Couldn't connect :("; | |
} | |
// get version from extcommand -> prints to text window | |
await nethackAPI.doInput("#version\n"); | |
const versionText = nethackAPI.getTextWindow(); | |
console.log(versionText.join("\n")); | |
await nethackAPI.doInput(" "); // close version window | |
// phew, enough playing, let's Save and exit | |
await nethackAPI.doInput("S"); | |
// print last message | |
// should print string 'Really save? [yn] (n) °' | |
console.log("messages", nethackAPI.messages.slice(-1)); | |
// yes, we want to Save | |
await nethackAPI.doInput("y"); | |
// close connection | |
nethackAPI.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment