Skip to content

Instantly share code, notes, and snippets.

@oduvan
Created December 7, 2019 13:06
Show Gist options
  • Save oduvan/d8385b0b6adc74c2fdd2d46b2e154635 to your computer and use it in GitHub Desktop.
Save oduvan/d8385b0b6adc74c2fdd2d46b2e154635 to your computer and use it in GitHub Desktop.
basic code for Python in Empire of Code . com
from battle import commander
# create craft object
craft_client = commander.CraftClient()
# command to craft - start landing units
craft_client.do_land_units()
def unit_landed(data):
# create unit object
unit_client = commander.UnitClient(data['id'])
def search_and_destroy(data=None):
# get the nearest enemy
enemy = unit_client.ask_nearest_enemy()
# command to unit - attack unit by id
unit_client.do_attack(enemy['id'])
# subscribe on even - when unit has nothing todo
unit_client.when_im_idle(search_and_destroy)
search_and_destroy()
# subscribe on event when new unit is landed
craft_client.when_unit_landed(unit_landed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment