def explore_near_planet(self, radius): galaxy = self._planet_location.coord.galaxy system = self._planet_location.coord.system res = [] for i in range(-radius, radius + 1): res += self._galaxy_explorer.galaxy_inactive_players( Coord(galaxy, system + i, 0)) return res
def get_location(self): header = self._parser.find("div", attrs={"class": "detail_msg_head"}) link = header.find("a", attrs={"class": "txt_link"}) res = re.search(".*\[(\d+):(\d+):(\d+)\]", link.text) galaxy = res.group(1) system = res.group(2) position = res.group(3) return Location(Coord(galaxy, system, position), DestinationTypeBuilder.planet())
def send_farm_attacks(self): fleet_status = self._update_fleet_status() free_fleet_slots = fleet_status.get_free_fleet_slots() for _ in range(free_fleet_slots): target = FLEET_TARGET_CONFIG.get_next_target() location = Location( Coord(target["galaxy"], target["system"], target["position"]), DestinationTypeBuilder.planet()) self._fleet_dispatcher.send_fleet( location, MissionTypeBuilder.Attack(), FleetBuilder().with_transporterSmall(42).build())
def send_expeditions(self): fleet_status = self._update_fleet_status() send_expedition = fleet_status.get_free_expedition_slots() for _ in range(send_expedition): fleet = fleet_status.fleet_army.split_fleet_into(send_expedition) exp_coord = Location( Coord(self._planet_location.coord.galaxy, self._planet_location.coord.system, 16), DestinationTypeBuilder.planet()) time.sleep(random.randint(5, 10)) print("Sleep before sending expeditions") self._fleet_dispatcher.send_fleet( exp_coord, MissionTypeBuilder().Expedition(), fleet)
def getInactivePlanets(self): inactive_players = [] galaxy_table = self._parser.find("table", attrs={"id": "galaxytable"}) galaxy = int(galaxy_table.attrs["data-galaxy"]) system = int(galaxy_table.attrs["data-system"]) inactives = galaxy_table.find_all("tr", attrs={"class": "row inactive_filter"}) for inactive in inactives: check_status = inactive.find("td", attrs={"class": ["playername", "inactive"]}) if check_status is None: continue position = int(inactive.find("td", attrs={"class": "position"}).text) player_id = int(inactive.find("a", attrs={"class": "sendMail"}).attrs["data-playerid"]) inactive_players.append({ "coord": Coord(galaxy, system, position), "player_id": player_id }) return inactive_players
def send_explorers_to_debris(self, max_explorers): if max_explorers == 0: return fleet_status = self._update_fleet_status() free_fleet_slots = fleet_status.get_free_fleet_slots() explorers_count = min(max_explorers, fleet_status.fleet_army.get_explorers().count) if free_fleet_slots == 0: return if explorers_count == 0: print("We haven't explorers to harvest debris.") return debris_location = Location( Coord(self._planet_location.coord.galaxy, self._planet_location.coord.system, 16), DestinationTypeBuilder.debris()) explorer_army = FleetBuilder().with_explorer(explorers_count).build() self._fleet_dispatcher.send_fleet( debris_location, MissionTypeBuilder.RecycleDebrisField(), explorer_army)
def get_location(self): head = self._el.find("head") position = head.find("meta", attrs={"name": "ogame-planet-coordinates"}).attrs["content"].split(":") planet_type = head.find("meta", attrs={"name": "ogame-planet-type"}).attrs["content"] return Location(Coord(*position), DestinationType(planet_type))