Пример #1
0
func main() {
	g = mb.NewGame()
	g.StartGame()

	http.HandleFunc("/", appHandler)
	http.HandleFunc("/mb/board/", mbBoardHandler)
	http.HandleFunc("/mb/log/", mbLogHandler)
	http.ListenAndServe(":8080", nil)
}
Пример #2
0
func main() {
	g := mb.NewGame()
	g.LogToConsole = true
	g.StartGame()
	for g.Response != nil {
		g.Request.Input = ""
		if g.Response.Error != nil {
			fmt.Printf("\nError: %s\n", g.Response.Error)
		}
		reader := bufio.NewReader(os.Stdin)
		// this is pretty hacky, but it'll do for keyboard input
		fmt.Print("\n" + g.Response.Prompt + "> ")
		s, _ := reader.ReadString('\n')
		line := strings.Split(s, "\r")[0]
		g.HandleRequest(mb.Request{Input: mb.Input(line)})
	}
	fmt.Println("\n\nEnd of game")
}