Skip to content

Commit

Permalink
fmt and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Sep 24, 2022
1 parent 8a6f179 commit c2a235f
Show file tree
Hide file tree
Showing 13 changed files with 539 additions and 542 deletions.
6 changes: 3 additions & 3 deletions cmd/c/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ func BuildShips(planetID, shipID, nbr C.int) (errorMsg *C.char) {
// TODO: GetProduction(PlanetID) ([]Quantifiable, error)

//export ConstructionsBeingBuilt
func ConstructionsBeingBuilt(planetID C.int) (buildingID, buildingCountdown, researchID, researchCountdown, lfBuildingID, lfBuildingCountdown C.int) {
a, b, c, d, e, f := bot.ConstructionsBeingBuilt(ogame2.CelestialID(planetID))
return C.int(a), C.int(b), C.int(c), C.int(d), C.int(e), C.int(f)
func ConstructionsBeingBuilt(planetID C.int) (buildingID, buildingCountdown, researchID, researchCountdown, lfBuildingID, lfBuildingCountdown, lfTechID, lfTechCountdown C.int) {
a, b, c, d, e, f, g, h := bot.ConstructionsBeingBuilt(ogame2.CelestialID(planetID))
return C.int(a), C.int(b), C.int(c), C.int(d), C.int(e), C.int(f), C.int(g), C.int(h)
}

//export CancelBuilding
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/v6/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,4 +902,4 @@ func (e *Extractor) ExtractLfTechs(pageHTML []byte) (ogame.LfTechs, error) {
// ExtractLfTechsFromDoc ...
func (e *Extractor) ExtractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
panic("not implemented")
}
}
2 changes: 1 addition & 1 deletion pkg/extractor/v6/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,7 @@ func TestCancelResearch(t *testing.T) {

func TestGetConstructions(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("../../../samples/unversioned/overview_active.html")
buildingID, buildingCountdown, researchID, researchCountdown, _, _ := NewExtractor().ExtractConstructions(pageHTMLBytes)
buildingID, buildingCountdown, researchID, researchCountdown, _, _, _, _ := NewExtractor().ExtractConstructions(pageHTMLBytes)
assert.Equal(t, ogame.CrystalMineID, buildingID)
assert.Equal(t, int64(731), buildingCountdown)
assert.Equal(t, ogame.CombustionDriveID, researchID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/v7/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TestExtractFleetSlot_FleetDispatch(t *testing.T) {
func TestGetConstructionsV7(t *testing.T) {
pageHTMLBytes, _ := ioutil.ReadFile("../../../samples/v7/overview_supplies_in_construction.html")
clock := clockwork.NewFakeClockAt(time.Date(2019, 11, 12, 9, 6, 43, 0, time.UTC))
buildingID, buildingCountdown, researchID, researchCountdown, _, _ := ExtractConstructions(pageHTMLBytes, clock)
buildingID, buildingCountdown, researchID, researchCountdown, _, _, _, _ := ExtractConstructions(pageHTMLBytes, clock)
assert.Equal(t, ogame.MetalMineID, buildingID)
assert.Equal(t, int64(62), buildingCountdown)
assert.Equal(t, ogame.EnergyTechnologyID, researchID)
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/v9/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ func (e *Extractor) ExtractLfTechs(pageHTML []byte) (ogame.LfTechs, error) {
// ExtractLfTechsFromDoc ...
func (e *Extractor) ExtractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
return extractLfTechsFromDoc(doc)
}
}
4 changes: 2 additions & 2 deletions pkg/extractor/v9/extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestGetConstructions(t *testing.T) {
// Without lifeform
pageHTMLBytes, _ := ioutil.ReadFile("../../../samples/v9.0.2/en/overview_all_queues.html")
clock := clockwork.NewFakeClockAt(time.Date(2022, 8, 20, 12, 43, 11, 0, time.UTC))
buildingID, buildingCountdown, researchID, researchCountdown, _, _ := ExtractConstructions(pageHTMLBytes, clock)
buildingID, buildingCountdown, researchID, researchCountdown, _, _, _, _ := ExtractConstructions(pageHTMLBytes, clock)
assert.Equal(t, ogame.MetalMineID, buildingID)
assert.Equal(t, int64(5413), buildingCountdown)
assert.Equal(t, ogame.ComputerTechnologyID, researchID)
Expand All @@ -119,7 +119,7 @@ func TestGetConstructions(t *testing.T) {
// With lifeform
pageHTMLBytes, _ = ioutil.ReadFile("../../../samples/v9.0.2/en/lifeform/overview_all_queues2.html")
clock = clockwork.NewFakeClockAt(time.Date(2022, 8, 28, 17, 22, 26, 0, time.UTC))
buildingID, buildingCountdown, researchID, researchCountdown, _, _ = ExtractConstructions(pageHTMLBytes, clock)
buildingID, buildingCountdown, researchID, researchCountdown, _, _, _, _ = ExtractConstructions(pageHTMLBytes, clock)
assert.Equal(t, ogame.MetalStorageID, buildingID)
assert.Equal(t, int64(33483), buildingCountdown)
assert.Equal(t, ogame.ComputerTechnologyID, researchID)
Expand Down
15 changes: 7 additions & 8 deletions pkg/extractor/v9/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
res.BiotechLab = GetNbr(doc, "lifeformTech11110")
res.Metropolis = GetNbr(doc, "lifeformTech11111")
res.PlanetaryShield = GetNbr(doc, "lifeformTech11112")
} else if doc.Find("#lifeform a div").HasClass("lifeform2") {

} else if doc.Find("#lifeform a div").HasClass("lifeform2") {
res.Rocktal = true
res.MeditationEnclave = GetNbr(doc, "lifeformTech12101")
res.CrystalFarm = GetNbr(doc, "lifeformTech12102")
Expand All @@ -601,7 +601,7 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
res.DeuteriumSynthesiser = GetNbr(doc, "lifeformTech12110")
res.MineralResearchCentre = GetNbr(doc, "lifeformTech12111")
res.MetalRecyclingPlant = GetNbr(doc, "lifeformTech12112")

} else if doc.Find("#lifeform a div").HasClass("lifeform3") {
res.Mechas = true
res.AssemblyLine = GetNbr(doc, "lifeformTech13101")
Expand All @@ -616,7 +616,7 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
res.HighPerformanceSynthesiser = GetNbr(doc, "lifeformTech13110")
res.ChipMassProduction = GetNbr(doc, "lifeformTech13111")
res.NanoRepairBots = GetNbr(doc, "lifeformTech13112")

} else if doc.Find("#lifeform a div").HasClass("lifeform4") {
res.Kaelesh = true
res.Sanctuary = GetNbr(doc, "lifeformTech14101")
Expand All @@ -631,14 +631,13 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
res.PsionicModulator = GetNbr(doc, "lifeformTech14110")
res.ShipManufacturingHall = GetNbr(doc, "lifeformTech14111")
res.SupraRefractor = GetNbr(doc, "lifeformTech14112")

} else {
res.None = true
}
return res, nil
}


func extractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
res := ogame.LfTechs{}
// Can have any lifeform techs whatever current planet lifeform is, so take everything
Expand All @@ -659,7 +658,7 @@ func extractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
res.DestroyerMkII = GetNbr(doc, "lifeformTech11215")
res.BattlecruiserMkII = GetNbr(doc, "lifeformTech11216")
res.RobotAssistants = GetNbr(doc, "lifeformTech11217")
res.Supercomputer = GetNbr(doc, "lifeformTech11218")
res.Supercomputer = GetNbr(doc, "lifeformTech11218")
res.VolcanicBatteries = GetNbr(doc, "lifeformTech12201")
res.AcousticScanning = GetNbr(doc, "lifeformTech12202")
res.HighEnergyPumpSystems = GetNbr(doc, "lifeformTech12203")
Expand All @@ -677,7 +676,7 @@ func extractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
res.DiamondEnergyTransmitter = GetNbr(doc, "lifeformTech12215")
res.ObsidianShieldReinforcement = GetNbr(doc, "lifeformTech12216")
res.RuneShields = GetNbr(doc, "lifeformTech12217")
res.RocktalCollectorEnhancement = GetNbr(doc, "lifeformTech12218")
res.RocktalCollectorEnhancement = GetNbr(doc, "lifeformTech12218")
res.CatalyserTechnology = GetNbr(doc, "lifeformTech13201")
res.PlasmaDrive = GetNbr(doc, "lifeformTech13202")
res.EfficiencyModule = GetNbr(doc, "lifeformTech13203")
Expand Down
Loading

0 comments on commit c2a235f

Please sign in to comment.