diff --git a/pkg/extractor/v9/extractor.go b/pkg/extractor/v9/extractor.go index 8ba61259..67ca3a60 100644 --- a/pkg/extractor/v9/extractor.go +++ b/pkg/extractor/v9/extractor.go @@ -78,7 +78,7 @@ func (e *Extractor) ExtractOverviewProduction(pageHTML []byte) ([]ogame.Quantifi // ExtractOverviewProductionFromDoc extracts ships/defenses (partial) production from the overview page func (e *Extractor) ExtractOverviewProductionFromDoc(doc *goquery.Document) ([]ogame.Quantifiable, error) { - return extractOverviewProductionFromDoc(doc) + return extractOverviewProductionFromDoc(doc, e.GetLifeformEnabled()) } // ExtractEspionageReport ... diff --git a/pkg/extractor/v9/extractor_test.go b/pkg/extractor/v9/extractor_test.go index c67b7d73..b6291024 100644 --- a/pkg/extractor/v9/extractor_test.go +++ b/pkg/extractor/v9/extractor_test.go @@ -215,3 +215,13 @@ func TestExtractTechnologyDetails(t *testing.T) { details, _ = NewExtractor().ExtractTechnologyDetails(pageHTMLBytes) assert.True(t, details.TearDownEnabled) } + +func TestExtractOverviewProduction_ships(t *testing.T) { + pageHTMLBytes, _ := ioutil.ReadFile("../../../samples/v9.0.5/en/overview_ships.html") + prod, _, _ := NewExtractor().ExtractOverviewProduction(pageHTMLBytes) + assert.Equal(t, 2, len(prod)) + assert.Equal(t, ogame.SmallCargoID, prod[0].ID) + assert.Equal(t, int64(1), prod[0].Nbr) + assert.Equal(t, ogame.SmallCargoID, prod[1].ID) + assert.Equal(t, int64(1), prod[1].Nbr) +} diff --git a/pkg/extractor/v9/extracts.go b/pkg/extractor/v9/extracts.go index d05a9701..a951ef00 100644 --- a/pkg/extractor/v9/extracts.go +++ b/pkg/extractor/v9/extracts.go @@ -196,9 +196,12 @@ func extractEmpire(pageHTML []byte) ([]ogame.EmpireCelestial, error) { return out, nil } -func extractOverviewProductionFromDoc(doc *goquery.Document) ([]ogame.Quantifiable, error) { +func extractOverviewProductionFromDoc(doc *goquery.Document, lifeformEnabled bool) ([]ogame.Quantifiable, error) { res := make([]ogame.Quantifiable, 0) - active := doc.Find("table.construction").Eq(4) + active := doc.Find("table.construction").Eq(2) + if lifeformEnabled { + active = doc.Find("table.construction").Eq(4) + } href, _ := active.Find("td a").Attr("href") m := regexp.MustCompile(`openTech=(\d+)`).FindStringSubmatch(href) if len(m) == 0 { diff --git a/samples/v9.0.5/en/overview_ships.html b/samples/v9.0.5/en/overview_ships.html new file mode 100644 index 00000000..ed56d37a --- /dev/null +++ b/samples/v9.0.5/en/overview_ships.html @@ -0,0 +1,1792 @@ + + + + + Ferdinand OGame + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + +
+ +
+ + + + + + +
+
+ + + + + + +
+ +
+ + + + + +
+
+
+
+
+ +
+
+
+ +
+ +
+
+
+ + 5,349,804 + +
+
+
+
+
+ + 5,349,462 + +
+
+
+
+
+ + 3,968,892 + +
+
+
+
+
+ + -2,899 + +
+
+
+
+ + +
+
+ + 8,000 + +
+
+
+ +
+ +
+
+ + + 5 + + + + + 2 + + +
+ +
+ ajax spinner + load... +
+ +
+
+ +
+
+
+ +
+
+
+
+ ? +
+
+
+
+
+
+ +
+ + + + + + +
+
+ +
+
+
+
+ + + + +
+
+ +
+
+
+ + +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + +
+ + +
+
+ + +
+
+ +
+
+ +
+ +
+ + +
+
+
+
+
+
+
+

Buildings

+
+ + +
+ +
+
+
+
+ +
+
+
+ +
+
+

Shipyard

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Small Cargo
+
+ + Small Cargo + +
+
1
+
Building duration
+ load... +
Total time:
+ load... +
+ +
+ + Halve time + + + Costs: + 750 DM + +
+
+ + + + + +
+ Small Cargo
+ 1 +
+
+ +
+ +
+
+
+ + + +
+
+ +
+
+
+ + + + + +
+
+ +
+ +
+ + + +
+
+ + + +