Skip to content

Commit

Permalink
technology details function
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Oct 1, 2022
1 parent 19e1f4f commit 8f2cdcc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/wrapper/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type Prioritizable interface {
GetTechs(celestialID ogame.CelestialID) (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches, ogame.LfBuildings, error)
SendFleet(celestialID ogame.CelestialID, ships []ogame.Quantifiable, speed ogame.Speed, where ogame.Coordinate, mission ogame.MissionID, resources ogame.Resources, holdingTime, unionID int64) (ogame.Fleet, error)
TearDown(celestialID ogame.CelestialID, id ogame.ID) error
TechnologyDetails(celestialID ogame.CelestialID, id ogame.ID) (ogame.TechnologyDetails, error)

// Planet specific functions
DestroyRockets(ogame.PlanetID, int64, int64) error
Expand Down
17 changes: 17 additions & 0 deletions pkg/wrapper/ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -2956,6 +2956,18 @@ func (b *OGame) IsV9() bool {
return len(b.ServerVersion()) > 0 && b.ServerVersion()[0] == '9'
}

func (b *OGame) technologyDetails(celestialID ogame.CelestialID, id ogame.ID) (ogame.TechnologyDetails, error) {
pageHTML, _ := b.getPageContent(url.Values{
"page": {"ingame"},
"component": {"technologydetails"},
"ajax": {"1"},
"action": {"getDetails"},
"technology": {utils.FI64(id)},
"cp": {utils.FI64(celestialID)},
})
return b.extractor.ExtractTechnologyDetails(pageHTML)
}

func getToken(b *OGame, page string, celestialID ogame.CelestialID) (string, error) {
pageHTML, _ := b.getPage(page, ChangePlanet(celestialID))
return b.extractor.ExtractUpgradeToken(pageHTML)
Expand Down Expand Up @@ -4491,6 +4503,11 @@ func (b *OGame) Build(celestialID ogame.CelestialID, id ogame.ID, nbr int64) err
return b.WithPriority(taskRunner.Normal).Build(celestialID, id, nbr)
}

// TechnologyDetails extract details from ajax window when clicking supplies/facilities/techs/lf...
func (b *OGame) TechnologyDetails(celestialID ogame.CelestialID, id ogame.ID) (ogame.TechnologyDetails, error) {
return b.WithPriority(taskRunner.Normal).TechnologyDetails(celestialID, id)
}

// TearDown tears down any ogame building
func (b *OGame) TearDown(celestialID ogame.CelestialID, id ogame.ID) error {
return b.WithPriority(taskRunner.Normal).TearDown(celestialID, id)
Expand Down
7 changes: 7 additions & 0 deletions pkg/wrapper/prioritize.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ func (b *Prioritize) Build(celestialID ogame.CelestialID, id ogame.ID, nbr int64
return b.bot.build(celestialID, id, nbr)
}

// TechnologyDetails extract details from ajax window when clicking supplies/facilities/techs/lf...
func (b *Prioritize) TechnologyDetails(celestialID ogame.CelestialID, id ogame.ID) (ogame.TechnologyDetails, error) {
b.begin("TechnologyDetails")
defer b.done()
return b.bot.technologyDetails(celestialID, id)
}

// TearDown tears down any ogame building
func (b *Prioritize) TearDown(celestialID ogame.CelestialID, id ogame.ID) error {
b.begin("TearDown")
Expand Down

0 comments on commit 8f2cdcc

Please sign in to comment.