forked from alaingilbert/ogame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetcher.go
71 lines (67 loc) · 2.34 KB
/
fetcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package ogame
import (
"net/url"
"strconv"
)
// Page names
const (
OverviewPage = "overview"
PreferencesPage = "preferences"
ResourceSettingsPage = "resourceSettings"
DefensesPage = "defenses"
SuppliesPage = "supplies"
FacilitiesPage = "facilities"
FleetdispatchPage = "fleetdispatch"
ShipyardPage = "shipyard"
MovementPage = "movement"
ResearchPage = "research"
PlanetlayerPage = "planetlayer"
LogoutPage = "logout"
JumpgatelayerPage = "jumpgatelayer"
FetchResourcesPage = "fetchResources"
FetchTechs = "fetchTechs"
TraderOverviewPage = "traderOverview"
GalaxyPage = "galaxy"
AlliancePage = "alliance"
PremiumPage = "premium"
ShopPage = "shop"
RewardsPage = "rewards"
HighscorePage = "highscore"
BuddiesPage = "buddies"
MessagesPage = "messages"
ChatPage = "chat"
// ajax pages
FetchEventboxAjaxPage = "fetchEventbox"
FetchResourcesAjaxPage = "fetchResources"
GalaxyContentAjaxPage = "galaxyContent"
EventListAjaxPage = "eventList"
AjaxChatAjaxPage = "ajaxChat"
NoticesAjaxPage = "notices"
RepairlayerAjaxPage = "repairlayer"
TechtreeAjaxPage = "techtree"
PhalanxAjaxPage = "phalanx"
ShareReportOverlayAjaxPage = "shareReportOverlay"
JumpgatelayerAjaxPage = "jumpgatelayer"
FederationlayerAjaxPage = "federationlayer"
UnionchangeAjaxPage = "unionchange"
ChangenickAjaxPage = "changenick"
PlanetlayerAjaxPage = "planetlayer"
TraderlayerAjaxPage = "traderlayer"
PlanetRenameAjaxPage = "planetRename"
RightmenuAjaxPage = "rightmenu"
AllianceOverviewAjaxPage = "allianceOverview"
SupportAjaxPage = "support"
BuffActivationAjaxPage = "buffActivation"
AuctioneerAjaxPage = "auctioneer"
HighscoreContentAjaxPage = "highscoreContent"
)
func (b *OGame) getPage(page string, celestialID CelestialID, opts ...Option) ([]byte, error) {
vals := url.Values{"page": {"ingame"}, "component": {page}}
if page == FetchResourcesPage || page == FetchTechs {
vals = url.Values{"page": {page}}
}
if celestialID != 0 {
vals.Add("cp", strconv.FormatInt(int64(celestialID), 10))
}
return b.getPageContent(vals, opts...)
}