package main import ( "fmt" "sort" "strings" ) var ( areas = map[string]*Area{ "town": { description: "You are in town", weather: "Sunny", }, "forest": { description: "You are in the forest", weather: "the sun beats down on you", }, } ) //Movement define world movement func Movement(player *Character) { //areaList := getAreaList(areas) var command [2]string var quit bool = false print("Character: ", player.name, "\n", "Location: ", player.location, "\n", "Description: ", areas["town"].description, "\n", "Weather: ", areas["town"].weather, "\n\n") var isArea string for quit != true { print("Enter text: ") fmt.Scanln(&command[0], &command[1]) command[0] = strings.ToLower(command[0]) command[1] = strings.ToLower(command[1]) if _, ok := areas[command[0]]; ok { isArea = command[0] } switch command[0] { case "q", "quit", "exit": print("Are you sure you want to quit?: (y/n) ") fmt.Scanln(&command[0]) if strings.ToLower(command[0]) == "y" { quit = true } case isArea: player.location = command[0] print(areas[player.location].description, "\n") //forestEvent(areas[player.location]) case "list": var areaList []string for key := range areas { areaList = append(areaList, key) } sort.Sort(sort.StringSlice(areaList)) print("\nPlaces:\n\n") //Ignore key iterator and print the range of the value only. for _, val := range areaList { print(val, "\n") } default: print("Wrong command\n") } } }