Hey, this is kinda off topic, but I am serious about dueling grounds, and if anybody has improvement suggestions for my code, please telll me
here it is:
def trapEnemy():
enemy = hero.findNearestEnemy()
if hero.isReady("bash"):
hero.bash(enemy)
hero.buildXY("bear-trap", enemy.pos.x, enemy.pos.y)
def buildBase():
hero.jumpTo({"x": 62, "y": 51})
hero.moveXY(62, 51)
point = hero.pos
hero.wait(1)
hero.buildXY("fence", point.x, point.y - 5)
hero.buildXY("fence", point.x + 5, point.y - 5)
hero.buildXY("fence", point.x - 7, point.y)
hero.buildXY("fence", point.x - 5, point.y + 5)
def deployUnits(unit, times):
for i in range(times):
if hero.gold > hero.costOf(unit):
hero.summon(unit)
else:
hero.say("Not enough Gold!")
def commandUnits(unit):
friends = hero.findFriends()
for friend in friends:
if friend.type == unit:
hero.command(friend, "attack", friend.findNearestEnemy())
trapEnemy()
hero.cast("invisibility", self)
buildBase()
hero.moveXY(59, 46)
deployUnits("soldier", 2)
deployUnits("archer", 2)
hero.moveXY(65, 54)
while True:
commandUnits("soldier")
commandUnits("archer")
if hero.gold > 25:
hero.buildXY("decoy", 58, 47)