Skip to content

Commit

Permalink
all LfBuildings + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Sep 24, 2022
1 parent 40d77f8 commit 44c3905
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 44 deletions.
96 changes: 84 additions & 12 deletions pkg/extractor/v71/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,42 @@ type planetTechsResp struct {
Num11110 int64 `json:"11110"`
Num11111 int64 `json:"11111"`
Num11112 int64 `json:"11112"`
Num12101 int64 `json:"12101"`
Num12102 int64 `json:"12102"`
Num12103 int64 `json:"12103"`
Num12104 int64 `json:"12104"`
Num12105 int64 `json:"12105"`
Num12106 int64 `json:"12106"`
Num12107 int64 `json:"12107"`
Num12108 int64 `json:"12108"`
Num12109 int64 `json:"12109"`
Num12110 int64 `json:"12110"`
Num12111 int64 `json:"12111"`
Num12112 int64 `json:"12112"`
Num13101 int64 `json:"13101"`
Num13102 int64 `json:"13102"`
Num13103 int64 `json:"13103"`
Num12304 int64 `json:"12304"`
Num13105 int64 `json:"13105"`
Num13106 int64 `json:"13106"`
Num13107 int64 `json:"13107"`
Num13108 int64 `json:"13108"`
Num13109 int64 `json:"13109"`
Num13110 int64 `json:"13110"`
Num13111 int64 `json:"13111"`
Num13112 int64 `json:"13112"`
Num14101 int64 `json:"14101"`
Num14102 int64 `json:"14102"`
Num14103 int64 `json:"14103"`
Num14104 int64 `json:"14104"`
Num14105 int64 `json:"14105"`
Num14106 int64 `json:"14106"`
Num14107 int64 `json:"14107"`
Num14108 int64 `json:"14108"`
Num14109 int64 `json:"14109"`
Num14110 int64 `json:"14110"`
Num14111 int64 `json:"14111"`
Num14112 int64 `json:"14112"`
}

func extractTechs(pageHTML []byte) (supplies ogame.ResourcesBuildings, facilities ogame.Facilities, shipsInfos ogame.ShipsInfos, defenses ogame.DefensesInfos, researches ogame.Researches, lfBuildings ogame.LfBuildings, err error) {
Expand Down Expand Up @@ -348,18 +384,54 @@ func extractTechs(pageHTML []byte) (supplies ogame.ResourcesBuildings, facilitie
ArmourTechnology: res.Num111,
}
lfBuildings = ogame.LfBuildings{
ResidentialSector: res.Num11101,
BiosphereFarm: res.Num11102,
ResearchCentre: res.Num11103,
AcademyOfSciences: res.Num11104,
NeuroCalibrationCentre: res.Num11105,
HighEnergySmelting: res.Num11106,
FoodSilo: res.Num11107,
FusionPoweredProduction: res.Num11108,
Skyscraper: res.Num11109,
BiotechLab: res.Num11110,
Metropolis: res.Num11111,
PlanetaryShield: res.Num11112,
ResidentialSector: res.Num11101,
BiosphereFarm: res.Num11102,
ResearchCentre: res.Num11103,
AcademyOfSciences: res.Num11104,
NeuroCalibrationCentre: res.Num11105,
HighEnergySmelting: res.Num11106,
FoodSilo: res.Num11107,
FusionPoweredProduction: res.Num11108,
Skyscraper: res.Num11109,
BiotechLab: res.Num11110,
Metropolis: res.Num11111,
PlanetaryShield: res.Num11112,
MeditationEnclave: res.Num12101,
CrystalFarm: res.Num12102,
RuneTechnologium: res.Num12103,
RuneForge: res.Num12104,
Oriktorium: res.Num12105,
MagmaForge: res.Num12106,
DisruptionChamber: res.Num12107,
Megalith: res.Num12108,
CrystalRefinery: res.Num12109,
DeuteriumSynthesiser: res.Num12110,
MineralResearchCentre: res.Num12111,
MetalRecyclingPlant: res.Num12112,
AssemblyLine: res.Num13101,
FusionCellFactory: res.Num13102,
RoboticsResearchCentre: res.Num13103,
UpdateNetwork: res.Num12304,
QuantumComputerCentre: res.Num13105,
AutomatisedAssemblyCentre: res.Num13106,
HighPerformanceTransformer: res.Num13107,
MicrochipAssemblyLine: res.Num13108,
ProductionAssemblyHall: res.Num13109,
HighPerformanceSynthesiser: res.Num13110,
ChipMassProduction: res.Num13111,
NanoRepairBots: res.Num13112,
Sanctuary: res.Num14101,
AntimatterCondenser: res.Num14102,
VortexChamber: res.Num14103,
HallsOfRealisation: res.Num14104,
ForumOfTranscendence: res.Num14105,
AntimatterConvector: res.Num14106,
CloningLaboratory: res.Num14107,
ChrysalisAccelerator: res.Num14108,
BioModifier: res.Num14109,
PsionicModulator: res.Num14110,
ShipManufacturingHall: res.Num14111,
SupraRefractor: res.Num14112,
}
return
}
Expand Down
48 changes: 36 additions & 12 deletions pkg/extractor/v9/extracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,6 @@ func GetNbr(doc *goquery.Document, name string) int64 {

func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error) {
res := ogame.LfBuildings{}
// res.ResidentialSector = GetNbr(doc, "residentialSector")
// res.BiosphereFarm = GetNbr(doc, "biosphereFarm")
// res.ResearchCentre = GetNbr(doc, "researchCentre")
// res.AcademyOfSciences = GetNbr(doc, "academyOfSciences")
// res.NeuroCalibrationCentre = GetNbr(doc, "neuroCalibrationCentre")
// res.HighEnergySmelting = GetNbr(doc, "highEnergySmelting")
// res.FoodSilo = GetNbr(doc, "foodSilo")
// res.FusionPoweredProduction = GetNbr(doc, "fusionPoweredProduction")
// res.Skyscraper = GetNbr(doc, "skyscraper")
// res.BiotechLab = GetNbr(doc, "biotechLab")
// res.Metropolis = GetNbr(doc, "metropolis")
// res.PlanetaryShield = GetNbr(doc, "planetaryShield")
res.ResidentialSector = GetNbr(doc, "lifeformTech11101")
res.BiosphereFarm = GetNbr(doc, "lifeformTech11102")
res.ResearchCentre = GetNbr(doc, "lifeformTech11103")
Expand All @@ -602,5 +590,41 @@ func extractLfBuildingsFromDoc(doc *goquery.Document) (ogame.LfBuildings, error)
res.BiotechLab = GetNbr(doc, "lifeformTech11110")
res.Metropolis = GetNbr(doc, "lifeformTech11111")
res.PlanetaryShield = GetNbr(doc, "lifeformTech11112")
res.MeditationEnclave = GetNbr(doc, "lifeformTech12101")
res.CrystalFarm = GetNbr(doc, "lifeformTech12102")
res.RuneTechnologium = GetNbr(doc, "lifeformTech12103")
res.RuneForge = GetNbr(doc, "lifeformTech12104")
res.Oriktorium = GetNbr(doc, "lifeformTech12105")
res.MagmaForge = GetNbr(doc, "lifeformTech12106")
res.DisruptionChamber = GetNbr(doc, "lifeformTech12107")
res.Megalith = GetNbr(doc, "lifeformTech12108")
res.CrystalRefinery = GetNbr(doc, "lifeformTech12109")
res.DeuteriumSynthesiser = GetNbr(doc, "lifeformTech12110")
res.MineralResearchCentre = GetNbr(doc, "lifeformTech12111")
res.MetalRecyclingPlant = GetNbr(doc, "lifeformTech12112")
res.AssemblyLine = GetNbr(doc, "lifeformTech13101")
res.FusionCellFactory = GetNbr(doc, "lifeformTech13102")
res.RoboticsResearchCentre = GetNbr(doc, "lifeformTech13103")
res.UpdateNetwork = GetNbr(doc, "lifeformTech12304")
res.QuantumComputerCentre = GetNbr(doc, "lifeformTech13105")
res.AutomatisedAssemblyCentre = GetNbr(doc, "lifeformTech13106")
res.HighPerformanceTransformer = GetNbr(doc, "lifeformTech13107")
res.MicrochipAssemblyLine = GetNbr(doc, "lifeformTech13108")
res.ProductionAssemblyHall = GetNbr(doc, "lifeformTech13109")
res.HighPerformanceSynthesiser = GetNbr(doc, "lifeformTech13110")
res.ChipMassProduction = GetNbr(doc, "lifeformTech13111")
res.NanoRepairBots = GetNbr(doc, "lifeformTech13112")
res.Sanctuary = GetNbr(doc, "lifeformTech14101")
res.AntimatterCondenser = GetNbr(doc, "lifeformTech14102")
res.VortexChamber = GetNbr(doc, "lifeformTech14103")
res.HallsOfRealisation = GetNbr(doc, "lifeformTech14104")
res.ForumOfTranscendence = GetNbr(doc, "lifeformTech14105")
res.AntimatterConvector = GetNbr(doc, "lifeformTech14106")
res.CloningLaboratory = GetNbr(doc, "lifeformTech14107")
res.ChrysalisAccelerator = GetNbr(doc, "lifeformTech14108")
res.BioModifier = GetNbr(doc, "lifeformTech14109")
res.PsionicModulator = GetNbr(doc, "lifeformTech14110")
res.ShipManufacturingHall = GetNbr(doc, "lifeformTech14111")
res.SupraRefractor = GetNbr(doc, "lifeformTech14112")
return res, nil
}
132 changes: 120 additions & 12 deletions pkg/ogame/lfBuildings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,54 @@ type LazyLfBuildings func() LfBuildings

// LfBuildings lifeform buildings
type LfBuildings struct {
ResidentialSector int64 // 11101
BiosphereFarm int64 // 11102
ResearchCentre int64 // 11103
AcademyOfSciences int64 // 11104
NeuroCalibrationCentre int64 // 11105
HighEnergySmelting int64 // 11106
FoodSilo int64 // 11107
FusionPoweredProduction int64 // 11108
Skyscraper int64 // 11109
BiotechLab int64 // 11110
Metropolis int64 // 11111
PlanetaryShield int64 // 11112
ResidentialSector int64 // 11101 // Lifeform (humans)
BiosphereFarm int64 // 11102
ResearchCentre int64 // 11103
AcademyOfSciences int64 // 11104
NeuroCalibrationCentre int64 // 11105
HighEnergySmelting int64 // 11106
FoodSilo int64 // 11107
FusionPoweredProduction int64 // 11108
Skyscraper int64 // 11109
BiotechLab int64 // 11110
Metropolis int64 // 11111
PlanetaryShield int64 // 11112
MeditationEnclave int64 // 12101 // Lifeform (rocktal)
CrystalFarm int64 // 12102
RuneTechnologium int64 // 12103
RuneForge int64 // 12104
Oriktorium int64 // 12105
MagmaForge int64 // 12106
DisruptionChamber int64 // 12107
Megalith int64 // 12108
CrystalRefinery int64 // 12109
DeuteriumSynthesiser int64 // 12110
MineralResearchCentre int64 // 12111
MetalRecyclingPlant int64 // 12112
AssemblyLine int64 // 13101 // Lifeform (mechas)
FusionCellFactory int64 // 13102
RoboticsResearchCentre int64 // 13103
UpdateNetwork int64 // 12304
QuantumComputerCentre int64 // 13105
AutomatisedAssemblyCentre int64 // 13106
HighPerformanceTransformer int64 // 13107
MicrochipAssemblyLine int64 // 13108
ProductionAssemblyHall int64 // 13109
HighPerformanceSynthesiser int64 // 13110
ChipMassProduction int64 // 13111
NanoRepairBots int64 // 13112
Sanctuary int64 // 14101 // Lifeform (kaelesh)
AntimatterCondenser int64 // 14102
VortexChamber int64 // 14103
HallsOfRealisation int64 // 14104
ForumOfTranscendence int64 // 14105
AntimatterConvector int64 // 14106
CloningLaboratory int64 // 14107
ChrysalisAccelerator int64 // 14108
BioModifier int64 // 14109
PsionicModulator int64 // 14110
ShipManufacturingHall int64 // 14111
SupraRefractor int64 // 14112
}

// Lazy returns a function that return self
Expand Down Expand Up @@ -55,6 +91,78 @@ func (b LfBuildings) ByID(id ID) int64 {
return b.Metropolis
case PlanetaryShieldID:
return b.PlanetaryShield
case MeditationEnclaveID:
return b.MeditationEnclave
case CrystalFarmID:
return b.CrystalFarm
case RuneTechnologiumID:
return b.RuneTechnologium
case RuneForgeID:
return b.RuneForge
case OriktoriumID:
return b.Oriktorium
case MagmaForgeID:
return b.MagmaForge
case DisruptionChamberID:
return b.DisruptionChamber
case MegalithID:
return b.Megalith
case CrystalRefineryID:
return b.CrystalRefinery
case DeuteriumSynthesiserID:
return b.DeuteriumSynthesiser
case MineralResearchCentreID:
return b.MineralResearchCentre
case MetalRecyclingPlantID:
return b.MetalRecyclingPlant
case AssemblyLineID:
return b.AssemblyLine
case FusionCellFactoryID:
return b.FusionCellFactory
case RoboticsResearchCentreID:
return b.RoboticsResearchCentre
case UpdateNetworkID:
return b.UpdateNetwork
case QuantumComputerCentreID:
return b.QuantumComputerCentre
case AutomatisedAssemblyCentreID:
return b.AutomatisedAssemblyCentre
case HighPerformanceTransformerID:
return b.HighPerformanceTransformer
case MicrochipAssemblyLineID:
return b.MicrochipAssemblyLine
case ProductionAssemblyHallID:
return b.ProductionAssemblyHall
case HighPerformanceSynthesiserID:
return b.HighPerformanceSynthesiser
case ChipMassProductionID:
return b.ChipMassProduction
case NanoRepairBotsID:
return b.NanoRepairBots
case SanctuaryID:
return b.Sanctuary
case AntimatterCondenserID:
return b.AntimatterCondenser
case VortexChamberID:
return b.VortexChamber
case HallsOfRealisationID:
return b.HallsOfRealisation
case ForumOfTranscendenceID:
return b.ForumOfTranscendence
case AntimatterConvectorID:
return b.AntimatterConvector
case CloningLaboratoryID:
return b.CloningLaboratory
case ChrysalisAcceleratorID:
return b.ChrysalisAccelerator
case BioModifierID:
return b.BioModifier
case PsionicModulatorID:
return b.PsionicModulator
case ShipManufacturingHallID:
return b.ShipManufacturingHall
case SupraRefractorID:
return b.SupraRefractor
}
return 0
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/wrapper/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ type Celestial interface {
GetDefense(...Option) (ogame.DefensesInfos, error)
GetFacilities(...Option) (ogame.Facilities, error)
GetItems() ([]ogame.Item, error)
GetLfBuildings(...Option) (ogame.LfBuildings, error)
GetProduction() ([]ogame.Quantifiable, int64, error)
GetResources() (ogame.Resources, error)
GetResourcesBuildings(...Option) (ogame.ResourcesBuildings, error)
GetResourcesDetails() (ogame.ResourcesDetails, error)
GetShips(...Option) (ogame.ShipsInfos, error)
GetTechs() (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches, ogame.LfBuildings, 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)
GetTechs() (ogame.ResourcesBuildings, ogame.Facilities, ogame.ShipsInfos, ogame.DefensesInfos, ogame.Researches, ogame.LfBuildings, error)
}

// Prioritizable list of all actions that needs to communicate with ogame server.
Expand Down Expand Up @@ -120,6 +120,7 @@ type Prioritizable interface {
EnsureFleet(celestialID ogame.CelestialID, ships []ogame.Quantifiable, speed ogame.Speed, where ogame.Coordinate, mission ogame.MissionID, resources ogame.Resources, holdingTime, unionID int64) (ogame.Fleet, error)
GetDefense(ogame.CelestialID, ...Option) (ogame.DefensesInfos, error)
GetFacilities(ogame.CelestialID, ...Option) (ogame.Facilities, error)
GetLfBuildings(ogame.CelestialID, ...Option) (ogame.LfBuildings, error)
GetProduction(ogame.CelestialID) ([]ogame.Quantifiable, int64, error)
GetResources(ogame.CelestialID) (ogame.Resources, error)
GetResourcesBuildings(ogame.CelestialID, ...Option) (ogame.ResourcesBuildings, error)
Expand All @@ -128,7 +129,6 @@ 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
GetLfBuildings(ogame.CelestialID, ...Option) (ogame.LfBuildings, error)

// Planet specific functions
DestroyRockets(ogame.PlanetID, int64, int64) error
Expand Down
3 changes: 1 addition & 2 deletions pkg/wrapper/ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -4674,8 +4674,7 @@ func (b *OGame) RegisterHTMLInterceptor(fn func(method, url string, params, payl
// Phalanx scan a coordinate from a moon to get fleets information
// IMPORTANT: My account was instantly banned when I scanned an invalid coordinate.
// IMPORTANT: This function DOES validate that the coordinate is a valid planet in range of phalanx
//
// and that you have enough deuterium.
// and that you have enough deuterium.
func (b *OGame) Phalanx(moonID ogame.MoonID, coord ogame.Coordinate) ([]ogame.Fleet, error) {
return b.WithPriority(taskRunner.Normal).Phalanx(moonID, coord)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/wrapper/prioritize.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,7 @@ func (b *Prioritize) FlightTime(origin, destination ogame.Coordinate, speed ogam
// Phalanx scan a coordinate from a moon to get fleets information
// IMPORTANT: My account was instantly banned when I scanned an invalid coordinate.
// IMPORTANT: This function DOES validate that the coordinate is a valid planet in range of phalanx
//
// and that you have enough deuterium.
// and that you have enough deuterium.
func (b *Prioritize) Phalanx(moonID ogame.MoonID, coord ogame.Coordinate) ([]ogame.Fleet, error) {
b.begin("Phalanx")
defer b.done()
Expand Down Expand Up @@ -709,7 +708,7 @@ func (b *Prioritize) OfferBuyMarketplace(itemID any, quantity, priceType, price,
return b.bot.offerMarketplace(3, itemID, quantity, priceType, price, priceRange, celestialID)
}

// OfferBuyMarketplace ...
// GetLfBuildings ...
func (b *Prioritize) GetLfBuildings(celestialID ogame.CelestialID, options ...Option) (ogame.LfBuildings, error) {
b.begin("GetLfBuildings")
defer b.done()
Expand Down

0 comments on commit 44c3905

Please sign in to comment.