First
This commit is contained in:
commit
9e9723ba50
80
main.go
Normal file
80
main.go
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// 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], "'")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user