Skip to content

Commit

Permalink
Get planet id from galaxy infos
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Sep 1, 2018
1 parent 5e8115b commit 83e004c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ func extractGalaxyInfos(pageHTML, lang string) ([]PlanetInfos, error) {
recyclersTxt := s.Find("div#debris" + position + " ul.ListLinks li").Eq(2).Text()

planetInfos := PlanetInfos{}
planetInfos.ID, _ = strconv.Atoi(s.Find("td.colonized").AttrOr("data-planet-id", ""))

moonID, _ := strconv.Atoi(s.Find("td.moon").AttrOr("data-moon-id", ""))
moonSize, _ := strconv.Atoi(strings.Split(s.Find("td.moon span#moonsize").Text(), " ")[0])
Expand Down
2 changes: 2 additions & 0 deletions ogame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func TestExtractGalaxyInfos(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/galaxy_ajax.html")
infos, _ := extractGalaxyInfos(string(pageHTMLBytes), "en")
assert.Equal(t, 5, len(infos))
assert.Equal(t, 33698600, infos[0].ID)
assert.Equal(t, 33698645, infos[1].ID)
}

func TestExtractUserInfos(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions planetInfos.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type MoonInfos struct {

// PlanetInfos ...
type PlanetInfos struct {
ID int
Activity int
Name string
Img string
Expand Down

0 comments on commit 83e004c

Please sign in to comment.