func (la *localAI) takeTurn(ctx context.Context, gid string, b *engine.Board, faction int) (botapi.Turn_List, error) { // TODO Probably don't ignore errors res, _ := la.TakeTurn(ctx, func(p botapi.Ai_takeTurn_Params) error { iwb, err := p.NewBoard() if err != nil { return err } wb, err := iwb.NewBoard() if err != nil { return err } wb.SetGameId(gid) return b.ToWireWithInitial(iwb, faction) }).Struct() return res.Turns() }
func (oa *onlineAI) takeTurn(ctx gocontext.Context, gid gameID, b *engine.Board, faction int, ch chan<- turnResult) { results, err := oa.client.TakeTurn(ctx, func(p botapi.Ai_takeTurn_Params) error { iwb, err := p.NewBoard() if err != nil { return err } wb, err := iwb.NewBoard() if err != nil { return err } wb.SetGameId(string(gid)) return b.ToWireWithInitial(iwb, faction) }).Struct() var te turnError if err != nil { te = append(te, err) } tl, err := results.Turns() if err != nil { te = append(te, err) } ch <- turnResult{tl, te} }