Add inventory

This commit is contained in:
Logen Kain 2018-01-29 14:55:05 -07:00
parent 2bebc944cb
commit f2fde37ec8

20
main.go
View File

@ -15,9 +15,11 @@ func main() {
type Player struct {
loc *Room
// items inventory
items map[string]string
}
inventory := map[string]string{}
/* 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" +
@ -28,7 +30,9 @@ func main() {
"none", "none", "entry", "none"},
}
player := Player{rooms["entry"]}
player := Player{rooms["entry"], inventory}
player.items["syringe"] = "A syringe with a missing needle is in your pocket."
var command [2]string
var quit bool = false
@ -79,7 +83,8 @@ func main() {
"(l)ook\n" +
"(g)et\n" +
"(u)se\n\n")
"(u)se\n" +
"(i)nventory\n\n")
case "w", "west":
if player.loc.west != "none" {
@ -113,6 +118,15 @@ func main() {
}
println("\nYou can't go that way!\n")
case "i", "inventory":
println("")
println("Inventory:\n")
//Listing items, and looking at them, should be different.
for k, v := range player.items {
println(k, " ", v)
}
println("")
default:
println("\nI don't know how to '", command[0], "'\n")