Skip to content
PiecePaperCode edited this page Mar 29, 2021 · 3 revisions

Scan and attack longinactive players

assuming longinactive players have no defence

for planet in empire.galaxy(coordinates(1, 1)):
    if status.inactive in planet.status and status.vacation not in planet.status:
        empire.send_fleet(mission=mission.attack,
                          id=empire.id_by_planet_name('MAIN_PLANET'),
                          where=coordinates(1, 1, planet.position),
                          ships=[ships.large_transporter(25), ships.cruiser(1)])

Send a Probe to Spy other Players

# Send a Spyprobe to a random Player
send_fleet = False
while not send_fleet:
    for planet in empire.galaxy(coordinates(randint(1,6), randint(1, 499))):
        if empire.send_fleet(mission.spy, id, planet.position, [ships.espionage_probe(1)]):
            send_fleet = True
            break

# Wait till Spyprobe arrives
for fleet in empire.fleet():
    if fleet.mission == mission.spy:
        while datetime.now() < fleet.arrival:
            continue

# Print out Spyreport
for spyreport in empire.spyreports():
    print(spyreport.list)

send expeditions

for expedition in range(4):
    empire.send_fleet(mission=mission.expedition,
                      id=empire.id_by_planet_name('Main_Planet'),
                      where=coordinates(randint(1, 6), randint(1, 499), 16),
                      ships=[ships.explorer(100), ships.large_transporter(200)],
                      holdingtime=1)

build mines routine

for id in empire.planet_ids():
    supply = empire.supply(id)
    res = empire.resources(id)
    if supply.crystal_mine.is_possible:
        empire.build(buildings.crystal_mine, id)
    if res.energy < 0 and not supply.solar_plant.is_possible:
        empire.build(buildings.solar_satellite(100), id)
    else:
        empire.build(buildings.solar_plant, id)

build defences routine

defence = empire.defences(id)
multiplier = 50
rocket_launcher = 1000 * multiplier
laser_cannon_light = 500 * multiplier
laser_cannon_heavy = 100 * multiplier
gauss_cannon = 20 * multiplier
plasma_cannon = 10 * multiplier
ion_cannon = 40 * multiplier

if defence.shield_dome_small is 0 or defence.shield_dome_large is 0:
    empire.build(buildings.shield_dome_large(1), id)
    empire.build(buildings.shield_dome_small(1), id)

elif defence.rocket_launcher < rocket_launcher:
    empire.build(buildings.rocket_launcher(rocket_launcher), id)

elif defence.laser_cannon_light < laser_cannon_light:
    empire.build(buildings.laser_cannon_light(laser_cannon_light), id)

elif defence.laser_cannon_heavy < laser_cannon_heavy:
    empire.build(buildings.laser_cannon_heavy(laser_cannon_heavy), id)

elif defence.gauss_cannon < gauss_cannon:
    empire.build(buildings.gauss_cannon(gauss_cannon), id)

elif defence.plasma_cannon < plasma_cannon:
    empire.build(buildings.plasma_cannon(plasma_cannon), id)

elif defence.ion_cannon < ion_cannon:
    empire.build(buildings.ion_cannon(ion_cannon), id)                  

Creating attack warning by Telegram by Bidu

1 - Access your telegram and add the contact “@BotFather” he is responsible for creating Telegram bots

2 - Start a conversation with “@BotFather”

Type: /newbot Type: <Name of Bot> Type: <username do bot> (ATTENTION this username must end with the string “Bot”)

3 - The "@BotFather" will answer you with the "token" this token will be used to send the conversations, save, because, we will use it. In the same message there is a t.me/ link, click this link to start a conversation with the bot you just created, you need to send any message to register that you accept to receive messages from the bot.

4 - Add the contact “@get_id_bot” in the telegram. He is responsible for telling you your user id in the telegram, also known as chat_id.

5 - Start a conversation with “@get_id_bot” Type: @get_id_bot Your Chat ID will be returned, save this value we will use in the code.

6 - Start Coding

import requests
class Telegram:
	def __init__(self):
 		self.TOKEN = <<Token Telegram>>
 		self.CHAT = << CHAT ID >>
 		self.URL = "https://api.telegram.org/bot{}".format(self.TOKEN)
 	def get_url(self, url):
 		response = requests.get(url)
 		content = response.content.decode("utf8")
 		return content
 	def send_message(self, text):
 		url = self.URL + "/sendMessage?text={}&chat_id={}".format(text, self.CHAT)
 		self.get_url(url)
#test
#Telegram().send_message('test')