func (h *Handler) CommandStartGame(g overpower.GameDat, facs []overpower.FactionDat, exodus bool) (errServer, errUser error) { if g == nil { return nil, NewError("USER HAS NO GAME TO START") } if g.Turn() > 0 { return nil, NewError("GAME ALREADY IN PROGRESS") } if len(facs) < 1 { return nil, NewError("GAME HAS NO PLAYERS") } f := func(source overpower.Source) (logE, failE error) { return nil, overpower.MakeGalaxy(source, exodus) } logE, failE := OPDB.SourceTransact(g.GID(), f) if my, bad := Check(failE, "command startgame failure", "gid", g.GID()); bad { return my, nil } if logE != nil { Log(logE) } return nil, nil }
func MakeTest(m *Manager) (logE, failE error) { g := &Game{ Owner: "Testing_User", Name: "TestGame", ToWin: 10, } m.CreateGame(g) err := m.Close() if my, bad := Check(err, "creategame testing failure", "game", g); bad { return nil, my } log.Println("MADE GAME", g) madeF := make([]*Faction, 5) for i := 0; i < 4; i++ { f := &Faction{ GID: g.GID, Owner: fmt.Sprintf("Tester%d", i), Name: fmt.Sprintf("Faction%d", i), } madeF[i] = f m.CreateFaction(f) } f := &Faction{ GID: g.GID, Owner: "Test", Name: "MainTestFaction", } madeF[4] = f m.CreateFaction(f) err = m.Close() if my, bad := Check(err, "createfaction testing failure", "factions", madeF); bad { return nil, my } log.Println("MADE FACTIONS", madeF) source := NewSource(m, g.GID) return nil, overpower.MakeGalaxy(source, false) }