Skip to content

Commit

Permalink
fix interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 18, 2022
1 parent 6692419 commit ea51052
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 164 deletions.
8 changes: 6 additions & 2 deletions extractor_v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (e ExtractorV6) ExtractAttacks(pageHTML []byte, ownCoords []Coordinate) ([]

func (e ExtractorV6) extractAttacks(pageHTML []byte, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
doc, _ := goquery.NewDocumentFromReader(bytes.NewReader(pageHTML))
return e.ExtractAttacksFromDoc(doc, clock, ownCoords)
return e.extractAttacksFromDoc(doc, clock, ownCoords)
}

// ExtractOfferOfTheDay ...
Expand Down Expand Up @@ -414,7 +414,11 @@ func (e ExtractorV6) ExtractOGameSessionFromDoc(doc *goquery.Document) string {
}

// ExtractAttacksFromDoc ...
func (e ExtractorV6) ExtractAttacksFromDoc(doc *goquery.Document, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
func (e ExtractorV6) ExtractAttacksFromDoc(doc *goquery.Document, ownCoords []Coordinate) ([]AttackEvent, error) {
return e.extractAttacksFromDoc(doc, clockwork.NewRealClock(), ownCoords)
}

func (e ExtractorV6) extractAttacksFromDoc(doc *goquery.Document, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
return extractAttacksFromDocV6(doc, clock, ownCoords)
}

Expand Down
10 changes: 7 additions & 3 deletions extractor_v71.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func (e ExtractorV71) ExtractAllResources(pageHTML []byte) (map[CelestialID]Reso
}

// ExtractAttacksFromDoc ...
func (e ExtractorV71) ExtractAttacksFromDoc(doc *goquery.Document, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
return extractAttacksFromDocV71(doc, clock, ownCoords)
func (e ExtractorV71) ExtractAttacksFromDoc(doc *goquery.Document, ownCoords []Coordinate) ([]AttackEvent, error) {
return e.extractAttacksFromDoc(doc, clockwork.NewRealClock(), ownCoords)
}

// ExtractAttacks ...
Expand All @@ -125,7 +125,11 @@ func (e ExtractorV71) ExtractAttacks(pageHTML []byte, ownCoords []Coordinate) ([

func (e ExtractorV71) extractAttacks(pageHTML []byte, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
doc, _ := goquery.NewDocumentFromReader(bytes.NewReader(pageHTML))
return e.ExtractAttacksFromDoc(doc, clock, ownCoords)
return e.extractAttacksFromDoc(doc, clock, ownCoords)
}

func (e ExtractorV71) extractAttacksFromDoc(doc *goquery.Document, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error) {
return extractAttacksFromDocV71(doc, clock, ownCoords)
}

// DMCost ...
Expand Down
1 change: 1 addition & 0 deletions fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func getAjaxPage[T AjaxPagePages](b *OGame, vals url.Values, opts ...Option) (T,
case MissileAttackLayerAjaxPage:
case FetchTechsAjaxPage:
case RocketlayerAjaxPage:
case PhalanxAjaxPage:
default:
panic("not implemented")
}
Expand Down
3 changes: 1 addition & 2 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/PuerkitoBio/goquery"
"github.com/alaingilbert/clockwork"
)

// Prioritizable ...
Expand Down Expand Up @@ -348,7 +347,7 @@ type Extractor interface {
ExtractFacilitiesFromDoc(doc *goquery.Document) (Facilities, error)
ExtractResearchFromDoc(doc *goquery.Document) Researches
ExtractOGameSessionFromDoc(doc *goquery.Document) string
ExtractAttacksFromDoc(doc *goquery.Document, clock clockwork.Clock, ownCoords []Coordinate) ([]AttackEvent, error)
ExtractAttacksFromDoc(doc *goquery.Document, ownCoords []Coordinate) ([]AttackEvent, error)
ExtractOfferOfTheDayFromDoc(doc *goquery.Document) (price int64, importToken string, planetResources PlanetResources, multiplier Multiplier, err error)
ExtractProductionFromDoc(doc *goquery.Document) ([]Quantifiable, error)
ExtractOverviewProductionFromDoc(doc *goquery.Document) ([]Quantifiable, error)
Expand Down
Loading

0 comments on commit ea51052

Please sign in to comment.