Created
December 7, 2019 13:06
-
-
Save oduvan/d8385b0b6adc74c2fdd2d46b2e154635 to your computer and use it in GitHub Desktop.
basic code for Python in Empire of Code . com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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