I'm in the process of writing my own Text Adventure/Interactive Fiction engine/library and am now running into a bit of a problem attempting to extend the parser.
On the implementation side (i e a game), this is how a game is initially set up. game = mid.Game{ Title: "Cloak of Darkness", Author: "Roger Firth (implemented by Mark Bauermeister)", Intro: `Hurrying through the rainswept November night, you're glad to see the bright lights of the Opera House. It's surprising that there aren't more people about but, hey, what do you expect in a cheap demo game...?`, Goodbye: "See you later!", MaxScore: 2, Verbs: map[string]func(...string){ "drop": drop, }, Synonyms: map[string][]string{ "drop": {"throw"}, }, } Now on the engine/library side, standard verbs are currently hardcoded inside the parser loop. Ideally, I'd like to add them to the same "Verbs" map though. Is there a straightforward way to include the contents of one map in another? Ideally, I'd like to have a "BuiltinVerbs" map and include it as such: Verbs: map[string]func(...string){ BuiltinVerbs, "drop": drop, }, The parser currently looks like this and "g.Verbs" should eventually contain both, the game designer's chosen verbs and (if so chosen) the built-in verbs: func (g *Game) Parse() { reader := bufio.NewScanner(os.Stdin) for { fmt.Print(">>> ") for reader.Scan() { switch reader.Text() { case "quit": if len(g.Goodbye) != 0 { fmt.Println(g.Goodbye) } else { fmt.Println("Goodbye!") } os.Exit(0) default: for n, c := range g.Verbs { s := g._synonymize(reader.Text()) switch s { case n: c() default: fmt.Println("I beg your pardon?") } } } fmt.Print(">>> ") } } } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.