Skip to content

Commit

Permalink
Fix galaxy debris on french servers
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 26, 2018
1 parent 791b42d commit ed5ec79
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,10 @@ func extractGalaxyInfos(pageHTML, lang string) ([]PlanetInfos, error) {
metalRgx = regexp.MustCompile(`Metal: ([\d.]+)`)
crystalRgx = regexp.MustCompile(`Cristal: ([\d.]+)`)
recyclersRgx = regexp.MustCompile(`Se necesitan recicladores: ([\d.]+)`)
case "fr":
metalRgx = regexp.MustCompile(`Métal: ([\d.]+)`)
crystalRgx = regexp.MustCompile(`Cristal: ([\d.]+)`)
recyclersRgx = regexp.MustCompile(`Recycleurs nécessaires: ([\d.]+)`)
}

metalTxt := s.Find("div#debris" + position + " ul.ListLinks li").First().Text()
Expand Down
9 changes: 8 additions & 1 deletion ogame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func TestExtractGalaxyInfos_debris(t *testing.T) {
assert.Equal(t, 1, infos[0].Debris.RecyclersNeeded)
}


func TestExtractGalaxyInfos_debris_es(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/galaxy_debris_es.html")
infos, _ := extractGalaxyInfos(string(pageHTMLBytes), "es")
Expand All @@ -176,6 +175,14 @@ func TestExtractGalaxyInfos_debris_es(t *testing.T) {
assert.Equal(t, 7, infos[5].Debris.RecyclersNeeded)
}

func TestExtractGalaxyInfos_debris_fr(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/galaxy_debris_fr.html")
infos, _ := extractGalaxyInfos(string(pageHTMLBytes), "fr")
assert.Equal(t, 100, infos[1].Debris.Metal)
assert.Equal(t, 600, infos[1].Debris.Crystal)
assert.Equal(t, 1, infos[1].Debris.RecyclersNeeded)
}

func TestExtractGalaxyInfos_vacation(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("samples/galaxy_ajax.html")
infos, _ := extractGalaxyInfos(string(pageHTMLBytes), "en")
Expand Down
1 change: 1 addition & 0 deletions samples/galaxy_debris_fr.html

Large diffs are not rendered by default.

0 comments on commit ed5ec79

Please sign in to comment.