Add validation to CreateUnion
@@ -1534,6 +1534,9 @@ func (b *OGame) executeJumpGate(originMoonID, destMoonID MoonID, ships ShipsInfo
}
func (b *OGame) createUnion(fleet Fleet) (int, error) {
+ if fleet.ID == 0 {
+ return 0, errors.New("invalid fleet id")
+ }
pageHTML, _ := b.getPageContent(url.Values{"page": {"federationlayer"}, "union": {"0"}, "fleet": {strconv.Itoa(int(fleet.ID))}, "target": {strconv.Itoa(fleet.TargetPlanetID)}})
payload := ExtractFederation(pageHTML)
by, err := b.postPageContent(url.Values{"page": {"unionchange"}}, payload)
