|
|
|
@ -160,7 +160,7 @@ func printWelcomeScreen(redisClient *redis.Client) string {
|
|
|
|
|
printRegisterScreen(redisClient) |
|
|
|
|
case "w": |
|
|
|
|
clearScreen() |
|
|
|
|
printProgressScreen(redisClient) |
|
|
|
|
printProgressScreen(redisClient, "") |
|
|
|
|
case "q": |
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
|
clearScreen() |
|
|
|
@ -200,7 +200,7 @@ func printUserScreen(redisClient *redis.Client, username string) string {
|
|
|
|
|
printWelcomeScreen(redisClient) |
|
|
|
|
case "w": |
|
|
|
|
clearScreen() |
|
|
|
|
printProgressScreen(redisClient) |
|
|
|
|
printProgressScreen(redisClient, username) |
|
|
|
|
case "p": |
|
|
|
|
wg.Add(1) |
|
|
|
|
currentTime := time.Now().UTC() |
|
|
|
@ -342,6 +342,12 @@ func printRegisterScreen(redisClient *redis.Client) {
|
|
|
|
|
userPath := fmt.Sprintf("%s/user/%s/ttyrec/", config.NethackLauncher.HackDir, username) |
|
|
|
|
exec.Command("mkdir", "-p", userPath).Run() |
|
|
|
|
|
|
|
|
|
// copy in rc file
|
|
|
|
|
// TODO make sure rc file exists before copying
|
|
|
|
|
hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir) |
|
|
|
|
hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) |
|
|
|
|
exec.Command("cp", hackRCLoc, hackRCDest).Run() |
|
|
|
|
|
|
|
|
|
// back to main screen
|
|
|
|
|
printUserScreen(redisClient, username) |
|
|
|
|
} |
|
|
|
@ -351,7 +357,7 @@ func printRegisterScreen(redisClient *redis.Client) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func printProgressScreen(redisClient *redis.Client) { |
|
|
|
|
func printProgressScreen(redisClient *redis.Client, username string) { |
|
|
|
|
// print header
|
|
|
|
|
fmt.Printf(" %s\n", config.NethackLauncher.ServerDisplay) |
|
|
|
|
println("") |
|
|
|
@ -401,7 +407,11 @@ func printProgressScreen(redisClient *redis.Client) {
|
|
|
|
|
if string(b) == "\n" { |
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
|
clearScreen() |
|
|
|
|
if username == "" { |
|
|
|
|
printWelcomeScreen(redisClient) |
|
|
|
|
} else { |
|
|
|
|
printUserScreen(redisClient, username) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// check if selection is in out map
|
|
|
|
@ -421,10 +431,12 @@ func printProgressScreen(redisClient *redis.Client) {
|
|
|
|
|
nh.Stdin = os.Stdin |
|
|
|
|
nh.Stderr = os.Stderr |
|
|
|
|
nh.Run() |
|
|
|
|
// TODO add username to this
|
|
|
|
|
// TODO fix bug where user has to <ctrl-c> when game exists
|
|
|
|
|
//printUserScreen(redisClient, username)
|
|
|
|
|
if username == "" { |
|
|
|
|
printWelcomeScreen(redisClient) |
|
|
|
|
} else { |
|
|
|
|
printUserScreen(redisClient, username) |
|
|
|
|
} |
|
|
|
|
// TODO fix bug where user has to <ctrl-c> when game exists
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|