Skip to content

Commit

Permalink
* Added Celestial Interface Functions
Browse files Browse the repository at this point in the history
- GetLfBuildings
- GetTechs

* Added pkg/parser/lfbuildingsPage.go (forget to add it for the Extractor)
  • Loading branch information
faunX authored and faunX committed Sep 15, 2022
1 parent 8bf3d81 commit 05e9663
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/parser/lfbuildingsPage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package parser

import "github.com/alaingilbert/ogame/pkg/ogame"

func (p SuppliesPage) ExtractLfBuildings() (ogame.LfBuildings, error) {
return p.e.ExtractLfBuildingsFromDoc(p.GetDoc())
}
1 change: 1 addition & 0 deletions pkg/wrapper/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Celestial interface {
GetShips(...Option) (ogame.ShipsInfos, error)
SendFleet([]ogame.Quantifiable, ogame.Speed, ogame.Coordinate, ogame.MissionID, ogame.Resources, int64, int64) (ogame.Fleet, error)
TearDown(buildingID ogame.ID) error
GetLfBuildings(...Option) (ogame.LfBuildings, error)
}

// Prioritizable list of all actions that needs to communicate with ogame server.
Expand Down
10 changes: 10 additions & 0 deletions pkg/wrapper/moon.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,13 @@ func (m Moon) Phalanx(coord ogame.Coordinate) ([]ogame.Fleet, error) {
//func (m *Moon) UseJumpGate() error {
// return nil
//}

// GetLfBuildings gets the lifeform buildings levels
func (m Moon) GetLfBuildings(options ...Option) (ogame.LfBuildings, error) {
return m.ogame.GetLfBuildings(m.ID.Celestial(), options...)
}

// GetTechs gets (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches)
func (m Moon) GetTechs() (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches, error) {
return m.ogame.GetTechs(m.ID.Celestial())
}
11 changes: 11 additions & 0 deletions pkg/wrapper/planet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wrapper

import (
"fmt"

"github.com/alaingilbert/ogame/pkg/ogame"
)

Expand Down Expand Up @@ -151,3 +152,13 @@ func (p Planet) FlightTime(destination ogame.Coordinate, speed ogame.Speed, ship
func (p Planet) SendIPM(planetID ogame.PlanetID, coord ogame.Coordinate, nbr int64, priority ogame.ID) (int64, error) {
return p.ogame.SendIPM(planetID, coord, nbr, priority)
}

// GetLfBuildings gets the lifeform buildings levels
func (p Planet) GetLfBuildings(options ...Option) (ogame.LfBuildings, error) {
return p.ogame.getLfBuildings(p.ID.Celestial(), options...)
}

// GetTechs gets (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches)
func (p Planet) GetTechs() (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches, error) {
return p.ogame.GetTechs(p.ID.Celestial())
}

0 comments on commit 05e9663

Please sign in to comment.