|
|
@ -18,10 +18,11 @@ func printUserScreen(redisClient *redis.Client, username string) string { |
|
|
|
println(" l) Logout") |
|
|
|
println(" l) Logout") |
|
|
|
println(" c) Change password") |
|
|
|
println(" c) Change password") |
|
|
|
println(" w) Watch games in progress") |
|
|
|
println(" w) Watch games in progress") |
|
|
|
println(" h) View highscores") |
|
|
|
println(" h) View NetHack highscores") |
|
|
|
println(" a) View all scores") |
|
|
|
println(" a) View all NetHack scores") |
|
|
|
println(" e) Edit config") |
|
|
|
println(" e) Edit NetHack config") |
|
|
|
println(" r) Recover from crash") |
|
|
|
println(" f) Edit SOTW config") |
|
|
|
|
|
|
|
println(" r) Recover NetHack from crash") |
|
|
|
fmt.Printf(" p) Play NetHack %s\n", config.NethackLauncher.NethackVersion) |
|
|
|
fmt.Printf(" p) Play NetHack %s\n", config.NethackLauncher.NethackVersion) |
|
|
|
fmt.Printf(" o) Play Shadow of the Wyrm %s\n", config.NethackLauncher.SotwVersion) |
|
|
|
fmt.Printf(" o) Play Shadow of the Wyrm %s\n", config.NethackLauncher.SotwVersion) |
|
|
|
println(" q) Quit") |
|
|
|
println(" q) Quit") |
|
|
@ -46,7 +47,30 @@ func printUserScreen(redisClient *redis.Client, username string) string { |
|
|
|
hackRCLoc := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) |
|
|
|
hackRCLoc := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) |
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
clearScreen() |
|
|
|
clearScreen() |
|
|
|
nh := exec.Command("vim", "-Z", hackRCLoc) |
|
|
|
nh := exec.Command("vim", "-i", "NONE", "-Z", hackRCLoc) |
|
|
|
|
|
|
|
nh.Stdout = os.Stdout |
|
|
|
|
|
|
|
nh.Stdin = os.Stdin |
|
|
|
|
|
|
|
nh.Stderr = os.Stderr |
|
|
|
|
|
|
|
nh.Run() |
|
|
|
|
|
|
|
clearScreen() |
|
|
|
|
|
|
|
printUserScreen(redisClient, username) |
|
|
|
|
|
|
|
case "f": |
|
|
|
|
|
|
|
// check if the file has been uplifted
|
|
|
|
|
|
|
|
SOTWLoc := fmt.Sprintf("%s/user/%s/sotw/swyrm.ini", config.NethackLauncher.HackDir, username) |
|
|
|
|
|
|
|
il, _ := os.Lstat(SOTWLoc) |
|
|
|
|
|
|
|
if il.Mode()&os.ModeSymlink == os.ModeSymlink { |
|
|
|
|
|
|
|
// the file is still a legacy symlink, remove and recopy
|
|
|
|
|
|
|
|
err := os.Remove(SOTWLoc) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
fmt.Println(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SOTWOrigin := fmt.Sprintf("%s/swyrm.ini", config.NethackLauncher.SotwRoot) |
|
|
|
|
|
|
|
exec.Command("cp", SOTWOrigin, SOTWLoc).Run() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
|
|
|
|
clearScreen() |
|
|
|
|
|
|
|
nh := exec.Command("vim", "-i", "NONE", "-Z", SOTWLoc) |
|
|
|
nh.Stdout = os.Stdout |
|
|
|
nh.Stdout = os.Stdout |
|
|
|
nh.Stdin = os.Stdin |
|
|
|
nh.Stdin = os.Stdin |
|
|
|
nh.Stderr = os.Stderr |
|
|
|
nh.Stderr = os.Stderr |
|
|
@ -70,6 +94,7 @@ func printUserScreen(redisClient *redis.Client, username string) string { |
|
|
|
currentTime := time.Now().UTC() |
|
|
|
currentTime := time.Now().UTC() |
|
|
|
fulltime := currentTime.Format("2006-01-02.03:04:05") |
|
|
|
fulltime := currentTime.Format("2006-01-02.03:04:05") |
|
|
|
go runGame(username, fulltime) |
|
|
|
go runGame(username, fulltime) |
|
|
|
|
|
|
|
//go runCleanup(username)
|
|
|
|
watcher := startWatcher(username, fulltime, redisClient) |
|
|
|
watcher := startWatcher(username, fulltime, redisClient) |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
close(watcher) |
|
|
|
close(watcher) |
|
|
@ -79,6 +104,7 @@ func printUserScreen(redisClient *redis.Client, username string) string { |
|
|
|
currentTime := time.Now().UTC() |
|
|
|
currentTime := time.Now().UTC() |
|
|
|
fulltime := currentTime.Format("2006-01-02.03:04:05") |
|
|
|
fulltime := currentTime.Format("2006-01-02.03:04:05") |
|
|
|
go runSotwGame(username, fulltime) |
|
|
|
go runSotwGame(username, fulltime) |
|
|
|
|
|
|
|
//go runCleanup(username)
|
|
|
|
watcher := startWatcher(username, fulltime, redisClient) |
|
|
|
watcher := startWatcher(username, fulltime, redisClient) |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
close(watcher) |
|
|
|
close(watcher) |
|
|
|