Skip to content

Commit

Permalink
consistant naming
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Oct 1, 2022
1 parent c1bf4b6 commit 7374792
Show file tree
Hide file tree
Showing 20 changed files with 159 additions and 168 deletions.
2 changes: 1 addition & 1 deletion cmd/c/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ 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, lfTechID, lfTechCountdown C.int) {
func ConstructionsBeingBuilt(planetID C.int) (buildingID, buildingCountdown, researchID, researchCountdown, lfBuildingID, lfBuildingCountdown, lfResearchID, lfResearchCountdown 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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ogamed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func start(c *cli.Context) error {
e.POST("/bot/planets/:planetID/resource-settings", wrapper.SetResourceSettingsHandler)
e.GET("/bot/planets/:planetID/resources-buildings", wrapper.GetResourcesBuildingsHandler)
e.GET("/bot/planets/:planetID/lifeform-buildings", wrapper.GetLfBuildingsHandler)
e.GET("/bot/planets/:planetID/lifeform-techs", wrapper.GetLfTechsHandler)
e.GET("/bot/planets/:planetID/lifeform-techs", wrapper.GetLfResearchHandler)
e.GET("/bot/planets/:planetID/defence", wrapper.GetDefenseHandler)
e.GET("/bot/planets/:planetID/ships", wrapper.GetShipsHandler)
e.GET("/bot/planets/:planetID/facilities", wrapper.GetFacilitiesHandler)
Expand Down
19 changes: 10 additions & 9 deletions pkg/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type OverviewExtractorBytes interface {
ExtractCancelLfBuildingInfos(pageHTML []byte) (token string, id, listID int64, err error)
ExtractCancelResearchInfos(pageHTML []byte) (token string, techID, listID int64, err error)
ExtractCharacterClass(pageHTML []byte) (ogame.CharacterClass, error)
ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64)
ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64)
ExtractDMCosts(pageHTML []byte) (ogame.DMCosts, error)
ExtractFleetDeutSaveFactor(pageHTML []byte) float64
ExtractOverviewProduction(pageHTML []byte) ([]ogame.Quantifiable, int64, error)
Expand Down Expand Up @@ -423,18 +423,18 @@ type LfBuildingsExtractorBytesDoc interface {
LfBuildingsExtractorDoc
}

type LfTechsExtractorBytes interface {
type LfResearchExtractorBytes interface {
ExtractUpgradeToken(pageHTML []byte) (string, error)
ExtractLfTechs(pageHTML []byte) (ogame.LfTechs, error)
ExtractLfResearch(pageHTML []byte) (ogame.LfResearches, error)
}

type LfTechsExtractorDoc interface {
ExtractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error)
type LfResearchExtractorDoc interface {
ExtractLfResearchFromDoc(doc *goquery.Document) (ogame.LfResearches, error)
}

type LfTechsExtractorBytesDoc interface {
LfTechsExtractorBytes
LfTechsExtractorDoc
type LfResearchExtractorBytesDoc interface {
LfResearchExtractorBytes
LfResearchExtractorDoc
}

// ResourcesBuildingsExtractorBytes supplies page
Expand Down Expand Up @@ -463,6 +463,7 @@ type PlanetLayerExtractorDoc interface {
}

type TechnologyDetailsExtractorBytes interface {
ExtractTechnologyDetails(pageHTML []byte) (ogame.TechnologyDetails, error)
ExtractTearDownButtonEnabled(pageHTML []byte) bool
}

Expand Down Expand Up @@ -492,7 +493,7 @@ type Extractor interface {
FullPageExtractorBytesDoc
HighscoreExtractorBytesDoc
LfBuildingsExtractorBytesDoc
LfTechsExtractorBytesDoc
LfResearchExtractorBytesDoc
MessagesCombatReportExtractorBytesDoc
MessagesEspionageReportExtractorBytesDoc
MessagesExpeditionExtractorBytesDoc
Expand Down
10 changes: 5 additions & 5 deletions pkg/extractor/v6/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ func (e *Extractor) ExtractFederation(pageHTML []byte) url.Values {
}

// ExtractConstructions ...
func (e *Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64) {
func (e *Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64) {
return extractConstructions(pageHTML)
}

Expand Down Expand Up @@ -894,12 +894,12 @@ func (e *Extractor) ExtractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBu
panic("not implemented")
}

// ExtractLfTechs ...
func (e *Extractor) ExtractLfTechs(pageHTML []byte) (ogame.LfTechs, error) {
// ExtractLfResearch ...
func (e *Extractor) ExtractLfResearch(pageHTML []byte) (ogame.LfResearches, error) {
panic("not implemented")
}

// ExtractLfTechsFromDoc ...
func (e *Extractor) ExtractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
// ExtractLfResearchFromDoc ...
func (e *Extractor) ExtractLfResearchFromDoc(doc *goquery.Document) (ogame.LfResearches, error) {
panic("not implemented")
}
2 changes: 1 addition & 1 deletion pkg/extractor/v6/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ func extractFederation(pageHTML []byte) url.Values {
return payload
}

func extractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64) {
func extractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64) {
buildingCountdownMatch := regexp.MustCompile(`getElementByIdWithCache\("Countdown"\),(\d+),`).FindSubmatch(pageHTML)
if len(buildingCountdownMatch) > 0 {
buildingCountdown = int64(utils.ToInt(buildingCountdownMatch[1]))
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/v7/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (e Extractor) ExtractResourcesDetails(pageHTML []byte) (out ogame.Resources
}

// ExtractConstructions ...
func (e Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64) {
func (e Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64) {
return ExtractConstructions(pageHTML, clockwork.NewRealClock())
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/v7/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func extractResourcesDetails(pageHTML []byte) (out ogame.ResourcesDetails, err e
return
}

func ExtractConstructions(pageHTML []byte, clock clockwork.Clock) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64) {
func ExtractConstructions(pageHTML []byte, clock clockwork.Clock) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64) {
buildingCountdownMatch := regexp.MustCompile(`var restTimebuilding = (\d+) -`).FindSubmatch(pageHTML)
if len(buildingCountdownMatch) > 0 {
buildingCountdown = int64(utils.ToInt(buildingCountdownMatch[1])) - clock.Now().Unix()
Expand Down
14 changes: 7 additions & 7 deletions pkg/extractor/v9/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (e *Extractor) ExtractResourcesDetailsFromFullPageFromDoc(doc *goquery.Docu
}

// ExtractConstructions ...
func (e *Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfTechID ogame.ID, lfTechCountdown int64) {
func (e *Extractor) ExtractConstructions(pageHTML []byte) (buildingID ogame.ID, buildingCountdown int64, researchID ogame.ID, researchCountdown int64, lfBuildingID ogame.ID, lfBuildingCountdown int64, lfResearchID ogame.ID, lfResearchCountdown int64) {
return ExtractConstructions(pageHTML, clockwork.NewRealClock())
}

Expand All @@ -102,13 +102,13 @@ func (e *Extractor) ExtractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBu
return extractLfBuildingsFromDoc(doc)
}

// ExtractLfTechs ...
func (e *Extractor) ExtractLfTechs(pageHTML []byte) (ogame.LfTechs, error) {
// ExtractLfResearch ...
func (e *Extractor) ExtractLfResearch(pageHTML []byte) (ogame.LfResearches, error) {
doc, _ := goquery.NewDocumentFromReader(bytes.NewReader(pageHTML))
return e.ExtractLfTechsFromDoc(doc)
return e.ExtractLfResearchFromDoc(doc)
}

// ExtractLfTechsFromDoc ...
func (e *Extractor) ExtractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
return extractLfTechsFromDoc(doc)
// ExtractLfResearchFromDoc ...
func (e *Extractor) ExtractLfResearchFromDoc(doc *goquery.Document) (ogame.LfResearches, error) {
return extractLfResearchFromDoc(doc)
}
16 changes: 8 additions & 8 deletions pkg/extractor/v9/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func ExtractConstructions(pageHTML []byte, clock clockwork.Clock) (buildingID ogame.ID, buildingCountdown int64,
researchID ogame.ID, researchCountdown int64,
lfBuildingID ogame.ID, lfBuildingCountdown int64,
lfTechID ogame.ID, lfTechCountdown int64) {
lfResearchID ogame.ID, lfResearchCountdown int64) {
buildingCountdownMatch := regexp.MustCompile(`var restTimebuilding = (\d+) -`).FindSubmatch(pageHTML)
if len(buildingCountdownMatch) > 0 {
buildingCountdown = int64(utils.ToInt(buildingCountdownMatch[1])) - clock.Now().Unix()
Expand All @@ -38,11 +38,11 @@ func ExtractConstructions(pageHTML []byte, clock clockwork.Clock) (buildingID og
lfBuildingIDInt := utils.ToInt(regexp.MustCompile(`onclick="cancellfbuilding\((\d+),`).FindSubmatch(pageHTML)[1])
lfBuildingID = ogame.ID(lfBuildingIDInt)
}
lfTechCountdownMatch := regexp.MustCompile(`var restTimelfresearch = (\d+) -`).FindSubmatch(pageHTML)
if len(lfTechCountdownMatch) > 0 {
lfTechCountdown = int64(utils.ToInt(lfTechCountdownMatch[1])) - clock.Now().Unix()
lfTechIDInt := utils.ToInt(regexp.MustCompile(`onclick="cancellfresearch\((\d+),`).FindSubmatch(pageHTML)[1])
lfTechID = ogame.ID(lfTechIDInt)
lfResearchCountdownMatch := regexp.MustCompile(`var restTimelfresearch = (\d+) -`).FindSubmatch(pageHTML)
if len(lfResearchCountdownMatch) > 0 {
lfResearchCountdown = int64(utils.ToInt(lfResearchCountdownMatch[1])) - clock.Now().Unix()
lfResearchIDInt := utils.ToInt(regexp.MustCompile(`onclick="cancellfresearch\((\d+),`).FindSubmatch(pageHTML)[1])
lfResearchID = ogame.ID(lfResearchIDInt)
}
return
}
Expand Down Expand Up @@ -638,8 +638,8 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
return res, nil
}

func extractLfTechsFromDoc(doc *goquery.Document) (ogame.LfTechs, error) {
res := ogame.LfTechs{}
func extractLfResearchFromDoc(doc *goquery.Document) (ogame.LfResearches, error) {
res := ogame.LfResearches{}
// Can have any lifeform techs whatever current planet lifeform is, so take everything
res.IntergalacticEnvoys = GetNbr(doc, "lifeformTech11201")
res.HighPerformanceExtractors = GetNbr(doc, "lifeformTech11202")
Expand Down
5 changes: 0 additions & 5 deletions pkg/ogame/lfBuildings.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ func newPlanetaryShield() *planetaryShield {
return b
}

// BaseLfTechnology base struct for lifeform technologies
type BaseLfTechnology struct {
BaseLevelable
}

// Rocktal
type meditationEnclave struct {
BaseLfBuilding
Expand Down
Loading

0 comments on commit 7374792

Please sign in to comment.