So basically I’m doing some of the brawl levels and I’m making code stuff but then I’m getting an error in my commandTroops() function. It’s in the paladin.canCast() but apparently it’s not defined yet?
def summonTroops():
summonTypes = ['paladin', "archer"]
summonType = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold < hero.costOf(summonType):
hero.summon(summonType)
def commandTroops(friends):
lowest = lowestHealthUnit(friends)
for friend in friends:
enemy = friend.findNearestEnemy()
#
#Here is where I sepereate between my archers and my paladins
#
if friend.type == "paladin":
paladin = friend
if friend.type == 'archer':
archer = friend
if paladin.canCast("heal", lowest):
#
#This is where my error of paladins not being defined yet occurs
#
hero.command(paladin, "cast", "heal", lowest)
if enemy:
hero.command(archer, "attack", enemy)
def lowestHealthUnit(friends):
lowestHealth = 999
lowestUnit = None
for friend in friends:
if friend.health < lowestHealth:
lowestUnit = friend
lowestHealth = friend.health
return lowestUnit
def summonTroops():
summonTypes = ['paladin', "archer"]
summonType = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold < hero.costOf(summonType):
hero.summon(summonType)
def commandTroops(friends):
lowest = lowestHealthUnit(friends)
for friend in friends:
enemy = friend.findNearestEnemy()
#
#Here is where I sepereate between my archers and my paladins
#
if friend.type == "paladin":
paladin = friend
if friend.type == 'archer':
archer = friend
if paladin.canCast("heal", lowest):
#
#This is where my error of paladins not being defined yet occurs
#
hero.command(paladin, "cast", "heal", lowest)
if enemy:
hero.command(archer, "attack", enemy)
def lowestHealthUnit(friends):
lowestHealth = 999
lowestUnit = None
for friend in friends:
if friend.health < lowestHealth:
lowestUnit = friend
lowestHealth = friend.health
return lowestUnit
def pickUpCoin():
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)
while True:
enemy = hero.findNearestEnemy()
friends = hero.findFriends()
summonTroops()
commandTroops(friends)
its just my functions wrapped in a while loop and I waited for my functions to be fixed before I make my hero start to do things.
ima be real with you chief I just started doing this because Ive been neglecting most replayable levels. I just been trying to make a decent program that can last me for a bit.
No worries…but, I still need to know which level of the brawl you are on. The flag for it, on the map, will have a number…what is that number? Or, in the level itself, you will see: