Lookin for codecombat dueling grounds suggestions

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 :slight_smile:

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)

just sayin’ it IS kind dirty.

@riticmaster908 any suggestions??

like things to make my code better

Yep, I know. ritic is pretty good at this so he can give you a few tips.

ok thnks @Vanessa (20charssssssssssss)

try removing the say code line so there is no interfierence in traping and attacking (if u do this)

1 Like

ok. (20 charsssssssssssssssssssssss)