Skip to content

Commit

Permalink
Rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 26, 2018
1 parent fa0ab25 commit 3d4e9c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions defence.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package ogame

import "strconv"

// Defenses ...
type Defenses struct {
// DefensesInfos ...
type DefensesInfos struct {
RocketLauncher int
LightLaser int
HeavyLaser int
Expand All @@ -16,7 +16,7 @@ type Defenses struct {
InterplanetaryMissiles int
}

func (d Defenses) String() string {
func (d DefensesInfos) String() string {
return "\n" +
" Rocket Launcher: " + strconv.Itoa(d.RocketLauncher) + "\n" +
" Light Laser: " + strconv.Itoa(d.LightLaser) + "\n" +
Expand Down
12 changes: 6 additions & 6 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Wrapper interface {
GetResourceSettings(PlanetID) (ResourceSettings, error)
SetResourceSettings(PlanetID, ResourceSettings) error
GetResourcesBuildings(PlanetID) (ResourcesBuildings, error)
GetDefense(PlanetID) (Defenses, error)
GetDefense(PlanetID) (DefensesInfos, error)
GetShips(PlanetID) (ShipsInfos, error)
GetFacilities(PlanetID) (Facilities, error)
Build(planetID PlanetID, id ID, nbr int) error
Expand Down Expand Up @@ -1629,14 +1629,14 @@ func (b *OGame) getResourcesBuildings(planetID PlanetID) (ResourcesBuildings, er
return res, nil
}

func extractDefense(pageHTML string) (Defenses, error) {
func extractDefense(pageHTML string) (DefensesInfos, error) {
doc, _ := goquery.NewDocumentFromReader(strings.NewReader(pageHTML))
bodyID, _ := doc.Find("body").Attr("id")
if bodyID == "overview" {
return Defenses{}, ErrInvalidPlanetID
return DefensesInfos{}, ErrInvalidPlanetID
}
doc.Find("span.textlabel").Remove()
res := Defenses{}
res := DefensesInfos{}
res.RocketLauncher, _ = getNbr(doc, "defense401")
res.LightLaser, _ = getNbr(doc, "defense402")
res.HeavyLaser, _ = getNbr(doc, "defense403")
Expand All @@ -1651,7 +1651,7 @@ func extractDefense(pageHTML string) (Defenses, error) {
return res, nil
}

func (b *OGame) getDefense(planetID PlanetID) (Defenses, error) {
func (b *OGame) getDefense(planetID PlanetID) (DefensesInfos, error) {
planetIDStr := planetID.String()
pageHTML := b.getPageContent(url.Values{"page": {"defense"}, "cp": {planetIDStr}})
return extractDefense(pageHTML)
Expand Down Expand Up @@ -2698,7 +2698,7 @@ func (b *OGame) GetResourcesBuildings(planetID PlanetID) (ResourcesBuildings, er

// GetDefense ...
// Fails if planetID is invalid
func (b *OGame) GetDefense(planetID PlanetID) (Defenses, error) {
func (b *OGame) GetDefense(planetID PlanetID) (DefensesInfos, error) {
b.Lock()
defer b.Unlock()
return b.getDefense(planetID)
Expand Down
2 changes: 1 addition & 1 deletion planet.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (p *Planet) GetResourcesBuildings() (ResourcesBuildings, error) {
}

// GetDefense ...
func (p *Planet) GetDefense() (Defenses, error) {
func (p *Planet) GetDefense() (DefensesInfos, error) {
return p.ogame.GetDefense(p.ID)
}

Expand Down

0 comments on commit 3d4e9c7

Please sign in to comment.