From 0fc99dbc624a15d162e51297b5d95fe065546d5a Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Tue, 30 Jan 2018 18:42:41 -0700 Subject: [PATCH] Add cave; add cave conditions --- main.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 07a9de6..a81f357 100644 --- a/main.go +++ b/main.go @@ -22,12 +22,15 @@ func main() { /* 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" + + "entry": {"Field", "\nYou 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.", - "none", "none", "none", "chest"}, - "chest": {"Chest", "You see a closed chest freezer in front of you.", + "none", "none", "cave", "chest"}, + "chest": {"Chest", "\nYou see a closed chest freezer in front of you.\n" + + "There is an empty field to the (w)est.\n", "none", "none", "entry", "none"}, + "cave": {"Cave", "\n A beast of inconevialable horror dwells in this" + + " cave and proceds to tear you apart.", "none", "none", "none", "entry"}, } player := Player{rooms["entry"], inventory} @@ -37,6 +40,8 @@ func main() { var command [2]string var quit bool = false + var steak_happened = false + println() println() println() @@ -49,6 +54,7 @@ func main() { println() for quit != true { println(player.loc.description, "\n") + fmt.Print("Enter text: ") fmt.Scanln(&command[0], &command[1]) @@ -129,8 +135,22 @@ func main() { default: println("\nI don't know how to '", command[0], "'\n") + } + if player.loc.name == "Cave" { + if _, ok := player.items["steak"]; ok { + println("\n You see a poodle sitting in the cave. You can't stand " + + "the smell of the steak anymore and decide to toss it " + + "out of the cave which the dog happily chases after.") + rooms["cave"].description = "You are in a dark cave.\n" + + "There is a key on the floor.\n" + + "Their is an empty field to the (e)ast." + steak_happened = true + } + if steak_happened == false { + println("Well, it looks like you died! Good luck next time!") + quit = true + } } } - }