81 lines
1.5 KiB
Go
81 lines
1.5 KiB
Go
// main
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
|
|
type Room struct {
|
|
name, description string
|
|
}
|
|
|
|
type Player struct {
|
|
location string
|
|
// items inventory
|
|
}
|
|
/* Pointing to the struct "Room" allows us to directly modify its values */
|
|
rooms := map[string]*Room{
|
|
"entry": {"Field", "You find yourself before a mansion to the (n)orth.\n" +
|
|
"There is a cave to the (w)est.\n" +
|
|
"In the distance, you see some sort of box to the (e)ast."},
|
|
"chest": {"Chest", "You see a closed chest freezer in front of you."},
|
|
}
|
|
println(rooms["chest"])
|
|
|
|
/*
|
|
|
|
cmd := exec.Command("clear")
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Run()
|
|
*/
|
|
|
|
var command [2]string
|
|
var quit bool = false
|
|
for quit != true {
|
|
fmt.Print("Enter text: ")
|
|
|
|
fmt.Scanln(&command[0], &command[1])
|
|
|
|
command[0] = strings.ToLower(command[0])
|
|
command[1] = strings.ToLower(command[1])
|
|
|
|
switch command[0] {
|
|
case "q", "quit":
|
|
print("Are you sure you want to quit? (y/n): ")
|
|
fmt.Scanln(&command[0])
|
|
if strings.ToLower(command[0]) == "y" {
|
|
|
|
println("The shame of quiting causes your liver to burst" +
|
|
" as you keel over.")
|
|
println("RIP")
|
|
quit = true
|
|
} else {
|
|
println("Welcome back from the edge! ")
|
|
}
|
|
case "h", "help":
|
|
print("Commands:\n\n" +
|
|
|
|
"(h)elp\n" +
|
|
"(c)lear\n" +
|
|
"(q)uit\n\n" +
|
|
|
|
"(n)orth\n" +
|
|
"(s)outh\n" +
|
|
"(e)ast\n" +
|
|
"(w)est\n\n" +
|
|
|
|
"(l)ook\n" +
|
|
"(g)et\n" +
|
|
"(u)se)\n")
|
|
|
|
default:
|
|
println("I don't know how to '", command[0], "'")
|
|
|
|
}
|
|
}
|
|
|
|
}
|