// Chapter 26 example: one room's name, description, exits and items in one // value, in place of the four maps of the Text Adventure. // Run with: go run exercises/26/02-room.go package main import ( "fmt" "strings" ) type room struct { name string description string exits map[string]int items []string } func main() { rooms := map[int]room{ 1: { name: "Forest Path", description: "You are on a moss covered forest path. Birdsong drifts on the air.", exits: map[string]int{"north": 2}, }, 2: { name: "Clearing", description: "A small clearing of wildflowers.", exits: map[string]int{"south": 1, "east": 3}, items: []string{"torch"}, }, } here := rooms[2] fmt.Println("--", here.name, "--") fmt.Println(here.description) fmt.Println("Items here:", strings.Join(here.items, ", ")) fmt.Println("East leads to room", here.exits["east"]) }