second
This commit is contained in:
parent
9e9723ba50
commit
eb2ccf643d
70
main.go
70
main.go
@ -9,32 +9,42 @@ import (
|
||||
func main() {
|
||||
|
||||
type Room struct {
|
||||
name, description string
|
||||
name, description string
|
||||
north, south, west, east string
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
location string
|
||||
loc *Room
|
||||
// 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."},
|
||||
"In the distance, you see some sort of box to the (e)ast.",
|
||||
"none", "none", "none", "chest"},
|
||||
"chest": {"Chest", "You see a closed chest freezer in front of you.",
|
||||
"none", "none", "entry", "none"},
|
||||
}
|
||||
println(rooms["chest"])
|
||||
|
||||
/*
|
||||
|
||||
cmd := exec.Command("clear")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
*/
|
||||
player := Player{rooms["entry"]}
|
||||
|
||||
var command [2]string
|
||||
var quit bool = false
|
||||
|
||||
println()
|
||||
println()
|
||||
println()
|
||||
println()
|
||||
println()
|
||||
println("Welcome to Crush Candy DX!")
|
||||
println("Type \"h\" for help!")
|
||||
println("Enjoy!")
|
||||
println()
|
||||
println()
|
||||
for quit != true {
|
||||
println(player.loc.description, "\n")
|
||||
fmt.Print("Enter text: ")
|
||||
|
||||
fmt.Scanln(&command[0], &command[1])
|
||||
@ -43,7 +53,7 @@ func main() {
|
||||
command[1] = strings.ToLower(command[1])
|
||||
|
||||
switch command[0] {
|
||||
case "q", "quit":
|
||||
case "q", "quit", "exit":
|
||||
print("Are you sure you want to quit? (y/n): ")
|
||||
fmt.Scanln(&command[0])
|
||||
if strings.ToLower(command[0]) == "y" {
|
||||
@ -69,10 +79,42 @@ func main() {
|
||||
|
||||
"(l)ook\n" +
|
||||
"(g)et\n" +
|
||||
"(u)se)\n")
|
||||
"(u)se\n\n")
|
||||
|
||||
case "w", "west":
|
||||
if player.loc.west != "none" {
|
||||
|
||||
player.loc = rooms[player.loc.west]
|
||||
break
|
||||
}
|
||||
println("\nYou can't go that way!\n")
|
||||
|
||||
case "e", "east":
|
||||
if player.loc.east != "none" {
|
||||
|
||||
player.loc = rooms[player.loc.east]
|
||||
break
|
||||
}
|
||||
println("\nYou can't go that way!\n")
|
||||
|
||||
case "n", "north":
|
||||
if player.loc.north != "none" {
|
||||
|
||||
player.loc = rooms[player.loc.north]
|
||||
break
|
||||
}
|
||||
println("\nYou can't go that way!\n")
|
||||
|
||||
case "s", "south":
|
||||
if player.loc.south != "none" {
|
||||
|
||||
player.loc = rooms[player.loc.south]
|
||||
break
|
||||
}
|
||||
println("\nYou can't go that way!\n")
|
||||
|
||||
default:
|
||||
println("I don't know how to '", command[0], "'")
|
||||
println("\nI don't know how to '", command[0], "'\n")
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user