Hi all. I’ve been stuck on Binary Deployment for a while, and I can’t figure out where my bug is. My hero (Ritic) will go to the first paladin, but instead of summoning nicely in a line (like I think the code should do), he just sort of summons a haphazard pile there, and then stops summoning altogether. I think I need to paste the whole code, just because I’m really clueless where the problem is. (I know that the while
loop is infinite right now, but I don’t think that’s the problem.):
def decToBase(n, newBase):
if n == 0:
return '0'
else:
e = n//newBase
q = n%newBase
if e == 0:
return str(q)
else:
return decToBase(e, newBase) + str(q)
def getThere(p):
while hero.distanceTo(p) > 2:
if hero.distanceTo(p) < 25 and hero.isReady("blink"):
hero.blink(p)
else:
hero.move(p)
def fixNumber(s):
if len(s) < 8:
e = 8 - len(s)
for i in range(e):
global s
s = '0' + s
return s
def summoner(s):
s = fixNumber(s)
for i in range(0,7):
n = s[i]
if n == '0':
getThere({'x': hero.pos.x + (3 * i), 'y': hero.pos.y})
hero.summon("soldier")
elif n == '1':
getThere({'x': hero.pos.x + (3 * i), 'y': hero.pos.y})
hero.summon("archer")
elif n == '2':
getThere({'x': hero.pos.x + (3 * i), 'y': hero.pos.y})
hero.summon("griffin-rider")
while True:
paladins = hero.findByType("paladin")
for pal in paladins:
getThere({'x': pal.pos.x + 5, 'y': pal.pos.y})
n = pal.deployment
toSummon = decToBase(n, 2)
summoner(toSummon)
warlocks = hero.findByType("warlock")
for war in warlocks:
getThere({'x': war.pos.x + 5, 'y': war.pos.y})
n = war.deployment
toSummon = decToBase(n, 3)
summoner(toSummon)